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

How to use eeprom and flash

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



Joined: 03 Sep 2021
Posts: 39

View user's profile Send private message

How to use eeprom and flash
PostPosted: Sat Dec 18, 2021 6:55 am     Reply with quote

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: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Dec 18, 2021 7:53 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Dec 18, 2021 10:53 pm     Reply with quote

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: 19537

View user's profile Send private message

PostPosted: Sun Dec 19, 2021 4:24 am     Reply with quote

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: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Dec 19, 2021 6:52 am     Reply with quote

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: 19537

View user's profile Send private message

PostPosted: Sun Dec 19, 2021 7:16 am     Reply with quote

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...).
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