请教各位大侠如何把显示用定时中断来实现??
数据口接P1;原来我用延时写的如下:
sbit LS138A=P2^2;
sbit LS138B=P2^3;
sbit LS138C=P2^4;
uchar code dis[] = { 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0XD8,0x80,0x90,
0x88,0x83,0xc6,0xa1,0x86,0x8e,0x89,0x86,0xc7,0xff};
void display(uchar dat)
{
uchar j;
wel[0]=dis[dat/10];
wel[1]=dis[dat%10];
wel[2]=dis[dat%10];
wel[3]=dis[dat%10];
wel[4]=dis[dat%10];
wel[5]=dis[dat%10];
wel[6]=dis[dat%10];
wel[7]=dis[dat%10];
for(j=0;j<8;j++)
{
P1=wel[j];//****位选****
switch(j)
{
case 0: LS138A=0; LS138B=0; LS138C=0; break;
case 1: LS138A=1; LS138B=0; LS138C=0; break;
case 2: LS138A=0; LS138B=1; LS138C=0; break;
case 3: LS138A=1; LS138B=1; LS138C=0; break;
case 4: LS138A=0; LS138B=0; LS138C=1; break;
case 5: LS138A=1; LS138B=0; LS138C=1; break;
case 6: LS138A=0; LS138B=1; LS138C=1; break;
case 7: LS138A=1; LS138B=1; LS138C=1; break;
}
delayms(1);//调用延时1ms延时程序
}
} |