cancel
Showing results for 
Search instead for 
Did you mean: 

What fastest way to change the size of the DMA addressed by a peripheral. In particular the DAC? Stopping and starting the DAC using HAL_DAC_Stop_DMA and HAL_DAC_Start_DMA with a new Data Length takes up a lot of cycles if I use the CubeMX functions. I

Claydonkey
Senior

I tried DMA_SetConfig after __HAL_DMA_DISABLE and clearly it is not enough.

Incidentally my intention is not change the size of the DMA allocated area - rather the size of this region accessed by a peripheral

3 REPLIES 3
GLASS
Senior

Hi, to manage high perf and lower CPU​usage take a look to DMA circular mode. So the DMA is never stopped and run continuously (automaticaly cycling). Doing so permit to manage alternatively one half of the buffer by CPU, during this time DMA continue to fill the other half buffer...

With HAL you only need to register DMA call back to half complete (​HC = the first half buffer) and transmit complete (TC = the second half buffer).

You MUST choose the correct size of buffer to be sure that you have sufficient time to handle an half buffer before the other one is full...​

GLASS
Senior

Ouups​. It's apply also to DAC. But in this case DMA read from memory to DAC...

And with CPU you write in the actually free half buffer.

First hal buffer after received HC​,

Second half buffet after received TC.

That all.

Claydonkey
Senior

Yes! That's exactly what I did. Got a memory pointer to point to another area of ram and yes sir. No noticeable delay from my end. Brilliant