CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

erase_eeprom() function not recognized with 12F683 compile

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
orb
Guest







erase_eeprom() function not recognized with 12F683 compile
PostPosted: Wed Apr 15, 2009 9:23 am     Reply with quote

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);
}

ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Apr 15, 2009 10:03 am     Reply with quote

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.
orb
Guest







PostPosted: Wed Apr 15, 2009 10:18 am     Reply with quote

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!!!!
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

checksum anybody ??
PostPosted: Wed Apr 15, 2009 10:32 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group