Skip to main content
Associate
Oct 9, 2026 10:00 AM UTC
Question

CUBEMX issue while configuring COMP with STM32H503

When Comparator is configured, the init sequence do not generate the option for Positive input selection 
one has to add this line manually, depending on the pin selected as INP. 
hcomp1.Init.InputPlus = COMP_INPUT_PLUS_IO1; 

or
 hcomp1.Init.InputPlus = COMP_INPUT_PLUS_IO2; 

or

hcomp1.Init.InputPlus = COMP_INPUT_PLUS_IO3; 

 

and so Comparator do not work if not checked. 

I am using CubeMX version 6.18.1

8 replies

Ghofrane GSOURI
ST Technical Moderator
Oct 9, 2026 10:11 AM UTC

Hello ​@bhushan_pawar 

I have performed a test using the latest version of STM32CubeMX6.18.1 and the generated code is correct . Please check the screenshots

I will be waiting for your feedback.

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate
Oct 15, 2026 8:30 AM UTC

Thanks sir… for your reply , but when i generated for MDK-ARM and found.. 

I verified once again … but the error remains same… My comparator INP is at PB2

Ghofrane GSOURI
ST Technical Moderator
Oct 15, 2026 8:32 AM UTC

Hello ​@bhushan_pawar 

Thank you for your reply.

I will perform a test using  MDK-ARM and get back to you ASAP.

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate
Oct 15, 2026 8:38 AM UTC

I verified with your provided test_COMP.ioc.. and the result remains same.. 

But for PA0 it generates… 
 

 

Ghofrane GSOURI
ST Technical Moderator
Oct 15, 2026 10:30 AM UTC

Hello ​@bhushan_pawar 

Thank your for your detailed explanation.

Issue has been escalated to dev team under internal ticket ID #0066638 

I will keep you posted with updates.

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Visitor
Oct 20, 2026 12:18 PM UTC

Try updating STM32CubeMX to the latest version and check that the STM32H503 firmware package is up to date. If the issue persists, sharing the exact COMP configuration and any error messages would help identify the cause.

Associate
Oct 20, 2026 2:15 PM UTC

Dear MikeJhones, 
Thaks for the concern… but I tried in updated versions also… for STM32H503 if we change the default COMP_INP pin (PA0 ) to other pins like PB2 it do not generate the line for the corrosponding Pin… 
Even stm32h5xx_hal_comp.h file has the options…
/** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
  * @{
  */
#if defined(STM32H503xx)
#define COMP_INPUT_PLUS_IO1            (0x00000000UL)         /*!< Comparator input plus connected to IO1 (pin PB0) */
#define COMP_INPUT_PLUS_IO2            (COMP_CFGR2_INPSEL0)   /*!< Comparator input plus connected to IO2 (pin PA0) */
#define COMP_INPUT_PLUS_IO3            (COMP_CFGR1_INPSEL1)   /*!< Comparator input plus connected to IO3 (pin PB2) */
#define COMP_INPUT_PLUS_DAC1_CH1       (COMP_CFGR1_INPSEL2)   /*!< Comparator input plus connected to (DAC1_CH1) */
#else
#define COMP_INPUT_PLUS_IO1            (0x00000000UL)         /*!< Comparator input plus connected to IO1
                                                                   (COMP1 pin PA7, COMP2 pin PB0) */
#define COMP_INPUT_PLUS_IO2            (COMP_CFGR1_INPSEL0)   /*!< Comparator input plus connected to IO2
                                                                   (COMP1 pin PB2, COMP2 pin PE7) */
#define COMP_INPUT_PLUS_DAC1_CH1       (COMP_CFGR1_INPSEL1)   /*!< Comparator input plus connected to DAC1 channel 1
                                                                   (specific to instance: COMP1) */
#define COMP_INPUT_PLUS_DAC1_CH2       (COMP_CFGR1_INPSEL1)   /*!< Comparator input plus connected to DAC1 channel 2
                                                                   (specific to instance: COMP2) */
#endif /* STM32H503xx */
/**
  * @}
  */


so theorotically it shall generate.. for PB2.. but it does not… 

Associate
Oct 20, 2026 2:20 PM UTC

I have to add the line additionally.. my concern is it has to be rectified, because i lost much time debugging…