Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Writing to EPROM when a power fail occurs (PIC18F2431)

Status
Not open for further replies.

seyyah

Advanced Member level 2
Joined
Oct 7, 2001
Messages
646
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,298
Activity points
6,233
I have a value ( 4 value actually - 4x8=32bits) that i should protect in every case, so i keep it in eprom. That value changes frequently, so i cannot write it to the eprom at every change occurs. I decided to write it when a power failure occurs. So i detect the failure and write it at that time once. For this purpose i supply a big enough capacitor for pics supply. As far as i know, writing to one eprom cell requires 4 ms and 4 of them take 16 ms. As you can see from the figure that there's plenty of time to write it. Sensing the power failure takes ~100-200 usecs. But it can only write one eprom value at most. What may be the problem and how can i solve it?
 

Hi!
You should place the big capacitor before 5V regulator.
The fuse brown out detect should not be activated because will reset the microcontroller.


Cristi
 

your i dea is ok i have done this kind of thing with at89c52 and it work fine.... i used 2200 uf capacitors in power supply and every time i pole the AC 5 volt using bridge and currecnt limmeting resistor and zeneri can e mail you CKT diagram if u want
 

Actually i even make the capacitor bigger but it still does not work. I'll appreciate if you can send me a schematic. I am going to be mad.
 

Actually i am using a 1000mfd capacitor which works well with avr.

I do have tried it with 89s52. Some of the circuit still working (2 years old).

The first problem i faced when designing it was the ciruit before 7805 uses the stored energy as 7805 has a internal reverse diode it. So i used a diode after 7805.

try it out. The second thing was dont use polling(checking at some interval)method. Insted use interrupt to detect the power fail.

Regards
Nandhu
 

I somehow resolved the problem, but still didn't understand the main issue. I have 2 time based interrupts : one is a 100us(high priority) and the second is a 5ms(low priority) interrupt. Initially I was polling the port at 100us interrupt. But it nearly always failed. When i made polling at another place such as main loop or at 5ms interrupt or whenever a low or high interrupt occurs; it worked perfectly even when i use smaller capacitors. I changed many things but still could not find the problem. The 100us interrupt itself does not do much thing; only changes some variables. Can you think of a reason?
 

Using timed polling losses sometime. So i asked you to use an external interrupt. it acts at the instance of powerfail.

Try it out and come up with results

Nandhu
 

nandhu015 said:
Using timed polling losses sometime. So i asked you to use an external interrupt. it acts at the instance of powerfail.

Try it out and come up with results

Nandhu

Yes you are right, it (delay of the sensing) would be the first thing to think, but it is not the situation here if you look at my description above again. A high speed and a high priority interrupt (100 microseconds) cannot handle the situation but a low priority and a low speed (5 milliseconds) interrupt can handle. First and fast interrupt polls at least 50 times more than the slow one. So the problem is not being late here, some other thing, that i could not understand.
 

i have done it by polling the pin at main loop for ,if you want to use timmer then reset the timmer after every zero crossing.
 

drbizzarow said:
i have done it by polling the pin at main loop for ,if you want to use timmer then reset the timmer after every zero crossing.

Hmm you are right. When i detect the power-off situation and go into eprom writing subroutine i disabled the timer and it worked, but disabling the interupt instead, didn't help. I'm still thinking the mechanism that affects the eprom writing though.
 

If your system have a power supply which is greater than 5 V you can monitor this voltage and set the trigger on some safe level, we normally use this way for 11÷30 V powered device.

Just a think.

Cheer
Powermos
 

TekUT said:
If your system have a power supply which is greater than 5 V you can monitor this voltage and set the trigger on some safe level, we normally use this way for 11÷30 V powered device.

Just a think.

Cheer
Powermos

Thanks but for now that's the second issue, i should understand what's going on here and i still could not find a logical answer.
 

Ok.. I have a few questions

Does your eprom and micro share the same 5v?

What is the operating voltage of the eprom?

Nandhu
 

yes this can also work coz pic got to vcc and gnd.....one is for digital vcc gnd and other is analog vcc gnd. so eeprom share digital vcc you can cut anlog vcc grnd after power failuer
 

Hi,
Once the power fail detect is done I hope you are disabling further action on this input until power becomes good? Alternatively, are you disabling the 100µsec. interrupt once the power fail is detected and enable it only when power is good?
Regards,
Laktronics
 

nandhu015 said:
Ok.. I have a few questions

Does your eprom and micro share the same 5v?

What is the operating voltage of the eprom?

Nandhu

Eprom is internal and yes, it shares the same 5V. Hmm i think i overlooked something here. I was assuming that it would operate at 2v or at least 2.5V but according to the datasheet, its minimum stable operating voltage at high speed (which it runs now) is 4.2V. This should be taken care of. Anyway i think it still does not completely answers why high priority, 100us, timer0 interrupt cannot do the proper eprom writing and the others can do. I also connected high capacity capacitors to prolong the discharge of 5V and still did not work. I suspect that it's a software or pic's peripheral problem. I should also mention that more than one wrong places/cells of eprom is written at a power-off if the related routine is placed in 100us timer0 interrupt.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top