2026-03-19 7:55 PM
Code generation of the attached .ioc file (copy of ST example file of similar name) does not generate clock init for UART4. This means the example application hard faults. I see no reason why the UART clock should not be initialised here and would save someone time debugging in the future!
In stm32mp2xx_hal.c:
void HAL_UART_MspInit(UART_HandleTypeDef* huart)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(huart->Instance==UART4)
{
/* USER CODE BEGIN UART4_MspInit 0 */
// TODO: Need this here! __HAL_RCC_UART4_CLK_ENABLE();
/* USER CODE END UART4_MspInit 0 */
/**UART4 GPIO Configuration
PH8 ------> UART4_RX
PH7 ------> UART4_TX
*/
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Alternate = GPIO_AF4_UART4;
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF4_UART4;
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
/* USER CODE BEGIN UART4_MspInit 1 */
/* USER CODE END UART4_MspInit 1 */
}
}
Solved! Go to Solution.
2026-03-22 11:59 AM - edited 2026-03-23 4:46 AM
Hello @ADunc.1
Your contribution is much appreciated.
Issue has been escalated to dev team under internal ticket ID #0060887
I will kee
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.
2026-03-22 11:59 AM - edited 2026-03-23 4:46 AM
Hello @ADunc.1
Your contribution is much appreciated.
Issue has been escalated to dev team under internal ticket ID #0060887
I will kee
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.
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.