How to make a 16f628 Sleep and Wakeup ?
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
Re: How to make a 16f628 Sleep and Wakeup ?
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
Re: How to make a 16f628 Sleep and Wakeup ?
Quote:
Originally Posted by
andybarrett1
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
This could be an interesting project for me I can help with the software. Richard's pcf8563 and interrupts look good to me.
Re: How to make a 16f628 Sleep and Wakeup ?
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.
Re: How to make a 16f628 Sleep and Wakeup ?
Quote:
Originally Posted by
andybarrett1
Hi All
Both Sleep and nap seem to be for short time durations.....???
You could cheat by using the ASM sleep directive thus.
Code:
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
Re: How to make a 16f628 Sleep and Wakeup ?
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.
Re: How to make a 16f628 Sleep and Wakeup ?
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 :-)