定时器中断彩灯控制程序
#include<reg51.h>
int i=1;
void main(void)using 0
{
EA=1;
TMOD=0X01;
TH0=0x00;//(65536-65535)%256;
TL0=0x00;//(65536-65535)/256;
TH1=(65536-2000)/256;
TL1=(65536-2000)%256;
PT0=1;
PT1=0;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
P0=0;
while(1)
{
P0=i;
}
}
void T1_int(void)interrupt 3 using 2
{
TH1=(65536-2000)/256;
TL1=(65536-2000)%256;
P0=0;
}
void T0_int(void)interrupt 1 using 1
{
TH0=0x00;
TL0=0x00;
if(i<8){i*=2;}
else{i=1;}
}
posted on 2017-12-11 11:04 MACHINE_001 阅读(427) 评论(0) 编辑 收藏 举报