Searching \ for 'Power Up from Sleep' 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/power.htm?key=power
Search entire site for: 'Power Up from Sleep'.

Truncated match.
PICList Thread
'Power Up from Sleep'
1996\06\27@084913 by myke predko

flavicon
face
Hi Gang,

I'm having a bit of trouble with a program I am writing; I'm trying to wake
up from "sleep" with some inline code.

The sleep code I am using is simply:

 clrwdt                        ;  Use WDT for Wake Up
 sleep
 nop                           ;  Make sure nothing potentiall unknown is
                               ;   Executed after "sleep"

When the WDT times out, or the interrupt executes, I seem to go back to
Address 0 with T0 PD both set (I verify this through the use of two LEDs
which show the value for these two bits).

The real purpose of this code is to be have a button press wake up the PIC.
I have just enabled the RB0/INT Pin (without setting the "GIE" bit) and this
does wake up the PIC from sleep, but also seems to reset the PIC.

As well, I tried setting a number of registers to a known value when the PIC
is active (before going to sleep) and then checking these values upon PIC
Reset (Execution at Address 0).  These values seem to be randomized each
time the PIC goes to sleep.

Does anybody have any idea of what I'm doing wrong?  I am expecting (and the
Data Sheet confirms this) that upon wake-up, I will continue executing from
the current PC (with PC+1 being the next address executed after Sleep), but
this is not happening.  I'm also confused as to why the file Registers are
changing (because they seem to stay static, even if _MCLR is pulled low for
some time).

Thanx!

Myke

Do you ever feel like an XT Clone caught in the Pentium Pro Zone?

1996\06\27@092422 by rdmiller

picon face
On Thu, 27 Jun 1996, myke predko wrote:
[...]
> The sleep code I am using is simply:
>
>   clrwdt                        ;  Use WDT for Wake Up
>   sleep
>   nop                           ;  Make sure nothing potentiall unknown is
>                                 ;   Executed after "sleep"
>
> When the WDT times out, or the interrupt executes, I seem to go back to
> Address 0 with T0 PD both set (I verify this through the use of two LEDs
> which show the value for these two bits).
>
> The real purpose of this code is to be have a button press wake up the PIC.
> I have just enabled the RB0/INT Pin (without setting the "GIE" bit) and this
> does wake up the PIC from sleep, but also seems to reset the PIC.
>
> As well, I tried setting a number of registers to a known value when the PIC
> is active (before going to sleep) and then checking these values upon PIC
> Reset (Execution at Address 0).  These values seem to be randomized each
> time the PIC goes to sleep.

First of all, the "clrwdt" instruction isn't necessary since entering
the power-down mode via the "sleep" instruction automatically clears
the watchdog timer.

If your watchdog timer times out, the PIC should reset... not continue.
That might explain why it's going to its reset vector (0x0000).  Maybe
you should check what your watchdog's pre-scalar is?

You may also wish to read Microchip's "Errata Sheet" for whatever
type of PIC you're using.  I know that I can't rely on the "PD" bit
of the PIC16C65 I'm using because the errata sheet says it may not
work right.

What seemed to be missing was some instruction to *clear* the RBIF
flag before going to sleep...  For that matter, you'd better make
sure that *any* interrupt flags which are enabled have been cleared
before executing the "sleep" instruction.

Good luck!

Rick Miller

1996\06\27@093041 by Clyde Smith-Stubbs

flavicon
face
Rick Miller <spam_OUTrickTakeThisOuTspamDigalogSys.com> wrote:

> If your watchdog timer times out, the PIC should reset... not continue.

No, not necessarily. This is true for the 12 bit PICs, but not for the
14 bitters. Myke did not say what chip he is using, but if my guess
is right, he is using a 14 bit chip. The 14 bit chips have two different
behaviours for WDT timeout - in sleep mode it just wakes the chip up
and it resumes execution. In non-sleep mode it resets.

Myke, perhaps you are getting a WDT timeout _after_ the sleep has
"returned", and this is causing the reset? How do you handle a WDT
timeout when the key is *not* pressed?

Clyde

--
Clyde Smith-Stubbs       | HI-TECH Software,       | Voice: +61 7 3300 5011
.....clydeKILLspamspam@spam@hitech.com.au      | P.O. Box 103, Alderley, | Fax:   +61 7 3300 5246
http://www.hitech.com.au | QLD, 4051, AUSTRALIA.   | BBS:   +61 7 3300 5235
----------------------------------------------------------------------------
For info on the World's best C cross compilers for embedded systems, point
your WWW browser at http://www.hitech.com.au, or email infospamKILLspamhitech.com.au

1996\06\27@103315 by Harrison Cooper

flavicon
face
In the seminar, we had some discussions on this.  Rick Miller is correct in
that when you put it to sleep, the WDT will awake it and RESET it, just like
the WDT always does.  There is one class of processors (don't remember if it
was just the high end) that if it gets an interupt, it will wake up and
continue on from where it goes to sleep.  I would bet that you never wake up
from the interupt, but its always the WDT.  Try disabling it when you reburn
the part and see if it executes correctly on the interupt.  You have to
remember that the WDT is pretty fast (and it should be) to protect from going
into and executing bad code.  If you are sitting around waiting for the button
to be pushed, and you are using the WDT, then you should probably put the
routine
at the reset org, look for the input and then go back to sleep.

1996\06\27@125907 by myke predko

flavicon
face
Hi Clyde,

As I said in my previous note, I set the Prescaler to the WDT and then
loaded the values with 0b0111 (which seems to give me the 2.3 sec delay that
it should according to 18 msec x 128).  So, I don't think that I am getting
another reset with the WDT, but could the OPTION Register be reset (turning
back the WDT delay to 18msecs)?

Actually, thinking about it, this may be very possible because I have not
looked very closely at what is happening when the button is pressed (Yet
another case where I wished I had a scope at home).  Componding the problem
is that I display the contents of STATUS and the button/WDT using LEDs, with
a looping delay before going back to sleep.  Maybe the program is working
correctly, but the WDT is timing it back out and I can't see what's
happening.  Although I did try turning off the WDT from the programmer,
maybe something else is happening (and something else for me to try).

Thanx for the Suggestion,

Myke


{Quote hidden}

Do you ever feel like an XT Clone caught in the Pentium Pro Zone?

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