I think I understand what you guys mean, this would be the metacode
set BODEN config bit to 1
set BOD bit to 1
set POR bit to 1
read level from eeprom / set level
mainloop
check for BOD/POR bits at PCON register
if BOD=0 then wait for POR=0 and change to next level and write it to eeprom.
goto mainloop
end
Is this correct?
I have some questions:
What would happen if power is lost while writing to eeprom?
Can this be handled with PBP without using interrupts?
Regarding the cap, I don't have a oscilloscope to see the discharge curve, it seems to last around 1seg to fall below 2v but this measurement was done by the eyemeter.
Hi, Peu
NO, you did not understand ...
1) You enable BODEN, nothing else required ...
2) AT program start, you first read the BOR bit
3) If BOR Bit = 0 THEN (and only IF ) you increase the EEPROM content : That means power is back, and did not reach ZERO !!! ( no Pb to write , then ...)
4) If BOR Bit = 1 power has gone to ZERO ( and BOR bit has been reset ) ... just read the EEPROM content .
5) you SET BOR bit
6) you run your "lighting" program ...
Think simple !!!
Alain
Last edited by Acetronics2; - 12th March 2008 at 20:55. Reason: BOR Electrical levels inverted ...
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
KISS principle... I know... Im getting older&rusty(just crossed the 40 mark).
Will give your post explanation a try in real code and let you know. Thanks!
Im kinda lost again:
From TABLE 9-6: INITIALIZATION CONDITION FOR SPECIAL REGISTERS
PCON is initialized with %00000010 (POR=1 BOD=0)From these datasheet entries I dont understand when BOD goes to 1From 2.2.2.6 PCON Register
REGISTER 2-6: PCON — POWER CONTROL REGISTER (ADDRESS: 8Eh)
bit 0 BOD: Brown-out Detect STATUS bit
1 = No Brown-out Detect occurred
0 = A Brown-out Detect occurred (must be set in software after a Brown-out Detect occurs)
Hi,
Do not worry !!!
1 = No Brown-out Detect occurred
0 = A Brown-out Detect occurred (must be set in software after a Brown-out Detect occurs)
sooo ... just use the Bit level corresponding to what happend ! ... invert BOR levels I indicated for 3) and 4) and you'll have it ...
I've correct the thread , NOW ... I had not used that feature for a while ...
<< Im getting older&rusty (just crossed the 40 mark). >>
... and me the 51 Mark !!!
Alain
Last edited by Acetronics2; - 12th March 2008 at 20:56.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Im reading different PIC datasheets so shed some light about the BOD sequence, but most of them share the same wording, Im really lost.
I made a little proggie to test what I've learned in this thread, but it does not work, maybe Im missing something stupid, but after many hours of trying, maybe what I need is a good rest:
then the schematic is pretty simple, a ceramic capacitor at the power lines for storing some battery, a couple of leds at the specified pins and a momentary switch that allows me to cut VDD for a moment.Code:@ device pic12f683,INTRC_OSC_NOCLKOUT , wdt_on, mclr_off, protect_off, bod_on CMCON0 = %00000111 ' Disable comparator VRCON = %00000000 ' disable ' I/Os TRISIO = %00000000 ' no inputs ' definitions BODD var PCON.0 gpio=%00000100 'I know program cold started pause 1000 'gpio.2 green led pin5 indicates coldstart gpio=%00000000 loop: if BODD=0 then gpio=%00000010 'GPIO.1 red led PIN6 shows a BOD state pause 1000 gpio=%00000000 BODD=1 endif goto loop
It does not vork
[edit] Maybe I need to check for POR=1 and BOD=0 to know for sure that a BOD reset happened
Help!![]()
Last edited by peu; - 13th March 2008 at 02:11.
gpio=%00000010 'GPIO.1 red led PIN6 shows a BOD state
pause 1000
Here is the best reason ( may be others ... I must check ) for your gadget not to work ...
THE DEVICE MUST DRAW AS LITTLE CURRENT AS POSSIBLE !!!
Your led leads VCC voltage to ZERO ... so ... POR and not BOR !!!
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Rest helped clear my mind
I will test this code as soon I arrive at my office:
I can't imagine simpler code to test the BOD function. Do you see something wrong?Code:@ device pic12f683,INTRC_OSC_NOCLKOUT , wdt_on, mclr_off, protect_off, bod_on CMCON0 = %00000111 ' Disable comparator VRCON = %00000000 ' disable ' I/Os TRISIO = %00000000 ' no inputs ' definitions ' init values if PCON.0=0 then gpio=%00000100 'Brown-out detected turn on LED on PIN5 else gpio=%00000010 'Brown-out NOT detected turn on LED on PIN6 endif 'main loop loop: goto loop
Bookmarks