Skip to main content
Brian Rau
Associate III
September 6, 2018
Question

Is there any good documentation or examples for how to use the STM32L4 HAL USARTEx FIFO functionality?

  • September 6, 2018
  • 2 replies
  • 1274 views

Previously posted to the STM32 "community", but it appears this might be the more appropriate forum...?

Perhaps I'm a bit thick and am missing something, but it appears that in the most recent versions of the STM32L4 HAL that FIFO support has been added in the USART extension driver. Specifically, there are functions defined:

HAL_USARTEx_EnableFifoMode()

HAL_USARTEx_DisableFifoMode()

HAL_USARTEx_SetTxFifoThreshold()

HAL_USARTEx_SetRxFifoThreshold()

HAL_USARTEx_RxFifoFullCallback()

HAL_USARTEx_TxFifoEmptyCallback()

However, the documentation for these is minimal at best, and there are "#if defined(USART_CR1_FIFOEN)" statements throughout the driver code, and I can find no definition for USART_CR1_FIFOEN anywhere, or how this should be defined. Can anyone shed some light on whether this USART FIFO functionality is supported, and how I can get it working?

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
September 6, 2018

Stuff usually gets managed at a chip level by a command line define to the compiler (STM32L4R9xx), this causes stm32l4xx.h to pull registers/defines (stm32l4r9xx.h)

#define USART_CR1_FIFOEN_Pos (29U)
#define USART_CR1_FIFOEN_Msk (0x1UL << USART_CR1_FIFOEN_Pos) /*!< 0x20000000 */
#define USART_CR1_FIFOEN USART_CR1_FIFOEN_Msk /*!< FIFO mode enable */
#define USART_CR1_TXFEIE_Pos (30U)
#define USART_CR1_TXFEIE_Msk (0x1UL << USART_CR1_TXFEIE_Pos) /*!< 0x40000000 */
#define USART_CR1_TXFEIE USART_CR1_TXFEIE_Msk /*!< TXFIFO empty interrupt enable */
#define USART_CR1_RXFFIE_Pos (31U)
#define USART_CR1_RXFFIE_Msk (0x1UL << USART_CR1_RXFFIE_Pos) /*!< 0x80000000 */
#define USART_CR1_RXFFIE USART_CR1_RXFFIE_Msk /*!< RXFIFO Full interrupt enable */

Not all L4 parts have a FIFO, just L4+ as I recall. Don't use the HAL drivers for USART interaction here, basically can now use while() instead of if() to fill/empty FIFO into local buffering.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Brian Rau
Brian RauAuthor
Associate III
September 6, 2018

Ah, you answered my question, sort of. I didn't realize that some devices (such as the L4R9) have a hardware FIFO that these functions are supporting; unfortunately the L431 I'm using does not.