Hi there
I found this code that is similar to what I need but I need to modify it a bit and not to sure how. This code uses a interrupt caused by the closing of a switch to ground to wake from sleep, flashes a LED 10 times and then returns to sleep. I need it so the interrupt wake the PIC, which then starts a timer, which when that expires (providing the switch hasn't opened), flashes the LED until the switch is open again (which would pull the input high via a pullup resistor, which would turn off the LED and return the PIC to sleep.
Hi, its great to see you visiting our forum. Why not try Proton Compiler for FREE?
Download the FREE version of Proton Compiler, Its called Amicus18 and its available from HERE
Already using proton Compiler??? Get rid of these pesky messages... get LICENSED USER STATUS
'A change from Vdd to Vss on GPIO.4 will cause the 12F675 to wake up
'It will then blink a LED times and go back to sleep
'Front end setup
Device = 12F675
Config WDT_OFF,PWRTE_ON,CP_OFF,MCLRE_OFF,BODEN_OFF
TRISIO=24 'sets GPIO.3 and GPIO.4 as inputs and all others as outputs (or %00011000)
CMCON=7 'turns off comparator function [CMCON0=7]
ADCON0=0 'no ADC - doesn't seem necessary but may be a good idea
ANSEL=0 'no ADC input - IMPORTANT if using ports in digital mode
VRCON=0 'turns off voltage reference to minimize sleep current
INTCON=8 'Enables port change interrupt ie GPIE
IOCB=16 'sets GPIO.4 for Interrupt on change [IOC=16]
OPTION_REG.6=0 'INT on falling edge
OPTION_REG.7=0 '00000000 WPU enabled,
WPU=38 '00100110 = 38 set unused ports 1,2 and 5 tied to weak pull-up resistors
'Define Variables
wakeup VAR GPIO.4 'input, interrupt on change.
LED VAR GPIO.0 'LED output
x VAR Byte
'Initial settings
LED=0
'Program
START:
INTCON.0=0
DelayMS 100
@ Sleep
DelayMS 100
For x= 1 To 10
LED=1
DelayMS 500
LED=0
DelayMS 500
Next x
GoTo START
End


Reply With Quote

