Question
PWM FORCED ACTIVE
Posted on February 15, 2018 at 09:32
Hi All,
in my application, i need sometimes to stop PWM and Force Output to High.
I write this code but seem not run good.
void forcePwmActive(void)
{ TIM_OC_InitTypeDef configOC;HAL_TIM_PWM_Stop(&htim21, TIM_CHANNEL_2);
configOC.OCMode = TIM_OCMODE_FORCED_ACTIVE; configOC.Pulse = 0; configOC.OCPolarity = TIM_OCPOLARITY_HIGH; configOC.OCFastMode = TIM_OCFAST_DISABLE;if(HAL_TIM_OC_ConfigChannel(&htim21, &configOC, TIM_CHANNEL_2) != HAL_OK)
{ _Error_Handler(__FILE__, __LINE__); }}Can anyone help?