|
|
View previous topic :: View next topic |
Author |
Message |
may26baf
Joined: 04 Oct 2006 Posts: 7
|
Help with brownout |
Posted: Sun Oct 15, 2006 8:19 am |
|
|
When power is removed my my device, and then reapplied, the progrmming is resuming from where it left off, and not restarting from the beginning. This is not the behavior I want, because I need to re-initialize all of the other components on my system.
I see that the BROWNOUT fuse is supposed to take care of this, but when I read the data sheet, it explains that 1) there are some configuration bits that have to be set and 2) that this doesn't happen when the device is in Sleep mode.
My question is, how do I configure the device to reset when power is removed and restored?
Here is a sample program I am testing with. If I remove and reapply power, it resumes counting from where it left off.
#include <18f6722.h>
//#device ICD=TRUE
#device ADC=10 // 10 bit a/d conversion
#fuses HS, NOLVP, NOWDT, PUT, BROWNOUT
#use delay (clock=4000000)
#include <led.c>
void main(void)
{
int8 i;
while( 1 )
{
for(i=0; i<10; i++)
blink_led(i);
delay_seconds(1);
}
return;
} |
|
|
Ttelmah Guest
|
|
Posted: Sun Oct 15, 2006 8:44 am |
|
|
If power genuinely was being removed from the device, it'd restart from the beginning, whether or not the 'brownout' fuse is set. The point about the brownout fuse, is that it will force such a restart, if the power rail drops a little, but there is still enough power for the device to run.
So the reason for the bahaviour you are seeing, at heart, is that there is enough capacitance on the supply rail, to run the device for a significant time....
Now, the brownout on your device, has four different 'modes', and one enables brownout behaviour even in sleep. Seperately, it then has the voltage at which brownout reset will occur programmable.
BROWNOUT,BORV45
Will make brownout work all the time, and switch at approximately 4.5v on the supply rail.
By default, brownout _does_ occur in sleep mode. If you did not want brownout to occur in sleep mode, the fuses would change to:
BROWNOUT_NOSL,BORV45
However, either of these will still require the supply voltage to actually drop by half a volt. If you want to genuinely detect external power removal faster, then you would need to add an external supervisory IC, looking at the incoming rail, or reduce the supply capacitance.
Best Wishes |
|
|
may26baf
Joined: 04 Oct 2006 Posts: 7
|
|
Posted: Sun Oct 15, 2006 9:30 am |
|
|
Thanks. That helped. I also discovered that including "#device ICD=TRUE" would override the fuses I was setting. (At least it does on version 3.249 of the compiler) |
|
|
|
|
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
|