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

1000000 writings on Eeprom

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



Joined: 15 Nov 2018
Posts: 42
Location: Çanakkale

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

1000000 writings on Eeprom
PostPosted: Tue Jan 01, 2019 3:11 am     Reply with quote

Hello everyone

In pic16f877a datasheet there is such a part
• 1,000,000 erase/write cycle Data EEPROM
memory typical.

If i only write a constant data on one specific address in every millisecond what happens in 16.7 minutes ? (1000000 milliseconds is equal to 16.7 minutes)
Do these writings spoil physical address?
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Tue Jan 01, 2019 3:49 am     Reply with quote

First thing, you can't write every mSec. The write takes between 4 and 8mSec to actually perform.

1M cycles, is the typical value. You should always look at the 'worst
case' value, since this is all that is actually guaranteed.

So writing every 10mSec say, you have a warranted 'life' of 100K cycles.
Gives the same 16.7 minutes.

Yes. The probability of the cell dying starts to appear at this point, and by
perhaps 167minutes, shifts from 'may happen' to 'becoming almost certain'.

You should never use EEPROM like this.

Store the value in RAM or something more durable.

Series of possibilities:
1) Add an external clock chip. Many of these offer 'battery backed' RAM.
2) Add just a battery backed RAM.
3) Implement a 'power fail' interrupt on the PIC, with a supply that can
be guaranteed to be maintained for long enough after this to allow the
value to be written to EEPROM after the power fail is detected.
4) Use an 'infinite life' storage technology, like FRAM.
Ömer Faruk



Joined: 15 Nov 2018
Posts: 42
Location: Çanakkale

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

PostPosted: Tue Jan 01, 2019 4:15 am     Reply with quote

Ttelmah wrote:

You should never use EEPROM like this.

Store the value in RAM or something more durable.

Series of possibilities:
1) Add an external clock chip. Many of these offer 'battery backed' RAM.
2) Add just a battery backed RAM.
3) Implement a 'power fail' interrupt on the PIC, with a supply that can
be guaranteed to be maintained for long enough after this to allow the
value to be written to EEPROM after the power fail is detected.
4) Use an 'infinite life' storage technology, like FRAM.


Thank you very much for your reply. In my program i have a set value. I can increase or decrease this value. I need to store it.

1) Could you write me a popular external 'Battery backed' RAM for examining ?
3) How can i implement power fail interrupt and hardware ?
Please show me the way.
temtronic



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

View user's profile Send private message

PostPosted: Tue Jan 01, 2019 6:03 am     Reply with quote

What kind of hardware you need depends on what you're trying to do.
first, the 877 is, well, obsolete, and should not be used for new designs. uChip offer several replacement PICs, all more powerful, pin compatible and cheaper !
2nd, how much 'data' do you need to store and how often ? If less than say 50 bytes, I'd use a DS1307 RTC chip/module. They are about $2 CDN and come with 56 bytes of battery backed user RAM. It's a great way to store a few variables that change 'all the time'. Bonus is a stable RTC that can interrupt the PIC at 1Hz. I use that as a 'PIC tic' to trigger events like LCD update of time, read sensors, etc.
Now if you want to store a lot of data, again use an RTC module, perhaps one with EEPROM like ...https://www.banggood.com/DS3231-AT24C32-IIC-High-Precision-Real-Time-Clock-Module-For-Arduino-p-81066.html?rmmds=search&cur_warehouse=CN....
I've used these for 2-3 years. They have a better RTC and a LOT of EEPROM. There are hundreds of choices.....

What you have to understand is that most external 'modules' these days use 3 volt devices, so you need to interface to them properly. An easy solution is to use a PIC that WILL run at 3 volts, that way you just hookup the PIC to peripheral.

If you need to use the 877, then as Mr. T says, save your data to RAM, and can be as simple at a 6v battery with 2 diodes in series. There is a lot of information on the web about 'battery backup for PICs', use Google !!

Jay
Ömer Faruk



Joined: 15 Nov 2018
Posts: 42
Location: Çanakkale

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

PostPosted: Tue Jan 01, 2019 7:02 am     Reply with quote

