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?
-
\$\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– DKNguyen2020年06月02日 20:07:13 +00:00Commented 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– muyustan2020年06月02日 20:11:45 +00:00Commented 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– DKNguyen2020年06月02日 20:12:10 +00:00Commented Jun 2, 2020 at 20:12
-
\$\begingroup\$ *Its own count register \$\endgroup\$DKNguyen– DKNguyen2020年06月02日 20:12:43 +00:00Commented 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– DKNguyen2020年06月02日 20:17:52 +00:00Commented Jun 2, 2020 at 20:17
1 Answer 1
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.
-
\$\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– muyustan2020年06月02日 20:12:35 +00:00Commented 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– DKNguyen2020年06月02日 20:14:25 +00:00Commented Jun 2, 2020 at 20:14
-
1\$\begingroup\$ All channles run with a single timer so they must have identical frequency. \$\endgroup\$Justme– Justme2020年06月02日 20:16:11 +00:00Commented Jun 2, 2020 at 20:16