CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Timer in Sleep Mode

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
avjarun



Joined: 28 Mar 2021
Posts: 12

View user's profile Send private message

Timer in Sleep Mode
PostPosted: Sun Dec 24, 2023 9:43 pm     Reply with quote

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: 19538

View user's profile Send private message

PostPosted: Mon Dec 25, 2023 1:45 am     Reply with quote

Just waiting for things to cook. Very Happy

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

View user's profile Send private message

PostPosted: Mon Dec 25, 2023 4:21 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 25, 2023 4:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 25, 2023 9:34 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group