今天学习的是中断函数
#include <REG52.H>
#include <INTRINS.H>
sbit LED = P1^0;
void time()
{
EA = 1;
EX0 = 1;
IT0 = 1;
}
void zhongduan() interrupt 0//中断函数在单片机中是P3^2
{
LED = 1;
Delay500();
}
void Delay500()//延时
{
unsigned char i, j, k;
_nop_();
_nop_();
i =22;
j = 3;
k = 227;
do
{
do
{
while(--k);
}while(--j);
}while(--i);
}
int main()
{
time();
Delay500();
while(1)
{
LED = 0;
}
return 0;
}