This is to share the idea of small pieces of codes, I modified from the Internet to fit my needs.
HardwareTimer timer1(TIM1); { timer1.getHandle()->Init.CounterMode=TIM_COUNTERMODE_CENTERALIGNED3; HAL_TIM_Base_Init(timer1.getHandle()); } timer1.setMode(1, TIMER_OUTPUT_COMPARE_PWM1, PA8); timer1.setMode(2, TIMER_OUTPUT_COMPARE_PWM1, PA9); timer1.setMode(3, TIMER_OUTPUT_COMPARE_PWM1, PA10); timer1.setMode(1, TIMER_OUTPUT_COMPARE_PWM1, PB13); timer1.setMode(2, TIMER_OUTPUT_COMPARE_PWM1, PB14); timer1.setMode(3, TIMER_OUTPUT_COMPARE_PWM1, PB15); { LL_TIM_OC_SetDeadTime(timer1.getHandle()->Instance,100); LL_TIM_CC_EnableChannel(hhhtimer1.getHandle()->Instance, LL_TIM_CHANNEL_CH1 | LL_TIM_CHANNEL_CH2 | LL_TIM_CHANNEL_CH3 | LL_TIM_CHANNEL_CH1N| LL_TIM_CHANNEL_CH2N| LL_TIM_CHANNEL_CH3N ); } timer1.setOverflow(SYS_FREQ, HERTZ_FORMAT); timer1.attachInterrupt(update_IT_callback); timer1.resume();