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 support@ccsinfo.com

flash variable erased

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



Joined: 19 Jan 2014
Posts: 4

View user's profile Send private message

flash variable erased
PostPosted: Tue Feb 10, 2015 12:33 pm     Reply with quote

I reserved a small flash area of a 18f45k22 to save some variables.
A device returned with this area erased.
How is this possible ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 10, 2015 12:50 pm     Reply with quote

Do a forum search for:
Quote:
flash corrupt*

Set it to: Search for all terms

There are many threads on this topic. Here are two of them:
http://www.ccsinfo.com/forum/viewtopic.php?t=40163
http://www.ccsinfo.com/forum/viewtopic.php?t=43035
Ttelmah



Joined: 11 Mar 2010
Posts: 19454

View user's profile Send private message

PostPosted: Tue Feb 10, 2015 1:25 pm     Reply with quote

as an 'add on' to the threads suggested by PCM_programmer, if you are 'reserving a small flash area to save some variables', have you studied how this has to be done. Flash is _not_ like EEPROM. You can't just write a byte. To change one byte, you have to read an entire _page_ (64bytes on this chip), change the single byte you want to modify, and write the whole page back. A write to the first byte of a page, _will_ erase the whole page.
lor3nzo



Joined: 19 Jan 2014
Posts: 4

View user's profile Send private message

PostPosted: Tue Feb 10, 2015 5:23 pm     Reply with quote

When flash erase size is equal to flash write size, bytes outside the range of the write block are not changed. Is this true?
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