Author Topic: EEPROM Tutorial  (Read 4636 times)

0 Members and 1 Guest are viewing this topic.

Offline Razor ConceptsTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
    • RazorConcepts
EEPROM Tutorial
« 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

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: EEPROM Tutorial
« Reply #1 on: February 25, 2009, 08:46:54 PM »
thanks! good reference to have!
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: EEPROM Tutorial
« Reply #2 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.

Offline Razor ConceptsTopic starter

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
    • RazorConcepts
Re: EEPROM Tutorial
« Reply #3 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).

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • Hardware and Firmware Designer
    • The Hellinic Robots Portal
Re: EEPROM Tutorial
« Reply #4 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!!!
For whom the interrupts toll...

Offline Jdog

  • Robot Overlord
  • ****
  • Posts: 259
  • Helpful? 3
Re: EEPROM Tutorial
« Reply #5 on: March 02, 2009, 08:50:53 PM »
Nevermind.
« Last Edit: April 01, 2009, 02:10:16 PM by Jdog »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: EEPROM Tutorial
« Reply #6 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
« Last Edit: March 31, 2009, 11:47:20 PM by Admin »

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: EEPROM Tutorial
« Reply #7 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

Well, maybe write a function like this:

for (int index = 0; index <= 250; index++) {
     eeprom_write_byte(index, array[index]);
}
Check out the uBotino robot controller!

Offline dolinay

  • Contest Winner
  • Jr. Member
  • ****
  • Posts: 18
  • Helpful? 0
Re: EEPROM Tutorial
« Reply #8 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