#include <reg52.h> void delay1ms(void) { unsigned char i,j; for(i=20;i>0;i--) for(j=248;j>0;j--); } unsigned char codedispbitcode[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; unsigned char code LEDcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x40}; unsigned char T0count; unsigned char T1count; unsigned char timecount; bit flag; unsigned long x; void Display() { P2=0xff; P2=0xdf; P0=LEDcode[x%1000000/100000]; delay1ms(); P2=0xef; P0=LEDcode[x%100000/10000]; delay1ms(); P2=0xf7; P0=LEDcode[x%10000/1000]; delay1ms(); P2=0xfb; P0=LEDcode[x%1000/100]; delay1ms(); P2=0xfd; P0=LEDcode[x%100/10]; delay1ms(); P2=0xfe; P0=LEDcode[x%10]; delay1ms(); } void main(void) { TMOD=0x55; C_T=0; CP_RL2=0; TH0=0; TL0=0; TH1=0; TL1=0; TH2=(65536-49972)/256; TL2=(65536-49972)%256; TR1=1; TR0=1; ET0=1; ET1=1; ET2=1; EA=1; while (1) { if(flag==1) { flag=0; x=(T0count*65536+TH0*256+TL0)/(T1count*65536+TH1*256+TL1)*10000; } Display(); } } void t0(void) interrupt 1 using 0 { T0count++; } void t1(void) interrupt 3 using 0 { T1count++; } void t2(void) interrupt 5 using 0 { TH2=(65536-49972)/256; TL2=(65536-49972)%256; timecount++; if(timecount==20) {TR0=0; TR1=0; TR2=0; timecount=0; flag=1; } } 帮忙看一下该程序和该电路哪里出错了。 |