Hi, my program about comparator interrupt has a problem. Can you help me with this one? The circuit below is a battery low voltage indicator. I think ISR is activated but it is always triggered. In my program, portb.f0's state should be inverted as soon as the voltage CMCON.C1OUT state is changed. Can you check my program? Here's my code:
Code:
void interrupt(void){
PORTB.F0 = ~PORTB.F0; //invert the output on portb pin 0
PIR2.CMIF = 0;
}
void main() {
TRISA = 0XFF;
TRISB = 0x00;
PORTB = 0x00;
CMCON = 0b00000011; //Use external voltage reference connected to RA3
//"-" input of C1 connected to RA0
//Mode 011
PIE2.CMIE = 1;
INTCON.PEIE = 1;
INTCON.GIE = 1;
while(1){}
}
I attached my schematic below. I hope you can help me.
Hi, I changed my code with this one. I think it is not anymore triggered. But can you double check my code please? I'm not so sure if I'm able to disable it.