The idea is that the chip sleeps until it gets an interrupt. This all works fine with 6 volts. I'm not setting the brown out to disabled here because I have to do it via the programmer (believe me, I've tried it both ways). I also set the internal oscillator with the programmer. It only has a setting for internal with or without the clock, not a frequency.
Code:
Code:
'----------------------------------------------------------------
' includes
'----------------------------------------------------------------
Include "modedefs.bas"
'----------------------------------------------------------------
' definitions
'----------------------------------------------------------------
'----------------------------------------------------------------
' constants
'----------------------------------------------------------------
'----------------------------------------------------------------
' variables
'----------------------------------------------------------------
i var byte
'----------------------------------------------------------------
' init
'----------------------------------------------------------------
init:
' set all VARs to zero
clear
' set configuration fuses
@ DEVICE pic16F628A, WDT_OFF ' turn watchdog timer off
' set up interrupt handler
INTCON = %10010000
OPTION_REG = 0
on interrupt goto handleInterrupt
low 7
' set portb/0 to input
TRISB.0 = 1
'----------------------------------------------------------------
' main
'----------------------------------------------------------------
main:
sleep 0
pause 1
' blink an LED on pin RB7
for i = 0 to 3
high 7
pause 300
low 7
pause 300
next
goto main
'----------------------------------------------------------------
' handleInterrupt
'----------------------------------------------------------------
disable
handleInterrupt:
' globally turn off interrupts
INTCON.7 = 0
' clear the interrupt triggered flag
INTCON.1 = 0
resume
enable
END
Thanks!
-Tom
Bookmarks