hello.
I've looked for posts discussing @sleep on 12f629 but I got nothing (I did get, but nothing helpful). I would like to make 12f629 sleep an wake on gp3/!MCLR/Vpp change (on falling edge).
Is this possible ? How?
Thanks!
Sylvio
hello.
I've looked for posts discussing @sleep on 12f629 but I got nothing (I did get, but nothing helpful). I would like to make 12f629 sleep an wake on gp3/!MCLR/Vpp change (on falling edge).
Is this possible ? How?
Thanks!
Sylvio
How wide is this falling edge pulse?
Do you realize that a short low going pulse on the MCLR pin is the same as a reset and therefore can be used as a wake up signal?
Maybe use a 10K pullup on MCLR to Vdd, put your pulse into the MCLR pin itself thru a capacitor. As the pulse goes low, so does the cap, for a short period of time (depending on the size of the cap and the value of the pullup), then shortly later, the pullup resistor charges the cap back to Vdd...BAM...instant pulse generator...also, instant wake up...
Try it and see what happens. It's worked for me before.
but i set MCLR_OFF
in my project gp3 is an input and it is connected trought the bc548 collector pin...
and the pulse takes around 1 second...
thanks...
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
If you just want to put the PIC to sleep, and wake up on keypress, you don't
need to enable global interrupts.
Here's something to start with.
You take it from here. Pretty much all you need is in the data sheet, and it'sCode:@ DEVICE INTRC_OSC_NOCLKOUT,WDT_OFF,MCLR_OFF DEFINE OSCCAL_1K 1 GIE VAR INTCON.7 ' Global interrupt enable 1=ON, 0=OFF GPIE VAR INTCON.3 ' Port change interrupt enable 1=ON, 0=OFF GPIF VAR INTCON.0 ' Port Change Interrupt Flag bit LED VAR GPIO.0 ' LED output GND---/\/\/\---|<|--GPIO.0 Key VAR GPIO.3 ' Key input (10K pull-up w/switch to ground) X VAR BYTE ' G.P. CMCON = 7 ' All digital GPIO = 0 ' Clear port on boot TRISIO = %00001000 ' GPIO.3 input, rest outputs GIE = 0 ' Disable global ints GPIE = 1 ' Enable port change int IOC.3 = 1 ' Int-on-change for GPIO.3 enabled X = GPIO ' Take a snap shot of port on boot Main: X = 10 REPEAT TOGGLE LED ' Toggle LED X = X - 1 PAUSE 250 UNTIL X = 0 @ SLEEP ' SLEEP until Key is pressed WHILE Key = 0 ' Wait for Key release WEND GPIF = 0 ' Clear port change interrupt flag GOTO Main END
simple to understand if you take your time...;o}
hey Bruce, thanks!
That is what i was trying to get..
I'm going to update my code and then i'll post de results...
thank very much!
Sylvio
Bookmarks