Implementation of External Interrupt 0 and 1

Source: Internet
Author: User

# include
# define uint unsigned int
# define uchar unsigned char
sbit p32 = P3 ^ 2;
sbit p33 = P3 ^ 3;
main () {
Ea = 1;
it0 = 1;
it1 = 1;
ex0 = 1;
ex1 = 1;
p0 = 0xff;
// turn off the LED lights of all P0 ports
P1 = 0xff;
// turn off the LED lights of all P0 ports
while (1); // infinite loop,

}< br>
/***************************** ***********************************
function: latency: about 0.6 Ms
********************************* * **********************************/
void delay (uint K)
{
uint I, j;
for (I = 0; I

{for (j = 0; j <121; j ++)

{;}}
}< span style = "white-space: pre">

/************************************ * ************************
function functions: Program
****************** **************************************** * ***/
void int1 (void) interrupt 0 // The interrupt Number of the External Interrupt 0 is 0
{< br> If (p32 = 0) {
delay (150);
If (p32 = 0)

p0 = ~ P0; // every time an interrupted request is generated, P1 returns the inverse.
}< BR >}

/************************************ * ************************
function functions: interrupted service programs with external interruptions of T0
****************************** * ******************************/
void int2 (void) interrupt 2 // The interrupt Number of the External Interrupt 2 is 2
{< br>
If (p33 = 0) {
delay (150);
If (p33 = 0)
P1 = ~ P1; // every time an interrupted request is generated, P1 returns the inverse.
}< br>
}

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.