ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Writing and Reading From ATmega EEPROM

Sat May 17, 2014 4:01 pm

I have been trying to write to and read from the EEPROM on my Gertboard ATmega328P - but have not been successful.

There is sample code in /usr/share/arduino/libraries/EEPROM/examples that write, read, and clear the EEPROM. They compile OK. The only thing I ever read from any EEPROM address is hex FF.

I wrote my own routines based on the information in the ATmega datasheet. I also only read hex FF from any location.

Anybody have any experience with the EEPROM?

Thanks.

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Writing and Reading From ATmega EEPROM

Sun May 18, 2014 2:00 pm

ytram99 wrote:I have been trying to write to and read from the EEPROM on my Gertboard ATmega328P - but have not been successful.

There is sample code in /usr/share/arduino/libraries/EEPROM/examples that write, read, and clear the EEPROM. They compile OK. The only thing I ever read from any EEPROM address is hex FF.

I wrote my own routines based on the information in the ATmega datasheet. I also only read hex FF from any location.

Anybody have any experience with the EEPROM?

Thanks.
Yes, I have.
But I did the same as what you said you did: I used the library routines.
However I had one advantage: I was using a JTAG-ICE debugger so I could verify
what was in the EEPROM using the Atmel provided GUI.

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Writing and Reading From ATmega EEPROM

Sun May 18, 2014 3:40 pm

It's been a while, but I've been using the avr-libc functions to read from and write to the eeprom. That sort of 'just worked'.

http://www.nongnu.org/avr-libc/user-man ... eprom.html

Something like this:

Code: Select all

#include <avr/eeprom.h>

uint8_t EEMEM myvar;
uint8_t writevalue = 42;

eeprom_update_byte(&myvar, writevalue);
uint8_t readvalue = eeprom_read_byte(&myvar);

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Sun May 18, 2014 9:17 pm

panik wrote:It's been a while, but I've been using the avr-libc functions to read from and write to the eeprom. That sort of 'just worked'.

http://www.nongnu.org/avr-libc/user-man ... eprom.html

Something like this:

Code: Select all

#include <avr/eeprom.h>

uint8_t EEMEM myvar;
uint8_t writevalue = 42;

eeprom_update_byte(&myvar, writevalue);
uint8_t readvalue = eeprom_read_byte(&myvar);
Pank, Thanks a million - It works.

I have a question though: Address seems to be only 8 bits. ATmega328 has 1k EEPROM. How do you access higher than address 255?

Thanks again,

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Sun May 18, 2014 10:29 pm

Gert van Loo wrote:
ytram99 wrote:I have been trying to write to and read from the EEPROM on my Gertboard ATmega328P - but have not been successful.

There is sample code in /usr/share/arduino/libraries/EEPROM/examples that write, read, and clear the EEPROM. They compile OK. The only thing I ever read from any EEPROM address is hex FF.

I wrote my own routines based on the information in the ATmega datasheet. I also only read hex FF from any location.

Anybody have any experience with the EEPROM?


Yes, I have.
But I did the same as what you said you did: I used the library routines.
However I had one advantage: I was using a JTAG-ICE debugger so I could verify
what was in the EEPROM using the Atmel provided GUI.
Gert, Thanks for responding. It's great to hear from the creator of the Gertboard, himself.

I tried the library functions again to no avail. The two sections of code below is what I wrote using direct register access: This did not work either. However, my version of Panik's code (not presented here) did function great. Strange.

Code: Select all

/* Write to address 0 of EEPROM */

#include <avr/io.h>

void EEPROM_write(byte addrh, byte addrl, unsigned char data){
  
  //wait for completion of any previous write operation
  while(EECR & (1<<EEPE));
  
  //Setup address
  EEARH = addrh;
  EEARL = addrl;
  
  //Setup data
  EEDR = data;
  
  //Setup EEPM1 EEPM0 to 00 meaning to erase then write
  EECR &= !(1<<EEPM1);
  EECR &= !(1<<EEPM0);
   
  //Write logical 1 to EEMPE
  EECR |= (1<<EEMPE);
  
  // Trigger EEPROM write
  EECR |= (1<<EEPE);
}

