lloydi12345
Member
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:
I attached my schematic below. I hope you can help me.
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.
Attachments
Last edited: