2016-01-26 04:18 PM
Hi, can anyone clear up as to why, when I configure the USART2 interrupt using the STM32CubeMX utility, the intialization code it generates calls functions in stm32l1xx_hal_uart.c instead of stm32l1xx_hal_usart.c? I am surprised at this since I am configuring a USART perhiperal, not one of the UART perhiperals.
I see no difference between the data structuresUSART_HandleTypeDef
andUART_HandleTypeDef
, but the generated initialization code seems to prefer the latter for use.Is there a document (other than the code modules themselves) that explains the difference between the UART functions compared with the USART modules?Thanks!2016-01-27 12:21 AM
It's an unfortunate naming convention used by the HAL developers.
USART means Universal Synchronous/Asynchronous Receiver/Transmitter, so the peripherals with USARTx name support both Synchronous and Asynchronous modes, while the peripherals named UARTx support only the Asynchronous mode. In the HAL library, (I suppose) it's different: when you want to use a peripheral in Asynchronous mode you use the UART_xxx functions, when you want to use the peripheral in Synchronous mode (if it supports that mode) then you use the USART_xxx functions. Maybe they should had been named the latter family of functions as USRT_xxx. And you can find the documentation of STM32L1 HAL libraryhttp://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00132099.pdf
.2016-01-27 01:01 AM
Hi lopez.dean,
I cannot reproduce your issue, I generated a project with MX4.12 witch enable the USART2 peripheral (Mode: Synchronous ), the generated project call functions from the stm32l1xx_hal_usart driver.so it seems that you configure the USART2 en mode Asynchronous in this case the project have to use the UART driver.-Syrine-2016-01-27 06:48 AM