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

Behavior after wake up from sleep mode

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



Joined: 04 Feb 2011
Posts: 5
Location: Japan

View user's profile Send private message Visit poster's website MSN Messenger

Behavior after wake up from sleep mode
PostPosted: Fri Jun 08, 2012 8:37 am     Reply with quote

Hi All,

I try to sleep mode on PIC18F46K22.

I can't understand why debug messages are different between following 2 codes when INT0 interrupt occurred.

code 1:
Code:

#INT_EXT
void int_ext_isr()
{
    clear_interrupt(INT_EXT);
    fprintf(DEBUG, "Interrupt EXT\r\n");
}

void main()
{

   clear_interrupt(INT_EXT);
   enable_interrupts(INT_EXT);
   enable_interrupts(global);
   ext_int_edge(H_TO_L);

   while(1)
   {
      fprintf(DEBUG, "Enter Sleep Mode \r\n");
      REGSLP = 1 ;
      IDLEN = 1;
      Sleep();


      fprintf(DEBUG, "run this line\r\n");
   }
}

RESULT DEBUG MESSAGE

Enter Sleep Mode
Interrupt EXT
run this line
Enter Sleep Mode
Interrupt EXT
run this line
Enter Sleep Mode

code2:
Code:

#INT_EXT
void int_ext_isr()
{
    clear_interrupt(INT_EXT);
    fprintf(DEBUG, "Interrupt EXT\r\n");
}

void main()
{

   clear_interrupt(INT_EXT);
   enable_interrupts(INT_EXT);
   enable_interrupts(global);
   ext_int_edge(H_TO_L);

   while(1)
   {
      fprintf(DEBUG, "Enter Sleep Mode \r\n");
      REGSLP = 1 ;
      IDLEN = 1;
      Sleep();

      setup_oscillator( OSC_16MHZ );

      fprintf(DEBUG, "run this line\r\n");
   }
}

RESULT DEBUG MESSAGE

Enter Sleep Mode
Interrupt EXT
Enter Sleep Mode
Interrupt EXT
Enter Sleep Mode

Please let me know why code 2 does not run the line 'fprintf(DEBUG, "run this line\r\n");'

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 08, 2012 6:07 pm     Reply with quote

Post the #include for the PIC, #fuses, #use delay(), and #use rs232()
lines for your program, so I can compile it.

Also post your CCS compiler version.

If you do that, I can test it in hardware on Sunday. I'm not really going
to look at it any more today. On Sunday I can do it, though.
Masaya Tanaka



Joined: 04 Feb 2011
Posts: 5
Location: Japan

View user's profile Send private message Visit poster's website MSN Messenger

PostPosted: Mon Jun 11, 2012 4:24 am     Reply with quote

Dear PCM programmer,

Thank you for your reply!
Sorry, my reply became slow...

#fuses, #use delay(), and #use rs232():
Code:

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES LP                       //Low power osc < 200 khz
#FUSES NOBROWNOUT               //No brownout reset
#FUSES WDT_NOSLEEP              //Watch Dog Timer, disabled during SLEEP
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)

#use delay(internal=32khz)

#use rs232(baud=300, parity=E, stop=1, xmit=PIN_B5, bits=8, restart_wdt, stream=DEBUG, errors)


CCS compiler version : PCWH Compiler (Version 4.112)

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19496

View user's profile Send private message

PostPosted: Mon Jun 11, 2012 7:06 am     Reply with quote

You do realise, that if the second version _does_ run the line, you'll probably never see anything?. Your code is setup to use the UART at 300bps, with the clock running at 32KHz. You then change the oscillator to 16MHz. The serial will run 500* faster (150000bps). Now, depending on the UART, this will either display a single 'garbage' character, or be ignored completely as a framing error.

Best Wishes
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