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

18F14K50 and sleep

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



Joined: 16 May 2006
Posts: 95

View user's profile Send private message

18F14K50 and sleep
PostPosted: Tue Aug 02, 2011 1:40 pm     Reply with quote

Hi friends.
will have a few questions about the mcu.
1-Can I switch to sleep mode, when timer1 is running?
2- how to wake-up 10 sec intervals
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 02, 2011 2:39 pm     Reply with quote

See this demo program:
http://www.ccsinfo.com/forum/viewtopic.php?t=45458&start=5
respected



Joined: 16 May 2006
Posts: 95

View user's profile Send private message

PostPosted: Tue Aug 02, 2011 3:25 pm     Reply with quote

Code:

#include <18F2550.h>
#device ADC=10
#fuses HSPLL,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,CPUDIV1,VREGEN,MCLR,PLL3
#use delay(clock=48000000)

#include <lcdlog.c>
int8 san=0;
int8 mode=0;

#int_TIMER1
void timer1_isr()
{
set_timer1(32768);
san++;
mode++;

}

void main(void)
{
   setup_adc(ADC_CLOCK_DIV_8 );
   setup_comparator(NC_NC_NC_NC);
   setup_timer_1(T1_EXTERNAL_SYNC | T1_DIV_BY_1 | T1_CLK_OUT);
   set_timer1(32768);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL); 
     lcd_init();

   while (TRUE)
      {
       printf(lcd_putc"\f%03u",san);
      output_high(PIN_a1);
      delay_ms(200);
      if(mode==5){
      mode=0;
      sleep();
      }
       
      }
}

Where is the error?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 02, 2011 3:32 pm     Reply with quote

Do you have a 32.768 KHz watch crystal (and capacitors) on the Timer1
oscillator pins ? These are separate pins from the main PIC oscillator pins.
respected



Joined: 16 May 2006
Posts: 95

View user's profile Send private message

PostPosted: Tue Aug 02, 2011 3:34 pm     Reply with quote

Yes, the circuit is operating normally. But staying asleep.
respected



Joined: 16 May 2006
Posts: 95

View user's profile Send private message

PostPosted: Tue Aug 02, 2011 4:00 pm     Reply with quote

do not wake the PIC Timer1 interrupt?
respected



Joined: 16 May 2006
Posts: 95

View user's profile Send private message

PostPosted: Tue Aug 02, 2011 4:16 pm     Reply with quote

help me please pcm programmer
0-1-2-3-4 on screen later mcu is sleeping.
but it's don't wake up.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 02, 2011 4:28 pm     Reply with quote

Please do not post every 5 minutes begging for me to help you.

Also, read the CCS manual. It says for some PICs a parameter is
available for the sleep() function, and that you should look in the .h
file for the PIC to see the list of parameters. If you did that, you
would see the following parameter is required:

Quote:

if(mode==5)
{
mode=0;
sleep(SLEEP_IDLE);
}
respected



Joined: 16 May 2006
Posts: 95

View user's profile Send private message

PostPosted: Tue Aug 02, 2011 4:42 pm     Reply with quote

Thank you for your help.
I am sorry. i take your time
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