渴望理解这个复杂的程序
8X8LED点阵显示数字
/* 名称:8X8LED点阵显示数字
说明:8X8LED点阵屏循环显示数字0~9,刷新过程由定时器中断完成。
*/
#include<reg51.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code Table_of_Digits[]=
{
0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00, //0
0x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00, //1
0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00, //2
0x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00, //3
0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,0x00, //4
0x00,0x72,0x51,0x51,0x51,0x4e,0x00,0x00, //5
0x00,0x3e,0x49,0x49,0x49,0x26,0x00,0x00, //6
0x00,0x40,0x40,0x40,0x4f,0x70,0x00,0x00, //7
0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, //8
0x00,0x32,0x49,0x49,0x49,0x3e,0x00,0x00 //9
};
uchar i=0,t=0,Num_Index;
//主程序
void main()
{
P3=0x80;
Num_Index=0; //从0开始显示
TMOD=0x00; //T0方式0
TH0=(8192-2000)/32; //2ms定时
TL0=(8192-2000)%32;
IE=0x82;
TR0=1; //启动T0
while(1);
}
//T0中断函数
void LED_Screen_Display() interrupt 1
{
TH0=(8192-2000)/32; //恢复初值
TL0=(8192-2000)%32;
P0=0xff; //输出位码和段码
P0=~Table_of_Digits[Num_Index*8+i];
P3=_crol_(P3,1);
if(++i==8) i=0; //每屏一个数字由8个字节构成
if(++t==250) //每个数字刷新显示一段时间
{
t=0;
if(++Num_Index==10) Num_Index=0; //显示下一个数字
}
}
显示原理i应该是输出段码,然后选通位码。一个字符应该是进行这样的操作8次。
好像是个点阵程序把
非常感谢你能给我解答,
P0=0xff; //输出位码和段码
P0=~Table_of_Digits[Num_Index*8+i];这两句起啥作用?
非常感谢你能给我解答,
P0=0xff; //输出位码和段码
P0=~Table_of_Digits[Num_Index*8+i];这两句怎么分析?