23. Comparator (COMP)
23.1 Introduction
The comparator can be used for a variety of functions including:
- • Wake-up from a low-power mode triggered by an analog signal
- • Analog signal conditioning
- • Cycle-by-cycle current control loop when combined with a PWM output from a timer
23.2 COMP main features
- • Selectable inverting analog inputs:
- – I/O pins
- – DAC channel outputs
- – Internal reference voltage and three submultiple values (1/4, 1/2, 3/4) provided by the scaler (buffered voltage divider)
- • I/O pins selectable as noninverting analog inputs
- • Programmable hysteresis
- • Programmable speed/consumption
- • Mapping of outputs to I/Os
- • Redirection of outputs to timer inputs for triggering:
- – Capture events
- – OCREF_CLR events (for cycle-by-cycle current control)
- – Break events for fast PWM shutdowns
- • Blanking of comparator outputs
- • Interrupt generation capability with wake up from Sleep and Stop modes (through the EXTI controller)
- • Interrupt output through the EXTI controller
- • Direct interrupt output to the CPU
- • Window mode
23.3 COMP implementation
23.3.1 COMP implementation for STM32C55x/562 and STM32C59x/5A3 devices
Table 166. COMP implementation for STM32C55x/562 and STM32C59x/5A3 (1)
| COMP features | COMP1 |
|---|---|
| Window mode | - |
| Programmable power and speed | X |
| Programmable hysteresis | X |
1. X = supported, - = not supported
Table 167. COMP implementation non-inverting input assignment for STM32C55x/562 and STM32C59x/5A3
| INPSEL [2:0] | COMP1 |
|---|---|
| 000 | COMP1_INP1 |
| 001 | COMP1_INP2 |
| 010 | COMP1_INP3 |
| 011 | dac1_ch1 |
| Others | Reserved |
23.3.2 COMP implementation for STM32C53x/542 device
Table 168. COMP implementation for STM32C53x/542(1)
| COMP features | COMP1 | COMP2 |
|---|---|---|
| Window mode | X | X |
| Programmable power and speed | X | X |
| Programmable hysteresis | X | X |
1. X = supported, - = not supported
Table 169. COMP implementation non-inverting input assignment for STM32C53x/542
| INPSEL [2:0] | COMP1 | COMP2 |
|---|---|---|
| 000 | COMP1_INP1 | COMP2_INP1 |
| 001 | COMP1_INP2 | COMP2_INP2 |
| 100 | COMP1_INP3 | COMP2_INP3 |
| 101 | dac1_ch1 | dac1_ch2 |
| Others | Reserved | Reserved |
The following table lists the paired comparators required for window mode.
Table 170. Window paired comparators
| Window comparator | #1 | #2 |
|---|---|---|
| Upper threshold comparator | COMP1 | COMP2 |
| Lower threshold comparator | COMP2 | COMP1 |
23.4 COMP functional description
23.4.1 COMP block diagram
The block diagram of the comparators is shown in the figure below.
Figure 151. Comparator functional block diagram

