从单片机基础到程序框架(全集 2019pdf版).pdf - 第604页

} P0=Su8Ge tCode; P1_0=1; P1_1=0; P1_2=1; P1_3=1; break; case 3: Su8GetCo de=Cu8DigTa ble[vGu8Di splay_Righ_ 3]; if(1==vG u8Display_R igh_Dot_3) / /如果打 开了需要显 示第 3 个数码管的 小数点 { Su8GetCo de=Su8GetCo de|0x80; //把第 7 位数据改为 1,…

100%1 / 836
}
void DisplayScan(void)
{
static unsigned char Su8GetCode;
static unsigned char Su8ScanStep=1;
if(0==vGu16ScanTimerCnt)
{
P0=0x00;
P1_0=1;
P1_1=1;
P1_2=1;
P1_3=1;
switch(Su8ScanStep)
{
case 1:
Su8GetCode=Cu8DigTable[vGu8Display_Righ_1];
/* 注释二:
* 这里是本节的关键。通过判断全局的接口变量的数值,来决定是否打开显示小数点。
* 从转换表取出字模数据后再跟 0x80 进行“或”运算即可把第 7 位数据改为 1。
*/
if(1==vGu8Display_Righ_Dot_1) //如果打开了需要显示第 1 个数码管的小数点
{
Su8GetCode=Su8GetCode|0x80; //把第 7 位数据改为 1,显示小数点
}
P0=Su8GetCode;
P1_0=0;
P1_1=1;
P1_2=1;
P1_3=1;
break;
case 2:
Su8GetCode=Cu8DigTable[vGu8Display_Righ_2];
if(1==vGu8Display_Righ_Dot_2) //如果打开了需要显示第 2 个数码管的小数点
{
Su8GetCode=Su8GetCode|0x80; //把第 7 位数据改为 1,显示小数点
}
P0=Su8GetCode;
P1_0=1;
P1_1=0;
P1_2=1;
P1_3=1;
break;
case 3:
Su8GetCode=Cu8DigTable[vGu8Display_Righ_3];
if(1==vGu8Display_Righ_Dot_3) //如果打开了需要显示第 3 个数码管的小数点
{
Su8GetCode=Su8GetCode|0x80; //把第 7 位数据改为 1,显示小数点
}
P0=Su8GetCode;
P1_0=1;
P1_1=1;
P1_2=0;
P1_3=1;
break;
case 4:
Su8GetCode=Cu8DigTable[vGu8Display_Righ_4];
if(1==vGu8Display_Righ_Dot_4) //如果打开了需要显示第 4 个数码管的小数点
{
Su8GetCode=Su8GetCode|0x80; //把第 7 位数据改为 1,显示小数点
}
P0=Su8GetCode;
P1_0=1;
P1_1=1;
P1_2=1;
P1_3=0;
break;
}
Su8ScanStep++;
if(Su8ScanStep>4)
{
Su8ScanStep=1;
}
vGu8ScanTimerFlag=0;
vGu16ScanTimerCnt=SCAN_TIME;
vGu8ScanTimerFlag=1;
}
}
void T0_time() interrupt 1
{
DisplayScan();
if(1==vGu8ScanTimerFlag&&vGu16ScanTimerCnt>0)
{
vGu16ScanTimerCnt--;
}
TH0=0xfc;
TL0=0x66;
}
void SystemInitial(void)
{
P0=0x00;
P1_0=1;
P1_1=1;
P1_2=1;
P1_3=1;
TMOD=0x01;
TH0=0xfc;
TL0=0x66;
EA=1;
ET0=1;
TR0=1;
}
void Delay(unsigned long u32DelayTime)
{
for(;u32DelayTime>0;u32DelayTime--);
}
void PeripheralInitial(void)
{
}