F4 TIMER2 外部触发 计数 问题

2019-07-21 03:17发布

[mw_shl_code=c,true]void TIM2_Configuration(void) { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_DeInit(TIM2); TIM_TimeBaseStructure.TIM_Period = 0xFFFF; TIM_TimeBaseStructure.TIM_Prescaler = 0x00; TIM_TimeBaseStructure.TIM_ClockDivision = 0x0; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); TIM_ITRxExternalClockConfig(TIM2,TIM_TS_ETRF); TIM_ETRClockMode2Config(TIM2, TIM_ExtTRGPSC_OFF, TIM_ExtTRGPolarity_NonInverted, 0); TIM_SetCounter(TIM2, 0); TIM_ARRPreloadConfig(TIM2, ENABLE); TIM_Cmd(TIM2, ENABLE); } void Init_timer2(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_ClocksTypeDef RCC_ClockFreq; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); SystemInit(); RCC_GetClocksFreq(&RCC_ClockFreq); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); TIM2_Configuration(); }[/mw_shl_code] 如上代码..用的 是PA0 ETR 采集,定时器2   但是   网上找了些代码,试着改了下,发现运行没有变化啊,我PA0接的是500HZ左右的 方波,但是  计数一个也没计....
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。