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 CCS Technical Support

CPU reset after wake from sleep
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Wed Apr 04, 2007 8:11 am     Reply with quote

Ok, what am I missing?
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Wed Apr 04, 2007 8:28 am     Reply with quote

Quote:
My counter variable is initialized to 0 at the beginning of the code but sleep is resetting all variables.


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.


You can't save variables through a RESET caused by a pin change?

I think you may have misunderstood the question based upon your code?
Static



Joined: 03 Apr 2007
Posts: 8

View user's profile Send private message

PostPosted: Wed Apr 04, 2007 8:33 am     Reply with quote

Just so I understand, there's no way for me to save the state of a one bit variable (or 8 bit) when using sleep()?
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Wed Apr 04, 2007 8:41 am     Reply with quote

ok, but variables aren't saved in registers they are saved in ram and according to the disassembly the only two instructions that modify the counter location (0x13) are the ones I used.

Code:

CCS PCB C Compiler, Version 3.249, 33857               04-Apr-07 10:34

               Filename: main.lst

               ROM used: 21 words (8%)
                         Largest free fragment is 235
               RAM used: 3 (19%) at main() level
                         3 (19%) worst case
               Stack:    0 locations

*
0000:  MOVWF  05
0001:  GOTO   002
.................... #include <10F200.h> 
.................... //////// Standard Header file for the PIC10F200 device ////////////////
.................... #device PIC10F200
.................... #list
.................... 
.................... 
.................... #case
.................... 
.................... #fuses   NOMCLR
.................... #fuses   NOPROTECT
.................... #fuses   NOWDT 
.................... 
.................... 
.................... #use delay(clock=4000000) 
.................... 
.................... 
.................... 
.................... 
.................... 
.................... void main( void )
.................... {
0002:  MOVLW  DF
0003:  OPTION
0004:  CLRF   04
.................... 
.................... unsigned int8 counter;
.................... 
....................    
.................... 
....................    switch ( restart_cause( ) ) {
0005:  MOVF   03,W
0006:  ANDLW  D8
0007:  BCF    03.6
0008:  BCF    03.7
0009:  BSF    03.3
000A:  BSF    03.4
000B:  XORLW  18
000C:  BTFSC  03.2
000D:  GOTO   012
000E:  XORLW  88
000F:  BTFSC  03.2
0010:  GOTO   014
0011:  GOTO   016
.................... 
....................       case NORMAL_POWER_UP :
....................          counter = 0;
0012:  CLRF   13
....................          break;
0013:  GOTO   016
.................... 
....................       case PIN_CHANGE_FROM_SLEEP :
....................          counter++;
0014:  INCF   13,F
....................          break;
0015:  GOTO   016
....................          
.................... 
....................    }
....................    
.................... 
.................... 
.................... 
.................... //Your Code Goes Here...
.................... 
.................... 
.................... 
.................... 
.................... 
.................... }
.................... 
0016:  SLEEP

Configuration Fuses:
   Word  1: 0FEB   NOMCLR NOPROTECT NOWDT
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Wed Apr 04, 2007 8:58 am     Reply with quote

Good point.

I was guessing the slate got wiped clean for any type of reset. The datasheet is unclear about the status of RAM during each type of RESET.

I guess the only way to figure it out is, try it....

John

BTW, I tried a 10F part once and got so fed up with it I went back to a regular part. It was really my fault because I failed to dig into the datasheet prior to designing and I paid the price. I just assumed they were fairly similar to the regular parts.
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Wed Apr 04, 2007 9:10 am     Reply with quote

John,

You are right though, the registers are affected by RESET and can be tricky to handle.


I had the same experience, designed in a 10F200 on the first rev of my board and the next rev had a 12F629 designed in because the code for the 10F part drove me nuts.

Kevin
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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