#include "reg52.h"
#define uint unsigned int
#define uchar unsigned char
uint Timer=0;
uint Timer1=0;
uint Timer2=0;
sbit led2=P1^2;
sbit led3=P1^7;
sbit led4=P1^4;
void intte0()
{
TMOD=0X01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
ET0=1;
//EA=1;
}
void inite1()
{
TMOD=0X20;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR1=1;
ET1=0;
EA=1;
}
void inite2()
{
TH2=(65536-50000)/256;
TL2=(65536-50000)%256;
ET2=1;
TR2=1;
EA=1;
}
void main()
{
intte0();
inite1();
inite2();
while(1);
}
void inite_0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
Timer++;
if(Timer==40)
{
Timer=0;
led4=~led4;
}
}
void inite_1() interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
Timer1++;
if(Timer1==20)
led2=~led2;
}
void intee_2() interrupt 5
{
TF2=0;
TH2=(65536-50000)/256;
TL2=(65536-50000)%256;
Timer2++;
if(Timer2==20)
{
Timer2=0;
led3=~led3;
led2=~led2;
}
}
//本人写的比较简单,大神莫喷
//联系方式:QQ:1678957377
//免费解答解惑,帮助更多人学到知识