Searching \ for '[PIC]: How to wake up PIC every 10 seconds?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'How to wake up PIC every 10 seconds?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: How to wake up PIC every 10 seconds?'
2001\11\08@081526 by questuk

picon face
Hi,

I wish to put a PIC into sleep mode then have it wake up every 10 seconds to check a port for activity, I know how to get PIC into sleep mode.
I believe you can wake it using the PIC's clock (I have a 4Mhz xtal that runs the PIC) using TMR x and prescaler?

Thanks Gary

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\11\08@102910 by Byron A Jeff

face picon face
On Thu, Nov 08, 2001 at 12:06:39PM -0000, questuk wrote:
> Hi,
>
> I wish to put a PIC into sleep mode then have it wake up every 10 seconds to check a port for activity, I know how to get PIC into sleep mode.
>
> I believe you can wake it using the PIC's clock (I have a 4Mhz xtal that runs the PIC) using TMR x and prescaler?
>
> Thanks Gary

I'll be blunt: it can be done! ;-) And to exactly 10 second intervals!

OK now's here's how: One of the reasons that SLEEP mode works so will is that
the oscillator for the PIC is turned off. So with two exceptions, there is no
clock available. So let's look at these execptions.

Exception 1 is the watch dog timer. It has two issues. First is that since it's
driven by an RC oscillator, it isn't very precise. Secondly I don't think that
even with the prescaler that you can get a 10 second timeout.

Exception 2 is Timer 1 on chips that have timer 1. timer 1 can be driven by
an external oscillator that continues to run even in sleep. So if you configure
timer 1 with interrupts on and an external crystal, it'll drop the chip out of
SLEEP upon the overflow interrupt. The only problem is that that only low
frequency crystal available is the 32.768 Khz crystal which will overflow
every two seconds. However with the prescaler this delay can be extended to
16 seconds. Which is long enough.

So this is what you do:

- Get a chip with timer 1. If you're using a 16F84 part, upgrade to 16F628.
- Attach a 32.768 Khz crystal to the timer 1 oscillator pins.
- Configure timer 1 for external oscillator and max prescale.
- Enable the timer 1 interrupt.
- Load timer 1 so that it'll time out after 10 seconds. The value for this
 is left as an exercise for the student. ;-)
- Go to SLEEP.

And voila! you'll wake up exactly 10 seconds after you go to sleep.

Thanks for the opportunity to explain. I started this post thinking that the
task couldn't be done. But after thinking it through, the above is how you do
it.

BAJ

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\11\08@132901 by Andrew Warren

face
flavicon
face
questuk <spam_OUTquestuk1TakeThisOuTspamhotmail.com> wrote:

> I wish to put a PIC into sleep mode then have it wake up every 10
> seconds to check a port for activity, I know how to get PIC into
> sleep mode. I believe you can wake it using the PIC's clock (I have
> a 4Mhz xtal that runs the PIC) using TMR x and prescaler?

Gary:

As Byron pointed out, the oscillator stops when the PIC is in sleep
mode, so that won't work.

If you don't need precise timing, just enable the watchdog timer,
assign the prescaler to it, and set the prescaler divide-by ratio to
max... You'll end up with a watchdog timer that expires in
approximately two and a half seconds.  Every four sleep/wake-up
cycles, therefore, is approximately 10 seconds.

If you need more precision, you can calibrate your code to the
watchdog timer dynamically... But it doesn't sound as though you need
anything real precise.

-Andy


=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\11\09@135054 by Harold M Hallikainen

picon face
On Thu, 8 Nov 2001 10:27:30 -0800 Andrew Warren <fastfwdspamKILLspamIX.NETCOM.COM>
writes:
{Quote hidden}

       AND, if you did need precise timing, some PICs (like the 16F870) let you
hang a low frequency crystal on one of the timers. It keeps running when
the PIC is asleep and wakes the PIC on timer interrupt (rollover to
0x00). I chose to still have the watchdog running, waking us up every 2.5
seconds, and having the crystal based timer wake us up every 16 seconds.
The watchdog wakeup is very short (just check to see if the other timer
has timed out), so power consumption is still low. I wanted to use the
watchdog in case the whole thing crashed.
       One thing on using the timer... Make sure the timer is set to
nonsynchronous. If set to synchronize with the PIC core, the synchronizer
shuts down when the PIC goes to sleep and the timer will never time out.
Only took me a couple days to figure that out...

Harold




FCC Rules Online at http://hallikainen.com/FccRules
Lighting control for theatre and television at http://www.dovesystems.com

________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today!  For your FREE software, visit:
dl.http://www.juno.com/get/web/.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\11\09@213406 by Joris van den Heuvel

flavicon
face
----- Original Message -----
From: Harold M Hallikainen <EraseMEharoldhallikainenspam_OUTspamTakeThisOuTJUNO.COM>
To: <PICLISTspamspam_OUTMITVMA.MIT.EDU>
Sent: Friday, November 09, 2001 5:55 PM
Subject: Re: [PIC]: How to wake up PIC every 10 seconds?


>         One thing on using the timer... Make sure the timer is set to
> nonsynchronous. If set to synchronize with the PIC core, the synchronizer
> shuts down when the PIC goes to sleep and the timer will never time out.
> Only took me a couple days to figure that out...
>
> Harold
>

That's really bummer it took you so long. I lost a few days getting the F628
UART to work properly. The T1SYNC issue startled me for a while, but reading
back the manual on TMR1 resolved the issue within 5 minutes.

If we collected all these "little" issues and put them in an indexed
document, PICcers worldwide would save years and years (total that is)
wondering why their app doesn't work like it's supposed to. But, on 2nd
thought, it wouldn't do any good, because most people tend to think "Manual?
I don't need no stinkin' manual" and thus not read the "idiots' guide to EZ
picc'n"

Regards,
Joris.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\11\10@192444 by Dwayne Reid

flavicon
face
At 10:18 AM 11/8/01 -0500, Byron A Jeff wrote:

>Exception 1 is the watch dog timer. It has two issues. First is that since
>it's
>driven by an RC oscillator, it isn't very precise. Secondly I don't think that
>even with the prescaler that you can get a 10 second timeout.

The watchdog timer can be calibrated!  Clear wdt and start timing how long
it takes for the wdt to time out.  On reset, use that time to figure out
how many wdt timeouts you need for 10 seconds.  Load a counter with that
value and go to sleep.  Each time you wake up, decrement that counter and
go back to sleep if count is not zero.

Its a tiny bit more involved that this, but not much.  I use a couple of
bytes to store a 'magic word' that tells me this is a wdt measure routine
instead of a power-up reset or reset caused by a glitch.  The processor
wakes for a few clock cycles every 18 ms or so and immediately goes to
sleep again if it is not time to wake up for real.  Every time you wake up
for real (10 seconds in this case), re-measure the watchdog timer because
it DOES drift with temperature.

You should be able to achieve 10 second periods with 1% accuracy - good
enough for most 'wake up and check for problems' type applications.

dwayne



Dwayne Reid   <@spam@dwaynerKILLspamspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 17 years of Engineering Innovation (1984 - 2001)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\11\12@133420 by Lawrence Lile

flavicon
face
Guys, this stuff will go into the "100 obscure things you need to know about
PIC's" file.  I am only up to about 60, and this is obscure enough to
qualify.  Now exactly what was the problem?

-- Lawrence

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...