 |
 |
View previous topic :: View next topic |
Author |
Message |
picj1984
Joined: 01 Mar 2010 Posts: 74
|
Using high-endurance program Flash memory (PFM) PIC16F1509 |
Posted: Fri May 30, 2025 3:16 pm |
|
|
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
|
|
Posted: Sat May 31, 2025 9:33 am |
|
|
OK.
Let's take a deep breath.
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. |
|
 |
|
|
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
|