View previous topic :: View next topic |
Author |
Message |
respected
Joined: 16 May 2006 Posts: 95
|
18F14K50 and sleep |
Posted: Tue Aug 02, 2011 1:40 pm |
|
|
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
|
|
|
respected
Joined: 16 May 2006 Posts: 95
|
|
Posted: Tue Aug 02, 2011 3:25 pm |
|
|
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
|
|
Posted: Tue Aug 02, 2011 3:32 pm |
|
|
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
|
|
Posted: Tue Aug 02, 2011 3:34 pm |
|
|
Yes, the circuit is operating normally. But staying asleep. |
|
|
respected
Joined: 16 May 2006 Posts: 95
|
|
Posted: Tue Aug 02, 2011 4:00 pm |
|
|
do not wake the PIC Timer1 interrupt? |
|
|
respected
Joined: 16 May 2006 Posts: 95
|
|
Posted: Tue Aug 02, 2011 4:16 pm |
|
|
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
|
|
Posted: Tue Aug 02, 2011 4:28 pm |
|
|
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
|
|
Posted: Tue Aug 02, 2011 4:42 pm |
|
|
Thank you for your help.
I am sorry. i take your time |
|
|
|