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

PIC Reset on Sleep

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



Joined: 29 Nov 2005
Posts: 4

View user's profile Send private message

PIC Reset on Sleep
PostPosted: Tue Nov 29, 2005 7:58 pm     Reply with quote

Hi All,

I am using PIC18F67J10 to develop a project. I need to put the PIC to sleep but it seems that the MCU resets everytime I put it to sleep. The specs states

"The power-managed Sleep mode is identical to the legacy
Sleep mode offered in all other PICmicro devices.
It is entered by clearing the IDLEN bit (the default state
on device Reset) and executing the SLEEP instruction."

Using any of the IDLE mode works perfectly. restart_cause() shows normal powerup.

I wrote a small demo code below. The printf statement was printing non stop.

#byte OSCCON = 0x0FD3
#bit IDLEN = OSCCON.7

Code:
printf("Start Init\r\n");
//SET MCU TO SLEEP
   IDLEN = 0;
   
   while(1)
   {
      sleep();
   }


The settings are

#fuses HS,NOWDT
#use delay(clock=32000000)
#use RS232 (BAUD=19200, XMIT=PIN_C6, RCV=PIN_C7, ERRORS)

Thanks,
SA
Guest








PostPosted: Wed Nov 30, 2005 9:35 am     Reply with quote

Try just putting it in a loop, and see if the same happens. It is worth 'ruling out' something like noise on the reset line.
Though it should not cause this, add a 'nop' (delay_cycles(1)) after the sleep, since the instruction following the sleep is 'pre-fetched', and in a more complex enviroment, this can cause a problem.
The fact that you are seeing normal 'power up' indication from the restart_cause function, suggests that you may be seeing a problem in the hardware.
I'd try setting 'NOFCMEN' in the fuses.

Best Wishes
sang



Joined: 29 Nov 2005
Posts: 4

View user's profile Send private message

PostPosted: Wed Nov 30, 2005 7:06 pm     Reply with quote

Thanks for the suggestion. I've tried them out but the problem remain unsolve. setting NOFCMEN in the fuses and adding NOP doesn't solve the problem.

What do you mean by "adding it in a loop"? the sleep() instruction is already in a while loop. I will be checking the hardware again but it seems strange that this only happen when IDLEN bit is set to 0. Setting it to 1 do not produce the same effect.

Regrds,
SA
Ttelmah
Guest







PostPosted: Thu Dec 01, 2005 3:48 am     Reply with quote

I mean, don't put the processor to sleep, and see what happens. So just use:
Code:

while(true) {
    delay_cycles(1);
}

If it still keeps printing, you have proved that the problem is not with the sleep, but with the hardware.

Best Wishes
sang



Joined: 29 Nov 2005
Posts: 4

View user's profile Send private message

PostPosted: Thu Dec 01, 2005 3:56 am     Reply with quote

Without the sleep instruction, it doestn't loop. Everything works fine. In fact sleep work fine if IDLEN = 1. I guess I will just settle with sleeping in idle mode.

Thanks.
SA
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