void interrupt isr(){
if(PIR1bits.TMR1IF == 1 && bit_0 ==1 ){ // bit_0 is a variable to denote the first time period T
PIR1bits.TMR1IF = 0;
counter_timer1++;
if(counter_timer1 == 1)
{
if(RB0==1)
{
PORTA = digit[2];
bit_0=0;
bit_1 = 1;
}
counter_timer1 = 0;
//IOCBNbits.IOCBN0 = 1;
T1CONbits.TMR1ON = 0; // disabe timer
TMR1H = 239; // preset for timer1 MSB register to start counting the next timer slot of 3T
TMR1L = 32; // preset for timer1 LSB register
T1CONbits.TMR1ON = 1; // bit 0 enables timer
}
}
// this is where it stops working
if(PIR1bits.TMR1IF == 1 && bit_1 ==1){ // checking condition to see if it has overflown 3T
PIR1bits.TMR1IF = 0;
PORTA=digit[5];
counter_timer2++;
if(counter_timer2 ==1 && RB0 ==0){
counter_timer2 = 0;
IOCBNbits.IOCBN0 = 1;
T1CONbits.TMR1ON = 0; // enables timer
}
}
}