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

Using high-endurance program Flash memory (PFM) PIC16F1509

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



Joined: 01 Mar 2010
Posts: 74

View user's profile Send private message

Using high-endurance program Flash memory (PFM) PIC16F1509
PostPosted: Fri May 30, 2025 3:16 pm     Reply with quote

Hello,

I'm using a PIC16F1509 with PCM Compiler V4.140.

I haven't updated the compiler in a long time because this version just seemed to work for all of my projects and I didn't want to take any chances.

I'm in a position now where circumstances have forced me to use a PIC161509 but I need it to remember a single bit on power down.

I searched around on the forum a bit and saw some function called write_virtual_eeprom() that could be used for this but it seemed like maybe it was buggy from the posts I read on a PIC161508.

I suspect that maybe this functionality is not even built in on V4.140. I'd prefer to stay on V4.140 but I know that's probably unreasonable and can upgrade.

Anyway, if I'm just looking to save a single bit on a power cycle on the device is there a relatively easy way to do this?
Ttelmah



Joined: 11 Mar 2010
Posts: 19850

View user's profile Send private message

PostPosted: Sat May 31, 2025 9:33 am     Reply with quote

OK.
Let's take a deep breath. Very Happy
You talk about this as being small?. Just a single bit???
How often does it need to change?.
These are critical questions.

The point about the HEF, is that like the program memory itself, it needs
to be page erased. So if you are writing just a single item, and it only needs
to change every few weeks, you can get rid of the code size/complexity
involved in the virtual EEPROM driver, and just writ the value into a single
location in this memory, erasing the page when you do this, Reserve the
whole page and then things are happy.
Now the problem you have is that there were bugs with the rwrite program
memory function on many of the older compilers. When I saw the start of
your post I thought 'no problem, all fixed', but then realised you were
using an antique compiler. Well over ten years old.
Now on your chip, the erase page, is 32 words. So this is the smallest
amount hat can be erased at a time. There is an issue, which you need to
be aware of, that the processor has to effectively 'stop' while the erase
is done. So about 4mSec. So long as this is not a problem, look at:
[url]
https://www.ccsinfo.com/forum/viewtopic.php?t=59721&start=0
[/url]

Where I posted fixed code to perform the read and write to this memory.
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