大家看看我的初始化有什么问题吗?为什么不管用?
void TIM3_Int_Init(u16 arr,u16 psc)
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
// NVIC_InitTypeDef NVIC_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE); ///ê1ÄüTIM1ê±Öó
TIM_DeInit(TIM1);
TIM_TimeBaseInitStructure.TIM_Period = 65535; //×Ô¶ˉÖØ×°ÔØÖμ
TIM_TimeBaseInitStructure.TIM_Prescaler=0; //¶¨ê±Æ÷·ÖÆμ
TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up; //ÏòéϼÆêyÄ£ê½
TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInit(TIM1,&TIM_TimeBaseInitStructure);//3õê¼»ˉTIM1
TIM_ClearFlag(TIM1, TIM_FLAG_Update);
TIM_ETRClockMode2Config(TIM1, TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_NonInverted, 0);
TIM_SetCounter(TIM1, 0);
TIM_Cmd(TIM1,ENABLE); //ê1Äü¶¨ê±Æ÷1
//
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; //GPIOA12
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //Ëù¶è50MHz
// GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //íÆíì¸′óÃêä3ö
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA,&GPIO_InitStructure); //3õê¼»ˉPA12
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我照着你这样改了 给了脉冲,可是还是没用!
F407的代码 PA12 这样配置
GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_TIM1);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; //GPIOA12
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //?ù?è50MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_Init(GPIOA,&GPIO_InitStructure); //3?ê??ˉPA12
一周热门 更多>