Eeprom reads 255 for an address it doesnt have.

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

The atmega328p has 1024 bytes of eeprom. When I try to read an invalid address like 1900, it is sending a value '255'. Why is this happening? Please tell me why all the bytes of eeprom has a default value of '255'. Also the first byte already had a value of '105'. Does that mean something? I am using an arduino Uno.

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

Sometimes an invalid address is 'don't care' and sometimes it may cause an error / exception.

AVRs are fairly simple. They tend to just ignore the unused bits. So reading 1025 would just access 1 on a 1024 byte memory.

If your address #0 contains 105, see if address #1024 reads the same.

An unused memory is all ones e.g. 0b11111111 or 255.

David.

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

Just out of interest what value were you expecting? It clearly has to be some value from 0x00 to 0xFF or do you know of some special state for 8 bits that is none of the above??

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

akhilpo wrote:
When I try to read an invalid address like 1900, it is sending a value '255'. Why is this happening?

Look on the data sheet:
The unused address bits of EEARH are read only and always 0.
So writing these bits has no effect.
You access always a valid EEPROM byte.

Peter

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

I got it.. thanks for replying.