cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5xxx UART communication problems

jessie_chiu
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
jessie_chiu
Associate III

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!

View solution in original post

20 REPLIES 20
STea
ST Employee

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

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Andrew Neil
Evangelist III

@jessie_chiu wrote:

 for some reason the text on the screen doesn't change.


So have you checked that any data is being received?

 

SofLit
ST Employee

Hello,

As stated by @STea you're not assigning the correct IOs for UART1 to connect it to VCP:

SofLit_0-1710777099982.png

So replace PB6 by PA9 and PB7 by PA10 in CubeMx.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

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?

 

jessie_chiu_1-1710810160258.png

 

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 

  1. #include "stdio.h"
  2. #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
  3. 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;
    }
     
you can get more information about this in this article  .
you should also make sure that you solder bridge configuration is the correct one for redirecting UART communications via VCP (your stock board if not modified should have the correct configuration of solder bridges ).
 
if you are still having some issues with outputting messages try adding fflush(0); after printf (redirected) or UART_Trassmit() to flush the internal buffer and make sure that your message is flushed to the VCP.
 
BR 
 
 
In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

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:

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Sorry if I was not clear enough. I used the simple code from the article and got 1.

So HW+UART config is communicable.

In that case as I said try to find the conflicting ressources between TouchGFX and UART

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.