2025-06-22 7:14 PM
I'm confused by the comparator settings. I've tested this a while ago and it was working. I assume it still is. But I am doing some code changes and it seems like its set to the wrong value and I don't understand.
For COMP1 on STM32G0 here are the pin assignments from the reference manual
I want PA1 and so I've chosen that in the STM32CubeMX
However, the generated code sets
and the value of InputPlus is
/** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
* @{
*/
#define COMP_INPUT_PLUS_IO1 (0x00000000UL) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2, pin PB0 for COMP3 (for devices featuring COMP3 instance)) */
#define COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2, pin PC1 for COMP3 (for devices featuring COMP3 instance)) */
#define COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2, pin PE7 for COMP3 (for devices featuring COMP3 instance)) */
Which apparently maps to PB2 which is wrong!
On the other hand, COMP2 I have chosen PB6 and its getting
Which in this case happens to be right!?
Any idea what is going on? I regenerated and get the same thing.
2025-06-22 7:19 PM
I changed COMP1 to PB2 and it stayed as is which is correct. Then I changed back to PA1 but the input did not change. And so it must be wrong!