The diagram illustrates the functional blocks of the Comparator (COMP) peripheral. Key components include:
- Input Multiplexers: Select inputs for COMPx_INP (COMPx_INP I/Os, dac1_ch1) and COMPx_INM (COMPx_INM I/Os, dac1_ch1, VSENSE, VREF_COMP, 3/4 VREF_COMP, 1/2 VREF_COMP, 1/4 VREF_COMP) using INPSEL[0..2] and INMSEL[3:0] registers.
- Comparator Core: A differential amplifier (COMP) with non-inverting (+) and inverting (-) inputs. It is controlled by HYST and PWRMODE bits.
- Polarity Selection: A multiplexer that selects the output polarity based on the POLARITY bit.
- Output Logic: The comparator output (Value) is processed through a polarity selection block and an AND gate to produce compx_out. This output can be connected to EXTI lines or timers via GPIO alternate functions.
- Blanking: A multiplexer (Blank source) controlled by BLANKING[3:0] provides a blanking signal to the interrupt logic.
- Interrupt Generation: The compx_out signal is combined with the blanking signal and ITEN (Interrupt Enable) to drive a DFF (D-type Flip-Flop). The DFF output (compx_it) is connected to an interrupt line and is cleared by CCxIF.
- Clocking: The comparator is clocked by compx_pclk.
MSv76141V1
Note: The VSENSE buffer is controlled by the ADC peripheral. To activate the buffer, set the TSEN bit in the ADCC_CCR register.
23.4.2 COMP pins and internal signals
The I/Os used as comparator inputs must be configured in analog mode in the GPIO registers.
The comparator outputs can be connected to the I/Os through their alternate functions. Refer to the product datasheet for more information.
The outputs can also be internally redirected to a variety of timer inputs for the following purposes:
- • Emergency shut-down of PWM signals, using BKIN and BKIN2 inputs
- • Cycle-by-cycle current control, using ETR inputs of timers
- • Input capture for timing measurements
The comparator output can be simultaneously addressed internally and to the I/O pins.
Table 171. COMP input/output internal signals
| Signal name | Signal type | Description |
|---|---|---|
| dac1_out1 | Analog input | Analog signal from DAC peripheral |
| comp_x_blkx | Digital output | See Table 173: COMP blanking source assignment |
| comp_x_out | Digital output | COMPx output |
| comp_x_it | Digital output | COMPx interrupt out |
Note: For the COMP non-inverting input, refer to Table 167: COMP implementation non-inverting input assignment for STM32C55x/562 and STM32C59x/5A3 and Table 169: COMP implementation non-inverting input assignment for STM32C53x/542.
Table 172. COMP inverting input assignment
| INMSEL [3:0] | COMP1 | COMP2 |
|---|---|---|
| 0000 | \(\frac{1}{4} V_{REFINT}\) | \(\frac{1}{4} V_{REFINT}\) |
| 0001 | \(\frac{1}{2} V_{REFINT}\) | \(\frac{1}{2} V_{REFINT}\) |
| 0010 | \(\frac{3}{4} V_{REFINT}\) | \(\frac{3}{4} V_{REFINT}\) |
| 0011 | \(V_{REFINT}\) | \(V_{REFINT}\) |
| 0100 | dac1_ch1 | dac1_ch2 |
| 0101 | COMP1_INM1 | COMP2_INM1 |
| 0110 | COMP1_INM2 | COMP2_INM2 |
| 0111 | COMP1_INM3 | COMP2_INM3 |
| 0100 | VENSE | opamp1_out |
Note: Other combinations are reserved.
Table 173. COMP blanking source assignment
| BLANKING[3:0] | COMP1 | COMP2 |
|---|---|---|
| 0000 | No blanking | No blanking |
| 0001 | tim1_oc5 | tim1_oc6 |
| 0010 | tim2_oc3 | tim2_oc3 |
| 0011 | tim5_oc3 | - |
| 0100 | tim5_oc4 | - |
| 0101 | tim8_oc5(1) | tim8_oc5 |
| 0110 | tim15_oc2 | lptim1_ch1 |
| 0111 | - | lptim1_ch2 |
1. Not available for STM32C53x and STM32C542.
23.4.3 COMP reset and clocks
The clock comp_pclk, provided by the clock controller, synchronous with the APB clock.
Note: Important: The polarity selection logic and the output redirection to the port work independently of the APB clock. This allows the comparator to operate even in Stop mode. The interrupt line, connected to the NVIC of the CPU, requires the APB clock (comp_pclk) to work. In absence of the APB clock, the interrupt signal comp_it cannot be generated.
23.4.4 Comparator LOCK mechanism
The comparators can be used for safety purposes, such as overcurrent or thermal protection. For applications with specific functional safety requirements, the comparator configuration can be protected against undesired alteration that could happen, for example, at program counter corruption.
For this purpose, the comparator configuration registers can be write-protected (read-only).
Upon configuring a comparator channel, its LOCK bit is set to 1. This causes the entire register set of the comparator channel to become read-only, including the LOCK bit.
The write protection can only be removed through the MCU reset.
23.4.5 Window comparator (optional feature)
The purpose of the window comparator is to monitor the analog voltage to ensure it is within the voltage range defined by the lower and upper thresholds.
The two embedded comparators, COMP1 and COMP2, can be used to create a window comparator. The monitored analog voltage is connected to the noninverting (plus) inputs of comparators connected together (COMP1 or COMP2). The upper and lower threshold voltages are connected to the inverting (minus) inputs of the comparators.
The output of the window comparator (COMP1 or COMP2) is selected with the control bit WINOUT.
Figure 152. Window comparators functional block diagram

