这个程序能显示数字但是不能倒记时,数字一直显示15,请高手帮忙找找原因,谢谢! #include<reg51.h> #include<absacc.h> #define zhiwei XBYTE [0x3fff] //字位的地址 #define zhixing XBYTE [0x5fff] //字型的地址 #define deng XBYTE [0x1fff] //灯的地址 #define uchar unsigned char #define uint unsigned int light(uchar a) ; xianshi(uint b); void delay();
uint e,b; //===============中断服务程序=================== time() interrupt 1 using 1 {TH0=0x3c; TL0=0xb0; if(--e==0) {--b; e=20;} } void delay() {uint i; for(i=0;i<100;++i); } //====灯显示程序==== light(uchar a) {deng=a; } //===倒记时程序======== xianshi(uint b) {while(b) {const unsigned char design[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xf8,0x80,0x90}; zhiwei=0x02; //确定字位 zhixing=design[b/10]; //确定字型 zhiwei=0x00; delay(); zhiwei=0x01; zhixing=design[b%10]; zhiwei=0x00; delay();
} }
void main() { e=20; TMOD=0X01; //定时和中断的初始化 EA=1; TR0=1; ET0=1; TH0=0x3c; TL0=0xb0; while(1) {light(0x80); xianshi(15); light(0x40); xianshi(6); light(0x20); xianshi(7); } }
|