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?

asked Jun 2, 2020 at 19:41
\$\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\$ Commented 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\$ Commented 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\$ Commented Jun 2, 2020 at 20:12
  • \$\begingroup\$ *Its own count register \$\endgroup\$ Commented 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\$ Commented 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.

answered Jun 2, 2020 at 20:03
\$\endgroup\$
3
  • \$\begingroup\$ ok, this answers my question, but, what about frequency? is it common for every channel of a timer? or can be different? \$\endgroup\$ Commented 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\$ Commented Jun 2, 2020 at 20:14
  • 1
    \$\begingroup\$ All channles run with a single timer so they must have identical frequency. \$\endgroup\$ Commented Jun 2, 2020 at 20:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.