真的很郁闷,我想用定时中断来写一段显示函数,不知道哪里出错了,请各位大虾指点下下………………
#include<reg52.h>
#define uchar unsigned char
void display();
uchar code dis[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0XD8,0x80,0x90,
0x88,0x83,0xc6,0xa1,0x86,0x8e,0x89,0x86,0xc7,0xbf};
uchar code bitwei[]={0xe3,0xe7,0xeb,0xef,0xf3,0xf7,0xfb,0xff};//**对应的数码管1-8**
void main()
{
TMOD=0x01;
TH0=(65536-3000)/256;
TL0=(65536-3000)%256;
TR0=1;
ET0=1;
EA=1;
for(;;);
}
void time() interrupt 1
{
TH0=(65536-3000)/256;
TL0=(65536-3000)%256;
display();
}
void display()
{
uchar k=0,temp;
k=k+1;
P2=bitwei[k]; //*******P2接位选*******
temp=P2;
switch(temp)
{
case 0xe3: P1=dis[1];break;//****P1接数据口*******
case 0xe7: P1=dis[2];break;
case 0xeb: P1=dis[3];break;
case 0xef: P1=dis[4];break;
case 0xf3: P1=dis[5];break;
case 0xf7: P1=dis[6];break;
case 0xfb: P1=dis[7];break;
case 0xff: P1=dis[8];break;
default: break;
}
} |