From e535bba6d1f68684a0b837439aecd2918841c8f5 Mon Sep 17 00:00:00 2001 From: Richard Unger Date: Sat, 31 Aug 2024 16:10:01 +0200 Subject: [PATCH] fix for software 6-PWM low side polarity --- src/drivers/hardware_specific/stm32/stm32_mcu.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/drivers/hardware_specific/stm32/stm32_mcu.cpp b/src/drivers/hardware_specific/stm32/stm32_mcu.cpp index 0128f486..d9e058ef 100644 --- a/src/drivers/hardware_specific/stm32/stm32_mcu.cpp +++ b/src/drivers/hardware_specific/stm32/stm32_mcu.cpp @@ -163,7 +163,7 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m } } TIM_OC_InitTypeDef channelOC; - channelOC.OCMode = TIM_OCMODE_PWM1; + channelOC.OCMode = mode; channelOC.Pulse = 0; //__HAL_TIM_GET_COMPARE(handle, channel); channelOC.OCPolarity = polarity; channelOC.OCFastMode = TIM_OCFAST_DISABLE; @@ -195,7 +195,14 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m - +/** +0110: PWM mode 1 - In upcounting, channel 1 is active as long as TIMx_CNTTIMx_CCR1 else active (OC1REF=’1’). +0111: PWM mode 2 - In upcounting, channel 1 is inactive as long as +TIMx_CNTTIMx_CCR1 else inactiv + */ // init high side pin TIM_HandleTypeDef* _stm32_initPinPWMHigh(uint32_t PWM_freq, PinMap* timer) { uint32_t polarity = SIMPLEFOC_PWM_HIGHSIDE_ACTIVE_HIGH ? TIM_OCPOLARITY_HIGH : TIM_OCPOLARITY_LOW;