2022-03-08 09:01 PM
I am following this tutorial and trying to get a complete understanding of the code:
https://embedded-lab.com/blog/continuing-stm8-microcontroller-expedition/6/
I have a few questions regarding the TIM2_setup(void) function:
1 Why is channel 1 and channel 2 used in identical fashion like this? Might this be to use the two output pins on the MCU in parallel for higher current capacity?
2 Isn't this line redundant:
"TIM2_SetCompare1(100);"
when the "duty cycle count" was already set to 1000 in this line?
TIM2_OC1Init(TIM2_OCMODE_PWM2, TIM2_OUTPUTSTATE_ENABLE, 1000, TIM2_OCPOLARITY_LOW);
3 Are these two lines effectively the same?
TIM2_OC1Init(TIM2_OCMODE_PWM2, TIM2_OUTPUTSTATE_ENABLE, 1000, TIM2_OCPOLARITY_LOW);
TIM2_OC1Init(TIM2_OCMODE_PWM1, TIM2_OUTPUTSTATE_ENABLE, 1000, TIM2_OCPOLARITY_HIGH);
If not, why would PWM mode 2 be chosen here?