E=0; }
void write_data(unsigned char t) { RS=1;
P0=t; delay(5);
//写数据
E=1; delay(5); E=0; }
void time1_int(void) interrupt 3 {
TH1=TL1=0;
TR1=1; x++; }
void time0_int(void) interrupt 1 {
TH0=(65535-50000)/256; //装初值,定时50ms TL0=(65535-50000)%6;
i++;
if(i==20) { i=0;
//1s时间已到
TR1=0; //关闭计数器1
count=65536*x+256*TH1+TL1; x=0;
//重新装初值 //重新启动计数器器1
TH1=TL1=0; TR1=1; } }
void show() {
write_com(0x85);write_data(shu[count/100000]); delay(5); //在第一行第五列
显示十万位
write_com(0x86);write_data(shu[(count/10000)]);delay(5); write_com(0x87);write_data(shu[(count/1000)]);delay(5); write_com(0x88); write_data(shu[(count/100)]);delay(5); write_com(0x89);write_data(shu[(count/10)]);delay(5); write_com(0x8a);write_data(shu[count]);delay(5);
//显示万位 //显示千位 //显示百位
//显示十位
//显示个位
write_com(0x83);write_data(0x66);delay(5); //显示频率表示的字符f write_com(0x84);write_data(0x3d);delay(5); //显示字符= write_com(0x8b);write_data(0x48);delay(5); //显示字母H write_com(0x8c);write_data(0x7a);delay(5); //显示字母z write_com(0x80+0x40); }
void main()
for(num=0;num<17;num++) { write_data(table[num]); delay(5); }
//第二行显示
{
TMOD=0x51;
//T1计数、T2定时,且都工作在方式1
TH1=0x00;TL1=0x00;
TH0=(65535-50000)/256; //装初值,定时50ms TL0=(65535-50000)%6; EA=1;
ET0=1;ET1=1; TR0=1;TR1=1;
dula=0; wela=0; RW=0;
E=0;
write_com(0x01); write_com(0x38); write_com(0x0c); write_com(0x06);
while(1)
{
show(); delay(5);
}
}
//开总中断 //中断允许 //启动定时器
//显示清零,数据指针清零
//设置16X2显示5X7点阵,8位数据口 //设置开显示,显示光标且闪烁 //写一个字符后地址指针加1