raushankumar586
Junior Member level 1
Hello guys,
I am using two timers timers i.e. timer0 and timer2.
implementation code given following:
For Timer 0 :
For Timer 2 :
Now the ISR :
interrupt settings :
My issue is , both timers are not working simultaneously , help me to solve that ...
I am using two timers timers i.e. timer0 and timer2.
implementation code given following:
For Timer 0 :
Code:
void Timer0Setup() {
T0CON = 0x00; // using a 16 bit timer0 with pre-scaler 4
T0CONbits.PSA = 0;
TMR0H = 0x01;
TMR0L = 0x00;
T0CONbits.TMR0ON = 1;
INTCONbits.TMR0IE = 1;
}
For Timer 2 :
Code:
void Timer2Setup() {
PIR1bits.TMR2IF = 0;
PIE1bits.TMR2IE = 1;
T2CON = 0b01111100;
TMR2 = 0x00;
PR2 = 0xFF;
T2CONbits.TMR2ON = 1;
}
Now the ISR :
Code:
if (timer0InterruptFired()) {
T0CON = 0x01;
TMR0H = 0x00;
TMR0L = 0x01;
T0CONbits.TMR0ON = 1;
INTCONbits.TMR0IF = 0;
readIt();
}
if (timer2InterruptFired()) {
T2CONbits.TMR2ON = 0;
T2CON = 0b01111100;
TMR2 = 0x00;
PR2 = 0xFF;
Count++;
ledCount++;
if (ledCount == blinkTime) { // blinkTime = 600;
ledCount = 0;
blinkLed();
}
if (Count > 100) {
Count = 0;
readIt();
}
T2CONbits.TMR2ON = 1;
PIR1bits.TMR2IF = 0;
}
interrupt settings :
Code:
void InterruptSetup() {
INTCONbits.PEIE = 1; //periferal interrupt enable
INTCONbits.GIE = 1;
INTCON2 = 0x00; // Set Falling Edge Trigger
}
My issue is , both timers are not working simultaneously , help me to solve that ...