Thanks Richards,
Sorry, maybe the word "trip" is not adequate (I'm speaking french)
BTW, what would be the correct word: "latching"?
I found this interresting video which made me start to try battery monitoring:
.
Unlike the video, I started with a 2 resistors divider. But a potentiometer (maybe easier for a start) and a corrected register CM2CON0 as you suggested made it work.
So, I missed this one you kindly pointed me to:
Finally, the "shortest possible" working code for a 0.6Volt threshold detection could be:
Code:TRISC = %00001000 ' Comparator's input port CM2CON0 = %10100111 ' Bit7 = comparator 2 is ON ' Bit5 = comparator's output pin (i.e. LED) is PORTC.4 (for "proof of life") ' Bit2 = connect Vref to C2Vin+ ' Bits1:0 = comparator's input pin (i.e. Vbatt) is PORTC.3





Bookmarks