UART/USART Does not Work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-30 1:16 PM
I would like to transmit data via USART and read the data sent to computer via a terminal(I have tried Putty and Real Term so far). To that end, I activate My USART configuration is seen as above. I also wrote the code below:
uint8_t myTxData[13] = "Hello World\r\n";
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_StatusTypeDef res = HAL_UART_Transmit(&huart1, myTxData, 13, 10);
if(!res) {
HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_1);
HAL_Delay(1000);
}
}
Note that I only put here inside the while loop. The other statements were generated by CubeMX.
Normally my code sends data to my pc if res is true, in other words, if it is HAL_OK, and also toggles the LED. Since it couldn't see the data in the terminal, I changed the condition in if statement, and saw that the led is toggled in each second. Therefore, I concluded that my USART channel does not work. What's the issue?
Thx for your help in advance.
Solved! Go to Solution.
- Labels:
-
UART-USART
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-01 5:27 AM
Your program runs on STM32F746, not on ST-Link CPU (STM32F103, which uses its PA2 and PA3 to connect to F746). The schematics of Discovery board shows the pins used in F746 for UART VCP connection are PA9 and PB7, which are USART1 TX and RX pins.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-30 1:50 PM
This doesn't show any of the initialization code for the USART, clocks and pins.
Check it is using the right pins.
Check pins with a scope.
Check bit timings of 'U' pattern, confirm baud rate settings.
The USART TX pin uses CMOS levels, this is not compatible with RS232 levels.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-30 10:15 PM
Thanks for your response, but unfortunately I understand nothing. May I ask you to give th more details about the steps plase?
In addition, AFAIK, sending a message to a terminal is fairly easy with UART? Am I wrong? What action do I take if USART TX pin uses CMOS level? And I am not using RS232, and I already disabled it.
Thx for your response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-31 12:26 AM
What is see is your timeout period is 10, change that to 100.
Next is check the baudrate on your serial terminal, it should be 115200.
It must work now!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-31 5:17 AM
Unfortunately, that doesn't work as well. I checked that the baud rate of the serial terminal is 115200, too.
Thx your response. I am pleased if you have another way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-31 5:33 AM
Did you change the timeout?
what is the board that you are using?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-31 5:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-31 5:51 AM
what is your RCC setting?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-31 6:04 AM
No details on which STM32 you are using, the board or the pins involved.
Code provided so far is superficial. Issue likely not timeout related, should still see 10 or so characters.
Perhaps look at other Cube/HAL examples, where information is less hidden.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-05-31 9:37 PM
I am sorry for these missing parts. I am newbie to both embedded systems and the forums.
I am using STM32F746NG discovery board. I tried all USART channels but I still got nothing.The image above is a part of the schematic of my board. I activated PA2 and PA3 pins for UART TX and RX pins, respectively. I am not sure however if it is correct.
