cancel
Showing results for 
Search instead for 
Did you mean: 

DMA interrupt on RX when get less the buffer size

Lmali.1
Associate III

Hello,

I use DMA UART on Rx.

but I get interrupts on half complete and full complete.

is it possible to get interrupt earlier? when I get "\n" char?

maybe the best way to mange is to use circular DMA, and when the half complete interrupt is fired, save the data on another memory, and keep do it until get all data?

Thanks,

Lior Malik

5 REPLIES 5

> is it possible to get interrupt earlier? when I get "\n" char?

This is not a property of DMA, but USART in some newer STM32 models have implemented Character Match and related interrupt. Read the USART chapter in RM.

JW

berendi
Principal

If there is more memory to store data copied from the DMA buffers, why don't you simply use a bigger DMA buffer?

DMA controllers on some STM32 series support updating the DMA memory pointer of the currently unused half-buffer.

What is the actual problem you are trying to solve?

I receive via UART strings without knowing the sizes of them.

it can be 2 bytes, it can by 20 bytes...

I have indication that data is coming only from the interrupts from DMA. i.e. only when the buffer is half or full.

if the buffer size is 10 bytes, and the incoming data is only 3 bytes I will not know that i received them, because i didnt reach the half/full buffer.

my solution I suggested (in the question) works for me...

but if you have any other idea, I will happy to learn.

If your USART does not support the character match feature, I'd suggest using USART interrupt receive mode instead of DMA.

Checking each character as it arrives on a relatively (compared to the CPU core speed) low speed UART interface is trivially easy and efficient (unless you are using the HAL library).

Piranha
Chief II

Use IDLE or RTO. More details here:

https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

And the same principles can be applied to interrupt mode also.