For the TIM5 interrupt handler, make the following explanation. (TIM5 interrupts include both timer update interrupts (timer count overflow), and capture interrupts)
U8 Tim5ch1_capture_sta = 0; TIM5 input capture state U16 Tim5ch1_capture_val; TIM5 input Capture value//TIM5 input capture interrupt function void Tim5_irqhandler (void) {if ((Tim5ch1_capture_sta & 0x80) ==0)//not captured successfully {if (TIM
_getitstatus (tim5,tim_it_update)! = RESET)//The update interrupt timer count has overflow {//update interrupt and capture interrupt must be a capture interrupt at the time of the first interrupt, the capture interrupt has been set BIT6 in order to 1 Therefore (Tim5ch1_capture_sta & 0x40) must be equal to 1//"An update interrupt timer count has overflow" case must have if (Tim5ch1_capture_sta & 0x40) is true, so do not need to E The LSE if (Tim5ch1_capture_sta & 0x40)//bit6=1 has captured the high level {if ((tim5ch1_capture_sta% 0x3F) ==0x3f)//Count times reached Maximum, forcing the end of this capture {Tim5ch1_capture_sta |= 0x80;
Bit7=1 Flag Complete One capture tim5ch1_capture_val = 0xFFFF;
} else//The number of times does not reach the maximum {tim5ch1_capture_sta++; }}} if (Tim_getitstatus (TIM5,TIM_IT_CC1)! = RESET)//occurred capture interrupt timer count no overflow {if (Tim5ch1_capture_sta & 0X //bit6=1 has captured the high level so this capture is captured to the falling edge {Tim5ch1_capture_sta |= 0x80; Bit7=1 Complete Capture Tim5ch1_capture_val = Tim_getcapture1 (TIM5); Gets the Count value Tim_oc1polarityconfig (tim5,tim_icpolarity_rising); Set to rising edge capture} else//bit6=0 not yet captured high so this capture is captured to the rising edge {tim5ch1_capture_sta = 0; Clear Capture flag bit tim5ch1_capture_val = 0; Clears the capture value Tim_setcounter (tim5,0); Empties the TIM5 count register value Tim5ch1_capture_sta |= 0x40; The bit6=1 has captured high-level tim_oc1polarityconfig (tim5,tim_icpolarity_falling); Set to falling Edge Capture}}} tim_clearitpendingbit (Tim5,tim_it_update | TIM_IT_CC1);
Clear the update interrupt flag bit and capture interrupt flag bit}