Skip to main content
Associate III
June 27, 2022
Question

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.

  • June 27, 2022
  • 3 replies
  • 2315 views

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

This topic has been closed for replies.

3 replies

GLASS
Visitor II
June 28, 2022

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
Visitor II
June 28, 2022

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.

Associate III
June 28, 2022

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