Skip to content

Commit e535bba

Browse files
committed
fix for software 6-PWM low side polarity
1 parent d688fcc commit e535bba

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/drivers/hardware_specific/stm32/stm32_mcu.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m
163163
}
164164
}
165165
TIM_OC_InitTypeDef channelOC;
166-
channelOC.OCMode = TIM_OCMODE_PWM1;
166+
channelOC.OCMode = mode;
167167
channelOC.Pulse = 0; //__HAL_TIM_GET_COMPARE(handle, channel);
168168
channelOC.OCPolarity = polarity;
169169
channelOC.OCFastMode = TIM_OCFAST_DISABLE;
@@ -195,7 +195,14 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m
195195

196196

197197

198-
198+
/**
199+
0110: PWM mode 1 - In upcounting, channel 1 is active as long as TIMx_CNT<TIMx_CCR1
200+
else inactive. In downcounting, channel 1 is inactive (OC1REF=‘0’) as long as
201+
TIMx_CNT>TIMx_CCR1 else active (OC1REF=’1’).
202+
0111: PWM mode 2 - In upcounting, channel 1 is inactive as long as
203+
TIMx_CNT<TIMx_CCR1 else active. In downcounting, channel 1 is active as long as
204+
TIMx_CNT>TIMx_CCR1 else inactiv
205+
*/
199206
// init high side pin
200207
TIM_HandleTypeDef* _stm32_initPinPWMHigh(uint32_t PWM_freq, PinMap* timer) {
201208
uint32_t polarity = SIMPLEFOC_PWM_HIGHSIDE_ACTIVE_HIGH ? TIM_OCPOLARITY_HIGH : TIM_OCPOLARITY_LOW;

0 commit comments

Comments
 (0)