The diagram illustrates the functional block diagram for two comparators, COMP1 and COMP2, configured as a window comparator.
- COMP1: Its non-inverting input (+) is selected by a multiplexer (INPSEL / WINMODE) from inputs COMP1_INP1, COMP1_INP2, or dac1_ch1. Its inverting input (-) is selected by a multiplexer (INNSEL) from VREFs, DACs, COMP1_INM1, or COMP1_INM2. The output of COMP1 passes through a Polarity Blanking block.
- COMP2: Its non-inverting input (+) is selected by a multiplexer (INPSEL / WINMODE) from inputs COMP2_INP1, COMP2_INP2, or dac1_ch2. Its inverting input (-) is selected by a multiplexer (INNSEL) from VREFs, DACs, COMP2_INM1, COMP2_INM2, or COMP2_INM3. The output of COMP2 passes through a Polarity Blanking block.
- Window Mode Logic: The outputs of both comparators are fed into OR gates. The output of the COMP1 OR gate is labeled 'comp1_value'. The output of the COMP2 OR gate is labeled 'comp2_value'. These values are then selected by a multiplexer (WINOUT) to produce the final outputs 'comp1_out' and 'comp2_out'.
- Control: A 'Window Mode' control signal is shown influencing the selection logic for the inputs of both comparators.
- Reference: The diagram is labeled MSv76142V1 in the bottom right corner.
23.4.6 Hysteresis
The comparator includes a programmable hysteresis to avoid spurious output transitions in case of noisy signals. The hysteresis can be disabled if it is not needed (for instance when exiting from low-power mode) to be able to force the hysteresis value using external components.
Figure 153. Comparator hysteresis

The diagram illustrates the hysteresis effect in a comparator. The top part of the graph shows the input signal (INM) as a noisy waveform. The bottom part shows the comparator output (COMP_OUT) as a digital signal. The hysteresis is represented by two horizontal dashed lines: the upper one is labeled INM and the lower one is labeled INM - Vhyst. The output transitions occur when the input crosses these thresholds, demonstrating how hysteresis prevents spurious transitions caused by noise.
MS19984V1
23.4.7 Comparator output blanking function
The purpose of the blanking function is to prevent the current regulation to trip upon short current spikes at the beginning of the PWM period (typically the recovery current in power switches anti parallel diodes). It uses a blanking window defined with a timer output compare signal. Refer to the register description for selectable blanking signals.
The blanking signal gates the internal comparator output such as to clean the comp_out from spurious pulses due to current spikes, as depicted in the following figure (the COMP channel number is not represented).
Figure 154. Comparator output blanking

