Skip to main content
OliverScheid
Associate II
April 21, 2026
Solved

LED Port configuration with STM32H573I-DK (PushPull vs. OpenDrain)

  • April 21, 2026
  • 1 reply
  • 166 views

When configuring the LEDs for the STM32H573I-DK using the STM32CubeMX it generated code which initializes the LED pins as PushPull (rather than OpenDrain).

Lookign at the schematics of the STM32H573I-DK it seems to be not "the best option".

Would you agree that OpenDrain (GPIO_MODE_OUTPUT_OD) is the better option here, rather than PushPull (GPIO_MODE_OUTPUT_PP)?

 

/**
 * @brief Configures LED on GPIO.
 * @PAram Led LED to be configured.
 * This parameter can be one of the following values:
 * @arg LED1
 * @arg LED2
 * @arg LED3
 * @arg LED4
 * @retval BSP status
 */
int32_t BSP_LED_Init(Led_TypeDef Led)
{
 int32_t ret = BSP_ERROR_NONE;
 GPIO_InitTypeDef gpio_init_structure;

 if ((Led != LED1) && (Led != LED2) && (Led != LED3) && (Led != LED4))
 {
 ret = BSP_ERROR_WRONG_PARAM;
 }
 else
 {
 switch (Led)
 {
 case LED2:
 /* Enable the LED2 GPIO clock */
 LED2_GPIO_CLK_ENABLE();
 break;
 case LED3:
 /* Enable the LED3 GPIO clock */
 LED3_GPIO_CLK_ENABLE();
 break;
 case LED4:
 /* Enable the LED4 GPIO clock */
 LED4_GPIO_CLK_ENABLE();
 break;
 case LED1:
 default:
 /* Enable the LED1 GPIO clock */
 LED1_GPIO_CLK_ENABLE();
 break;
 }
 /* Configure the GPIO_LED pin */
 gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP;
 gpio_init_structure.Pull = GPIO_NOPULL;
 gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
 gpio_init_structure.Pin = LED_PIN [Led];
 HAL_GPIO_Init(LED_PORT[Led], &gpio_init_structure);
 HAL_GPIO_WritePin(LED_PORT [Led], (uint16_t)LED_PIN[Led], GPIO_PIN_SET);
 }

 return ret;
}

 STM32CubeMX-LEDs.png

STM32H573I-DK-USER_LEDs.png

Best answer by OliverScheid

Well, "perfectly fine" is not what I would call it. Because I assume that the 3V3 supply of the LEDs is (slightly) higher than what the STM32H5 drives on the PF4/PF1/PI8/PI9. So, even if LEDs are OFF, you will have a small (useless) current flow.

But if you don't care about current consumption, then, of course, you are perfectly fine ;)

1 reply

Andrew Neil
Super User
April 21, 2026

Both would work.

OD is all that's needed, but push-pull would not hurt.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
OliverScheid
Associate II
April 21, 2026

For clarification: The tool generates push-pull.

I am saying it should create open-drain, instead.

Andrew Neil
Super User
April 21, 2026

Moved to the CubeMX forum then.

 

But the generated code is perfectly fine - no problem in using push-pull.

 

PS:

There are cases where not all GPIOs support open-drain - so maybe it's just taking the most general case?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.