各位专家您好,我在重映射TIM10的时候,无法输出PWM
我的函数如下,请专家指导,谢谢。
void?stepper_pwm_init(?void) { ????GPIO_InitTypeDef????????GPIO_InitStructure={0}; ????TIM_OCInitTypeDef???????TIM_OCInitStructure={0}; ????TIM_TimeBaseInitTypeDef?TIM_TimeBaseInitStructure={0}; ????RCC_APB2PeriphClockCmd(?RCC_APB2Periph_GPIOE?|?RCC_APB2Periph_TIM10?|?RCC_APB2Periph_AFIO,?ENABLE?); ????GPIO_PinRemapConfig(GPIO_FullRemap_TIM10?,?ENABLE); ????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5; ????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_AF_PP; ????GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz; ????GPIO_Init(?GPIOE,?&GPIO_InitStructure?); ????TIM_TimeBaseInitStructure.TIM_Period?=?65536; ????TIM_TimeBaseInitStructure.TIM_Prescaler?=?1439; ????TIM_TimeBaseInitStructure.TIM_ClockDivision?=?TIM_CKD_DIV1; ????TIM_TimeBaseInitStructure.TIM_CounterMode?=?TIM_CounterMode_Up; ????TIM_TimeBaseInit(?TIM10,?&TIM_TimeBaseInitStructure); #if?(PWM_MODE?==?PWM_MODE1) ????TIM_OCInitStructure.TIM_OCMode?=?TIM_OCMode_PWM1; #elif?(PWM_MODE?==?PWM_MODE2) ????TIM_OCInitStructure.TIM_OCMode?=?TIM_OCMode_PWM2; #endif ????TIM_OCInitStructure.TIM_OutputState?=?TIM_OutputState_Enable; ????TIM_OCInitStructure.TIM_Pulse?=?32767; ????TIM_OCInitStructure.TIM_OCPolarity?=?TIM_OCPolarity_High; ????TIM_OC1Init(?TIM10,?&TIM_OCInitStructure?); ????TIM_OC2Init(?TIM10,?&TIM_OCInitStructure?); ????TIM_OC3Init(?TIM10,?&TIM_OCInitStructure?); ????TIM_CtrlPWMOutputs(TIM10,?ENABLE?); ????TIM_OC1PreloadConfig(?TIM10,?TIM_OCPreload_Disable?); ????TIM_OC2PreloadConfig(?TIM10,?TIM_OCPreload_Disable?); ????TIM_OC3PreloadConfig(?TIM10,?TIM_OCPreload_Disable?); ????TIM_ARRPreloadConfig(?TIM10,?ENABLE?); ????TIM_Cmd(?TIM10,?ENABLE?); }
热门产品 :
CH641: PD及无线充电专用MCU