2025-09-22 10:31 AM
I tried to search the forum so I'm sorry if there is a solution posted to this problem.
I have been struggling with creating the pattern inside the image.
Every 10 seconds I want a short heartbeat pulse generated by DAC. (DAC goes high, then low).
The period can experience a bit of jitter, no problem, but ideally it's every 10 seconds. However, the pulse is very important to have the correct timing as it is not allowed to be longer.
I have tried to drive a timer in OPM mode with a slower timer as trigger, and the timers worked, but I couldn't get DAC and DMA to function the way I wanted, if this approach is possible, configuration pointers would be appreciated.
I have also tried to enable a timer in software and disable it on DAC DMA complete transfer interrupt but this didn't work too well. If there is any way I can toggle the DAC with help of a timers capture compare that would be great. Then I could just enable the timer on some sys tick interrupt, use two CC's and disable it in software also.
But the more i can drive this behavior from hardware, the better.
Sidenote: I'm using a STM32G0B1 board and TIM2 is already used by another application.
2025-09-22 11:05 AM
Sure.
Set up a timer that triggers an interrupt every 10s.
In that handler, set up a 2-byte noncircular DMA -> DAC transfer that send the high value, then the low value 35us later. You will need another timer for this.
2025-09-22 11:27 AM
Sounds like a neat solution. I will test it tomorrow and post results.
2025-09-22 11:31 AM
> You will need another timer for this.
No necessarily - the same timer can be "recycled" for this purpose with some extra programming.
And, expanding on this idea, the same trigger signal could be also used to trigger a second DMA channel through which the timer would reprogram itself so that it generates both the 10s and the 35us pulse in succession, without software intervention. Not trivial, though, and I haven't thought through all the possible pitfalls.
JW