cancel
Showing results for 
Search instead for 
Did you mean: 

multiple rxcallback for circular dma operation

rtursen
Associate II
Posted on November 08, 2015 at 16:59

Hello all,

Data is coming from uart in chunks of 30 bytes via uart. I want to get these incoming chunks of 30 bytes and store them in a circular buffer of size 240 bytes by using DMA.

I want to configure the DMA such that  it works in

 * circular mode with a 240 wide buffer

 * fires the rxcallback function for every 30 bytes of data transfer

I have read the reference manual for STM32F30 and checked the examples but couldn't find how to configure the above settings.

Can you please tell me whether it is possible to achieve the above settings or should I use linear DMA and some extra logic to achieve this

thank you for your time

#circular-dma-uart-hal
2 REPLIES 2
Posted on November 08, 2015 at 17:36

The DMA can trigger at half and complete transfers, not arbitrary fractions of the buffer.

If you're bound to the 240 byte buffer, you might just want to do circular DMA of 60 bytes into a buffer, and copy out 30 bytes at HT/TC.

I suspect you'd still need to deal with sync and byte loss issues.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
rtursen
Associate II
Posted on November 08, 2015 at 19:26

Hello Clive,

Thanks for the answer. Then how about I do the below,

Allocate a buffer of 240 bytes

DMA in linear mode with 30 bytes transfers, with target address set to start of 240 byte buffer

At every RX_callback, I increase the base address by 30 and restart the DMA in linear mode, 30 bytes

After 8 RX_callbacks, I reset the base address to the start of my buffer.

I think the above approach should be fine. Do you see any problems with this?

With the above approach, do you still think that I get sync and byte loss issues?

Thank you very much again for you help

have a nice week

rifo

ps: I can change the buffer size if it would do any help