Searching \ for 'Power-on vs. awake 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-on vs. awake from sleep'.

Truncated match.
PICList Thread
'Power-on vs. awake from sleep'
1998\06\24@122024 by MattA

flavicon
face
Hello to the PIC List.  Here's my problem.  Any thoughts would be greatly
appreciated.

On a 16C55, I'd like to be able to distinguish between the first time the
chip powers up and every other time it awakes from sleep.

Only during the initial power up, I want to initialize some variables (used
to count an external event).  I do not want to re-initialize these
variables every time the unit awakes from sleep.  I should also say that
the circuit is designed similar to the one in AN528, but uses a 55 instead
of a 54.  So I am using a low on the MCLR pin to cause a reset and awake
the chip.

The STATUS register has a couple of bits, PD and TO, dealing in this area,
but I don't know if there is a logical combination that will give me what I
need.

If the 16C55 can't, is there another part that could?  If the 16C55 can't
using the STATUS reg, is there another simple way to solve this problem
that is 100% foolproof.  (I can envision checking a file register(s) to
either allow or not the variable initialization routine.  The problem I see
is that on power-on, the contents of that register(s) is undefined and
therefore could initially (1 out of 256) equal the value I would set it to,
which nullifies its use.  The odds improve by using multiple registers, 1
out of 65536 for 2 regs, 1 out of  16.7 million for 3 regs, etc.)

Another approach might be to add some latching hardware which would work,
but would add cost and require PCB space.

1998\06\24@151240 by Mike Keitz

picon face
On Wed, 24 Jun 1998 09:49:50 -0400 "Matthew J. Ancona" <spam_OUTMattATakeThisOuTspamEDL.com>
writes:

>On a 16C55, I'd like to be able to distinguish between the first time
>the
>chip powers up and every other time it awakes from sleep.

There are bits in the STATUS register for this purpose.


>The STATUS register has a couple of bits, PD and TO, dealing in this
>area,
>but I don't know if there is a logical combination that will give me
>what I
>need.

The PD bit is the one to look at.  If the chip has been asleep since the
power was turned on, it will be 0.  Turning the power off and back on
sets the bit to 1.  Executing a  SLEEP instruction sets it to 0.  So if
after a reset you find the PD bit is 1, initialize everything.  If it is
zero, it's just a wakeup from SLEEP.
>
>If the 16C55 can't, is there another part that could?

I think all PICs, 12 and 14-bit, have the same logic.

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

1998\06\24@175156 by Dwayne Reid

flavicon
face
>On a 16C55, I'd like to be able to distinguish between the first time the
>chip powers up and every other time it awakes from sleep.

I'm not sure if there is any way to distinguish between power up and
external reset.  If you have an uncommitted port pin, you can try my old
standby which is a 1 uF cap connected to the port pin.  When the system is
first powered up, the cap has been dishcarged thru the ESD clamping diode.
It will read as a logic low.  Do all your init stuff, then turn the pin to
an output and set the pin to logic HI.  When you go to sleep, the pin
remains HI and keeps the cap charged.

After the system has been reset, the pin has been turned back into an input.
So long as the reset pulse was not too long (several minutes or hours), the
pin will still read as logic HI.  Jump past all your init stuff, turn the
pin back into an output (logic HI), and continue on your merry way.  Total
cost: 1 port pin and 1 capacitor.  Note that port pin RA4 does NOT have the
required ESD protect diode and would require the discharge diode from the
pin to VDD.

dwayne


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

1998\06\25@041204 by Dr. Imre Bartfai

flavicon
face
Hello,
I had the same problem, but I'm not bound to 16C55. In a newer stuff,
there is e.g.16C71x having particular bits can you give the answer.

However, there is another idea:

There are bits set definitely in a particular state upon power-up. Take
one of them, and set it to the opposite upon program entry. Then you can
check it, whether it is re-set by POR.

Imre

On Wed, 24 Jun 1998, Matthew J. Ancona wrote:

{Quote hidden}


'Power-on vs. awake from sleep'
1998\07\07@104011 by MattA
flavicon
face
Thanks to all that responded.

The best I have been able to come up with (without adding extra parts) is
to use a file register.  On power-up, the file register contents are
undefined.  I run through a quick test to see if the file register equals
some number (I used 8).  Since the register is undefined, there is a 1 in
256 chance that the register powered- up containing number 8.  After
testing the register and finding that it doesn't equal 8, I run through an
initialization routine to reset all the program variables (file registers).
When the PIC awakes from sleep, the program re-executes only to find
number 8 in the test register which then allows the program logic to jump
around the initialization routine.  The bottom line:  this design allows
the init routine to run only once on power-up and has a 1 in 256 chance of
failure.  If a failure does occur, the user simply removes and then
reinstalls the batteries from the circuit (executing another power-up
sequence).  The odds of failure can be improved by using more than one file
register (building a key), but I don't have any registers to spare.

Comments are welcome.

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