Page 1 of 1

PIC12F617 Comparator not working

Posted: Sat Oct 03, 2020 8:48 am
by Jörg Güldner
Hello Anyone,
an old project is running under Flowcode V6. Now under V8 is a other compiler. There I couldn`t get the comparator working. May be, that the syntax is not correct writtten from me. Program is in the attachment. Analog in is on pin6, reference is set to intern. The dedicated flag is read out and sets the output to high or low. A smal program. But I get it not running. Is there anyone, who have an idea?

Best regards

Jörg

Re: PIC12F617 Comparator not working

Posted: Mon Oct 05, 2020 2:20 pm
by Benj
Hello Jorg,

The only thing I spotted is this inside the decision icon in the interrupt macro.

comparator_flag_bit = 1

Try this instead

comparator_flag_bit

This will check to see if the value is anything but 0 and might help if the value returned isn't strictly a 1.

Re: PIC12F617 Comparator not working

Posted: Mon Oct 05, 2020 4:01 pm
by Jörg Güldner
Hello Benj,
thanks for your answere. I`ve got it running now, but is was not "comparator_flag_bit = 1".

From the old project and written in big letters = FCV_COMPARATOR_FLAG_BIT = test_bit(PIR1, CMIF);
and clear_bit (PIR1, CMIF);
is not running!

Changing to FCV_COMPARATOR_FLAG_BIT = PIR1bits.CMIF;
and PIR1bits.CMIF = 0;
works fine.

Jörg

Re: PIC12F617 Comparator not working

Posted: Mon Oct 05, 2020 10:40 pm
by Benj
Hi Jörg,

Excellent glad you've got it working and many thanks for letting us know.