We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
根据官方文档,在 Ubuntu 上自行编译 RT-Thread Nano 中的例程 bsp/stm32f103-msh,发现串口无法正常输入。
bsp/stm32f103-msh
然后,测试 RT-Thread v4.0.3,使用例程 bsp/stm32/stm32f103-mini-system,发现工作正常。
bsp/stm32/stm32f103-mini-system
最后自行研究了两天,发现问题出在 Nano 版本的 bsp/stm32f103-msh/drivers/board.c 文件,原来代码是这样的:
bsp/stm32f103-msh/drivers/board.c
void HAL_UART_MspInit(UART_HandleTypeDef *huart) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if (huart->Instance == USART2) { __HAL_RCC_USART2_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); /**USART2 GPIO Configuration PA2 ------> USART2_TX PA3 ------> USART2_RX */ GPIO_InitStruct.Pin = USART_TX_Pin | USART_RX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); } }
改为:
void HAL_UART_MspInit(UART_HandleTypeDef *huart) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if (huart->Instance == USART2) { __HAL_RCC_USART2_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = USART_TX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Configure USART Rx as alternate function push-pull */ GPIO_InitStruct.Pin = USART_RX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); } }
然后再测试,就能正常输入了。
PS. 似乎串口的 Rx 必须设置为 GPIO_MODE_INPUT
GPIO_MODE_INPUT
The text was updated successfully, but these errors were encountered:
No branches or pull requests
根据官方文档,在 Ubuntu 上自行编译 RT-Thread Nano 中的例程
bsp/stm32f103-msh
,发现串口无法正常输入。然后,测试 RT-Thread v4.0.3,使用例程
bsp/stm32/stm32f103-mini-system
,发现工作正常。最后自行研究了两天,发现问题出在 Nano 版本的
bsp/stm32f103-msh/drivers/board.c
文件,原来代码是这样的:改为:
然后再测试,就能正常输入了。
PS. 似乎串口的 Rx 必须设置为
GPIO_MODE_INPUT
The text was updated successfully, but these errors were encountered: