Dear all,
we are trying to port RT-Thread ver. 5 to our custom STM32H723 board. I hang in the initialization section, when RT-Thread want to print the welcome screen.
I follow the instruction "How to make a STM32 BSP for RT-Thread.md" from rt_thread/rt-thread/bsp/stm32/docs/. They may be a bit outdated, but the only info I could find.
The code loop forever in
while (__HAL_UART_GET_FLAG(&(uart->handle), UART_FLAG_TC) == RESET);
I have to use UART4, and try it without DMA. When I try to enable DMA for UART4 in Kconfig, the compiler complain about missing UART4_RX_DMA_INSTANCE:
rt_thread/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/config/h7/uart_config.h:117:21: error: 'UART4_RX_DMA_INSTANCE' undeclared (first use in this function)
.Instance = UART4_RX_DMA_INSTANCE,
Searching for that, it seems there is no UART4_RX_DMA_INSTANCE defined in
rt_thread/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/config/h7/
only UART2_RX_DMA_INSTANCE. Searching over other STM32 families, they all seem to have UART4_RX_DMA_INSTANCE, but not the H7.
From the debug picture, it seems the UART4 is not fully setup,
BaudRate = 115200, WordLength = 0, StopBits = 0, Parity = 0,
WordLength should be 8, StopBit 1 and so on. I could not find, where to setup these details for UART4.
To fix that problem, I was guessing that the UART4 clock tree was not correct initalized. So I copied the function
HAL_UART_MspInit
from the CubeMX generated code into board.c. This fixes the problem with the
while (__HAL_UART_GET_FLAG(&(uart->handle), UART_FLAG_TC) == RESET);
loop. This was just guess work, and I dont know the side effects.
Now RT-Thread run, and the main app blinks a LED. But no output on the console of UART4. How to fix this?
Somebody can give me a hint?
Best regards,
I forgot, this is the code I copy from CubeMX to board.c. It is called direct after SystemClock_Config:
void HAL_UART_MspInit(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
/** Initializes the peripherals clock
*/
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_UART4;
PeriphClkInitStruct.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
{
Error_Handler();
}
/* Peripheral clock enable */
__HAL_RCC_UART4_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
/**UART4 GPIO Configuration
PC10 ------> UART4_TX
PC11 ------> UART4_RX
*/
GPIO_InitStruct.Pin = U4TX_Pin|U4RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF8_UART4;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/* UART4 interrupt Init */
HAL_NVIC_SetPriority(UART4_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(UART4_IRQn);
}
by debugging further, I found out, that the UART4_IRQHandler is called only once, when the UART ist setup:
rt_thread/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/drv_usart.c:244
stm32_control()
Shoulnd this UART4_IRQHandler called each time, when msh or finsh print something?