View previous topic :: View next topic |
Author |
Message |
GiG
Joined: 03 Sep 2021 Posts: 39
|
How to use eeprom and flash |
Posted: Sat Dec 18, 2021 6:55 am |
|
|
Hello geniuses,
I searched the internet for a while and did not find the right answer.
I wanted to know how to use internal eeprom (e2prom).
I used 16f723 that i think doesn't have eeprom (e2prom).
So If true how to use flash for read and write ?
What i need to write and read is a bit or maybe a temperature as byte
and check it at start of program.
An example code can be a Great help.
Thank you |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9224 Location: Greensville,Ontario
|
|
Posted: Sat Dec 18, 2021 7:53 am |
|
|
While I don't use that PIC...
I downloaded the datasheet for the 723 and I can't see that you can write to flash (aka program memory). There are others in the 'family' that have additional memory that you can use, but NOT the 723. |
|
|
GiG
Joined: 03 Sep 2021 Posts: 39
|
|
Posted: Sat Dec 18, 2021 10:53 pm |
|
|
Thank you for your attention.
Well, as you say, then there is no way to store information for a power outage? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19503
|
|
Posted: Sun Dec 19, 2021 4:24 am |
|
|
This is actually a very unusual chip in not offering Program Memory Write.
Historically the oldest PIC's did not offer this. For newer chip over 95% do.
Using the program memory is hard compared to using EEPROM, since if you
want to clear any bit in a cell, you have to erase an entire page. Honestly
why not just add an external I2C EEPROM?. Just two pins needed to do this
and using software I2C, almost any pins can be used. Or if your device
needs a clock, then add a basic RTC module. 90% of these also offer some
battery backed RAM. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9224 Location: Greensville,Ontario
|
|
Posted: Sun Dec 19, 2021 6:52 am |
|
|
As Mr. T suggests, add an external EEP or RTC. My vote is for the RTC. Not only can it store a few bytes of data, it gives your PIC a battery backed clock.
Since you're concerned about 'power failure', another option is to add a big battery, supercap and some code that senses 'power line failure' then puts PIC program into a 'hibernate' mode. Then, when power is restored, it wakes up and runs normally.
I'd think 4 D cells could power a PIC for months,though we don't know what else is connected to it. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19503
|
|
Posted: Sun Dec 19, 2021 7:16 am |
|
|
There is also another reason why other methods are 'better'. If you are
physically writing to to the program memory at the moment a power fail
occurs, in some cases this can result in damage to the whole of the program
memory (not just the cell being written...). |
|
|
|