I do not know why the comparator does not compare correctly. I use AIN6 as Vin+; ANI0 as Vin-. The code is show in below. The comparator is work in differential mode.
The output of compare is show in below.
yellow line: input signal of comparator. Frequency: 10Hz; High voltgae: 0.5V; low voltage: -0.5V, Symm: 50%.
blue line: output of comparator.
Vin+ of the comparator is connected to the yellow line signal, the Vin- of comparator is connected to GND. Therefore, the duty cycle of blue line should be 50%. But now the duty cycle of
blue line is not 50%. I do not know why.
I try to bias the input signal to 0.5V and use 0.5V as the voltage reference. The result is shown in below.
yellow line: input signal of comparator. High voltgae: 1V; low voltage: 0V, Symm: 50%
Vin+ of the comparator is connected to the yellow line signal, the Vin- of comparator is connected to 500mV.
The blue line is output of comparator, which means the comparator does not work.
Hmm that's strange. Do you mind observing the output of the comparator while you're increasing the bias from 0mv to 500mv? Since we know it "works" at 0V bias there should be a certain bias voltage where it stops working. This might tell us something. If it does not work at 0mv bias (original setup) then the ESD diodes are likely blown and the analog input will be undefined. If the ESD diode is blown in such a way that it acts as a short circuit to GND then Vin - will be at 0V, and Vin + > Vin - will always be true.