cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable USART driver in CubeMX?

HF.Wang
Associate II

The code generated by the STM32CubeMX is using the UART rather than the USART.

How do we generate the code using the USART driver lib via the CubeMX?

1 ACCEPTED SOLUTION

Accepted Solutions
Guenael Cadier
ST Employee

Hi @Community member​ 

USART1, USART2, ... and/or UART4 or UART5, ... are instances of peripherals, able to achieve UART/USART communications.

Usually, USARTx instances are able to handle :

- UART comms : Asynchronous communication, no CLK signal

- USART comms : Synchronous, based on a CLK signal

while UARTy instances only handle :

- UART comms : Asynchronous communication, no CLK signal

So depending on what type of communication you want to handle, you need to select the appropriate type in CubeMx configuration :

"Asynchronous" => Use of HAL UART API, UART comm type

"Synchronous" => Use of HAL USART API, USART comm type

0693W00000Y7wnqQAB.png 

Hope this answers your question

Regards

View solution in original post

4 REPLIES 4
HF.Wang
Associate II

Using the STM32L412 with the latest CubMx and Lib.

Karl Yamashita
Lead II

It's the same driver for both types

If you find my answers useful, click the accept button so that way others can see the solution.
Guenael Cadier
ST Employee

Hi @Community member​ 

USART1, USART2, ... and/or UART4 or UART5, ... are instances of peripherals, able to achieve UART/USART communications.

Usually, USARTx instances are able to handle :

- UART comms : Asynchronous communication, no CLK signal

- USART comms : Synchronous, based on a CLK signal

while UARTy instances only handle :

- UART comms : Asynchronous communication, no CLK signal

So depending on what type of communication you want to handle, you need to select the appropriate type in CubeMx configuration :

"Asynchronous" => Use of HAL UART API, UART comm type

"Synchronous" => Use of HAL USART API, USART comm type

0693W00000Y7wnqQAB.png 

Hope this answers your question

Regards

Thanks. Got it. That mean the USART only be used when the synchronous mode selected. If the only asynchronous mode used, the CubeMX will only use the UART lib.