I want to use Timer1 in asynchronus mode to save power while the pic is put to sleep. I cannot get it to work. See program. The program should blink a led every 8 seconds. I don't know if I need to set OSC = LP, if I need to use Ext or OSC for InitTimer1.
SET INTCON.6 ON 'Enables all unmasked peripheral interrupts
SET INTCON.7 ON 'Enables all unmasked interrupts
SET PIE1.0 ON 'Enables the TMR1 overflow interrupt
SET T1CON.0 ON 'Enables Timer1
SET T1CON.2 ON 'Do not synchronize external clock input
SET T1CON.3 ON 'LP oscillator is enabled for Timer1 clock
InitTimer1 Ext, PS1_1/4 'Timer overflows every 8 seconds with 32khz crystal
ClearTimer 1
StartTimer 1
On Interrupt Timer1Overflow Call IncCounter
Start:
asm sleep
'Jump back to the start of the program
goto Start
Sub IncCounter
SET Led ON
Wait 2 s
SET Led OFF
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I want to use Timer1 in asynchronus mode to save power while the pic is put to sleep. I cannot get it to work. See program. The program should blink a led every 8 seconds. I don't know if I need to set OSC = LP, if I need to use Ext or OSC for InitTimer1.
Pleas advise.
#chip 12f629,4
#config OSC = INT, BODEN = OFF, MCLR = OFF, PWRT = OFF, WDT = OFF
#define Led GPIO.1
DIR GPIO b'00000000'
SET INTCON.6 ON 'Enables all unmasked peripheral interrupts
SET INTCON.7 ON 'Enables all unmasked interrupts
SET PIE1.0 ON 'Enables the TMR1 overflow interrupt
SET T1CON.0 ON 'Enables Timer1
SET T1CON.2 ON 'Do not synchronize external clock input
SET T1CON.3 ON 'LP oscillator is enabled for Timer1 clock
InitTimer1 Ext, PS1_1/4 'Timer overflows every 8 seconds with 32khz crystal
ClearTimer 1
StartTimer 1
On Interrupt Timer1Overflow Call IncCounter
Start:
asm sleep
'Jump back to the start of the program
goto Start
Sub IncCounter
SET Led ON
Wait 2 s
SET Led OFF
end sub