我是把外部信号直接加在了 PA0,就是TIM2_CH1_ETR上,
信号示波器看频率在80K,但实测 观察捕获值才60K,不知道哪里问题,大家给看看
配置有没有问题
TIM_TimeBaseStructure.TIM_Period = 0xffff; //自动重装值
TIM_TimeBaseStructure.TIM_Prescaler = 1; //预分频值, 使TIMx_CLK=72MHz 时钟频率=72/(时钟预分频+1)
TIM_TimeBaseStructure.TIM_ClockDivision = 0; //输入时钟分频
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //向上计数
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0x0;
TIM_PWMIConfig(TIM2, &TIM_ICInitStructure);
TIM_SelectInputTrigger(TIM2, TIM_TS_TIM_TS_ETRF);
TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Reset);
TIM_SelectMasterSlaveMode(TIM2, TIM_MasterSlaveMode_Enable);
TIM_Cmd(TIM2, ENABLE);
TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE); |