uchar getcode(uchar i) //根据共阴极字型编码表获取0~9,A~B字型代码
{
uchar p;
switch(i)
{
case 0: p=0x3f; break;
case 1: p=0x06; break;
case 2: p=0x5B; break;
case 3: p=0x4F; break;
case 4: p=0x66; break;
case 5: p=0x6D; break;
case 6: p=0x7D; break;
case 7: p=0x07; break;
case 8: p=0x7F; break;
case 9: p=0x67; break;
case 10: p=0x77; break;
case 11: p=0x7C; break;
case 12: p=0x39; break;
case 13: p=0x5E; break;
case 14: p=0x79; break;
case 15: p=0x71; break;
default: break;
}
return(p);
}
void display(void)
{
uchar i;
switch (digbit)
{
case 1: i = 0; break;
case 2: i = 1; break;
case 3: i = 2; break;
case 4: i = 3; break;
default: break;
}
DIGPORT = 0; //关闭显示
WORDPORT = getcode(wordbuf); //送字型码
DIGPORT = digbit; //送字位码
if(digbit<0x80)
digbit = digbit*2;
else
digbit = 0x01;
}
下边这两句按书上说的,应该在AlE有效后往P0口送数据,可是我用keil仿真怎么没有观察到呢!!!!!!!!!!!!!
WORDPORT = getcode(wordbuf); //送字型码
DIGPORT = digbit; //送字位码