Rtk89
Newbie level 6

A would like to generate interrupts every 250ms with Timer1, but I get interrupts with more than 1 sec using the code below (I am writing it in MikroC PRO for PIC).
I set frequency to 8MHz with internal oscillator.
What is the problem?
Thank you for helping.
I set frequency to 8MHz with internal oscillator.
What is the problem?
Thank you for helping.
Code:
void InitTimer1(){
T1CON = 0x31;
TMR1IF_bit = 0;
TMR1H = 0x0B;
TMR1L = 0xDC;
TMR1IE_bit = 1;
INTCON = 0xC0;
}
void Interrupt(){
if (TMR1IF_bit){
TMR1H = 0x0B;
TMR1L = 0xDC;
PORTC.F0 = ~PORTC.F0;
TMR1IF_bit = 0;
}
}
void main() {
TRISA = 1;
TRISB = 0;
TRISC = 0;
ANSELA = 0;
ANSELB = 1;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
ADON_bit = 1; // ADC on
ADNREF_bit = 0; // -VREF = VSS
ADPREF0_bit = 1; //VREF+ is connected to internal Fixed Voltage Reference (FVR) module(1)
ADPREF1_bit = 1;
ADC_Init(); // Initialize ADC module with default settings
InitTimer1();
do{
}while(1);