Munib
Advanced Member level 4
pic sleep instruction
well i am workiong on PIC 18f452, using C18 compiler and using MPLab 6.62
PLz have a look at this code :
when i run this code in the simulator and watch on the timer 1 contents, the timer 1L dont increase from 0, and as aresult program never comes out of sleep,
i am not using any subroutines for handling of interrupts so, GIE=0;
and my operating frequncy is 8MHZ, and timer 1 oscalltor works at 32 KHz
when i ran this code on MPLAb simulator, it showed PD pin going low, but timer 1 never started , also the BOR and POR bits are also cleared ,
and i cant figure out wats going on
well i am workiong on PIC 18f452, using C18 compiler and using MPLab 6.62
PLz have a look at this code :
when i run this code in the simulator and watch on the timer 1 contents, the timer 1L dont increase from 0, and as aresult program never comes out of sleep,
i am not using any subroutines for handling of interrupts so, GIE=0;
and my operating frequncy is 8MHZ, and timer 1 oscalltor works at 32 KHz
Code:
#include <p18f452.h> /* for the special function register declarations */
#include <delays.h>
#pragma config OSC = HS
#pragma config OSCS = ON
#pragma config WDT = OFF
#pragma config LVP = OFF
int a;
void main ()
{
TRISB=0;
IPR1bits.TMR1IP=1; //setting priority for interrupt
INTCON=0x00; //GIE=0;
a=1;
while (1)
{
T1CON=0b10111110; //configuring timer 1 without switching it on
OSCCON=0x01; //switching the clock
PIE1bits.TMR1IE=1; //setting the interrupt
IPR1bits.TMR1IP=1;
T1CONbits.TMR1ON=1; // makjing timer 1 on
PORTB=a;
Sleep();
T1CONbits.TMR1ON=0;
Delay10KTCYx(1);
OSCCON=0x00; //swtichign teh clock back
a=a+1;
}
}
when i ran this code on MPLAb simulator, it showed PD pin going low, but timer 1 never started , also the BOR and POR bits are also cleared ,
and i cant figure out wats going on