用STM32 定时器的外部捕获 捕抓到的 误差很大,不知道是哪里的原因,是不是这种方式不能支持这么搞的 频率
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE); //endabe tim2 clk
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); //endabe tim2 clk
// GPIO_InitStructure_Modem.GPIO_Pin = GPIO_Pin_1;
// GPIO_InitStructure_Modem.GPIO_Speed = GPIO_Speed_50MHz;
// GPIO_InitStructure_Modem.GPIO_Mode = GPIO_Mode_IPD;
//// GPIO_InitStructure_Modem.GPIO_Mode = GPIO_Mode_AF_PP;
// GPIO_Init(GPIOA, &GPIO_InitStructure_Modem);
// GPIO_ResetBits(GPIOA,GPIO_Pin_1); //down pull
// TIM_TimeBaseStructure_Modem.TIM_Prescaler = 0;
// TIM_TimeBaseStructure_Modem.TIM_CounterMode = TIM_CounterMode_Up;
// TIM_TimeBaseStructure_Modem.TIM_Period = 65535;
// TIM_TimeBaseStructure_Modem.TIM_ClockDivision = TIM_CKD_DIV1;
//// TIM_TimeBaseStructure.TIM_RepetitionCounter = ;
// TIM_TimeBaseInit(TIM2,&TIM_TimeBaseStructure_Modem);
//
//
// TIM2_ICInitStructure_Modem.TIM_Channel = TIM_Channel_2; //IC1 映射到 TI2
// TIM2_ICInitStructure_Modem.TIM_ICPolarity = TIM_ICPolarity_Rising;// 上升沿出发
// TIM2_ICInitStructure_Modem.TIM_ICSelection = TIM_ICSelection_DirectTI; //IC1 映射到 TI1
// TIM2_ICInitStructure_Modem.TIM_ICPrescaler = TIM_ICPSC_DIV1; //无分频
// TIM2_ICInitStructure_Modem.TIM_ICFilter = 0; //无滤波
//// TIM_ICInit(TIM2,&TIM2_ICInitStructure_Modem);
// TIM_PWMIConfig(TIM2,&TIM2_ICInitStructure_Modem);
//
// TIM_SelectInputTrigger(TIM2, TIM_TS_TI2FP2); //选择IC2为始终触发源
//
// TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Reset);//TIM从模式:触发信号的上升沿重新初始化计数器和触发寄存器的更新事件
//
// TIM_SelectMasterSlaveMode(TIM2, TIM_MasterSlaveMode_Enable); //启动定时器的被动触发
//
// MY_NVIC_Init(2,3,TIM2_IRQChannel,2);// 抢占2 子优先级3 组2,最低优先级
//
// TIM_ITConfig(TIM2,TIM_IT_Update|TIM_IT_CC2,ENABLE) ; //更新中断和捕获中断
//// TIM_ITConfig(TIM2,TIM_IT_CC2,ENABLE) ;
// TIM_Cmd(TIM2,ENABLE);
|