您好我是学习单片机的新手
我编写了从0到60的数码管显示 但只个位显示 十位只闪耀
请您帮助求解 #include<reg51.h>#define uint unsigned int#define uchar unsigned charsbit DUAN=P2^6;sbit WEI=P2^7;unsigned code ds[]={0x30,0x06,0x5b,0x4f,0x66, 0x6d,0x7d,0x07,0x7f,0x6f, 0x77,0x7c,0x39,0x5e,0x79,0x71};uchar shiwei,gewei,temp,aa;uint x,y;void delay(uint z); //延时void display(uchar shiwei,uchar gewei); //显示函数声明void InitTimer0();void main(void){ InitTimer0(); while(1) if(aa==20) //判断是否达到1秒 { aa=0; temp++; if(temp==60) //temp变化范围 { temp=0; } shiwei=temp/10; //十位 gewei=temp%10; // 个位 display(shiwei,gewei); //调用显示函数 } }void delay(uint z){ // uint x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void display(uchar shiwei,uchar gewei) //显示函数{ P0=ds[shiwei]; DUAN=1; DUAN=0; P0=0xfe; WEI=1; WEI=0; delay(5); P0=ds[gewei]; DUAN=1; DUAN=0; P0=0xfd; WEI=1; WEI=0; delay(5);} void InitTimer0(void) //定时器 初始化{ DUAN=0; WEI=0; temp=0; TMOD = 0x01; TH0 = 0x4c; TL0 = 0x00; EA = 1; ET0 = 1; TR0 = 1;}void Timer0Interrupt(void) interrupt 1 // 中断{ TH0 = 0x4c; TL0 = 0x00; aa++; } |