STM8S003F3 PWM的使用
2021-09-15 来源:eefocus
这里我使用timer1,gpio PC3来举例:
GPIO_Init(GPIOC, GPIO_PIN_3, GPIO_MODE_OUT_PP_LOW_FAST);
TIM1_DeInit();
TIM1_TimeBaseInit(0x01, TIM1_COUNTERMODE_UP, 10000, 0x00);
TIM1_OC3Init(TIM1_OCMODE_PWM1, TIM1_OUTPUTSTATE_ENABLE,TIM1_OUTPUTNSTATE_DISABLE, 5000, TIM1_OCPOLARITY_LOW,TIM1_OCNPOLARITY_LOW, TIM1_OCIDLESTATE_RESET,TIM1_OCNIDLESTATE_RESET);//50%占空比
TIM1_CCxCmd(TIM1_CHANNEL_3, ENABLE);
TIM1_OC3PreloadConfig(ENABLE);
TIM1_CtrlPWMOutputs(ENABLE);
TIM1_Cmd(ENABLE);
相关文章
最新器件