求助,stm32定时器输入捕获通道3和通道4该如何配置,这是我参考的例程写的。将里面的通道和中断改为通道1便可以测量,但是通道4和3,测量结果总是乱跳???
void TIM_Configure()
{
TIM_ICInitTypeDef TIM_ICInitngnj;
TIM_TimeBaseInitTypeDef TIM_TimeBasevfv;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);
TIM_TimeBasevfv.TIM_ClockDivision=0;
TIM_TimeBasevfv.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBasevfv.TIM_Period=0xffff;
TIM_TimeBasevfv.TIM_Prescaler=71;
TIM_TimeBaseInit(TIM3,&TIM_TimeBasevfv);
TIM_ICInitngnj.TIM_Channel=TIM_Channel_4;
TIM_ICInitngnj.TIM_ICFilter=0x0;
TIM_ICInitngnj.TIM_ICPolarity=TIM_ICPolarity_Rising;
TIM_ICInitngnj.TIM_ICPrescaler=TIM_ICPSC_DIV1;
TIM_ICInitngnj.TIM_ICSelection=TIM_ICSelection_DirectTI;
TIM_ICInit(TIM3,&TIM_ICInitngnj);
TIM_SelectInputTrigger(TIM3,TIM_TS_TI1FP1);
TIM_SelectSlaveMode(TIM3,TIM_SlaveMode_Reset);
TIM_SelectMasterSlaveMode(TIM3,TIM_MasterSlaveMode_Enable);
TIM_Cmd(TIM3,ENABLE);
TIM_ITConfig(TIM3,TIM_IT_CC4,ENABLE);
}
求大神指导??? |