8*8点阵显示程序C语言 大神把这个程序指导一下 想不明白进入中断怎么执行
#include<reg52.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedintuch...
#include<reg52.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;
TMOD=0x00;
TH0=(65536-20000)/256; //恢复初值
TL0=(65536-20000)%256;
IE=0x82;
TR0=1; //启动 T0
while(1);
}
//T0 中断函数
void LED_Screen_Display() interrupt 1
{
TH0=(65536-20000)/256; //恢复初值
TL0=(65536-20000)%256;
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; //显示下一个数字
}
} 展开
#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;
TMOD=0x00;
TH0=(65536-20000)/256; //恢复初值
TL0=(65536-20000)%256;
IE=0x82;
TR0=1; //启动 T0
while(1);
}
//T0 中断函数
void LED_Screen_Display() interrupt 1
{
TH0=(65536-20000)/256; //恢复初值
TL0=(65536-20000)%256;
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; //显示下一个数字
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询