EEPROM 101 anyone? PLEASE

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the subject of EEPROM use has been broached a number of times in these discussions.

Unfortunately all too often beyond my grasp.

Eric Weddington had done a marvelous job with his post PROGRAMMING 101 of october 4 , 2004. dealing with handling of bits etc.

I wonder if anybody had addressed EEPROM issues in the same ( beginners ) way?

In the meantime a notionally simple problem:

how to read and write a byte in EEPROM using facilities of avr/eeprom.h
that is how to select a specific location in EEPROM and read and write to it?

PLEASE :?

I have tried to understand the help file but no joy... even the smallest of hints would be appreciated

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Declare and define variables:
const uint8_t EE_dummy_0_addr __attribute__ ((section (".eeprom"))) = 0;
const uint8_t EE_my_address __attribute__ ((section (".eeprom"))) = 1;
const uint16_t EE_timer_CPC __attribute__ ((section (".eeprom"))) = 0x55aa;
const float EE_temp_coef __attribute__ ((section (".eeprom"))) = 1.25;

Read:
addr = eeprom_read_byte(&EE_my_address);
OCR1A = eeprom_read_word(&EE_timer_CPC);
eeprom_read_block(&tcoef , &EE_temp_coef, sizeof(float));

Write:
eeprom_write_byte (&EE_my_address, 0x52);
eeprom_write_word (&EE_timer_CPC, 0x55ab);
eeprom_write_block (&tcoef, &EE_temp_coef, sizeof(float));

You can also read write at specified address like this:
addr = eeprom_read_byte((const uint8_t*)0x20);
eeprom_write_byte ((const uint8_t*)0x20, 0x52);
but this is in 99.9% of cases useless, errorprone and not needed at all.

Regards,

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

isn't thatl all documented in the avr docs?

MY MICROCONTROLLER CAN BEAT THE HELL OUT OF YOUR MICROCONTROLLER /ATMEL

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Arturl,

Thank You for the post.

the sample code will help interpret the dcumentation.

MaxK,

Have You not found the help info a bit lacking in explanatory and application notes.

To me and I am shure other beginers, the help notes much like man notes are written by people in the know for people in the know.
As far as I am concerned .. A CASE OF TITS ON A BULL or not to put too fine a point on it a case of a hatfull of ar**holes...useless

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Heya ignoramus,

Im not that much of a programmer myself though, but I saw the procedure name eeprom_read_byte() and just tried it out. Flash it and read a few bytes you''ve flashed/eep'd into it.

About the appnotes, they sometimes are very "HUHH" able yes.

MY MICROCONTROLLER CAN BEAT THE HELL OUT OF YOUR MICROCONTROLLER /ATMEL

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ignoramus, MaxK:

Please realize that avr-libc is an all volunteer project. If the docs aren't good enough, then *please* help out and write better docs and submit a patch to the avr-libc project. The only way it improves, is through the work of volunteers.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh please don't get me wrong. :(

100% AVR and GCC supporter here!! :P

Id like to support the community, but im not that good yet. See my Crapcode on this other thread about a sed1520 lcd driver.

MY MICROCONTROLLER CAN BEAT THE HELL OUT OF YOUR MICROCONTROLLER /ATMEL

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

EW,

I appreciate the efforts and work of volunteers. I understand they are far more capable than I in these matters.

I just hope they understand that i come from a very beginners position and need to
a) come to grips with subject matter
b) but in the firstinstanc need to come to grips with jargon and form of presentation

I appreciate this is not rocket science, that it is just a collection of rules someone before me came up with. There is no reason to obfuscate rules by making claims without explaining them ( providing samples on how to implement rules.

There will always be new users needing that extra bit of support in the begining.

To all volunteers.. a great thank you for the work You are doing ut please think of us lowly beginers at times.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Eric Weddington had done a marvelous job with his post PROGRAMMING 101 of october 4 , 2004

Didn't know that Eric could travel forward in time :D

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
Didn't know that Eric could travel forward in time :D

I didn't know I could either. :shock: Since I wrote that post....

Maxk, Ignoramus:

So you know I wasn't attempting to make anyone feel like they should be grateful for what's there... :(

I was hoping to inspire people to help where ever they can. I know that the developers of avr-libc are incredibly busy, and what seems like adequate documentation to them, may not be enough for beginners, and most importantly, the developers either may not know it, or they may not have them time to make it better. Any contributions, in the right format, are always welcome. We all want to make it a better "product". :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I do have to say that the AVR libc documentation gives better answes after you start to know the C language better..

Last night i downloaded the PDF to my pocket pc and went reading it in bed. Sure now appreciate the existance of all those printf_P functions in standard IO!! Previously I made my own printf_p's :oops:

And I really like to help if I can!
i was interrested in making a sort of universal LCD driver that could used. Most expensive packages come with 2x16/20/24/40 char lcd support. This isnt in the AVR GCC setup AFAIK . Well character LCD's
are really simple so shouldn't be too hard.
*Im self writing drivers for sed1520, plain graphical matrix display.
also have some fairly overcomplete t6963 drivers ready too, but they quite large in code because it supports font loading, display TIF's etc.
display text scrolling.

MY MICROCONTROLLER CAN BEAT THE HELL OUT OF YOUR MICROCONTROLLER /ATMEL