Quote Originally Posted by charudatt View Post
Hello Mel,

I am trying to get this sleep comand to work and it simply does not work.

my code:
@ DEVICE PIC16F628A, INTRC_OSC_NOCLKOUT, WDT_OFF, LVP_OFF, PWRT_OFF, PROTECT_OFF, BOD_OFF
CMCON=7
VRCON=%01101100 'VRCON bit7 is OFF for no current drain
OPTION_REG.7 = 0 ' ENABLE INTERNAL PULLUPS
Trisa = %01111111
Trisb = %11111111
LED VAR PORTA.7

'
' PIC Low-Power Sleep Routine
' ---------------------------
'
' Set Sleep Interrupts
' --------------------
INTCON=%00011000 ' Interrupt Control Register
' 7=0 - GIE - Global Interrupt Enable
' 6=0 - PEIE - Peripheral Interrupt Enable
' 5=0 - TOIE - TMR0 Overflow Interrupt Enable
' 4=1 - INTE - RB0/INT Enable
' 3=1 - RBIE - PORTB change interrupt Enable
' 2=0 - TOIF - TMR0 Overflow Flag
' 1-0 - INTF - RB0/Ext Interrupt Flag
' 0=0 - RBIF - PORTB Interrupt Flag
OPTION_REG.6=1 ' 1=RB0 Rising-Edge Trigger, 0=Falling-Edge Trigger

CYCLE:
'
' Reset Interrupt Flags
' ---------------------
INTCON.1=0 ' Reset RB0 Flag
INTCON.0=0 ' Reset PORTB change Flag
'
' Sleep
' -----
LOW LED
@ SLEEP
@ nop
@ nop
@ nop
@ nop

Pause 100 ' Needed for system Wake-Up
HIGH LED : PAUSE 200 : LOW LED
GOTO CYCLE

Maybe I could be missing some thing. The LED just keeps blinking.

Basically I am trying to incorporate this in a garage code lock project.

any help ?
Change the
OPTION_REG.7 = 0 ' ENABLE INTERNAL PULLUPS
to
OPTION_REG.7 = 1 ' DISABLE INTERNAL PULLUPS