cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with USART2 of stm32 f446ze

MAziz.1
Associate II

Hi, I am also new to stm32 micro controllers. I am trying to use UART2 of my microcontroller which is not default(It is not connected with the ST-Link, hence no virtual COM PORT), I am using a USB to TTL connector(TX,RX and GND) for this, I am taking the connection of USART2 from ST Morpho pins of my microcontroller. I provided separate supply to my CN12 pins from ST Zio connector, Can you please tell me if I am missing something while initializing? I am assigning USART 2 pins (PA2 and PA3 for TX and RX) from cube MX(Asynchronous mode, Baud rate = 115200, parity = none, , stop bits = 1, word length = 8 bits). and then in KEIL I am just creating a transmitting variable txdata[30] = "Hello";, and just using HAL_UART_Transmit(&huart2,txdata,sizeof(txdata),100); command in while loop. It works for my default USART3 but it is not working for USART2. USART2 is also connected to APB1 bus same as USART3. Can You please identify if I am missing some initialization for this USART2? Or do I have to initialize some extra parameters for this USART in cubeMX as this is not default USART? In CubeMX I only enable USART2 by making it Asynchronous, other than this I didn't change anything else. Thanks.

2 REPLIES 2
TDK
Guru

You initialize USART2 the same way as USART3. The HAL initialization routine takes care of any different in peripheral clocks.

Ensure your USB to TLL is working properly first by connecting it in loopback mode.

If you feel a post has answered your question, please click "Accept as Solution".

Hello, Thankyou for the reply, Actually I am trying to run the external mode demo file provided by stm MAT-TARGET for the nucleo F446ZE LQFP144 as I also have the same board. But whenever I am running and "Build deploy and start" it is giving me the following error, I thought it is because of no proper connection of USARTs, but now I checked my USARTs as well, they are functioning properly. Do you have any idea what is the cause of this error? I am using MATLAB2020a, is this version of MATLAB causing the error?

I am using 2 USARTs (USART2 for PIL and USART3 for external mode).