Well, if you're not going to use the WDT, and you can spare RB6 and RB7, you could use a
32,768kHz crystal with Timer1.
Code:
@ DEVICE PIC16F628A,WDT_OFF,LVP_OFF,MCLR_OFF,INTRC_OSC,BOD_OFF
DEFINE OSC 4
SYMBOL LED = PORTB.0
LED = 1 ' At POR, LED off after 1st toggle
TRISB.0 = 0 ' LED pin an output
TMR1H = $60 ' Pre-load TMR1 with $6001
TMR1L = $01
PIR1.0 = 0 ' Clear TMR1 overflow interrupt flag bit
PIE1.0 = 1 ' TMR1 overflow interrupt enabled
INTCON.6 = 1 ' Enable TMR1 peripheral interrupt
T1CON = %00111111 ' External 32,768kHz crystal w\caps used, 1:8 prescale, TMR1 on
Main:
TOGGLE LED ' Indicates wake-up timing
@ SLEEP ' Goto sleep (for ~9.999 seconds)
T1CON.0 = 0 ' Stop TMR1 on overflow wake-up
TMR1H = $60 ' Re-load TMR1 with $6001
TMR1L = $01
PIR1.0 = 0 ' Clear TMR1 over-flow int flag
T1CON.0 = 1 ' Re-start TMR1
GOTO Main
END
That would wake-up after sleep at roughly 10 second intervals without a button press. Do
whatever you need for the .1 sec, then go back to sleep.
Bookmarks