Is this possible? I am using a 16F1705 and I want to use a clock crystal to wake up the processor from sleep after an accurate (and precise) number of seconds (the watch dog timer is just is proving to be not accurate enough).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
as per the datasheet it should be possible with external clock source/xtal.
page 250
25.8 Timer1 Operation During Sleep
Timer1 can only operate during Sleep when setup in
Asynchronous Counter mode. In this mode, an external
crystal or clock source can be used to increment the
counter. To set up the timer to wake the device:
• TMR1ON bit of the T1CON register must be set
• TMR1IE bit of the PIE1 register must be set
• PEIE bit of the INTCON register must be set
• T1SYNC bit of the T1CON register must be set
• TMR1CS bits of the T1CON register must be
configured
• T1OSCEN bit of the T1CON register must be
configured
The device will wake-up on an overflow and execute
the next instructions. If the GIE bit of the INTCON
register is set, the device will call the Interrupt Service
Routine.
tony
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes that works, thanks. I was looking for a GCBasic solution, but this is an unusual thing to want to do so I suspose it is not covered. So just to summarize the following lines are needed.
Is this possible? I am using a 16F1705 and I want to use a clock crystal to wake up the processor from sleep after an accurate (and precise) number of seconds (the watch dog timer is just is proving to be not accurate enough).
as per the datasheet it should be possible with external clock source/xtal.
page 250
25.8 Timer1 Operation During Sleep
Timer1 can only operate during Sleep when setup in
Asynchronous Counter mode. In this mode, an external
crystal or clock source can be used to increment the
counter. To set up the timer to wake the device:
• TMR1ON bit of the T1CON register must be set
• TMR1IE bit of the PIE1 register must be set
• PEIE bit of the INTCON register must be set
• T1SYNC bit of the T1CON register must be set
• TMR1CS bits of the T1CON register must be
configured
• T1OSCEN bit of the T1CON register must be
configured
The device will wake-up on an overflow and execute
the next instructions. If the GIE bit of the INTCON
register is set, the device will call the Interrupt Service
Routine.
tony
Yes that works, thanks. I was looking for a GCBasic solution, but this is an unusual thing to want to do so I suspose it is not covered. So just to summarize the following lines are needed.
t1con=b'10111101' 'timer1 1:8
intcon.6=1
pie1.0=1
.
.
sleep
nop
pir1.0=0 'reset interrupt
Yes don't forget to reset the interrupt flag.