View previous topic :: View next topic |
Author |
Message |
avjarun
Joined: 28 Mar 2021 Posts: 12
|
Timer in Sleep Mode |
Posted: Sun Dec 24, 2023 9:43 pm |
|
|
Hello All.
I am working with 16F18323 and I am wondering if someone could advise me on the following questions.
1. Does the chip support enabling a timer during sleep?
2. During sleep it consumes about 10-20 microamps of power and will that continue to be if the timer is enabled in sleep?
3. I have noticed that for running timers the chip does need low-power oscillator support and the datasheet specified one for extremely low-power features (Secondary Oscillator: 300 nA @ 32 kHz). Will this help?
4. I have done some tests with the following fuses and code. However, I am running out of luck. Am I doing it wrong or trying to execute a feature that does not exist?
FUSES:
#include<16F18323.h>
#fuses RSTOSC_LFINTRC,NOBROWNOUT,WDT_SW,NOMCLR,PUT,NOCLKOUT
#use delay(clock=1000000)
// Timer setup
setup_timer_0 (T0_LFINTOSC);
set_timer0(0);
/// Counting
mscounter=mscounter+get_timer0()/1000;
My goal is to count the minutes elapsed and execute a task in exact 5 / 10 minutes. Pls advice. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Mon Dec 25, 2023 1:45 am |
|
|
Just waiting for things to cook.
One critical thing. Look at data sheet:
Quote: |
When operating synchronously, Timer0 will halt.
When operating asynchronously, Timer0 will continue to increment
|
Now look at the Timer0 settings:
#define T0_INPUT_NOT_SYNCRONIZED 0x0010
The timer needs to be running async, or it'll stop when the master
oscillator stops. |
|
|
avjarun
Joined: 28 Mar 2021 Posts: 12
|
|
Posted: Mon Dec 25, 2023 4:21 am |
|
|
Thank you for your response. I will check that out. I was trying to work on
#byte CPUDOZE = 0x918
#bit IDLEMODE = CPUDOZE.7
#bit DOZEN = CPUDOZE.6
It seems to be working, but consumes more current. I will check on your comment and get back to you. Thank you. |
|
|
avjarun
Joined: 28 Mar 2021 Posts: 12
|
|
Posted: Mon Dec 25, 2023 4:42 am |
|
|
A quick question. With the following settings.
#fuses RSTOSC_LFINTRC,NOBROWNOUT,WDT_SW,MCLR,PUT,NOCLKOUT
#use delay(clock=1000000)
setup_wdt(WDT_8S);
setup_timer_0(T0_LFINTOSC | T0_INPUT_NOT_SYNCRONIZED);
set_timer0(0);
while(TRUE)
{
sleep(); delay_cycles(1);
printf("\n\rTimer C:%lu ** \n\r",get_timer0());
}
I do get an output of values of 1 565 1197 1863 2528 etc...
Does this mean that the timer is ON and working? Are the values correct for every 8 sec wakeup? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Dec 25, 2023 9:34 am |
|
|
if my reading and math are right...
LFosc is 31KHz, so in 8 seconds that's be 248,000 pulses or counts
assuming no prescaler or postscaler, that really is above the max count of 16 bits or 65526 for the timer
also unknown is the stability of the 31KHz clock and the +- range of the WDT. Some WDT are terrible,so 8 seconds will not be 8 seconds, each and every time. |
|
|
|