EEPROM address registers

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

Hi.

When writing the EEPROM address registers, and subsequently reading a byte of data from the EEPROM, can I then be certain that the address registers still have the same value? The datasheet doesn't say anything specific about this.

I want to read a lot of bytes from EEPROM (one at a time), and depending on what I read, I may want to write something else at the location just read. Can I go ahead and write right away, or do I have to write the same address once more first?
I am of course making sure that no interrupt can spoil anything between the read and the write.

BTW. I am using a Mega16, but I don't think that matters for this question.

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

I always present the address when I read or write to the EEpom as it is part of my 'standard' routine. The time involved in writting the address is so small with respect to writting to an eeprom, it may not be worth the extra code space used up writting a second routine just to avoid the task.

I also check the data after writing to the eeprom and return an error if they are not the same.
Mike

Keep it simple it will not bite as hard

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

Mike gives sound advice. Aside from that, as long as you don't purpousely change the EEARH/L contents, they'll stay fixed even after a read or write access.

On a sideline ('good advice' ...): We out of habit also after EEPROM accesses reset EEARH/L to 0 - if there's an amok write, we at least know where it hits.

Andreas

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

Indeed a couple of extra writes doesn't count much. I'll just add them even if it works without them. Also good advice with the reset to 0.

I was just debugging my code a bit, and I got into a big pile of trouble. I am using a Mega16 together with a JTAG interface. All starts out well, but suddenly I can't program a new *.eep file into the AVR. No error messages (unless I run a verify), but the EEPROM contents in the AVR was unaltered.
I manually checked the *.eep file, and it DID have new values in it. I also tried everything with the "preserve EEPROM" settings, both the Mega16 fuse and a similar setting somewhere in the JTAG setup.
I am using Studio 3.56 as I still consider this the most stable for JTAG use. I am using the new assembler from Studio 4.08 though.

I tried to erase everything and reprogram both flash and EEPROM (after removing the "preserve EEPROM" fuse), but nothing helped. That is, until I out of desperation tried to change something in the code (ie changed something in flash). Then at the first programming of .hex and .eep, all worked again.
Can you explain that? I sure can't :(