Society of Robots - Robot Forum

Software => Software => Topic started by: Razor Concepts on February 25, 2009, 08:02:25 PM

Title: EEPROM Tutorial
Post by: Razor Concepts on February 25, 2009, 08:02:25 PM
Just wrote up a quick little EEPROM tutorial. Very easy to use and VERY useful  ;D
http://www.societyofrobots.com/member_tutorials/node/309
Title: Re: EEPROM Tutorial
Post by: airman00 on February 25, 2009, 08:46:54 PM
thanks! good reference to have!
Title: Re: EEPROM Tutorial
Post by: Admin on February 28, 2009, 08:56:09 PM
Nice tutorial! I've been considering starting to use EEPROM as I am getting into learning algorithms now. Needed a way to store what it learned during resets . . .

Quote
BOD (Brown Out Detection) shuts down the microcontroller at a certain voltage. EEPROM gets messed up at low voltage levels, so set the BOD fuse to a voltage right under your normal operating voltage. Most AVR circuits run at about 5v, so select the 4.3v option.
It does? Hmmmm that would have caused me some hair pulling for sure!

Quote
So for example, if we were to write the byte 64 to location 23 of the EEPROM, the code would look like this:

eeprom_write_byte ((uint8_t*) 23, 64);
How would I store a long int, or char perhaps? Simply uint16_t*?


Also, do you know by any chance if EEPROM is initialized as zeros during manufacture?

Hmmmm the Axon is sold with EEPROM uninitialized . . . maybe I should change that in the next batch . . . and just a reference to anyone interested, the Axon has 4K Bytes EEPROM with about ~100,000 rewrites until failure.
Title: Re: EEPROM Tutorial
Post by: Razor Concepts on March 02, 2009, 01:19:55 PM
Hmm sorry I don't know enough about it, there should be some info scattered around avr freaks (where I learned it).

I'm pretty sure the EEPROM is initiallized as 255 (0xFF).
Title: Re: EEPROM Tutorial
Post by: TrickyNekro on March 02, 2009, 03:07:14 PM
I just gave a  look at the datasheet for the 2560 I got...
I didn't noticed anything about the memory yet, I'm still reading,
But I show that the ADC has even a stage gain amplifier in it that can give
x10 db, x20 db and x46 db!!!! And that's really great!!!
I'm still, looking for other things at it....

Hell, admin these are things to point out!!!
Title: Re: EEPROM Tutorial
Post by: Jdog on March 02, 2009, 08:50:53 PM
Nevermind.
Title: Re: EEPROM Tutorial
Post by: Admin on March 31, 2009, 11:26:59 PM
Hey Razor Concepts . . . another question . . .

The most useful use of EEPROM I can think of involves storing large arrays. Know how to do this with EEPROM?

This code doesn't make it easy to store 50x50 matrices :P

eeprom_write_byte ((uint8_t*)<<location>>, <<byte to be written>>);


edit: posted this question up on avrfreaks (http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=557254#557254)
Title: Re: EEPROM Tutorial
Post by: Ro-Bot-X on April 01, 2009, 06:07:18 AM
Hey Razor Concepts . . . another question . . .

The most useful use of EEPROM I can think of involves storing large arrays. Know how to do this with EEPROM?

This code doesn't make it easy to store 50x50 matrices :P

eeprom_write_byte ((uint8_t*)<<location>>, <<byte to be written>>);


edit: posted this question up on avrfreaks (http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=557254#557254)

Well, maybe write a function like this:

for (int index = 0; index <= 250; index++) {
     eeprom_write_byte(index, array[index]);
}
Title: Re: EEPROM Tutorial
Post by: dolinay on April 02, 2009, 11:31:03 AM
There are several other functions in the WinAVR (AVR Libc) library besides the eeprom_write_byte. It is possible to save whole block of memory like this:

Let's say you have array of 50 8-bit numbers:

uint8_t data[50];

and save it like this:

eeprom_write_block(data, (void*)adr1, sizeof(data));

adr1 is the address in EEPROM where the array should be saved, defined like this:

uint8_t* adr1 = (uint8_t*)0x00;


Here is link to the EEPROM functions:
http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html (http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html)