Hi, here is all the code..:
@ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ; System Clock Options
@ DEVICE pic12F629, WDT_OFF ; Watchdog Timer
@ DEVICE pic12F629, PWRT_ON ; Power-On Timer
@ DEVICE pic12F629, MCLR_OFF ; Master Clear Options (Internal)
@ DEVICE pic12F629, BOD_OFF ; Brown-Out Detect
@ DEVICE pic12F629, CPD_OFF ; Data Memory Code Protect
@ DEVICE pic12F629, PROTECT_OFF
Include "modedefs.bas"
IGNICAO VAR GPIO.0
IMOB VAR GPIO.1
PARTIDA VAR GPIO.2
AUX VAR GPIO.3
ALARME VAR GPIO.4
TEMPO VAR WORD 'time..
LOAD VAR WORD
CONT VAR BYTE
CMCON = 7
TRISIO = %00001000 'GPIO.3 INPUT ONLY
GPIO = 0
cont = 0
TEMPO = 0
LOAD = 55543
ALARME = 0
INTCON = %11000000 'enable interrupt
PIE1 = 1 'enable tmr1 overflow interrupt
On Interrupt Goto TE
TMR1L=load.lowbyte
TMR1H=load.highbyte
IN: PIR1.0 = 0 'tmr1 flag clear
if aux = 1 then
SELECT CASE cont
' CASE 0
' IF TEMPO = 3000 THEN
' SLEEP AND WAKE ON GPIO.3 FALLING EDGE
' GOTO IN
' ENDIF
CASE 1, 2
IF TEMPO = 1000 THEN
GOSUB RE
ENDIF
CASE 3
IF TEMPO = 6000 THEN
GOSUB RE
ENDIF
END SELECT
goto in
endif
BRANCH CONT, [E1, E2,E3,E4]
E1: PAUSE 100 ' THERE ARE THINGS DELETED INSIDE E1 - E4 LABELS
CONT = CONT + 1
T1CON = 1
GOTO IN
E2: PAUSE 100
CONT = CONT + 1
tempo = 0
T1CON = 1
GOTO IN
E3: PAUSE 100
CONT = CONT + 1
T1CON = 1
GOTO IN
E4: PAUSE 100
CONT = 0
T1CON = 0
GOTO IN
DISABLE
TE: tempo = tempo + 1
PIR1.0 = 0
TMR1L=load.lowbyte
TMR1H=load.highbyte
resume
ENABLE
RE: IGNICAO = 0
IMOB = 0
PARTIDA = 0
TEMPO = 0
CONT = 0
T1CON = 0
alarme = 0
RETURN
END
---------------------
so, take a look on label IN, CASE 0
i would like that to happen..
i think it's necessary to use a kind of an interrupt handler and check the flags.. but a i dont know what flags to check..
i think i'll need to set IOC.3 = 1 'enable gpio3 interrupt on pin chage
.....
i hope you help me.. sorry if that is too much..
thanks a lot..!
Sylvio
Bookmarks