0
\$\begingroup\$

Ok, it may look a bit confusing. I am specifically talking about STM32 MCUs, or even more specific, STM32F103C8T6. I did some amount of reading, but could not find the answer to this.

Let's say I want 4 PWM signals each at 50 Hz but all with different duty cycles. In such a case will I need 4 distinct timers, or can I use one timer with 4 channels? I mean can each channel of same timer be configured with different duty cycle?

\$\endgroup\$
6
  • \$\begingroup\$ What did you think a channel was for if not this? The answer, by the way, is in the fact that each channel has it's own register. \$\endgroup\$
    – DKNguyen
    Jun 2, 2020 at 20:07
  • \$\begingroup\$ @DKNguyen I am no sure but maybe for using same timer for both PWM and input capture for example. \$\endgroup\$
    – muyustan
    Jun 2, 2020 at 20:11
  • \$\begingroup\$ Fair enough. But then what if there were 4 channels (which there should be on most timers). \$\endgroup\$
    – DKNguyen
    Jun 2, 2020 at 20:12
  • \$\begingroup\$ *Its own count register \$\endgroup\$
    – DKNguyen
    Jun 2, 2020 at 20:12
  • \$\begingroup\$ The count register determines when a channel triggers (for output compare) or what timer count it captures (for input capture). \$\endgroup\$
    – DKNguyen
    Jun 2, 2020 at 20:17

1 Answer 1

2
\$\begingroup\$

That's why timers have multiple channels, to generate multiple PWM signals with same timer. If you use multiple separate timers, their output may not be synchronized.

\$\endgroup\$
4
  • \$\begingroup\$ ok, this answers my question, but, what about frequency? is it common for every channel of a timer? or can be different? \$\endgroup\$
    – muyustan
    Jun 2, 2020 at 20:12
  • 1
    \$\begingroup\$ @muyustan Frequency is common because they all run off the same clock and pre-divider so all channels count at the same time. \$\endgroup\$
    – DKNguyen
    Jun 2, 2020 at 20:14
  • 1
    \$\begingroup\$ All channles run with a single timer so they must have identical frequency. \$\endgroup\$
    – Justme
    Jun 2, 2020 at 20:16
  • \$\begingroup\$ @DKNguyen thank you both. \$\endgroup\$
    – muyustan
    Jun 2, 2020 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.