2021-07-30 07:03 AM
iam using stm8s003f3 microcontroller i configured centeraligned pwm but not working
attached wave form also please suggest.
void TIM1_setup(void)
{
TIM1_DeInit();
TIM1_TimeBaseInit(0, TIM1_COUNTERMODE_CENTERALIGNED3 , 1000, 0);
TIM1_BDTRConfig(TIM1_OSSISTATE_DISABLE,TIM1_LOCKLEVEL_OFF, 10,TIM1_BREAK_DISABLE,TIM1_BREAKPOLARITY_LOW,TIM1_AUTOMATICOUTPUT_DISABLE);
TIM1_OC1Init(TIM1_OCMODE_PWM2,
TIM1_OUTPUTSTATE_ENABLE,
TIM1_OUTPUTNSTATE_ENABLE,
1000,
TIM1_OCPOLARITY_LOW,
TIM1_OCNPOLARITY_LOW,
TIM1_OCIDLESTATE_RESET,
TIM1_OCNIDLESTATE_RESET);
TIM1_OC2Init(TIM1_OCMODE_PWM2,
TIM1_OUTPUTSTATE_ENABLE,
TIM1_OUTPUTNSTATE_ENABLE,
1000,
TIM1_OCPOLARITY_LOW,
TIM1_OCNPOLARITY_LOW,
TIM1_OCIDLESTATE_RESET,
TIM1_OCNIDLESTATE_RESET);
TIM1_CtrlPWMOutputs(ENABLE);
TIM1_Cmd(ENABLE);
}