Dear All,
I have to ON GREEN LED if interrupt occurs on RB4-RB7 pins (IOC). Next, If Interrupt occurs (INT0) while GREEN LED is ON, RED LED should be ON for 5 minutes and then OFF. If again interrupt occurs on RB4-RB7 pins (IOC) while RED LED is ON, I have to switch off RED LED immediately. I have used timer1. Everything works fine except switch OFF the RED LED. I could not able to read interrupt on RB4-RB7 pins (IOC) while timer1 runs. Any help pl?. The following is the code:
I have to ON GREEN LED if interrupt occurs on RB4-RB7 pins (IOC). Next, If Interrupt occurs (INT0) while GREEN LED is ON, RED LED should be ON for 5 minutes and then OFF. If again interrupt occurs on RB4-RB7 pins (IOC) while RED LED is ON, I have to switch off RED LED immediately. I have used timer1. Everything works fine except switch OFF the RED LED. I could not able to read interrupt on RB4-RB7 pins (IOC) while timer1 runs. Any help pl?. The following is the code:
Code:
void interrupt isr(void){
if (INTE && INTF) {
delay_ms(10);
if(RB0 == 0){
if (LED == 1){
LED = 0;
ALARM = 1;
T1CON=0b00000001;
while (1){
while (! TMR1IF);
TMR1IF = 0;
count ++;
if (count == 75){
count = 0; // Reset Counter
ALARM = 0; // OFF the Alarm
TMR1IF = 0; // Clear Timer Flag
TMR1IE = 0; //disable timer1
break;
}
}
//delay_5min();
// ALARM = 0;
}
}
INTF = 0;
INTE = 1;
}
if(RBIE && RBIF){
delay_ms(10);
if(RB4 == 1){
RBIE = 0;
if (ALARM == 1){
count = 0; // Reset Counter
ALARM = 0; // OFF the Alarm
TMR1IF = 0; // Clear Timer Flag
TMR1IE = 0; //disable timer1
}
else{
if(LED == 1){
LED = 0;
beep_Off();
}
else{
LED = 1;
beep_On();
for(i=0;i<150;i++){
for(j=0;j<150;j++);
}
beep_On();
}
}
}
mismatch_Clr = PORTB;
RBIF = 0;
RBIE = 1;
}
SLEEP();
}