Re: Comparator not tripping above 0.6V (Vref) on PIC 16F690
this works if you mean "trip pin" means pin is set when below 0.6v and cleared when over
#CONFIG
__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOD_ON & _IESO_ON & _FCMEN_ON
#ENDCONFIG
' ====== 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)
led var portc.0 ; proof of life
CM2CON0 = %10100111 ' Comparator2 Module (def.: %00000000)
' Bit1/C2ON = Comp C2 is ON
' Bit5/C2OE = Output is PORTC.4
' Bits1-0 = Input is PORTC.3
;bit2 connect c2+ to fvr output
ansel.4=0 "just to prove c2+ is not connected to this
VRCON = %00110000
' Bit2/C2VREN = Comparator C2 voltage ref is ON
' Bit4/VP6EN = 0.6V ref is ON
' ====== DEFINES ================================================== =================================
DEFINE OSC 4
' ====== PROGRAM START ================================================== ===========================
MAIN:
toggle led ; proof of life
pause 1000
GOTO MAIN:
END
Warning I'm not a teacher
Bookmarks