View previous topic :: View next topic |
Author |
Message |
sjharris
Joined: 11 May 2006 Posts: 78
|
Problem when power disconnected |
Posted: Fri Jan 05, 2007 3:02 am |
|
|
Hello,
I have created a program that runs with very low current consumption when the PIC is asleep, ~3uA.
The PIC wakes up from sleep with an interrupt from a pin. The pin must be held low for 3 seconds, then the PIC will wake and go into normal operate mode.
I have a problem with the pic in normal mode. If I disconnect the battery from the PIC and then re-connect it the PIC does not resume from where it was nor does it restart the program instead the PIC does not respond to any input from the user at all.
It is as if the PIC has gone into some intermediate state where it will not respond.
I am using a 16f688
and the first thing it does is to go to sleep (after setting up PIC).
FUSES are:-
NOWDT
PUT
INTRC_IO
NOBROWNOUT
NOIESC
NOFCMEN
Please can anyone help!!
(I cannot post too much code due to security but I will try and accomodate as much as possible).
Many Thanks
S Harris |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Fri Jan 05, 2007 4:57 am |
|
|
Two ideas:
- Try it with BROWNOUT enabled (this would prevent the PIC going into indeterminate state upon temporary low voltage)
- Use the Watchdog to reset the PIC when the code goes astray or execution freezes. |
|
|
sjharris
Joined: 11 May 2006 Posts: 78
|
Thanks |
Posted: Fri Jan 05, 2007 5:18 am |
|
|
OK,
I know that with Watchdog timer I have to reset it otherwise it resets the PIC but do I need to with brownout as well?
PS What is the correct way to set up WDT on 16F688 ?
PPS Can I set the WDT to reset at any given delay, e.g. 60 seconds?
Thanks
Also is there a difference between Brownout and Software Brown Out??
Thanks again |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Fri Jan 05, 2007 5:39 am |
|
|
No. The BROWNOUT feature enabled will reset the PIC when supply voltage drops below a certain level, read the manual for the values. You don't have to regularly 'reset' the brownout detector in software like the watchdog. It will work by itself.
You can however check for what reason a reset has occured in software in the beginning of your code and act accordingly if you wish.
Do you have any I/O pins receiving power into them when no power supply present ? This can also cause a random latch-up you observe. |
|
|
sjharris
Joined: 11 May 2006 Posts: 78
|
|
Posted: Fri Jan 05, 2007 5:50 am |
|
|
When the PIC is in normal operate mode (powered and out of sleep) there are 3 with a possiblity of a fourth pin that could be powered. But when the power is disconnected there is no power to these pins.
There maybe a bit of cap discharge through one of the pins that is set to an output, could the caps be discharging through the output pins on the PIC? |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Fri Jan 05, 2007 6:10 am |
|
|
Does a hardware reset (pulling low the MCLR pin) bring the PIC out of this indeterminate state ?
You can read this Application Note AN607 for some clues. Here |
|
|
sjharris
Joined: 11 May 2006 Posts: 78
|
|
Posted: Fri Jan 05, 2007 6:59 am |
|
|
I have now read the app note and have disconnected the caps that may be powering the pins to the PIC. This has not solved the problem. I may need to add a brownout circuit!!
Any other help would be most apreciated.
Thanks
SHarris |
|
|
sjharris
Joined: 11 May 2006 Posts: 78
|
|
Posted: Fri Jan 05, 2007 7:35 am |
|
|
I think my problem stems from the fact that the power supply is disconnected abruptly.
Would the brownout detect this sudden drop in voltage or does it need a ramp to enable the brownout?
Would a cap discharging across the Vdd be better?
Dont worry about the cap idea, too much leakage current.
Thanks
S Harris |
|
|
|