我在做51数码管动态显示的实验,出了问题,怎么也没找出来 硬件连接如下,8个数码管的位选接P2口,段选接P0口, 现要让8个数码管显示12345678,程序如下,看看那里出了问题 #include<reg52.h> #define uchar unsigned char uchar aa,numd,numw; uchar code table[]={ 0xc0,0xf9,0xa4,0xb0, 0x99,0x92,0x82,0xf8, 0x80,0x90,0x88,0x83, 0xc6,0xa1,0x86,0x8e}; uchar code tablew[]={ 0xfe,0xfd,0xfb,0xf7, 0xef,0xdf,0xbf,0x7f}; void mian() { numw=0; numd=0; aa=0; TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; ET0=1; TR0=1; while(1) { if(aa==20) { aa=0; numd++; if(numd==9) numd=1; P0=table[numd]; numw++; if(numw==8) numw=0; P2=tablew[numw]; } } } void timer0() interrupt 1 { TH0=(65536-50000)/256; TL0=(65536-50000)%256; aa++; } |