26. Using the timer interrupt in the microcontroller, set every precise time measurement in the main process while (1) {}

Source: Internet
Author: User

 void  Timer0_isr () interrupt 5  {countmilliseconds  + +; //  is only responsible for self-addition, add to the maximum and start again from 0  }u16 Setdelay (U16 t) { return  (                                             Countmilliseconds + T-1  ); }u8 Checkdelay (U16 t)  //  returns a nonzero representation Timed end  { return  (((T- countmilliseconds) & 0x8000 ) >> 8 ); // } 

Use 1: (more general usage)

void Delay_ms (U16 W)// delay How many ms{     u16 temp     ; = Setdelay (w);       while (! Checkdelay (temp));}

Use 2:

U16 dely_500ms = Setdelay (+);  while (1) {... if (Checkdelay (dely_500ms)) {}// indicates that the timekeeping time has arrived

...
}

26. Using the timer interrupt in the microcontroller, set every precise time measurement in the main process while (1) {}

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.