Skip to main content
mrasz.1
Visitor II
November 16, 2022
Question

How to manage 2 channel PWM with DMA - STM32L073

  • November 16, 2022
  • 1 reply
  • 723 views

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?

This topic has been closed for replies.

1 reply

waclawek.jan
Super User
November 17, 2022

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