Hi all,

I need some advice on BOD Brown Out Detect programming as I'm doing my head in....

Pic 12F683 locks up when Vdd voltage drops below 0.6Vdc and then returns => 1.5Vdc.

Obviously I need to use the built in BOD feature but I'm having issues getting it to work the way I want. Here are my issues:

1. If I set config fuse BOD = ON -> the device is continually in reset even when Vdd = 5V - basically a complete lock up.

2. If I set config fuse BOD = SBODEN and enable BOD within the program - the PIC will reset at the place the code executes the enable BOD command. However - the pic does indeed BOD reset when voltage BOD occures.

3. If I never enable BOD - then the program continues to work happily until a voltage BOD occures.

What I want is for the program to keep running until a BOD occurres (~2.0Vdc) - then reset.

Can someone see where I have gone wrong and point me in the right direction?

Code:
' SET FUSES
ASM  ; PIC12F683 
   __CONFIG    _MCLRE_OFF & _WDT_ON & _INTRC_OSC_NOCLKOUT & _BOD_SBODEN & _CPD_OFF &_PWRTE_ON 
ENDASM
    PAUSE 100                              ' STARTUP DELAY
    CMCON0 = 7                             ' TURN ANALOG COMPARATOR MODE OFF
    ANSEL = 0                              ' MAKE ALL GPIOS INPUT ACCEPT GP2
    TRISIO = $3B                           ' INT OSC 4MHZ
    OSCCON = $61                           
    
    SBOREN  VAR PCON.4
    POR     VAR PCON.1
    BOR     VAR PCON.0
         
    SBOREN = 0                              ; BOR DISABLED
    
    
    PAUSE 1000
    SEROUT2 GPIO.2,188,["XXXXXXXXXXXX",13,10]    ; CLEAR BUFFER
    SEROUT2 GPIO.2,188,["RESET",13,10]     ; ANNOUNCE PROGGY STARTED/RESET
  
MAIN:
  if POR = 0 then                          ; POWER RESET OCCURRED
        SEROUT2 GPIO.2,188,["POWER RESET OCCURRED",13,10]
        POR = 1                            ; CLEAR POR FLAG
        ENDIF  
  if BOR = 0 then                          ; BROWN OUT OCCURRED
        SEROUT2 GPIO.2,188,["BOR OCCURRED",13,10]
        BOR = 1                            ; CLEAR BOR FLAG
        ENDIF
  
    SEROUT2 GPIO.2,188,["Hello World!",13,10]
    PAUSE 1000
                    
    SBOREN = 1 ' ENABLE BOR                ; ENABLE BRWN OUT DETECT
    
    GOTO MAIN
    END