Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

help using the comparators

Status
Not open for further replies.

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
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
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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top