这是我写的代码,仿真时如图所示,请问错了哪里啊?#include<reg51.h>#define uchar unsigned char#define uint unsigned intuchar flag,wan,qian,bai,shi,ge;uint a,shu;uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};void init();void display(uchar wan,uchar qian,uchar bai,uchar shi,uchar ge);void main(){ init(); while (1) { if(RI==1) { while (!RI); RI = 0; shu = SBUF; } wan = shu / 10000; qian = shu % 10000 /1000; bai = shu % 1000 /100; shi = shu % 100 / 10; ge = shu % 10; display(wan,qian,bai,shi,ge); }}void init(){ TMOD = 0x20; TH1 = 0xf3; TL1 = 0xf3; TR1 = 1; SCON = 0x50; EA = 1; ES = 1;}void display(uchar wan,uchar qian,uchar bai,uchar shi,uchar ge){ uchar i; P2 = 0x01; P0 = table[wan]; i = 10; while (i--); P0 = 0x00; P2 = 0x02; P0 = table[qian]; i = 10; while (i--); P0 = 0x00; P2 = 0x04; P0 = table[bai]; i = 10; while (i--); P0 = 0x00; P2 = 0x08; P0 = table[shi]; i = 10; while (i--); P0 = 0x00; P2 = 0x10; P0 = table[ge]; i = 10; while (i--); P0 = 0x00;}
哪里不对啊?
我加你了,请确认下,谢谢!