Showing results for 
Search instead for 
Did you mean: 

Get DMA count

Associate II
Posted on May 29, 2017 at 17:55

Hi all,

I'm using USART with DMA to implement a Modbus rtu slave node.

I want to implement this:

- the USART use DMA to store received characters in a buffer

- a contdown-timer count the time between character to recognise the end of the frame.

- the timer is loaded when new characters are loaded by the DMA. I want to recognize them with a 20kHz ISR that I use to do other stuff: Checking the value of the DMA count I know if new bytes has arrived.

I use the DMA as a sort of FIFO, because:

- I don't know the size of the message

- I don't want to use a ISR for each character to avoid loss of information.

Unfortunately, I didn't find any information about getting DMA count!

Does anyone can help me?

Thank you very much.

#stm32-dma #stm32f4 #modbus
Posted on June 05, 2017 at 10:48

I have only a question regarding the USART IDLE interrupt: this is a specific feature of a micro? In the documentation of the stm32f4 I don't find it.

See bit4 of both USART_SR and USART_CR1.

Also beware of



Posted on June 05, 2017 at 17:45


The STM32F4xx Reference Manual, section 30.4, lists the Idle Line Detected interrupt for the F4 MCU's USARTs. In my experience, the F4 peripherals are essentially identical to the F2 series, and I use this interrupt there. I searched the STM32CubeMX driver files for the F4 USART, and stm32f4xx_hal_usart.h does indeed contain an interrupt control flag for USART_FLAG_IDLE, so I am certain the support is there for this interrupt. It may be that the firmware examples don't include this (there's a lot of interesting stuff they miss!), but the MCU *does* support this interrupt.