cancel
Showing results for 
Search instead for 
Did you mean: 

Faster implementation of HAL_DAC_Start_DMA() to retrigger a single DMA transfer to DAC

JScho.599
Associate

I have configured a DAC to use DMA in single mode. I have created HAL_DAC_ConvCpltCallbackCh1(). In this function, I reenable the DMA process using HAL_DAC_Start_DMA(...), which appears to be really slow. How can I make this faster. I don't want to reinitialize the entire DMA but rather just retrigger it.

2 REPLIES 2

You could review the RM for the STM32 in question to understand the register level implementation. Likely have to disable the channel to change address/length, and then re-enable/engage.

Most use cases use a circular buffer, serviced a HT/TC DMA interrupts, to create a ping-pong buffer, and where you fill the inactive half.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

You did not tell us the STM32 model you are using. And you don't have a normal name/nick, please change it.

> HAL_DAC_Start_DMA(...), which appears to be really slow.

How do you know it's slow?

> You could review the RM for the STM32 in question to understand the register level implementation.

Or, you just take the function in question, copy it into your project, and remove everything which is redundant and may cause the "slowness", e.g. unused branches, writes to variables which are already set to the same value, etc.. There may be a chain of calls so you may want to do them all. There may be inherent obstacles, though, like waiting for some genuine event to happen, e.g. trigger of the last holding-to-output register transfer. Also reconsider your compiler optimization options.

Of course, it never hurts to know what are you doing, i.e. I still recommend reading the given chapters in the RM, and dump Cube.

JW