There's no built-in command to read a comparator status. you need to read the register.
this something to start...
Code:@ __config _INTRC_OSC_NOCLKOUT & _MCLRE_OFF TRISIO = %11001111 ' GPIO.4, GPIO.5 as output CMCON = %00000010 ' COUT=1 when Vin+(GPIO.0) > Vin- (GPIO.1) ' comparator mode :comparator without output Clip var GPIO.4 Normal var GPIO.5 Speaker var byte start: speaker=CMCON.6 ' read from internal comparator Select case speaker case 0 clip=0 normal=1 case 1 clip=1 normal=0 pause 100 Clip=0 end select goto start





Bookmarks