temtronic wrote:

uChip offer several replacement PICs, all more powerful, pin compatible and cheaper !



Thanks for your reply. Which uControllers can i use instead of pic16f877a especially cheapers
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Tue Jan 01, 2019 8:29 am     Reply with quote

If you simply go to the 16F877A page at uChip, it says:
'not recommended for new designs', and suggests the PIC16F18877 as the
direct replacement. Faster, 10* the RAM. 4* the ROM. Extra peripherals,
lower power. The price $1.16, against $4.26 for the older chip. Now honestly
there are dozens of even faster chips with more peripherals once you move
up to PIC8's, but as the PIC16 'direct replacement', this is the chip they
suggest.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 01, 2019 9:50 am     Reply with quote

Before you buy a new PIC, make sure your programmer supports it.
Check the device support list for your programmer. The new PIC may
cost $2 but a new programmer may cost $50.
Ömer Faruk



Joined: 15 Nov 2018
Posts: 42
Location: Çanakkale

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

PostPosted: Tue Jan 01, 2019 10:03 am     Reply with quote

Ttelmah wrote:
If you simply go to the 16F877A page at uChip, it says:
'not recommended for new designs', and suggests the PIC16F18877 as the
direct replacement. Faster, 10* the RAM. 4* the ROM. Extra peripherals,
lower power. The price $1.16, against $4.26 for the older chip. Now honestly
there are dozens of even faster chips with more peripherals once you move
up to PIC8's, but as the PIC16 'direct replacement', this is the chip they
suggest.

You are right but when i search this cheaper chip on the internet there is no sale.
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Tue Jan 01, 2019 10:52 am     Reply with quote

DigiKey, Mouser, Microchip direct sale. All list this.

Beware of 'ebay' chip sellers. Many are selling chips that have failed testing
or are poor copies of the real chips. Only buy from the main suppliers.
Ömer Faruk



Joined: 15 Nov 2018
Posts: 42
Location: Çanakkale

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

PostPosted: Tue Jan 01, 2019 11:13 am     Reply with quote

Ttelmah wrote:
DigiKey, Mouser, Microchip direct sale. All list this.

Beware of 'ebay' chip sellers. Many are selling chips that have failed testing
or are poor copies of the real chips. Only buy from the main suppliers.

I will try them thanks a lot.
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Wed Jan 02, 2019 1:42 am     Reply with quote

On the question 'how to implement a power fail detection', this depends totally
on how your board is powered.

Where the supply comes 'from' (DC source, battery, mains transformer)?.
How it is regulated?.
What else is powered from the PIC supply?. Can these devices be turned off
by the PIC?.
How many bytes need to be saved?.

The minimum current that can be achieved on the PIC's supply rail, determines
the reservoir needed to do the write (dependant on how many bytes have to
be written). The best way of detecting the power going 'off' depends on where
the supply actually comes from.
Ömer Faruk



Joined: 15 Nov 2018
Posts: 42
Location: Çanakkale

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

PostPosted: Wed Jan 02, 2019 2:53 am     Reply with quote

Ttelmah wrote:

Where the supply comes 'from' (DC source, battery, mains transformer)?.
How it is regulated?.


The power supply 220V AC ->transformer->bridge rectifier-> filters >7805 regulator-> 5V
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Wed Jan 02, 2019 3:46 am     Reply with quote

OK. That's actually one of the easiest to do.
Look at a chip like the DS1231. Figure 5 in it's data sheet.
Choose the resistors so that the required sense voltage is given when the
output of the transformer is perhaps 80% of it's nominal figure.
Then as soon as the transformer voltage falls below this point the NMI
output will go low.
Feed this to an interrupt input on the PIC.
Have the code in the interrupt, write the EEPROM, and then sit reading
the INT input pin. If the pin goes high again, wait a few mSec, and then
return from the interrupt (this way the chip will carry on if the power is
restored).
All you need then to do is ensure that the capacitance on the supply rail
can maintain the 5v above the minimum voltage to write the EEPROM for
at least the time needed to write however many bytes are needed (give
at least a 50% margin on this).
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