STM32U5xxx UART communication problems
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-18 3:39 AM
I am using the STM32U5A9J-DK for a UART communication test, and I expect to display the content sent from the computer's Serial port on the screen (textArea).
I'm using UART1, 115200 Baud rate, 8 data bits, 1 stop bits, and I've turned on the UART interrupt, but for some reason the text on the screen doesn't change.
There are not many examples that I can find, so I hope someone can help me to clear this up!
Here is my code
Solved! Go to Solution.
- Labels:
-
FreeRTOS
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-25 7:47 PM
Update the status of this issue:
I have now resolved the issue with the UART communication problem, and I will move the rest of the questions to a new thread.
Thanks again to everyone who replied to this thread! :folded_hands:
Here is my test code for anyone using the STM32U5A9J-DK development board for UART communication, hope it helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-18 6:14 AM
Hello @jessie_chiu ,
you are sharing the IOC file and it seems like you are not using the correct pins for UART communication . the UART instance connected to VCP (virtual com port)of STlink is UART1 on pins PA8 and PA9. check you configuration to make sure you are using the correct pins and if you are using printf to display the text make sure you are correctly surcharging it .
BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-18 6:59 AM
@jessie_chiu wrote:for some reason the text on the screen doesn't change.
So have you checked that any data is being received?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-18 8:53 AM
Hello,
As stated by @STea you're not assigning the correct IOs for UART1 to connect it to VCP:
So replace PB6 by PA9 and PB7 by PA10 in CubeMx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-18 6:02 PM
Thank you for your reply. I didn't notice the pin problem!!
But after I fixed the pin define, I still don't get the message.
Do you have any other suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-18 6:19 PM
Hello @jessie_chiu ,
after making sure that you pinout configuration is good you should verify the baudrate and UART related configuration from the PC terminal side is matching .
if you are using Pritnf to output messages here is what you need to add to you main file
-
#include "stdio.h"
- #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
-
PUTCHAR_PROTOTYPE{/* Place your implementation of fputc here *//* e.g. write a character to the UART2 and Loop until the end of transmission */HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);return ch;}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-19 2:16 AM - edited ‎2024-03-19 2:24 AM
hi @STea , I referenced the article you mentioned, thanks for your help.
This is what I found:
1. If I generate the project directly from cubeIDE, I can receive messages from the serial monitor.
2. if the project is generated by TouchGFX, using the same code will not work.
I'm not sure if this has anything to do with the FreeRTOS setup, hopefully someone can give me some experience with this. :folded_hands:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-19 3:54 AM
2. if the project is generated by TouchGFX, using the same code will not work.
You didn't mention if you already succeeded with a simple code: no TouchGFX nor RTOS!
Did you try a simple project using UART? This is the first step you need to do at least to validate your HW+UART config.
Another thing to have in mind, check the conflicting resources between UART and the display/Touch screen pins: it could be a GPIO conflict between UART pins and the LCD/Touch screen pins you are using.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-19 5:54 PM
Sorry if I was not clear enough. I used the simple code from the article and got 1.
So HW+UART config is communicable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-03-20 5:24 AM
In that case as I said try to find the conflicting ressources between TouchGFX and UART
