void TIM14_PWM_Init(void)
{
//????·??è????????IO???è??
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM14,ENABLE); //TIM14?±??????
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE); //????PORTF?±??
GPIO_PinAFConfig(GPIOF,GPIO_PinSource9,GPIO_AF_TIM14); //GPIOF9???????¨?±?÷14
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //GPIOF9
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; //????????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; //????100MHz
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //???©????
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; //????
GPIO_Init(GPIOF,&GPIO_InitStructure); //??????PF9
TIM_TimeBaseStructure.TIM_Prescaler=83; //?¨?±?÷·???
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up; //?ò??????????
TIM_TimeBaseStructure.TIM_Period=99; //×?????×°????
TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInit(TIM14,&TIM_TimeBaseStructure); //???????¨?±?÷14
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; //?????¨?±?÷????:TIM?????í???÷??????2
TIM_OCInitStructure.TIM_Pulse =50; //?è??????±?
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; //±???????????
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; //????????:TIM????±?????????
TIM_OC1Init(TIM14, &TIM_OCInitStructure); //?ù??T???¨???????????????èTIM1 4OC1
TIM_OC1PreloadConfig(TIM14, TIM_OCPreload_Enable); //????TIM14??CCR1?????¤×°???????÷
TIM_ARRPreloadConfig(TIM14,ENABLE); //ARPE????
TIM_Cmd(TIM14, ENABLE); //????TIM14
}
初始化这个函数以后 STM32 F4007 板子,为什么pF9 输出的方波不正常,一会有,一会没有。 除了10khz的波以外, 就是规律的有一段时间是没有波形的,请问下为什么呢?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>