cancel
Showing results for 
Search instead for 
Did you mean: 

DAC with DMA

JFric
Associate II

Hi,

I'm using DAC with DMA to implement a shape generator on STM32F746.

So i'm creating a buffer filled with the datas of the shape concerned that i transmit to the DMA with HAL_DAC_Start_DMA() function.

While most of the time everything is ok and the shape is generated well, there is sometimes an issue with the DMA : the CNDTR register stay stuck to the last value of the data array (involving a constant output instead of a PWM).

I didn't see any error code in the DMA structure that could cause the trouble. The only difference between a working signal and a problematic one is the CNDTR who stay stuck.

However, there's a error in the DAC structure :

hdac->State = HAL_DAC_STATE_ERROR

hdac->ErrorCode = 1 (DMA underrun on channel 1)

Does anyone could help me ?

Thank you.

1 REPLY 1

Well, your DAC underflows because you trigger it too fast and DMA is at times slower.

Read the DMA underrun subchapter of DMA chapter in RM.

Read AN4031 to understand the DMA latencies.

Marginally relevant thread https://community.st.com/s/question/0D50X0000BNLWeiSQH/dac-maximum-sampling-rate-of-stm32f407

JW