MSv75183V1
23.4.8 COMP startup stabilization time
The comparator parameters and its output is undefined after the COMP is enabled (power-on) for a period defined as startup stabilization time. See the product datasheet for more details. If the comparator output is driving any critical stage of the design, it is recommended to redirect the comparator output to the device I/O through the GPIO alternate function or through IP configuration (such as timers) after the stabilization time elapses.
23.4.9 COMP power and speed modes
The power consumption of the COMP channels versus propagation delay can be programmed with PWRMODE[1:0] bit field in COMP_CFGRx registers.
23.5 COMP low-power modes
Table 174. Comparator behavior in low-power modes
| Mode | Description |
|---|---|
| Sleep | No effect on the comparators. Comparator interrupts cause the device to exit the Sleep mode. |
| Stop | No effect on the comparators. Comparator interrupts cause the device to exit the Stop mode. |
Note: The comparators cannot be used to exit the device from Sleep or Stop mode when the internal reference voltage is switched off.
23.6 COMP interrupts
There are two ways to use the comparator as interrupt source.
The comparator outputs are internally connected to the extended interrupt and event controller (EXTI). Each comparator has its own EXTI line and can generate either interrupts or events to make the device exit low-power modes.
The comparator also provides an interrupt line to the NVIC of the CPU. This functionality is used when the CPU is active to handle low-latency interrupt. It requires APB clock running.
23.6.1 COMP wake-up interrupt through EXTI
Refer to the Section 16: Extended interrupts and event controller (EXTI) for more details.
Sequence to enable the COMPx interrupt through EXTI block:
- 1. Enable the COMPx and wait for stabilization.
- 2. Configure the EXTI line, receiving the compx_wkup signal, in interrupt mode, select the rising, falling or either-edge sensitivity and enable the EXTI line.
- 3. Configure and enable the NVIC IRQ channel mapped to the corresponding EXTI lines.
Table 175. COMP wake-up interrupt through EXTI control bits
| Interrupt event | Event flag | Enable control bit | Exit Sleep mode | Exit Stop modes | Exit Standby mode |
|---|---|---|---|---|---|
| compx_wkup | Through EXTI | Through EXTI | Yes | Yes | N/A |
23.6.2 COMP NVIC interrupt through EXTI
Refer to the Section 16: Extended interrupts and event controller (EXTI) and Section 15: Nested vectored interrupt controller (NVIC) for more details.
Sequence to enable the COMPx interrupt through the EXTI block:
- 1. Enable the COMP and wait for stabilization.
- 2. Configure the EXTI line, receiving the comp_out signal, in interrupt mode, select the rising, falling, or either-edge sensitivity and enable the EXTI line.
- 3. Configure and enable the IMx in EXTI_IMRx.
Table 176. COMP NVIC interrupt through EXTI control bits
| Interrupt event | Interrupt flag | Enable control bit | Interrupt clear bit | Exit Sleep mode | Exit Stop modes |
|---|---|---|---|---|---|
| compx_it | RPIFx or FPIFx in EXTI_RPRx or EXTI.FPRx | RTx or FTx in EXTI.RTSRx or EXTI.FTSRx and IMx in EXTI.IMRx | RPIFx or FPIFx in EXTI_RPRx or EXTI.FPRx | Yes (with APB clock) | Yes |
Note: It is mandatory to enable the APB clock to use this interrupt. If the clock is not enabled, an interrupt is not generated.
23.6.3 COMP interrupt through NVIC of the CPU
Refer to the Section 15: Nested vectored interrupt controller (NVIC) for more details.
Sequence to enable the COMP interrupt through NVIC of the CPU:
- 1. Enable the COMP and wait for stabilization.
- 2. Configure and enable the NVIC IRQ channel mapped to the comp_it line.
- 3. Configure and enable the ITEN in COMP_CFGRx.
Table 177. COMP interrupt through NVIC of the CPU control bits
| Interrupt event | Interrupt flag | Enable control bit | Interrupt clear bit | Exit Sleep mode | Exit Stop modes |
|---|---|---|---|---|---|
| comp_it | C1IF in | ITEN in COMP_CFGR1 | CC1IF | Yes (with APB clock) | No |
| C2IF in | ITEN in COMP_CFGR2 | CC2IF | Yes (with APB clock) | No |
Note: It is mandatory to enable APB clock to use this interrupt. If clock is not enabled, interrupt is not generated.
The interrupt is active on level and not automatically clear by hardware. It must be cleared in the comparator interrupt handler by firmware with ITEN = 0 (COMP_CFGR1 register).
The interrupt signal comp_it is generated on comparator level, for this reason: upon interruption occurrence, the comp_it signal must be set to low as soon as possible to avoid comparator interrupt handler re-entrance. This can be done by setting ITEN = 0 or changing the comparator POLARITY bit.
23.7 SCALER function
The scaler block is available to provide the different voltage reference levels to the comparator inputs. It is based on an amplifier driving a resistor bridge. The amplifier input is connected to the internal voltage reference \(V_{REFINT}\).
The amplifier and the resistor bridge can be enabled separately. The amplifier is enabled by the SCALEN bits of the COMP_CFGRx registers. The resistor bridge is enabled by the BRGEN bits of the COMP_CFGRx registers.
When the resistor-divided voltage is not used, the resistor bridge disconnect to reduce the consumption.
Figure 155. Scaler block diagram

