cancel
Showing results for 
Search instead for 
Did you mean: 

Comparator Settings

Carl_G
Senior II

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

Carl_G_0-1750644467047.png

I want PA1 and so I've chosen that in the STM32CubeMX

Carl_G_1-1750644553274.png

However, the generated code sets 

Carl_G_2-1750644605926.png

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 

Carl_G_4-1750644871312.png

Which in this case happens to be right!?

Any idea what is going on? I regenerated and get the same thing.

1 REPLY 1
Carl_G
Senior II

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!