View Full Version : PIC16F690 EEPROM not retaining data
xnihilo
- 13th June 2008, 22:50
Hi,
I've got a very strange behaviour.
I write data to the internal eeprom with statement such as:
write healed_,healed
READ healed_,tempvar
IF (tempvar != healed) then
SOUND speaker,[100,200]
LCDOUT $fe,1,"writeRoR"
PAUSE 2000
ENDIF
and get no message, which means the write could be verified.
Then, when I turn off the circuit and turn on again, I display the values in the EEPROM and they are those I set at the time I flashed the PIC:
DATA @10,0,0 'first hit
DATA @12,0,0
DATA @14,0,0
DATA @16,0,0
DATA @18,0,0
DATA @20,0,0
It happens as if the EEPROM does not keep the data I WRITE.
Would anyone have an idea why??
mister_e
- 13th June 2008, 23:11
Healed, Healed_ AND TempVar are Bytes?
mackrackit
- 13th June 2008, 23:26
DATA @10,0,0 'first hit
DATA @12,0,0
DATA @14,0,0
DATA @16,0,0
DATA @18,0,0
DATA @20,0,0
Is the above in the code you are running.
I display the values in the EEPROM and they are those I set at the time I flashed the PIC:
If so, every time the PIC starts those values are written. If this is not the case then...
mister_e
- 13th June 2008, 23:47
Nope.. DATA is performed at programming time only. :o
xnihilo
- 14th June 2008, 00:07
Healed, Healed_ AND TempVar are Bytes?
healed is a BYTE var
healed_ is a CON pointing to the EEPROM location where I backup value of healed variabme
tempvar is a BYTE var
xnihilo
- 14th June 2008, 00:09
DATA @10,0,0 'first hit
DATA @12,0,0
DATA @14,0,0
DATA @16,0,0
DATA @18,0,0
DATA @20,0,0
Is the above in the code you are running.
If so, every time the PIC starts those values are written. If this is not the case then...
Really?
I thought that DATA @... was only used at the time the PIC is programmed only.
Then How should I set initial values at programming time???
xnihilo
- 14th June 2008, 00:10
Nope.. DATA is performed at programming time only. :o
Ah, that's what I thought, otherwise DATA would make no sense.
There is another instruction to alter EEPROM value: it is READ and WRITE
Archangel
- 14th June 2008, 00:10
Hello xnihilo,
what does your code which makes healed_ into an address location look like ?
xnihilo
- 14th June 2008, 00:15
Thank you for your help but this time I could solve the problem:
I was using a routine that displays at the begining of the program the contents of the EEPROM at location 10 to 21 using an index var (hitnr).
Then later in the program I was writing to EEPROM using the index var BUT i forgot to reset the index var to its initial value after using it at the begining of my program so I was thinking I was writing to location 10 while the index var was already at 12. So when restarting the pic, I was displaying values of locations 10 and 11, that were still at 0 so I thought EEPROM write failed somehow. I was at the wrong memory offset...
Stupid error, I should get some sleep :)
Have a nice day.
mackrackit
- 14th June 2008, 00:32
Stupid error, I should get some sleep
ME TOO. I was close.
Powered by vBulletin® Version 4.1.7 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.