Hello I am trying to use timer1 interrupt on PIC18F26K83. I use Micro C as compiler. So I set my timer for 30 ms and after that 30 ms, it is supposed to enter an interrupt and light the LED. But it never lights up the LED (never enters the interrupt/interrupt never occurs.). The code is:
#define led LATA.RA2
void Clk_8Mhz(){
//8 MHz clock
// OSCCON1 REGISTER
NOSC2_BIT=1;
NOSC1_BIT=1;
NOSC0_BIT=0;//HF INTERNAL OSC
//OSCFRQ REGISTER HFINTOSC FREQ. SELECTION
OSCCON1 =0b01100000; //HFINTOSC, Divider =1;
FRQ3_BIT=0;
FRQ2_BIT=0;
FRQ1_BIT=1;
FRQ0_BIT=1; // 0011 :8MHz //0100 = 16 Mhz
}
//Timer1
//Prescaler 1:1; TMR1 Preload = 5536; Actual Interrupt Time : 30 ms
void InitTimer1(){
T1CON = 0x01;
TMR1IF_bit = 0;
TMR1H = 0x15;
TMR1L = 0xA0;
TMR1IE_bit = 1;
INTCON = 0xC0;
}
void main (){
TRISA.B2=0;
led=0;
clk_8Mhz();
InitTimer1();
while(1){
delay_ms(10);
} }
void Interrupt(){
if (TMR1IF_bit){
TMR1IF_bit = 0;
TMR1H = 0x15;
TMR1L = 0xA0;
led=1;
}
}
What maybe the cause of this never occuring interrupt? Thanks beforehand.