View previous topic :: View next topic |
Author |
Message |
orb Guest
|
erase_eeprom() function not recognized with 12F683 compile |
Posted: Wed Apr 15, 2009 9:23 am |
|
|
Hi All,
I have used the erase_eeprom() function on a 16F526 successfully but
it will give me a "Undefined identifier -- erase_eeprom" when compiling it for my 12F683. The write_eeprom() function works well.
Any suggestions?
Here's my code:
Code: | VOID saveToMem(INT lastState){
erase_eeprom(0x00);
write_EEPROM(lastStateAdd, lastState);
write_EEPROM(ftpuAdd, ftpuVal);
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Apr 15, 2009 10:03 am |
|
|
The documentation in the CCS manual is limited and only says: Quote: | Function: This will erase a row of the EEPROM or Flash Data Memory. | My guess is the catch is in the word 'row'.
A PIC12F519 has EEPROM data which can only be erased in rows of 8 bytes.
The PIC12F683 has EEPROM data where each individual byte will be erased on writing, there is no need to do a separate erase action. |
|
![](templates/subSilver/images/spacer.gif) |
orb Guest
|
|
Posted: Wed Apr 15, 2009 10:18 am |
|
|
Oh is that the case? I thought all baseline devices containing EEPROM used the same erase-all-eight-bytes technique.
Thanks for pointing that out.
I'll remove the erase_eeprom() function.
Thank you!!!! |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
checksum anybody ?? |
Posted: Wed Apr 15, 2009 10:32 am |
|
|
these look like key program parameters you are saving
and
i see what you want to do
but
there is a serious risk:
You are not writing a checksum to be sure the data - when read - IS VALID! ( kind of a small pic to implement a CRC check)
so after programming - on first run - you will have random or otherwise potentially useless/dangerous nonsense in flash .
Try - this
initialize a byte or word to some value - any value will do
then as you write the data to flash , create a running checksum
with that value as a seed. ( just add the data you are writing to the seed value)
And finally write that checksum to flash also - after your data
THEN on READBACK -
extract the values , INTO TEMP VARS , and sum them starting from the same checksum seed as when you stored them.
Next be sure that the checksum you wrote - is valid when you compare.
if so - use the vlaues read - if NO match sub safe values instead.
with int8 as a check seed - there is a 1 in 256 chance of corruption
with int16 a 1:65536 chance
it protects on an initial startup - since you can reject bad data and substitute safe - or initial conditions ..
and only properly saved data will be able to be restored
then you will have confidence in the performance of the program. |
|
![](templates/subSilver/images/spacer.gif) |
|