2025-06-30 1:27 PM
I've been working on this for a few days now, I can't seem to get the DAC to work with the DMA. I can get the DMA to work with ADC easily, I can use the DAC without DMA easily, but the DAC doesn't feel like working with the DMA. I set up the DMA to work with the DAC channel 1 using DMA1 channel 3. I set up the interrupt to be timer 6. My code for setting things up is
HAL_TIM_Base_Start(&htim6);
HAL_DAC_Start_DMA(&hdac1, DAC_CHANNEL_1, (uint32_t*) &dma_buffer, 2*DMA_BUFFER_SIZE, DAC_ALIGN_12B_R);
This code is put outside of the while loop in the main function. I also checked for error codes using
uint32_t result = HAL_DAC_GetError(&hdac1);
and
uint32_t result = HAL_DMA_GetError(&hdma_dac_ch1);
which both returned 0 in the result when debugging. I put an incrementing variable in the half and full
complete callbacks for debugging as well, and these interrupts appear to never fire because the variables
never increment. I followed a guide on setting up the DMA with DAC very carefully so
my lack of knowledge would be out of the question but still it doesn't work. I know the DAC and
DMA both work so why would they not work together?
2025-07-01 1:19 AM
Hi @jasoncramer
>>I also checked for error codes
A known limitation exists when the DAC channel operates in DMA mode (DMAEN of DAC_CR register set), the DMA channel underrun flag (DMAUDR of DAC_SR register) fails to rise upon an internal trigger detection if that detection occurs during the same clock cycle as a DMA request acknowledge.
As a result for this limitation, you'll not be informed if an underrun error occurred. (This behavior is documented in STM32L471xx/475xx/476xx/486xx Description of device errata)
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.