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

HEF many write cycles
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

HEF many write cycles
PostPosted: Thu Sep 23, 2021 3:14 pm     Reply with quote

Hello.
I would like to ask a question.
I have a code that at each change of state of a pin that will turn on a light, on or off, so I need to record the state that is being turned off, to know how it is when turning on, so I'm writing in HEF, however I saw that in the datasheet it says 100k erase/write, I think it will take a long time to reach this value, but let's say that when it reaches 80k problems may start to occur, or only when it exceeds 100k?
thanks.

PIC 10F322
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Thu Sep 23, 2021 5:53 pm     Reply with quote

The quoted life should not be interpreted as being a set-in-stone value which every unit will achieve before failures start to occur. I believe that your estimate of 80k cycles before "most units" start to see a failure is probably quite reasonable. Temperature extremes as well as power supply value (for example if powered directly from a battery) will impact that number/lifetime.

If my boss was asking the same question, I'd say that 50k would be a wise number to tell him so that his expectations are set appropriately.
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Fri Sep 24, 2021 12:31 am     Reply with quote

Agree with newguy on this.
Lots of other things:

1) Make sure the chip revision is new. If you look at the original 10F32x data
sheet it didn't have HEF. This was added in a later sheet revision. Older
versions of the chip do not have this... Caveat.
2) You can degrade the write life of flash memory very badly if the supply
smoothing is poor. Careful design needed if you are to get close to the
quoted figure,
3) The 'reliability' figures, have the big caveat:
"These parameters are for design guidance only and are not tested.".
4) Be aware the HEF, is only the low byte of each word involved. Don't
try to use the upper bits of the instruction you are writing.
5) The smallest block you can erase is 16 words. Every write or erase uses
a 'life'.
6) You can have failures from life 1. However the probability is very low.
This is why SSD's used instead of hard drives, have spare blocks, and error
checking. They don't rely on even one cell working 100% reliably. If
your data needs reliability, consider writing data with a checksum.
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 24, 2021 4:34 am     Reply with quote

Thank you for your answers.
I only need to save 1 byte and each state change, but I did some calculations and 50k or even 80k would be too little, considering that each write and erase consumes a lifetime.
What would be the other alternative I would have to do this? Does anyone have a tip?
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Sep 24, 2021 5:15 am     Reply with quote

One possible solution..
Have main() during normal operation, save the status of the control pin in RAM. Probably already is.
When the power to the PIC fails or you turn it off, quickly write that 'status' byte to the HEF.
When the PIC is repowered, read the HEF 'saved status' byte and decide how to proceed.

The 'tricks' are
1) to monitor that the PIC has lost power
and
2) have enough reserve electrons in the PSU cap to have the PIC write to the HEF.

I don't know if that PIC can set an interrupt on 'losing power', others might.
How big a cap you need depends on actual PIC current draw and HEF write time. Say you need 20ms of write time....use a cap to give you 3-4x that amount, so it WILL sucessfully write to HEF.
Doing this you only use up an HEF write, once per 'power down' cycle NOT every switch on-off cycle.

Jay
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 24, 2021 5:45 am     Reply with quote

Got it, this PIC model doesn't have a power loss interruption. I would have to do it using external components and maybe with the portA state change interrupt. But I don't have more physical space on the board for more components. But it's a good option, I'll see if it could be done. Thanks
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Fri Sep 24, 2021 7:05 am     Reply with quote

FRAM is quoted as having an "infinite" lifetime, but FRAM memories aren't cheap.

Can you incorporate RAM + small coin cell battery?
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Fri Sep 24, 2021 9:37 am     Reply with quote

Can I suggest something like an I2C clock chip. Most of these have
a small amount of RAM.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Sep 24, 2021 10:55 am     Reply with quote

I'm thinking that since a 10F series is used, cost is a factor ??
Have to admit, I spend $4 for a premade DS3231/EEP module that comes WITH battery. There's 7 or 8 bytes you can use as battery backed RAM in the DS3231 AND you get a 'free' 1Hz interrupt.....oh yeah a real time clock as well....
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Fri Sep 24, 2021 11:23 am     Reply with quote

Actually Cypress has serial FRAM for less than 2 bucks
apiece. I have used them for years and no failures yet.
_________________
Google and Forum Search are some of your best tools!!!!
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Sep 24, 2021 12:06 pm     Reply with quote

If (haha) you had a spare pin, configure it as analog, to measure VDD. Have main() read it, if say >4.5, take no action. when it drops below, indicating a power fail, then save the 'status'. ?
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 24, 2021 2:11 pm     Reply with quote

newguy wrote:
FRAM is quoted as having an "infinite" lifetime, but FRAM memories aren't cheap.

Can you incorporate RAM + small coin cell battery?


I can't embed anything else.
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 24, 2021 2:12 pm     Reply with quote

Ttelmah wrote:
Can I suggest something like an I2C clock chip. Most of these have
a small amount of RAM.


I can't embed anything else.
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 24, 2021 2:14 pm     Reply with quote

temtronic wrote:
If (haha) you had a spare pin, configure it as analog, to measure VDD. Have main() read it, if say >4.5, take no action. when it drops below, indicating a power fail, then save the 'status'. ?


I thought about it, I'm going to test it, because I can't have delays or anything consuming processing, as it can affect the IR reading.
But it's the only option without adding anything.
rodrigo_cirilo



Joined: 31 Mar 2019
Posts: 43
Location: Sao paulo/Brazil

View user's profile Send private message Send e-mail

PostPosted: Fri Sep 24, 2021 2:16 pm     Reply with quote

thanks everyone, i will test this option and be back to report success or failure.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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