TronicBrain
Member
I am tring to get some familiraity with comparators and tring some small projects.
and my problem that I can not bcf the CMIF, it still set after that Vin+>VIN-,
and I can clear it when back to Vin+<VIN-
I made this code to see what is happening to the CMIF
P=16F630
The LED still blinking after Vin+>Vin- that means the CMIF is not clrear.
Would you please hlep me to find my mistake because I'm really confused.
and my problem that I can not bcf the CMIF, it still set after that Vin+>VIN-,
and I can clear it when back to Vin+<VIN-
I made this code to see what is happening to the CMIF
P=16F630
Code:
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
main bsf STATUS,RP0 ; set file register bank to 1
MOVLW B'10001111'
MOVWF VRCON
MOVLW B'000011'
MOVWF TRISA
CLRF TRISC
BSF PIE1,3
CLRF EEADR
bcf STATUS,RP0 ; set file register bank to 0
MOVLW B'00000011'
MOVWF CMCON
CLRF INTCON
CLRF PORTC
CLRF PIR1
CHECK
BTFSS PIR1,CMIF ; set When VIN+>Vin-
GOTO ZERO
BSF PORTC,0 ; LED ON
CALL DELAY
BCF PORTC,0
BCF PIR,CMIF
CALL DELAY
GOTO CHECK
ZERO
BCF PORTC,0
GOTO CHECK
end
Would you please hlep me to find my mistake because I'm really confused.