OPAMP can be configured as an inverting or non-inverting comparator with programmable hysteresis. Applying hysteresis will prevent constant toggling of the output, caused by noise when the input signals are close to each other.
In both inverting and non-inverting comparator configurations the positive input is connected to the resistor ladder. When OPAMP is configured as an inverting comparator with programmable hysteresis, the input voltage must be applied to the negative input and RES1MUX must be connected to the ground. When an OPAMP is configured as a non-inverting comparator with programmable hysteresis, the input voltage must be applied to RES1MUX and the negative input must be connected to the ground.
To configure an OPAMP as an inverting comparator with programmable hysteresis, the OPAMPCTRLx register can be configured as follows:
MUXPOS | MUXNEG | RES1MUX | POTMUX | RES2VCC | RES2OUT | RES1EN | ANAOUT | |
---|---|---|---|---|---|---|---|---|
OPAMP0 | 0001 | 000 | 010 | 001 | 0 | 1 | 1 | 0 |
Value | R1 | R2 | Threshold = Vcc * R1 / (R1 + R2) |
---|---|---|---|
0x0 | 14R | 2R | 7/8 * Vcc |
0x1 | 12R | 4R | 3/4 * Vcc |
0x2 | 8R | 8R | 1/2 * Vcc |
0x3 | 6R | 10R | 3/8 * Vcc |
0x4 | 4R | 12R | 1/4 * Vcc |
0x5 | 3R | 13R | 3/16 * Vcc |
0x6 | 2R | 14R | 1/8 * Vcc |
0x7 | R | 15R | 1/16 * Vcc |
To configure an OPAMP as a non-inverting comparator with programmable hysteresis, the OPAMPCTRLx register can be configured as follows:
MUXPOS | MUXNEG | RES1MUX | POTMUX | RES2VCC | RES2OUT | RES1EN | ANAOUT | |
---|---|---|---|---|---|---|---|---|
OPAMP0 | 0001 | 010 | 000 | 100 | 0 | 1 | 1 | 0 |
OPAMP1 | 0001 | 010 | 000 | 100 | 0 | 1 | 1 | 0 |
OPAMP2 | 0001 | 010 | 000 | 100 | 0 | 1 | 1 | 0 |
Value | R1 | R2 | Threshold = Vcc * R1 / R2 |
---|---|---|---|
0x0 | 14R | 2R | Vcc * 7 (unused) |
0x1 | 12R | 4R | Vcc * 3 (unused) |
0x2 | 8R | 8R | Vcc (unused) |
0x3 | 6R | 10R | 0.6* Vcc |
0x4 | 4R | 12R | 1/3 * Vcc |
0x5 | 3R | 13R | 3/13 *Vcc |
0x6 | 2R | 14R | 1/7 * Vcc |
0x7 | R | 15R | 1/15 * Vcc |