/* TIM2 Initialization */ TIM_DeInit(TIM2); TIM_CounterCmd(TIM2,TIM_STOP); TIM_CounterCmd(TIM2,TIM_CLEAR); TIM_StructInit(&TIM_InitStructure); TIM_InitStructure.TIM_Mode = TIM_OCM_CHANNELA; TIM_InitStructure.TIM_OCA_Modes = TIM_Timing; TIM_InitStructure.TIM_Clock_Source = TIM_ICAP_2; TIM_InitStructure.TIM_Pulse_Length_A = 0; TIM_InitStructure.TIM_Prescaler = 0;
TIM_Init(TIM2,&TIM_InitStructure);
/* TIM5 Initialization */ TIM_DeInit(TIM5); TIM_CounterCmd(TIM5,TIM_STOP); TIM_CounterCmd(TIM5,TIM_CLEAR); TIM_StructInit(&TIM_InitStructure); TIM_InitStructure.TIM_Mode = TIM_OCM_CHANNELA; TIM_InitStructure.TIM_OCA_Modes = TIM_Timing; TIM_InitStructure.TIM_Clock_Source = TIM_ICAP_5; TIM_InitStructure.TIM_Pulse_Length_A = 0; TIM_InitStructure.TIM_Prescaler = 0;
TIM_Init(TIM5,&TIM_InitStructure);
其中,TIM_ICAP_2和TIM_ICAP_5管脚都设成GPIO_Mode_IN_TRI_TTL方式 |