CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

variable

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
danspage



Joined: 14 Sep 2005
Posts: 8

View user's profile Send private message

variable
PostPosted: Thu Sep 15, 2005 11:10 am     Reply with quote

How do I keep a variables value when the PIC goes to sleep and then is
woke up on pin change?

PIC 12C508

Thanks!
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Thu Sep 15, 2005 11:15 am     Reply with quote

The RAM is retained during sleep as long as you don't reset.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 15, 2005 11:40 am     Reply with quote

The problem is that the 12C508 does a reset when it wakes up from
sleep. Read section 8.9.2 in the data sheet:
Quote:

8.9.2 WAKE-UP FROM SLEEP
The device can wake-up from SLEEP through one of
the following events:
1. An external reset input on GP3/MCLR/VPP pin,
when configured as MCLR.
2. A Watchdog Timer time-out reset (if WDT was
enabled).
3. A change on input pin GP0, GP1, or GP3/
MCLR/VPP when wake-up on change is
enabled.
These events cause a device reset.

I looked in the data sheet and I can't find any statement on
the condition of RAM after a wake-up from sleep reset.
It's probably unchanged. So you can probably preserve
the contents of RAM, by just not using a #zero_ram statement.
If you have a #zero_ram statement in your program, then remove it.
DP
Guest







PostPosted: Thu Sep 15, 2005 12:39 pm     Reply with quote

I just declared an int, and everything was fine.

I thought a first I had to declare a static int, but that didn't seem to work.

Thanks!


Very Happy
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Thu Sep 15, 2005 1:38 pm     Reply with quote

Hello

That statement about register values at reset is at page 38:

Quote:

Some registers are not reset in any way; they are
unknown on POR and unchanged in any other reset.
Most other registers are reset to reset state on power on
reset (POR), MCLR, WDT or wake-up on pin
change reset during normal operation. They are not
affected by a WDT reset during SLEEP or MCLR reset
during SLEEP, since these resets are viewed as
resumption of normal operation.


mfg
Felix
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group