void setup(){
  
  EEPROM_write(0, 0, 5);
}
void loop(){}
------------------------------------------------------------------------------------------------------

Code: Select all

/* Read from address 0 of EEPROM */

#include <avr/io.h>

unsigned char EEPROM_read(byte addrh, byte addrl){ 

  //wait for completion of any previous write operation
  while(EECR & (1<<EEPE));
  
  //Setup address
  EEARH = addrh;
  EEARL = addrl;

  //Trigger EEPROM read
  EECR |= (1<<EERE);
  return EEDR;
}  

void setup(){
    unsigned char data;
  
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  
  data = EEPROM_read(0, 0);
  Serial.println(data);
}
void loop(){}
Last edited by ShiftPlusOne on Mon May 19, 2014 3:02 am, edited 1 time in total.
Reason: Enabled BBCode

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Writing and Reading From ATmega EEPROM

Mon May 19, 2014 8:20 am

using direct register access
Long time since I used the eeprom but my recollection is that you need to unlock access with a number
of signature writes. I suggest you do an intense read of the eeprom section of the datasheet.

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Writing and Reading From ATmega EEPROM

Mon May 19, 2014 2:26 pm

ytram99 wrote:I have a question though: Address seems to be only 8 bits. ATmega328 has 1k EEPROM. How do you access higher than address 255?
Good question. I'm not an expert, but I'm guessing it has to do with the fact there are 256 'pages' of 4 bytes each. If you want to store 4 bytes on page address 0, convert the 4 bytes to a uint32_t and use eeprom_write_dword().

Much like a boolean (1 bit) still takes up a full byte in memory. You can store 8 booleans for the price of 1 in a uint8_t.

Again, just guessing. I'd like some confirmation on this though. Consider this a question from me as well, not a statement/fact. ;)

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Mon May 19, 2014 3:13 pm

Thank you for your response. This EEPROM thing is driving me crazy. Your suggestion in your first post gave me a glimmer of hope of solving this thing. I took your code snippet and wrote the following really simple sketch:

Code: Select all

#include <avr/eeprom.h>
void setup(){  
  Serial.begin(9600);
  
  byte address;
  byte data_byte_write;
  byte data_byte_read;
  
  address = 0x0a;
  data_byte_write = 0x6b;
  
  eeprom_write_byte(&address, data_byte_write); 
  data_byte_read = eeprom_read_byte(&address);  
  Serial.println(data_byte_read, HEX);
}
void loop(){}
THIS WORKED!!
So I split it up into two sketches, one to write and one to read. I just just copied the sketch that worked into two sketches and deleted what was not needed:

Code: Select all

#include <avr/eeprom.h>
void setup(){
  byte address;
  byte data_byte_write;
  
  address = 0x0a;
  data_byte_write = 0x6B;
  
  eeprom_write_byte(&address, data_byte_write); 
}
void loop(){}
And:

Code: Select all

#include <avr/eeprom.h>
void setup(){
  Serial.begin(9600);
  
  byte address;
  byte data_byte_read;
  
  address = 0x0a; 
  data_byte_read = eeprom_read_byte(&address);
  Serial.println(data_byte_read, HEX);
}
void loop(){}
This does not work. All I ever get back is FF. I tried a whole bunch of stuff, changing the byte to unsigned chars, added delays. Nothing helped. I'm still trying more things.

Do you (or anyone else) have any ideas?

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Writing and Reading From ATmega EEPROM

Mon May 19, 2014 3:24 pm

My guess (again) is that the moment you flash the second sketch, the stuff the first sketch wrote to eeprom is overwritten with FF's.

