Hi All,
I'm struggeling to get my 16F690's comparator 2 output to trip when the measured voltage gets above 0.6V (for battery level monitoring).
Code:
' ====== FUSES =====================================================================================
@ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
' ====== REGISTERS =================================================================================
' Registers 76543210
OPTION_REG = %10000000 ' PORT A&B Pull-Ups and Prescaler (def.: %11111111)
OSCCON = %01100000 ' Internal Oscillator 4MHz (def.: %01101000)
TRISC = %00001000 ' Set Input/Output (0 to 7) (def.: %11111111)
CM2CON0 = %10100011 ' Comparator2 Module (def.: %00000000)
' Bit1/C2ON = Comp C2 is ON
' Bit5/C2OE = Output is PORTC.4
' Bits1-0 = Input is PORTC.3
VRCON = %00110000
' Bit2/C2VREN = Comparator C2 voltage ref is ON
' Bit4/VP6EN = 0.6V ref is ON
' ====== DEFINES ===================================================================================
DEFINE OSC 4
' ====== PROGRAM START =============================================================================
MAIN:
GOTO MAIN:
END
These are the registers:
And this is my PIC:
My voltage divider (that comes from Vbatt) is connected to PORTC.3 and I'm expecting the PORTC.4 (C2 output pin) to trip when Vbatt exceeds 0.6Volts, but this nevers happens.
What am I missing please?
Bookmarks