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 support@ccsinfo.com

sleep() and waking per internal timer?

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



Joined: 01 Apr 2007
Posts: 195

View user's profile Send private message

sleep() and waking per internal timer?
PostPosted: Thu May 31, 2007 9:34 pm     Reply with quote

I'm trying to put a PIC18LF2525 to sleep for about two minutes. I'd like to use one of internal timers to do this. Is this possible? Is there a link to a forum subject that discusses this?

I've tried a search on "sleep()" but have only found articles related to an external interrupt being input on the EXT0 pin. Unfortunately, I don't have that available as an input (it is being used as another interrupt source for a different input).

I've looked through the compiler manual and it's not clear. It looks like I could set a timer and put the chip to sleep but its not clear if the timer would continue to run or not. I looked at the chip document and it appears to be possible but there are several modes where the timer remains active and several where it is not active.

Any help would be appreciated. Crying or Very sad
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 31, 2007 11:00 pm     Reply with quote

For two minutes you probably have to use the Watchdog Timer.
Timer1 could run from an external 32.768 KHz crystal. It would roll
over every 2 seconds. Using the divide-by-8 prescaler, this could
become 16 seconds. But only the Watchdog is going to do two minutes.
libor



Joined: 14 Dec 2004
Posts: 288
Location: Hungary

View user's profile Send private message

PostPosted: Fri Jun 01, 2007 1:07 am     Reply with quote

I suggest to put the PIC for several shorter naps (2-16 seconds each) with the Timer1 and count these naps waking up shortly after every nap and go to sleep again if the count has not reached the desired timing.
Doing so you get a more precise and widely adjustable sleep algorithm (beyond any time limit) with almost the same average current consumption as sleeping thru all the time.

FYI: Timer1 requires an external crystal (a 32768Hz* clock crystal is used commonly) to be running during sleep.
I don't know, there may be slower crystals, are there ?
starfire151



Joined: 01 Apr 2007
Posts: 195

View user's profile Send private message

PostPosted: Fri Jun 01, 2007 10:53 am     Reply with quote

Forgive my ignorance... I haven't tried to set a PIC up for sleep or WDT modes before.

Could someone please explain what exactly I need to do to set up a watchdog timer and to have my program execute from where it left off when it wakes back up after going to sleep for about 2 minutes?

I also found a reference to going into "idle" mode (more power usage than sleep but less than full operation) by using the setup_oscillator(OSC_IDLE). I tried this statement using a PIC18F2525 (with NanoWatt technology) and the CCS version 3.249 compiler, but it didn't recognize the "OSC_IDLE". Is this something new with the version 4.x compiler?

Thanks.

Dave
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