2020-01-20 04:54 AM
2020-01-21 02:10 AM
period and pulse are not initialized.
void PWM_Timer_Init(void)
{
/* Enable TIM3 clock */
__HAL_RCC_TIM3_CLK_ENABLE();
/* Configuration for TIM3 */
ConfTimer.Instance = TIM3;
ConfTimer.Init.Prescaler = 215U;
ConfTimer.Init.CounterMode = TIM_COUNTERMODE_UP;
ConfTimer.Init.Period = 999U; //(1000000U / 1000U) - 1U;
ConfTimer.Init.ClockDivision = 0U; /* no divider */
ConfTimer.Init.RepetitionCounter = 0U;
ConfTimer.Init.AutoReloadPreload = 0U; /* disabled */
//ConfTimer.Channel = TIM_CHANNEL_2;
if (HAL_TIM_PWM_Init(&ConfTimer) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 499U;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
//sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCNIdleState = TIM_OCIDLESTATE_SET;
sConfigOC.OCNIdleState= TIM_OCNIDLESTATE_RESET;
if (HAL_TIM_PWM_ConfigChannel(&ConfTimer, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
//HAL_TIM_Base_Start(&ConfTimer);
}
2020-01-21 02:17 AM
Thank you Mike, that was the issue. :)