PIC Comparator Interrupt Code

Apr 21, 2008 0 Replies

Can somebody check this code for errors. I'm attempting to use a PIC16f628 to detect an external edge, generate an interrupt, and then supply an output at some known later time. I don't want to poll a pin due the unknown time of detection. If I use the comparator/ interrupt mode, the time from input to output should be constant?


-Bill


bsf STATUS,5 bcf STATUS,6 movlw b'00000110' ; PortA, RA1, RA2 are input movwf TRISA clrf TRISB ; Port B is output bcf STATUS,5



movlw b'10100110' ; Enable low Voltage reference movwf VRCON



movlw b'00000101' ; single comparator RA1, RA2 movwf CMCON



bcf PIR1,6 ; Clear interrupt flag bsf PIE1,6 ; Interrupt enable bsf INTCON, 6 ; Interrupt enable bsf INTCON, 7 ; Global interrupt enable


Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required