I tried reading stored values from EEPROM and putting them into SRAM on my ATmega16. SRAM isn't a problem, but EEPROM is. I followed a tutorial about reading from EEPROM stored values and got this:
ldi acc, low(EaddrL); get address for reading ldi acc2, high(EaddrL) out EEARL, acc ; set address for reading out EEARH, acc2 sbi EECR, EERE ; activate reading in acc, EEDR ; get result sts addrL, acc ; store to SRAM ; (marked position) .dseg addrL: .byte 1 .eseg EaddrL:.db 0x00
When testing in AVR Studio 4.13, the line
in acc, EEDR
always reads 0xFF while it should read 0x00 which is stored in EEPROM.
The funny thing: they (the tutorial) are talking about a loop that waits for data being read from EEPROM, but added a simple
at the marked position. This can't be right because the line reading EEDR isn't being recalled and the loop is endless, i.e. the program will never get out of that loop again. Their program has an out to a port instead of the sts I have put there...
In the tutorials section here, I only found C-Tutorials related to EEPROM and a search for EEPROM in this forum returned about 500 results, the first page didn't do any good.
The ATmega16 datasheet has almost the same example except it uses sbic instead of sbi. But as this is the only EEPROM access (yet), it should be working.
So how do you suggest creating that loop so it actually does wait and continue after data is loaded?
Thanks for any advice or comment!