Not sure how you write to flash without overwriting the EEPROM (pretty sure it can be done, just not *how*. Let alone with the Arduino IDE, which I'm also guessing you're using. There's an avrdude commandline switch. I believe you can also pre-program the EEPROM with avrdude).

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Mon May 19, 2014 3:49 pm

panik wrote:My guess (again) is that the moment you flash the second sketch, the stuff the first sketch wrote to eeprom is overwritten with FF's.

Not sure how you write to flash without overwriting the EEPROM (pretty sure it can be done, just not *how*. Let alone with the Arduino IDE, which I'm also guessing you're using. There's an avrdude commandline switch. I believe you can also pre-program the EEPROM with avrdude).

Yes, I am using the Arduino IDE. I found that the sketch I thought worked really does not. If I program a byte, into one address, all the addresses read that same byte value. Also, If I comment out the write command, the sketch reads FF. So I don't think I am writing to the EEPROM at all. I really need to get this working, somehow, and working with the Arduino IDE. If you are familiar with the 1-wire temperature devices, each one has an 8 byte unique code stored in it's ROM. You can have a nearly unlimited number of these devices connected together. They are individually addressed by their code. I can scan for the codes, but need a place to store the values. I don't want them taking valuable Flash memory, so the EEPROM seems to be an ideal solution.

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Writing and Reading From ATmega EEPROM

Mon May 19, 2014 8:01 pm

ytram99 wrote:I don't want them taking valuable Flash memory, so the EEPROM seems to be an ideal solution.
There's 32KB of Flash, and only 1KB of EEPROM. Are you sure you're running out of space in Flash? [edit:] There are ways of using the Flash as a 'sort of' eeprom with the PROGMEM modifier, but there have also been reports it doesn't play well with the current version of the IDE. No idea what's up with that. http://arduino.cc/en/Reference/PROGMEM

I have this sketch on a regular Arduino (based on the example code from the menu):

Code: Select all

#include <EEPROM.h>

// start reading from the first byte (address 0) of the EEPROM
int address = 0;
byte value;

void setup()
{
  // initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  
  Serial.println("reset");
  
  // read a byte from the current address of the EEPROM
  value = EEPROM.read(address);
  
  Serial.print(address);
  Serial.print("\t");
  Serial.print(value, DEC);
  Serial.println();
  
  if (value != 0) {
    Serial.println("non-zero found, writing a 0");
    EEPROM.write(address, 0);
  } else {
    Serial.println("zero found, writing a 1");
    EEPROM.write(address, 1);
  }
}

void loop()
{

}
That gives the following output on the serial monitor when pressing the resetbutton a few times:

Code: Select all

reset
0	124
non-zero found, writing a 0
reset
0	0
zero found, writing a 1
reset
0	1
non-zero found, writing a 0
reset
0	0
zero found, writing a 1
reset
0	1
non-zero found, writing a 0

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Tue May 20, 2014 4:36 pm

panik wrote:
ytram99 wrote:I don't want them taking valuable Flash memory, so the EEPROM seems to be an ideal solution.
There's 32KB of Flash, and only 1KB of EEPROM. Are you sure you're running out of space in Flash? [edit:] There are ways of using the Flash as a 'sort of' eeprom with the PROGMEM modifier, but there have also been reports it doesn't play well with the current version of the IDE. No idea what's up with that. http://arduino.cc/en/Reference/PROGMEM

I have this sketch on a regular Arduino (based on the example code from the menu):

Code: Select all

#include <EEPROM.h>

// start reading from the first byte (address 0) of the EEPROM
int address = 0;
byte value;

void setup()
{
  // initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  
  Serial.println("reset");
  
  // read a byte from the current address of the EEPROM
  value = EEPROM.read(address);
  
  Serial.print(address);
  Serial.print("\t");
  Serial.print(value, DEC);
  Serial.println();
  
  if (value != 0) {
    Serial.println("non-zero found, writing a 0");
    EEPROM.write(address, 0);
  } else {
    Serial.println("zero found, writing a 1");
    EEPROM.write(address, 1);
  }
}

void loop()
{

}
That gives the following output on the serial monitor when pressing the resetbutton a few times:

Code: Select all

reset
0	124
non-zero found, writing a 0
reset
0	0
zero found, writing a 1
reset
0	1
non-zero found, writing a 0
reset
0	0
zero found, writing a 1
reset
0	1
non-zero found, writing a 0

Thanks again for your time. To make sure I got exactly what you wrote, I uploaded your code to the Pi, compiled and ran it. Unfortunately , it still did not work. My output was:

reset
0 255
non-zero found, writing a 0
reset
0 255
non-zero found, writing a 0

My son also successfully wrote to and read from the EEPROM on his Arduino. He sent me his code and it did not work for me either. Earlier, I tried another chip, and the results were the same. So, I don't think the fault is with the chip.

I know the fuse programming is not the fault. I don't know of other significant differences between Arduino and Gertboard.

I can't use the Serial Monitor that comes with the Arduino IDE, I use a terminal program called minicom. Any possible way that could be the problem?

Maybe I have to look into Avrdude.

Whether I wind up using the EEPROM for my project or not, I would like to resolve the issue, I think it would be of interest to the RaspberryPi community. When I resolve this, I'll report my findings on this forum and on my blog (thepiandi.blogspot.com).

I'm a newcomer to all of this and I do this mainly to learn. I'm retired and this stuff keeps my mind active.

I looked into abandoning the Arduino IDE and came upon your excellent how-to post. Don't know if I'm ready for that just yet.

Thanks again.

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Writing and Reading From ATmega EEPROM

Tue May 20, 2014 7:08 pm

Ok, so I've recreated your situation.

Hooked up the gertboard to the pi, installed Arduino IDE with Gordon's patches and scripts, and uploaded the 'read a 1 write a 0, read a 0 write a 1' sketch. Output to minicom (not being able to use the builtin serial monitor is a known inconvenience).

That worked as it should. Writing a 0 or a 1 to EEPROM address 0 after each reset. To be honest, I'm a bit stumped. I don't see why this doesn't work for you. Everything else seems fine (the programming, serial output and what not).

The EEPROM wears out after a 100000 writes or so. Theoretically it's possible to destroy it pretty fast in a while loop, but you also tried another chip so that seems pretty unlikely. Also, you'll really have to try. Someone was bored and made a device to make it easier: http://dangerousprototypes.com/2010/05/ ... destroyer/
ytram99 wrote:I'm a newcomer to all of this and I do this mainly to learn. I'm retired and this stuff keeps my mind active.
Awesome. I like your blog. Please keep it up! Retiring sounds fun! :D

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Tue May 20, 2014 8:10 pm

Geez, don't know what to think. You and I have done the same thing. I'm so wrapped up in this I ordered an Arduino Uno. Didn't realize they were so inexpensive. Also ordered three more Atmega328's. I ordered the two I have at the same time and the markings indicate they may be of the same production run. Who knows, maybe they are both defective. Don't think I wrote over 100.000 times - maybe 1000. Thanks for your efforts here. It's much appreciated. I'm glad you like my blog. I'm writing a new post now.

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Sat May 24, 2014 4:13 pm

The EEPROM saga continues - but with good information, I think. Think I'll list the the events:

1. Purchased Arduino Uno
2..On PC, found that my sketches to write to, and read from, the EEPROM worked just fine. These are the two sketches you can find in my response to Gert on May 10. They start with the comment: "Write to address 0" and "Read from address 0"
3. Connected Arduino to Pi
4. Found that the two sketches worked with Arduino connected to USB connector of Pi.
5. Expanded the sketches to write varying data to, and read the data back, from all 1024 memory locations. It Worked!
6. To make absolutely sure sketches were working, wrote to the EEPROM (all 1024 locations) on the PC and read all 1024 locations on the Pi. Worked fine.
7. Now knew that the sketches were OK and underlying software on Pi was OK.
8. Replaced ATmega328P on the Arduino with ATmega328P from the Gertboard.
9. Ran the two sketches with the Arduino (Gertboard ATmega on-board) on the PC, and then ran the two sketches with the Arduino connected to the Pi. The sketches worked fine with the Arduino on the PC, as well as the Arduino on the Pi.
10. Now knew that the ATmega chips were OK.
11. Removed the ATmega from the Arduino and re-installed it on the Gertboard.
12. Now ran the sketch with the Gertboard connected to the Pi to read from the EEPROM. EEPROM was pre-written with data from the last operation.
13. The result of the read operation was FF in all locations. This confirms the original problem.

I wonder if the problem may be with the USART connection. I use the minicom terminal program (minicom ama0).
What do you think?

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Writing and Reading From ATmega EEPROM

Sat May 24, 2014 7:51 pm

Now I'm fully stumped.

Reading/writing the EEPROM is all happening on the silicon, inside the black box. It either works anywhere, or it's kaput everywhere.

I highly doubt it's the USART connection. On the Gertgoard, the USART pins of the ATmega are directly connected to the USART pins of the Pi (ttyAMA0). It doesn't get any better than that. Some people dislike minicom (I think it's fine). If you don't trust it, try 'screen' ("screen /dev/ttyAMA0 9600" or something). But there's no indication at all there's something wrong with it.

On the Arduino, there's an FTDI USB-to-serial chip (or a dedicated ATmega32U4/16U2 on newer Arduinos, whatever) that converts all the signals (ttyACM0 or ttyUSB0). It's more likely for things to go wrong there.

I really hope someone comes along and solves this, because I'm plaatsvervangend[*] annoyed.

[* I'm not aware of an English word for this. "I'm annoyed for you"?]

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Sat May 24, 2014 9:00 pm

Only you and Gert responded to this problem. I'm going to reply back to Gert's last post and suggest he take a look. I would think he would be interested.

Thanks again for your help.

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Sat May 24, 2014 9:16 pm

Gert van Loo wrote:
using direct register access
Long time since I used the eeprom but my recollection is that you need to unlock access with a number
of signature writes. I suggest you do an intense read of the eeprom section of the datasheet.
Gert,

I have taken the EEPROM issue to an extreme. Panik and I have had quite a few discussions. I hope you may find it interesting to read my reply to him for today where I list the steps I have taken. That reply should be almost to the bottom of this rather long thread.

Basically, I found my sketches to write to and read from the EEPROM work just fine with an Arduino Uno, connected to my PC, and then with the Arduino connected to the Raspberry Pi. They just do not work with the Gertboard, nor will any other sketch I have tried.

Your thoughts would be appreciated. Thanks.

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Writing and Reading From ATmega EEPROM

Sun May 25, 2014 9:26 am

Reading/writing the EEPROM is all happening on the silicon, inside the black box.
Indeed, that is why this has me stumped.
I have one more suggestion:
1/ Program on Arduino.
2 Check on Arduino. (probably works)
3/ Put on Gertboard
4/ Check with Gertboard (probably fails)
Now:
5/ Go back to Arduino and check.
If the contents is the same you have a read problem.
If it is FF somehow it got erased.
Not a solution but at least it will give an indication what is going wrong.

Just to repeat: the major differences are:
The Gertboard run at 12 MHz, the Arduino at 16MHz
he Gertboard runs at 3V3, the Arduino at 5V.
[* I'm not aware of an English word for this. "I'm annoyed for you"?]
The English word your are looking for is 'substitute'.

User avatar
panik
Posts: 369
Joined: Fri Sep 23, 2011 12:29 pm
Location: Netherlands

Re: Writing and Reading From ATmega EEPROM

Sun May 25, 2014 11:49 am

The English word your are looking for is 'substitute'.
Yeah, I found that on google, but wasn't able to use it in a full sentence. Later I found "second-hand" and "vicarious" ("felt through imagined participation in the experience of others"). Anyway, I had a hunch both you and ytram99 would know what I meant. :D
Just to repeat: the major differences are:
The Gertboard run at 12 MHz, the Arduino at 16MHz
he Gertboard runs at 3V3, the Arduino at 5V.
It would be really interesting if any of these differences turn out to be the culprit. USART can be a whiny little bitch (pardon my French) when it comes to baudrates vs crystal frequencies. For a specific project I ran an AVR with a 11.0592 MHz crystal because that's one of the few frequencies with 0% error rate. One would expect the USART to be one of the first peripherals to fail when changing frequencies, but it seems pretty solid (also, eeprom reading/writing is perfectly fine on both my Gertboard and a 'slapped together' 328p on a piece of protoboard running [email protected]).

I've also ran AVRs on 1.8V without any noticable side effects (not full speed of course, 4MHz is the theoretical maximum for the 328p on this voltage but I'm sure there's headroom for overclocking).

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Sun May 25, 2014 4:11 pm

Gert van Loo wrote:
Reading/writing the EEPROM is all happening on the silicon, inside the black box.
Indeed, that is why this has me stumped.
I have one more suggestion:
1/ Program on Arduino.
2 Check on Arduino. (probably works)
3/ Put on Gertboard
4/ Check with Gertboard (probably fails)
Now:
5/ Go back to Arduino and check.
If the contents is the same you have a read problem.
If it is FF somehow it got erased.
Not a solution but at least it will give an indication what is going wrong.

Just to repeat: the major differences are:
The Gertboard run at 12 MHz, the Arduino at 16MHz
he Gertboard runs at 3V3, the Arduino at 5V.
[* I'm not aware of an English word for this. "I'm annoyed for you"?]
The English word your are looking for is 'substitute'.
I did what you suggested and read FF on the Arduino after reading on the Gertboard. One thing though, in order to allow the Arduino to upload again, I had to burn the bootloader on to the ATmega while it was on the Gertboard before installing it again on the Arduino. Would this also erase the EEPROM?

Doing some research, I found in the Avrdude's user's guide that if Avrdude is run with the -e switch, it will reset the flash and the EEPROM to FF's.

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Writing and Reading From ATmega EEPROM

Sun May 25, 2014 4:28 pm

Would this also erase the EEPROM?
Possible. Check the arguments passed by the IDE to the avrdude programming tool.
(There is some where an IDE-option-verbose mode)

ytram99
Posts: 29
Joined: Thu Dec 13, 2012 9:07 pm

Re: Writing and Reading From ATmega EEPROM

Sun Jun 15, 2014 9:22 pm

panik wrote:
The English word your are looking for is 'substitute'.
Yeah, I found that on google, but wasn't able to use it in a full sentence. Later I found "second-hand" and "vicarious" ("felt through imagined participation in the experience of others"). Anyway, I had a hunch both you and ytram99 would know what I meant. :D
Just to repeat: the major differences are:
The Gertboard run at 12 MHz, the Arduino at 16MHz
he Gertboard runs at 3V3, the Arduino at 5V.
It would be really interesting if any of these differences turn out to be the culprit. USART can be a whiny little bitch (pardon my French) when it comes to baudrates vs crystal frequencies. For a specific project I ran an AVR with a 11.0592 MHz crystal because that's one of the few frequencies with 0% error rate. One would expect the USART to be one of the first peripherals to fail when changing frequencies, but it seems pretty solid (also, eeprom reading/writing is perfectly fine on both my Gertboard and a 'slapped together' 328p on a piece of protoboard running [email protected]).

I've also ran AVRs on 1.8V without any noticable side effects (not full speed of course, 4MHz is the theoretical maximum for the 328p on this voltage but I'm sure there's headroom for overclocking).
Hello again,

I though you may be interested in the project I am doing that involves the EEPROM programming. It is my latest blog entry at http://www.thepiandi.blogspot.com. I discuss the EEPROM difficulity about half way down the text. Thanks again for your time and help. I sorry we could not get a solution to the problem.

Return to “HATs and other add-ons”