STM32G4: trigger one DMA stream by both capture & overflow/update timer events?
I am trying to capture timestamp values using STM32G474RE.
Requirement
I need to route:
-
COMP1 output -> Timer input capture
-
COMP2 output -> Timer input capture
On each comparator edge, the timer should capture the current counter value and transfer it to RAM using DMA.
In addition to edge captures, I also want the same timestamp stream/buffer to receive an entry whenever the timer overflows/updates.
Example desired stream: (Consider its a 8bit Timer)
240, 244, 248, 254, overflow_marker_or_last_CCR, 6, 8, 12
or during no-edge periods:
200, 200, 200, 200
if the update DMA reads the last captured CCRx value.
STM32F072 behavior
On STM32F072, I was able to achieve similar behavior by enabling both DMA request bits:
TIMx->DIER |= TIM_DIER_CC1DE | TIM_DIER_UDE;
This allowed the DMA stream to be triggered by both:
-
capture/compare event
-
update/overflow event
Issue on STM32G474RE
On STM32G474RE, DMA routing goes through DMAMUX. For example:
-
TIM2_CH1 has one DMAMUX request ID
-
TIM2_UP has another DMAMUX request ID
So one DMA channel appears to be able to select either TIM2_CH1 or TIM2_UP, but not both.
Questions
-
Is there any timer on STM32G474RE, such as TIM1, TIM2, TIM3, TIM4, TIM5, TIM8, or TIM20, that can merge CCx and UP DMA requests into one DMA stream?
-
Can TIMx_DCR / TIMx_DMAR DMA burst mode help here, or does it still require one selected DMAMUX request source?
-
Can DMAMUX request generator or synchronization be used to OR/combine TIMx_CHx and TIMx_UP events?
-
Can HRTIM capture both comparator external events and timer update events into the same capture register and then DMA that register? (Note: with HRTIM it is possible but i need to run the timer at 2.4MHz so i can't use the HRTIM)
-
If this is not possible in hardware, is the recommended method to use capture DMA plus update interrupt, or two separate DMA channels?
Can someone confirm whether STM32G474RE supports this single-DMA-stream behavior, or whether the STM32F072-style method is no longer possible because of DMAMUX?
Thanks.
