cancel
Showing results for 
Search instead for 
Did you mean: 

How to manage 2 channel PWM with DMA - STM32L073

mrasz.1
Associate

We try to generate audio signal with 2 PWM signals. We use TIM2_CH1 and TIM2_CH2 with DMA1 channel 5 and channel 3. This two PWM signals must be synchronized, but we noticed some delay between this 2 channels, which unfortunately is not constant. For example we have 5th value at channel 1 and 1st value at channel 2. How can we deal with this?

1 REPLY 1

Set up the two DMA channels first, and only after that start the timer.

Better, use the TIMx_DMAR/DCR mechanism and a single DMA channel triggered by timer Update (you'll need to have the values interspersed in a single array).

Generally, if you cannot click it simply in CubeMX, it's likely that Cube will get into your way, so you may be better off by ditching Cube and writing your own program. In any case, you should start with reading the TIM and DMA chapters in RM.

JW