cancel
Showing results for 
Search instead for 
Did you mean: 

USART1 and USART2 STM32H7B3I-DK

User1340
Associate II

Hello everyone!

I am working with STM32H7B3I-DK and I have enabled USART1 based on the available example, but I need to enable USART2 to connect to the WiFi. If I use the same code but with RX and TX pins from USART2, I can see nothing on console. Do I need to enable additional pins for USART2 ?

Thanks in advance!

9 REPLIES 9
SofLit
ST Employee

Hello,

If you want to "port" an UART function to another, you need to insure:

  • The right UART pins configs and their alternate functions. As well as the RCC clock enable of the port(s) on which the pins are belonging.
  • The RCC Clock enable of the UART.
  • The UART RCC clock source.

Are you using CubeMx tool? it can help you to overcome all these complexities.

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.

@User1340 wrote:

If I use the same code but with RX and TX pins from USART2


If all you do is change the RX & TX pins, then the rest of the code will will be using USART1 !

Are you doing this with CubeMX & HAL, or at register level?

Even if you don't plan on using CubeMX for your final code, start by using it, to see how it does this - then adapt that to your own code.

Thank you on your fast response! Yes, I am working through CubeMX tool. I have configured:
-USART2_CTS(PA0)

-USART2_TX(PD5)

-USART2_RX(PD6)
-USART2_RTS(PD4)
Unfortunately, I still cannot see anything on console. 
Can you help me with RCC configurations?
I am so sorry but I am really struggling with this board and the documentation about this section is really poor. 

Yes, I am working with CubeMX and HAL and still facing issues and couldn't enable the USART2...

The Console, on a PC connected too the ST-LINK VCP? 

If that's physically connected to USART1 you're not going to see interactions on USART2 connected to a WiFi module.

If you want to interact with that on the PC you'll need to forward back and forth between USART1 and USART2 in your code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I am using option in the console Command Shell Console and it is configured just as settings of the USART2 (port, baud rate, data bits, stop bits and parity) and it could be used for any usart probably.. 
To be clear, I have disabled USART1 and only enabled USART2 to communicate...


@User1340 wrote:

I am using option in the console Command Shell Console and it is configured just as settings of the USART2 (port, baud rate, data bits, stop bits and parity) and it could be used for any usart probably.. 


Yes, it can be used for any USART - but how have you physically connected USART2 from your target system to this Command Shell Console  on your computer?

 


@User1340 wrote:

To be clear, I have disabled USART1 and only enabled USART2 to communicate...


That doesn't clarify anything at all.

Enabling USART2 to communicate will not provide any connection from that USART to the PC.

How do you make the physical connection from USART2 to the PC?

 

EDIT:

As you can see from the User Manual, USART1 is connected to the ST-Link (Red), but USART2 is not (Blue):

AndrewNeil_0-1713524185064.png

So you're going to need to make some other arrangement to get the signals from USART2 to the PC ...

Ok, but how that's supposed to magically connect?

To get data out of the ST-LINK's VCP you're going to have to enable both USART1 and USART2, and then in the crudest implementation, sit in a loop checking the receive status of each, and moving data from one to the other

while(1) // Pseudo code, probably also want to tackle noise, overrun, framing errors
{
  if (USART2->ISR & USART_ISR_RXNE)
   USART1->TDR = USART2->RDR;

  if (USART1->ISR & USART_ISR_RXNE)
   USART2->TDR = USART1->RDR;
...
}
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Isn't that equivalent to having a light bulb (console) connected to wall switch 1 (UART1), but you've decide to disconnect switch 1 from the light bulb and install switch 2 (UART2) without physically connecting it to the light bulb? 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.