Getting started with STM32L053: UART Full duplex in DMA Mode with IDLE Line Detection

In the previous guide (here), we saw how to configure the UART in full duplex mode with DMA. However, the application need to know the number of transfer in advanced in order to receive data. Using IDLE line, the application doesn’t need to know number of character to be received in advanced.

In this guide, we shall cover the following:

  • Configure UART for IDLE interrupt.
  • Code.
  • Demo.

1. Configure UART for IDLE interrupt:

To add IDLE line interrupt as simple as enabling it in CR1 (Control Register 1) and enable USART2 interrupt in NVIC

C

For interrupt handler:

  • Stop the DMA (optional).
  • Check if the source is IDLE line.
  • Set the received to 1.
  • Clear the pending IDLE line interrupt flag

C

In while loop:

Check if the received is set to 1 and print the received data using DMA also:

C

2. Code:

Hence, the entire code is as following:

C

3. Demo:

Happy coding 🙂

Add Comment

Your email address will not be published. Required fields are marked *