2026-04-21 6:40 AM
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;
}
Solved! Go to Solution.
2026-04-21 1:27 PM
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 ;)
2026-04-21 6:47 AM
Both would work.
OD is all that's needed, but push-pull would not hurt.
2026-04-21 6:55 AM
For clarification: The tool generates push-pull.
I am saying it should create open-drain, instead.
2026-04-21 7:03 AM - edited 2026-04-21 7:14 AM
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?
2026-04-21 1:27 PM
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 ;)