51单片机写usc1903时序代码
#include
#defineucharunsignedchar
#defineuintunsignedint
ucharcodeledtab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//0-9
ucharscanled;
uchardisdat[4];
uintss,time;
sbitled=P1^0;
voiddischg()
{
disdat[3]=ss%10;
disdat[2]=(ss/10)%10;
disdat[1]=(ss/100)%10;
disdat[0]=(ss/1000)%10;
}voidt0isr()interrupt1
{
ss++;
dischg();
}
voidt1isr()interrupt3//显示
{
TH1=(65536-5000)/256;
中文写代码软件TL1=(65536-5000)%256;
P2=1<
P0=~ledtab[disdat[scanled]];
scanled++;
scanled%=4;
time++;
if(time>100){time=0;led=~led;}
}
main()
{
TMOD=0x16;
TH0=0xff;
TL0=0xff;
TH1=(65536-5000)/256;
TL1=(65536-5000)%256;
TR1=1;
TR0=1;
ET0=1;
ET1=1;
EA=1;
led=0;
scanled=0;
ss=0;
dischg();
while(1);
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论