23.8 COMP registers
23.8.1 Comparator status register (COMP_SR)
The COMP_SR is the comparator status register.
Address offset: 0x00
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | C2IF | C1IF |
| r | r | ||||||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | C2VAL | C1VAL |
| r | r |
Bits 31:18 Reserved, must be kept at reset value.
Bit 17 C2IF: COMP2 channel interrupt flag
This bit is set by hardware when the COMP2 channel output is set.
This bit is cleared by software by writing CC12F = 1 in the COMP_ICFR register.
Bit 16 C1IF: COMP1 channel interrupt flag
This bit is set by hardware when the COMP1 channel output is set.
This bit is cleared by software by writing CC1IF = 1 in the COMP_ICFR register.
Bits 15:2 Reserved, must be kept at reset value.
Bit 1 C2VAL: COMP2 channel output status bit
This bit is read-only. It reflects the current COMP1 channel output taking into account POLARITY and BLANKING bits effect.
Bit 0 C1VAL: COMP1 channel output status bit
This bit is read-only. It reflects the current COMP1 channel output taking into account POLARITY and BLANKING bits effect.
23.8.2 Comparator interrupt clear flag register (COMP_ICFR)
The COMP_ICFR is the comparator interrupt clear flag register.
Address offset: 0x04
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | CC2IF | CC1IF |
| rc_w1 | rc_w1 | ||||||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
Bits 31:18 Reserved, must be kept at reset value.
Bit 17 CC2IF: Clear COMP2 channel interrupt flag
Writing 1 clears the C2IF flag in the COMP_SR register.
Bit 16 CC1IF: Clear COMP1 channel interrupt flag
Writing 1 clears the C1IF flag in the COMP_SR register.
Bits 15:0 Reserved, must be kept at reset value.
23.8.3 Comparator configuration register 1 (COMP_CFGR1)
The COMP_CFGR1 is the COMP1 configuration register.
Address offset: 0x0C
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| LOCK | Res. | Res. | Res. | BLANKING[3:0] | Res. | INPSEL[2:0] | INMSEL[3:0] | ||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | ||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | WINOUT | PWRMODE[1:0] | Res. | Res. | HYST[1:0] | Res. | ITEN | Res. | WINMODE | POLARITY | SCALE N | BRGEN | EN | ||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | |||||
Bit 31 LOCK: Lock
This bit is set by software and cleared by a hardware system reset. It locks the whole content of the COMP channel configuration register COMP_CFGR1[31:0]
0: COMP_CFGR1[31:0] register is read/write
1: COMP_CFGR1[31:0] is read-only
Bits 30:28 Reserved, must be kept at reset value.
Bits 27:24 BLANKING[3:0]: COMP1 channel blanking source selection
Bits of this field are set and cleared by software (only if LOCK not set).
The field selects the input source for COMP1 channel output blanking.
Note: See Table 173: COMP blanking source assignment for more details.
Bit 23 Reserved, must be kept at reset value.
- Bits 22:20 INPSEL[2:0]: COMP1 non-inverting input selection
These bits are set and cleared by software (only if LOCK not set).
They select which input is connected to the non-inverting input of COMP1 channel.
Note: See Table 167: COMP implementation non-inverting input assignment for STM32C55x/562 and STM32C59x/5A3 and Table 169: COMP implementation non-inverting input assignment for STM32C53x/542 for more details. - Bits 19:16 INMSEL[3:0]: COMP1 channel inverting input selection
These bits are set and cleared by software (only if LOCK not set). They select which input is connected to the inverting input of COMP1 channel.
Note: See Table 172: COMP inverting input assignment for more details. - Bit 15 Reserved, must be kept at reset value.
- Bit 14 WINOUT: COMP1 output selector
This bit is controlled by software (if not locked). It selects the COMP1 output.
0: COMP1_VALUE
1: COMP1_VALUE XOR COMP2_VALUE (required for window mode, see Figure 152: Window comparators functional block diagram) - Bits 13:12 PWRMODE[1:0]: Power mode of the COMP1 channel
These bits are set and cleared by software (only if LOCK not set). They control the power/speed of the COMP channel.
00: High speed/high power
01: Medium speed/medium power
All others values: Reserved - Bits 11:10 Reserved, must be kept at reset value.
- Bits 9:8 HYST[1:0]: COMP channel hysteresis selection
These bits are set and cleared by software (only if LOCK not set). They select the hysteresis voltage of the COMP channel.
00: No hysteresis
01: Low hysteresis
10: Medium hysteresis
11: High hysteresis - Bit 7 Reserved, must be kept at reset value.
- Bit 6 ITEN: COMP channel interrupt enable
This bit is set and cleared by software (only if LOCK not set). This bit enable the interrupt generation of the COMP channel.
0: Interrupt generation disabled for COMP channel
1: Interrupt generation enabled for COMP channel - Bit 5 Reserved, must be kept at reset value.
- Bit 4 WINMODE: COMP1 non-inverting input selector for window mode
This bit is controlled by software (if not locked). It selects the COMP1_INP input of COMP1.
0: Signal selected with INPSEL[1:0]
1: COMP2_INP signal of COMP2 (required for window mode, see Figure 152: Window comparators functional block diagram) - Bit 3 POLARITY: COMP channel polarity selection
This bit is set and cleared by software (only if LOCK not set). It inverts COMP channel polarity.
0: COMP channel output is not inverted
1: COMP channel output is inverted
Bit 2 SCALEN: Voltage scaler enable
This bit is set and cleared by software (only if LOCK not set). This bit enables the \(V_{REFINT}\) scaler for the COMP channels.
0: \(V_{REFINT}\) scaler disabled
1: \(V_{REFINT}\) scaler enabled
Bit 1 BRGEN: Scaler bridge enable
This bit is set and cleared by software (only if LOCK not set). This bit enables the bridge of the scaler.
0: Scaler resistor bridge disabled
1: Scaler resistor bridge enabled
Bit 0 EN: COMP channel enable
This bit is set and cleared by software (only if LOCK not set). It enables the COMP channel.
0: Disable
1: Enable
23.8.4 Comparator configuration register 2 (COMP_CFGR2)
The COMP_CFGR2 is the COMP2 configuration register.
Address offset: 0x10
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| LOCK | Res. | Res. | Res. | BLANKING[3:0] | Res. | INPSEL[2:0] | INMSEL[3:0] | ||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | ||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | WINOUT | PWRMODE[1:0] | Res. | Res. | HYST[1:0] | Res. | ITEN | Res. | WINMODE | POLARITY | SCALEN | BRGEN | EN | ||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | |||||
Bit 31 LOCK: Lock
This bit is set by software and cleared by a hardware system reset. It locks the whole content of the COMP channel configuration register COMP_CFGR1[31:0]
0: COMP_CFGR2[31:0] register is read/write
1: COMP_CFGR2[31:0] is read-only
Bits 30:28 Reserved, must be kept at reset value.
Bits 27:24 BLANKING[3:0]: COMP2 channel blanking source selection
Bits of this field are set and cleared by software (only if LOCK not set).
The field selects the input source for COMP1 channel output blanking.
Note: See Table 173: COMP blanking source assignment for more details.
Bit 23 Reserved, must be kept at reset value.
Bits 22:20 INPSEL[2:0]: COMP2 non-inverting input selection
These bit are set and cleared by software (only if LOCK not set).
They select which input is connected to the non-inverting input of COMP2 channel.
Note: See Table 169: COMP implementation non-inverting input assignment for STM32C53x/542 for more details.
- Bits 19:16 INMSEL[3:0]: COMP2 channel inverting input selection
These bits are set and cleared by software (only if LOCK not set). They select which input is connected to the inverting input of COMP1 channel.
Note: See Table 172: COMP inverting input assignment for more details. - Bit 15 Reserved, must be kept at reset value.
- Bit 14 WINOUT: COMP2 output selector
This bit is controlled by software (if not locked). It selects the COMP1 output.
0: COMP2_VALUE
1: COMP1_VALUE XOR COMP2_VALUE (required for window mode, see Figure 152: Window comparators functional block diagram) - Bits 13:12 PWRMODE[1:0]: Power mode of the COMP2 channel
These bits are set and cleared by software (only if LOCK not set). They control the power/speed of the COMP channel.
00: High speed/high power
01: Medium speed/medium power
All others values: Reserved - Bits 11:10 Reserved, must be kept at reset value.
- Bits 9:8 HYST[1:0]: COMP channel hysteresis selection
These bits are set and cleared by software (only if LOCK not set). They select the hysteresis voltage of the COMP channel.
00: No hysteresis
01: Low hysteresis
10: Medium hysteresis
11: High hysteresis - Bit 7 Reserved, must be kept at reset value.
- Bit 6 ITEN: COMP channel interrupt enable
This bit is set and cleared by software (only if LOCK not set). This bit enable the interrupt generation of the COMP channel.
0: Interrupt generation disabled for COMP channel
1: Interrupt generation enabled for COMP channel - Bit 5 Reserved, must be kept at reset value.
- Bit 4 WINMODE: COMP2 non-inverting input selector for window mode
This bit is controlled by software (if not locked). It selects the COMP2_INP input of COMP2.
0: Signal selected with INPSEL[1:0]
1: COMP2_INP signal of COMP2 (required for window mode, see Figure 152: Window comparators functional block diagram) - Bit 3 POLARITY: COMP channel polarity selection
This bit is set and cleared by software (only if LOCK not set). It inverts COMP channel polarity.
0: COMP channel output is not inverted
1: COMP channel output is inverted - Bit 2 SCALEN: Voltage scaler enable
This bit is set and cleared by software (only if LOCK not set). This bit enables the \(V_{REFINT}\) scaler for the COMP channels.
0: \(V_{REFINT}\) scaler disabled
1: \(V_{REFINT}\) scaler enabled
Bit 1 BRGEN: Scaler bridge enable
This bit is set and cleared by software (only if LOCK not set). This bit enables the bridge of the scaler.
0: Scaler resistor bridge disabled
1: Scaler resistor bridge enabled
Bit 0 EN: COMP channel enable
This bit is set and cleared by software (only if LOCK not set). It enables the COMP channel.
0: Disable
1: Enable
23.8.5 COMP register map
Table 178. COMP register map and reset values
| Offset | Register name | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x00 | COMP_SR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | C2IF | C1IF | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | C2VAL | C1VAL |
| Reset value | 0 | 0 | 0 | 0 | |||||||||||||||||||||||||||||
| 0x04 | COMP_ICFR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | CC2IF | CC1IF | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| Reset value | 0 | 0 | |||||||||||||||||||||||||||||||
| 0x0C | COMP_CFGR1 | LOCK | Res. | Res. | Res. | BLANKING [3:0] | Res. | INPSEL [2:0] | INMSEL [3:0] | Res. | WINMOUT | PWRRMODE [1:0] | Res. | Res. | HYST[1:0] | Res. | ITEN | Res. | WINMODE | POLARITY | SCALEN | BRGEN | EN | ||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||||
| 0x10 | COMP_CFGR2 | LOCK | Res. | Res. | Res. | BLANKING [3:0] | Res. | INPSEL [2:0] | INMSEL [3:0] | Res. | WINMOUT | PWRRMODE [1:0] | Res. | Res. | HYST[1:0] | Res. | ITEN | Res. | WINMODE | POLARITY | SCALEN | BRGEN | EN | ||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||||
Refer to Section 2.2: Memory organization for the register boundary addresses.