cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Problem with USART

Hello_World
Associate

Hi, I want to use USART2 as transmitter on stm32f429zi mcu (nucleo board). I configure registers as in the picture, but transmission don't work. I use USART2 on PA2 pin and I need transmission with 115200 baudrate, alternate function is AF7 and usart2 is connected to APB1 bus with 45Mhz default frequency. Where did I make a mistake?

4 REPLIES 4
Issamos
Lead II

Hello @Hello_World 

I suggest you to take a look at your bauderate configuration. 

Screenshot_2023-09-17-16-28-06-87_e2d5b3f32b79de1d45acd1fad96fbb0f.jpg

You can refer to this exemples. 

Screenshot_2023-09-17-16-27-40-63_e2d5b3f32b79de1d45acd1fad96fbb0f.jpg

On the RM0090 . Also, is better to use fast speed. For the data register, I advise you to create a function to transmit your data that is better to put it in a uint8_t variable and then append this variable to your data register. Finally, don't forget to make sure that you are connecting your TX to the external peripheral Rx and RX to TX. And if you are using a serial monitor, maker sure that all settings works fine. Finally, if the issue persist, you can try to debug your code.

This video is a good guide also. 

Best regards.

II

I suggest that you start a new project in CubeIDE, set up the clock and enable UART2, then have it generate code. Then compare ST's code to yours and see what the differences are.

FBL
ST Employee

Hello, 

Maybe you should check the desired baud rate,  
USART2->BRR = (7<<0) | (24<<4); // Baud rate of 115200, PCLK1 at 45MHz

 

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.

At 16-OVER mode it might be easier to see if USART2->BBR = 45000000/115200 or (45000000/115200)-1 works better.

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