Atomic Battleship stm32--Timer capture Interrupt Library function Description of interrupt handler function in program

Source: Internet
Author: User
Tags count reset

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}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.