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 support@ccsinfo.com

Interrupt disabling while in eeprom writing

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



Joined: 17 Oct 2011
Posts: 23
Location: Iran-tehran

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

Interrupt disabling while in eeprom writing
PostPosted: Sun Apr 28, 2013 6:46 am     Reply with quote

hello all.
I'm writing a program for controlling a triac component.(a variable dc power supply).and I've used a zero cross circuit for understanding beginning of AC input signal. and I have connect this circuit to external interrupt.
also I have a timer for understanding machines life and I should save this time to the EEPROM every minute .
the problem is that : when program arrive to the eeprom writing line . it cause problem for the interrupt . and prevent it from working .
Is there any way for disabling this situation?
( I have used this code:"#device WRITE_EEPROM = NOINT" but there is still a stop of about 1 second in every minute of my program)
Thanks
_________________
thanks and hope of success for you
Mohammad_Hosein
dyeatman



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

View user's profile Send private message

PostPosted: Sun Apr 28, 2013 8:00 am     Reply with quote

Your problem comes from the fact that EPROM writes take a lot of time from
the CPU cycle perspective and can't be interrupted.

Try FRAM. FRAM delay-less writes eliminate those issues and there are drop
in replacements for many EPROMs. Plus you get a longer memory life as a bonus!
_________________
Google and Forum Search are some of your best tools!!!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19359

View user's profile Send private message

PostPosted: Sun Apr 28, 2013 8:21 am     Reply with quote

It'd help if you told us 'what chip'?.
On most modern chips, there are _parts_ of the EEPROM write cycle, that must have the interrupts disabled, but these are very brief. Basically the unlock sequence to the moment the write is started. If this is interrupted, the unlock won't work. However the long delay (wait for the write to occur), can have interrupts enabled.
However on most chips, you should not be writing to the EEPROM every minute. This will typically kill the chip in anything from ten days to a couple of years. You should either only update the data after power fails, or switch to an external memory without the write life limitations, like the FRAM.....

Best Wishes
mhjccsinfo



Joined: 17 Oct 2011
Posts: 23
Location: Iran-tehran

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

PostPosted: Sun Apr 28, 2013 8:55 am     Reply with quote

thanks for your help.

the MCU I'm using is "PIC16f877A" .
I may change it to "PIC18f452" if it has the ability.
-------
Quote:
Try FRAM. FRAM delay-less writes eliminate those issues and there are drop
in replacements for many EPROMs. Plus you get a longer memory life as a bonus!

I have not used I2c or FRAM ever so I don't know how long will it take to work with it and also how much does it cost.
Quote:
You should either only update the data after power fails

how is this ?
thanks
_________________
thanks and hope of success for you
Mohammad_Hosein
Ttelmah



Joined: 11 Mar 2010
Posts: 19359

View user's profile Send private message

PostPosted: Sun Apr 28, 2013 9:30 am     Reply with quote

On your chip, the write life of the EEPROM is only warranted for 100K cycles. About 3months.

The FRAM (in I2C versions), can be driven by the code in the library for the equivalent EEPROM's. Key though is that write is basically instantaneous. You finish sending the data, and it is written. Write life is also enormous (trillions of cycles...).

All you do is have enough capacitance on the supply rail to keep the chip running for enough mSec to write the data you want, and detection to say 'power has gone off'. Feed this to an interrupt, and when this fires write the data. Then have the code sit and wait, and if the supply doesn't go off, restart, or continue.

Best Wishes
mhjccsinfo



Joined: 17 Oct 2011
Posts: 23
Location: Iran-tehran

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

PostPosted: Sun Apr 28, 2013 10:16 am     Reply with quote

Ttelmah wrote:

The FRAM (in I2C versions)

could you please introduce a part number of these FRAMs ?
Ttelmah wrote:

All you do is have enough capacitance on the supply rail

I have many LEDs on the circuit so I think I should separate MCU power from other components ( for example by two 7805 ICs )
I have never done this . is this a common way ?does everyone who wants to have a real time clock must use this method ?there is another problem for me to design a circuit for understanding that power is going off[/list]
_________________
thanks and hope of success for you
Mohammad_Hosein
Ttelmah



Joined: 11 Mar 2010
Posts: 19359

View user's profile Send private message

PostPosted: Sun Apr 28, 2013 10:37 am     Reply with quote

Consider just using a real time clock chip. These have memories in them, that do not have the write life limitations of EEPROM. EEPROM is designed for things like configuration information, that changes rarely, not for things that need changes at repeated intervals. Most people doing something like this, probably use one of these.
FM24V02 for the smallest I2C FRAM, but for what you want, reconsider the approach.
Having the processor on a separate supply from anything drawing significant power is always good practice. Do the LED's really need a regulated supply?.
There is a potential problem with any approach writing the time like this, unless you have capacitance to cover the write. What would happen if you have written one byte of your 'time', and then the power failed?.

Best Wishes
dyeatman



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

View user's profile Send private message

PostPosted: Sun Apr 28, 2013 10:55 am     Reply with quote

Here is info from TI about FRAM:
http://www.ti.com/ww/en/mcu/fram_ultra_low_power_embedded_memory/fram_mcu_faqs.htm

Here is info from RAMTRON (the original source for FRAM)
http://www.ramtron.com/support/faqs.aspx

Here is the entire history of FRAM
http://en.wikipedia.org/wiki/Ferroelectric_RAM
_________________
Google and Forum Search are some of your best tools!!!!
mhjccsinfo



Joined: 17 Oct 2011
Posts: 23
Location: Iran-tehran

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

PostPosted: Sun Apr 28, 2013 12:20 pm     Reply with quote

thanks a lot
_________________
thanks and hope of success for you
Mohammad_Hosein
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 29, 2013 7:56 am     Reply with quote

Another alternative is to use Microchips NVSRAM series of chips. These are vastly cheaper than FRAM, but require a backup battery to maintain state.
_________________
Andrew
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