2026-01-30 5:16 AM - edited 2026-01-30 8:17 AM
Dear all,
I'm trying to generate a waveform using DAC OUT1.
I configured pin PA4 as analog (works)
I configured DAC1 without DMA and it works
I configured TIM6 and it works
Then I configured DAC with DMA, configured DMA, but output never changes.
Where can I check?
I enclose the minimun configuration code:
/* DAC Configuration */
if(!(RCC->APB1ENR & RCC_APB1ENR_DAC1EN)) RCC->APB1ENR |= RCC_APB1ENR_DAC1EN; // Enable DAC clock
DAC1->CR |= DAC_CR_DMAEN1 | DAC_CR_MAMP1_3 | DAC_CR_EN1; // DMA1 enable | Amplitude 511 |Wave generation disabled | Timer6 TRGO event | Trigger enable | Buffer enable | DAC1_OUT1 enable
/* DAC Timer */
if(!(RCC->APB1ENR & RCC_APB1ENR_TIM6EN)) RCC->APB1ENR |= RCC_APB1ENR_TIM6EN; // Enable TIM6 clock
TIM6->CR2 |= TIM_CR2_MMS_2; // The update event is selected as a trigger output (TRGO).
TIM6->DIER |= TIM_DIER_UIE | TIM_DIER_UDE; //Enable interrupt | Enable DMA request
TIM6->EGR = TIM_EGR_UG; // Re-initializes the timer counter and generates an update of the registers
TIM6->CR1 |= TIM_CR1_CEN; // Enable TIM6
/* DAC DMA */
if(!(RCC->AHBENR & RCC_AHBENR_DMA1EN)) RCC->AHBENR |= RCC_AHBENR_DMA1EN; // Enable DMA1 clock
SYSCFG->CFGR1 |= SYSCFG_CFGR1_TIM6DAC1Ch1_DMA_RMP;
DMA1_Channel3->CCR |= DMA_CCR_PL_0 | DMA_CCR_MSIZE_0 | DMA_CCR_PSIZE_0 | DMA_CCR_MINC | DMA_CCR_CIRC | DMA_CCR_DIR | DMA_CCR_TCIE; // Medium priority | size 16 bit both mem and periph | mem increment | circular | mem to periph | Transfer complete interrupt
DMA1_Channel3->CNDTR = 100; // Data to be transfered
DMA1_Channel3->CPAR = (uint32_t) &(DAC1->DHR12R1); // Peripheral address
DMA1_Channel3->CMAR = (uint32_t) &sen[0]; // Memory address
DMA1_Channel3->CCR |= DMA_CCR_EN; // Enable DMA
Both TIM6_DAC_IRQn and DMA1_Channel3_IRQn are enabled.
I tried to find also some examples or AN documents, but I faild.
Any hint would be appreciated.
Thank you
Freya
2026-01-30 5:33 AM
Hello,
In next time please use </> to share a code. Please read How to write your question to maximize your chances to find a solution
I invite you to edit your post to comply with the rule.
Thank you for your understanding.
2026-01-30 5:40 AM - edited 2026-01-30 5:44 AM
Read out and check/post content of relevant DMA, DAC, TIM and GPIO registers.
If you want to use timer (or any external event, including software trigger) to trigger DAC, you need to set DACx_CR.TENx, too.
JW
2026-01-30 8:34 AM
Hi,
I did it, but nothing changed
DAC1->CR |= DAC_CR_DMAEN1 | DAC_CR_MAMP1_3 | DAC_CR_TEN1 | DAC_CR_EN1;I think DMA configuration is correct, maybe I fail in setting interrupt to activate it?
It should be TIM6 update event that activate DMA. Is it correct?
Thank you
Freya
2026-01-30 9:18 AM
Usually, it is not done this way. You are now trying to generate DMA requests from the timer. But normally, DMA requests are generated by the DAC, whose conversion is triggered by the timer.
The SYSCFG_CFGR1_TIM6DAC1Ch1_DMA_RMP bit controls whether the third DMA channel will receive requests from the timer or the DAC. The DMA now expects requests to come from the DAC, whereas in your case they are sent by the timer and therefore do not arrive.
Either reset this bit and let the DMA requests come from the timer. Or do it the way it's normally done. Set up a timer-triggered conversion in the DAC (as advised by waclawek.jan) and enable DMA requests in the DAC, leaving the SYSCFG_CFGR1_TIM6DAC1Ch1_DMA_RMP bit set (so that requests come to the DMA from the DAC and not from the timer). This solution will give you slightly more precise control over the timing of the DA conversion (eliminating any jitter in DMA requests).
2026-01-31 2:47 AM
Read out and check/post content of relevant DMA, DAC, TIM and GPIO registers.
JW
2026-01-31 5:28 AM
Hi to all,
hereafter I enclose registers value:
DAC1->CR = 0x00001A05
DAC->DOR1 = 0x00000000
TIM6->CR1 = 0x00000001
TIM6->CR2 = 0x00000040
TIM6->DIER = 0x00000101
TIM6->EGR = 0x00000000
SYSCFG->CFGR1 = 0x00000000
DMA1_Channel3->CCR = 0x000015B3
DMA1->ISR = 0x00000000and in annex all code regarding DAC.
I tried also to use Software trgger instead of Timer 6 TRGO event, but the result has been the same.
When a DAC trigger occurs, the TIM6_DACUNDER_IRQHandler() routine is invoked, but no DMA1_CH3_IRQHandler() routine.
Thank you
Freya
2026-01-31 7:00 AM - edited 2026-01-31 7:05 AM
TIM6->CR2 = 0x00000040
Also, as @TDK said above, for more correct timing, you want to set DMA *not* to be triggered from TIM6 (i.e. clear TIM6_DIER.UDE), but from DAC1 (for which you need to set the remap pin in SYSCFG).
As it is now, it should work too, but then - again for correctness - switch off the DMA request from DAC.
JW
2026-02-03 4:00 AM
Hi to all,
I think I'll quit DMA.
I tried all combinations, but I am not able to activate DMA.
At present I am using TIM6 interrupt to the value in DAC. It's not too much mcu consuming and I'll triy again later.
Thank you
Freya
2026-02-03 12:01 PM
One more thing: the DMA buffer can't be in the CCM RAM.
JW