Skip to main content
EAnde.3
Associate
August 23, 2021
Question

How to generate PWM with offset / delay?

  • August 23, 2021
  • 4 replies
  • 3306 views

I need to generate two signals as shown below.

I need to be able to adjust A and B independently. Is there some way to use TIMER1's OC1 and OC2? I can't figure out how to make an offset in the output compares - everything seems to start at the main counter expiring. I also looked into feeding TIMER2 into TIMER1 but I didn't see a solution there either.

Any nudge in the correct direction would help me, thanks!

Erik0693W00000Dq2rmQAB.png

This topic has been closed for replies.

4 replies

rpip.1
Associate II
August 23, 2021

Generally,you can use Asymmetric PWM mode of TIMER to generate this signal .

EAnde.3
EAnde.3Author
Associate
August 23, 2021

Thanks for the reply. I don't see an Asymmetric PWM mode in RM0016 manual, do you mean "center-aligned"? Center-aligned isn't quite what I want though.

rpip.1
Associate II
August 24, 2021

Based on this MCU, I recommand to use TIM2 to trigger TIM1 to output. TIM2 output the signal you pictured above on TIM2 OC1. TIM2 OC1 is connected to TIM1 ETR to trigger TIM1 to output the signal you pictured below. And TIM1 worked on one-pulse mode and PWM mode 1. I'm not sure if you need to ouput these signal just on TIM1 OC1 and OC2.

EAnde.3
EAnde.3Author
Associate
August 24, 2021

Got it, I'll give it a shot and report back. thank you