#includereg52.h#defineuintunsignedint#defineucharunsignedcharsbitwela=P2^7;sbitdula=P2^6;uintnum,tt;ucharcodetable[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};voidmain(){num=0;tt=0;TMOD=0x01;//(TMOD地址为98H不能被8整除不可进行位操作,必需进行寄存器整体赋值)设置定时器0为工作方式1TH0=(65536-50000)/256;//求模TL0=(65536-50000)%256;//求余EA=1;//开总中断ET0=1;//开定时器0中断TR0=1;//启动定时器0wela=1;P0=0xfe;wela=0;dula=1;P0=0x3f;dula=0;while(1){if(tt==20){tt=0;num++;if(num==16){num=0;}dula=1;P0=table[num];dula=0;}}}voidtimer0()interrupt1{TH0=(65536-50000)/256;TL0=(65536-50000)%256;tt++;}