UART2 Output Stripped - NUCLEO-F401RE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-02-15 1:04 AM
Working on a prototype and am using HAL_UART_Transmit to output to UART2. Upon output over UART2 the string seems to be truncated. Code below:
```
char stuff[] = "HELLO YOU FINE FELLOW";
HAL_UART_Transmit(&huart2,stuff,sizeof(stuff),1);
```
Output is HELLO YOU FINE FEL.
Any advice would be helpful.
- Labels:
-
STM32F4 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-02-15 1:43 AM
Ask a noob question and voila I stumble across the answer. Strangely enough the answer was the timeout in HAL_UART_Transmit ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-02-15 8:46 AM
Not causing THAT problem, but also a "noob" mistake with the "size" parameter. Question: what is the difference between sizeof(stuff) and strlen(stuff)? And why is there a difference? Is it sending what you expect?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-02-15 8:52 AM
Use strlen() for strings otherwise you'll get the NUL terminator transmitted too. The timeout needs to provide for sufficient time to transmit all the bytes at the baud rate you're using.
at 9600 baud around millisecond a character.
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
‎2023-02-15 10:34 PM
Actually I wonder why there is a notion of a timeout for a usart TX.... to generate posts ?
