Timer and long (hours) sleep period - how to?
Hello,
I need to record temperature & humidity over days with a sample frequency of 15 minutes.
Since the PIC will be battery powered, I think about putting it to SLEEP until the next sample record happens.
According to my PIC's data sheet (16F88 - 4MHz), the TMR0 won't be able to wakeup during SLEEP mode.
What is the best way to time the PIC for long sleep periods?
What is exactly the Watchdog ment for?
I'll try this one.
But what is the Watchdog exactly ment for? I thought it is some kind of internal controlling timer.
Why wouldn't I use a "timer" to do this job? There are 3 available timers in 16F88...
Any code sample using WDT please?
I really need some help on this one. Does anybody have a code sample using Watchdog timer?
I read the "Watchdog Timer Operation" datasheet, but it is still not very clear to me.
Here is my piece of code (that works) when I don't use the WDTCON postscaler:
Code:
' Fuses
@ DEVICE PIC16F88,INTRC_OSC_NOCLKOUT,PROTECT_OFF,WDT_ON,PWRT_ON,MCLR_ON
@ DEVICE PIC16F88,BOD_ON,LVP_OFF,CPD_OFF,DEBUG_OFF,CCPMX_OFF
'-------------------------------------------------------------------------------
' Register settings
OSCCON = %01100000 'Internal RC set to 4MHZ
ANSEL = %00000000 'Disable Analogue Inputs
OPTION_REG = %00000111 'enable PORTB pullups, prescaler to WDT, rate 1:128
'WDTCON = %00000001 'Prescaler 1:32, WDT ON
'-------------------------------------------------------------------------------
' Init
LED1 var PORTB.0
'-------------------------------------------------------------------------------
' Program
MAIN:
toggle LED1
NAP 7
goto main
end
If I use SLEEP instead of NAP, I can set up the sleeping time up to more than 18 hours.
It looks as the pre- or postscaler don't affect the sleep period... (?)
I'm completely lost....
Yes - possible alternatives
Thank you for your suggestions.
Two minutes may look acceptable in some cases but if you have to record datas over days and weeks, it's is no more accurate enough.
I'll have to make some tries but, as said by skimask, an RTC is maybe the best choice after all.
Thanks again.