STM32F103C8T6 , Timer1 PWM channels have different frequencies ?
STM32F103C8T6 MCU is used for controlling a brushless DC Motor. Firstly I used bipolar switching for Inverter Circuit. TIM1_CH1 ,CH2 ,CH3 pins used for upper mosfets of each leg and TIM1_CH1N,CH2N,CH3N used for lower mosfets. When I want to set the pwm frequency at 18kHz , One of the legs (CH1 and CH1N - Phase A) both upper and lower mosfets aren't working (MCU doesn't create pwm signals) and when i decrease the frequency to 10.2kHz then MCU creates pwm signals on these pins but not same frequency with other Pins (CH2 , CH3 , CH2N , CH3N).
after start-up procedure pwms signals are set in interrupt.
a example of IT codes;
case GPIO_PIN_0:
if(HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_0))
{
HAL_TIM_PWM_Stop(&htim1,TIM_CHANNEL_2);
HAL_TIMEx_PWMN_Stop(&htim1,TIM_CHANNEL_2);
HAL_TIMEx_PWMN_Stop(&htim1,TIM_CHANNEL_3);
HAL_TIM_PWM_Stop(&htim1,TIM_CHANNEL_1);
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_3);
HAL_TIMEx_PWMN_Start(&htim1,TIM_CHANNEL_1);
}
if(!HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_0))
{
HAL_TIM_PWM_Stop(&htim1,TIM_CHANNEL_2);
HAL_TIMEx_PWMN_Stop(&htim1,TIM_CHANNEL_2);
HAL_TIMEx_PWMN_Stop(&htim1,TIM_CHANNEL_1);
HAL_TIM_PWM_Stop(&htim1,TIM_CHANNEL_3);
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);
HAL_TIMEx_PWMN_Start(&htim1,TIM_CHANNEL_3);
}
break;
