Skip to main content
sheng yang
Senior
Feb 23, 2025 11:33 PM UTC
Solved

faied do uart send with uart5 with stm32h7b0zb

I use cubemx generate a project with uart5. It's ok.

But when I move some init codes of uart5 to function ``void SystemInit (void)`` tail as below

```

MPU_Config();
HAL_Init();
SystemClock_Config();
PeriphCommonClock_Config();
MX_UART5_Init();
dbg_console_tx5("ABC21", 5);

```

 when I debug with cmsis-dap debugger I found the code stuck with

shengyang_0-1740353545384.png

 

besides the function ``dbg_console_tx5`` is 

```

 
void dbg_console_tx5(const uint8_t *pData, uint16_t Size)
{
HAL_UART_Transmit(&huart5, pData, Size, -1);
}

```

 

is there any tips of this issue ?

 

This topic has been closed for replies.
sheng yang
sheng yangBest answer
Senior
Mar 4, 2025 12:34 AM UTC

I'm sorry reply so late, the issue has resolved. Becase I move MX_UART5_Init prior _bss clear code, So the global handler of uart5 has some garbage value, so after I memset the global handler uart5 to zero before init the handler in MX_UART5_Init(); It's ok now.

3 replies

Tesla DeLorean
Guru
Feb 23, 2025 11:45 PM UTC

You move WHAT there exactly?

Perhaps don't move the code there?

SystemInit() is called prior to main(), so the clocks won't be setup optimally,and SysTick won't be working, and thus timeout loops, etc. Things that normally get done in HAL_Init()

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
sheng yang
Senior
Feb 24, 2025 12:11 AM UTC

thanks for your reply,I moved these codes :

MPU_Config();
HAL_Init();
SystemClock_Config();
PeriphCommonClock_Config();
MX_UART5_Init();
dbg_console_tx5("ABC21", 5);

 

prior to main()

sheng yang
sheng yangAuthorBest answer
Senior
Mar 4, 2025 12:34 AM UTC

I'm sorry reply so late, the issue has resolved. Becase I move MX_UART5_Init prior _bss clear code, So the global handler of uart5 has some garbage value, so after I memset the global handler uart5 to zero before init the handler in MX_UART5_Init(); It's ok now.