我在调试时遇到这样的问题: 下面这段程序在TIM1上有PWM输出,而在TIM8上却没有,请问版主,TIM1和TIM8用作PWM模式时的设置不同吗? RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8,ENABLE); RCC_APB2PeriphClockCmd( (RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO), ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); TIM_TimeBaseStructure.TIM_Period = 199 TIM_TimeBaseStructure.TIM_Prescaler = 0; TIM_TimeBaseStructure.TIM_ClockDivision = 0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure); TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_Pulse = 100; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OC4Init(TIM8, &TIM_OCInitStructure); TIM_CtrlPWMOutputs(TIM8, ENABLE); TIM_Cmd(TIM8, ENABLE); 把这段程序换成TIM1,引脚换成PA8就有PWM输出,请版主帮帮我!
|