PDA

View Full Version : How to make a 16f628 Sleep and Wakeup ?



andybarrett1
- 25th July 2014, 10:21
Hi All

Simple Question I know... But I cannot figure it out...

Both Sleep and nap seem to be for short time durations.....???

What I am looking for is basically an alarm function using the rtcxu.pbp code...

The RTC to be running all the time... The PIC to wake up latch an alarm for X Seconds then go back to sleep.

Ultimately saving me battery power.

Originally I was thinking of using the Hours and Mins VARs as a trigger. But the PIC needs to be awake for this to happen !

Arghhhhhhhhhh......... Hardware is easy ... Software not so.

Any Ideas or links to examples help welcome. I have looked,

Andy

richard
- 25th July 2014, 10:46
looks like the max wdt sleep is 2.3 sec ,so the only other way is via a wake up from an interrupt source (int_INT or rbc_INT).
if you use a different rtc chip (like a pcf8563 ) that has an alarm driven interrupt output the world is your oyster

EarlyBird2
- 25th July 2014, 22:03
Hi All

Simple Question I know... But I cannot figure it out...

Both Sleep and nap seem to be for short time durations.....???

What I am looking for is basically an alarm function using the rtcxu.pbp code...

The RTC to be running all the time... The PIC to wake up latch an alarm for X Seconds then go back to sleep.

Ultimately saving me battery power.

Originally I was thinking of using the Hours and Mins VARs as a trigger. But the PIC needs to be awake for this to happen !

Arghhhhhhhhhh......... Hardware is easy ... Software not so.

Any Ideas or links to examples help welcome. I have looked,

AndyThis could be an interesting project for me I can help with the software. Richard's pcf8563 and interrupts look good to me.

Charlie
- 26th July 2014, 11:59
Wake up once per second, check the time, if not alarm time go back to sleep.
The time you are awake is so small, you are still asleep well over 99% of the time.

Jerson
- 26th July 2014, 13:46
Hi All
Both Sleep and nap seem to be for short time durations.....???


You could cheat by using the ASM sleep directive thus.


asm
sleep
nop
nop
endasm

See section 14.8.1 (Wake-up from sleep) in the datasheet to understand why you may need nops.

This way you can make the processor sleep indefinitely

aratti
- 26th July 2014, 18:42
You can use watchdog reset to wakeup the MCU from sleep. Since you can establish the time delay for the watchdog reset ( setting the prescaler) you can increment a word variable at each wakeup and go to sleep again. When the count reach the Allarm setpoint then you will service the Allarm, reset the count and return to sleep.

Cheers

Al.

andybarrett1
- 3rd August 2014, 11:07
Thank you all….

I sorted it … Well with an old post from Melanie I found….Where is she now !!

I was missing some setup options for the int

Working now :-)