 Hello and welcome to this presentation of the STM32G4 Analog Comparators. It covers the main features of the ultra-low power comparators and gives some application examples. Up to seven analog comparators inside STM32 microcontrollers provide a binary output which indicates if the analogue voltage on the plus input is larger than the voltage on the negative input. It allows the MCU to react when the analogue signal crosses a predefined threshold. The comparator continuously monitors voltage in contrast to an analogue to digital converter which operates in sampled mode. The comparator can be used to wake up devices from sleep and stop modes. Motor control loop is simplified by enabling a cooperation between the following units Comparators, Timers, DACs and Virefint. Applications can benefit from the flexible configuration of comparator properties which can be locked for safety reasons. Another safety feature of the comparator is its ability to generate a brake signal for timers allowing to safely stop the generation of PWM driving signals. Delay between analogue threshold crossing and digital output assertion is less than 15 nanoseconds. STM32G4 microcontrollers implement up to seven comparators. The comparator includes a programmable hysteresis to avoid various output transitions with noisy input signals. It offers flexible interconnections of inputs and outputs allowing the selection of thresholds for several external and internal inputs such as the AC outputs or internal reference voltage outputs. The comparator output can be connected to IOs using the alternate function channels or internally redirected to a variety of timer inputs enabling the brake event for fast PWM shutdown. It's also possible to create cycle-by-cycle current control or input captures for timing measurements. The CompX control registers can be locked until the next microcontroller is set. The number of comparators depends on the exact reference of the STM32G4 microcontroller. STM32G4 3X and STM32G4 4X series implement four comparators while STM32G4 7X and STM32G4 8X series implement seven comparators. The figure shows the general block diagram of the comparator integrated in STM32G4 microcontrollers. The multiplexes on the left select the voltage sources to be compared. GPIOs, DAC outputs, VRF int with four divide ratios. The output of the comparator can be inverted. The state of the comparator can be connected to GPIOs, XDI module to generate a wake-up request or an event to the CPU, timer inputs. It's possible to have the comparator output simultaneously redirected internally and externally. Each comparator has a non-inverting input and an inverting input. The in-mself field in the Comp1 CSR and Comp2 CSR registers is used to select the inverting input. Note that VRF int, possibly divided, can be selected as the in-m input of any comparator. The in-p self field in the Comp1 CSR and Comp2 CSR registers is used to select the non-inverting input. Note that the output of any comparator can be connected to timers and EXDI units. The blanking function aims to mask the output of the comparator during period of times indicated by a timer. This is typically used in the PFC technique for predictive functional control technique. The output of the comparator, called value, is ignored when the timer Timxocy signal is asserted. The comparator can be used in the cycle-by-cycle regulation loop for monitoring the peak value of the current flowing into the load. The purpose of the blanking function is to prevent incorrect current regulation tripping due to short-duration current spikes at the beginning of the PWM period. Short current spikes caused by activating the power switches can produce false pulses on the comparator output marked by the blue collar on the diagram. These pulses need to be masked by a blanking window to avoid false fault detection. The blanking window waveform can be generated by one of the timer output channels. The comparator's output can be masked during a blanking time defined by the timer output compare value selected in the blank cell field. For each comparator, this table indicates which timer output signal is used to control the blanking. The comparator includes a programmable hysteresis to avoid spurious output transitions with noisy input signals. It's non-symmetrical and only acting to a falling edge of the comparator output. The internal hysteresis function can be disabled so as to set the amount of hysteresis with external components which can be useful for example when exiting a low power mode. The comparators have internal connections with the timer units. The output can be internally redirected to a wide range of timer inputs for the following purposes. Emergency shutdown of PWM signals using BK in and BK in two inputs. Cycle by cycle current control using electronic timing relay or ETR inputs. Input capture for timing measures. The connection between the comparators and the timer is generally used for two purposes. Cycle by cycle current limitation based on the blanking mechanism. External counter reset when the voltage drops below threshold. Zero crossing detection. When both are needed simultaneously, the current limitation is based on the ETR timer input and a counter reset is signaled through a timer channel input. The figure represents an example of direct connection between timer and compute units. Overcurrent limitation uses the ETR input and external reset uses the CH1 input. The comparator can trigger an interrupt on the rising, falling or both edges of the comparator output through the EXTI line. This is required to exit the stop modes. The output can also be connected to the CPU's nested vectored interrupt controller or NVIC. The on-shape comparator remains active in the following modes, run, sleep and stop modes. In standby and shutdown modes, it's powered down and must be rationalised for use if returning to one of the higher powered modes. The comparator supports interrupt generation with wake up from sleep and stop modes through the EXTI unit. This is a list of peripherals related to the comp unit. Please refer to these peripheral trainings for more information if needed.