📄 lcd.c
字号:
#include <reg52.h>
#include <absacc.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define PA8255 XBYTE[0x3ffc]
#define PB8255 XBYTE[0x3ffd]
#define PC8255 XBYTE[0x3ffe]
#define COM8255 XBYTE[0x3fff]
#define LcdWComm XBYTE[0x5ffc]
#define LcdRComm XBYTE[0x5ffd]
#define LcdWData XBYTE[0x5ffe]
#define LcdRData XBYTE[0x5fff]
sbit cs138=P1^6;
uchar key;
void LcdInit(void);
void LcdWRComm(uchar);
void LcdWRData(uchar);
void delay(uchar);
void timer11(void);
uchar times=0 , temp0='2',temp1='0',temp2='0',temp3='8',temp4='0',temp5='7',temp6='2',
temp7='8',temp8='0',temp9='0',tempA='0',tempB='0',tempC='0',tempD='0';
void main(void)
{
TMOD=0x01;
TH0=0x4c;
TL0=0x00;
IE=0x82;
TR0=1;
cs138=0;
LcdInit();
while(1)
{
LcdWRComm(0x82 );
LcdWRData(0xbb);LcdWRData(0xb6);LcdWRData(0xd3);LcdWRData(0xad);
LcdWRData(0xca);LcdWRData(0xb9);LcdWRData(0xd3);LcdWRData(0xc3);
LcdWRComm(0x91 );
LcdWRData(0xbb);LcdWRData(0xe3);LcdWRData(0xb4);LcdWRData(0xb4);
LcdWRData(0xd6);LcdWRData(0xc7);LcdWRData(0xc4);LcdWRData(0xdc);
LcdWRData(0xcf);LcdWRData(0xb5);LcdWRData(0xcd);LcdWRData(0xb3);
LcdWRComm(0x89 );
LcdWRData(temp8);LcdWRData(temp9);LcdWRData(0xa1);LcdWRData(0xc3);
LcdWRData(tempA);LcdWRData(tempB);LcdWRData(0xa1);LcdWRData(0xc3);
LcdWRData(tempC);LcdWRData(tempD);
// LcdWRComm(0x9a );
// LcdWRData(0xba);LcdWRData(0xee);LcdWRData(0xc9);LcdWRData(0xad);
// LcdWRData(0xbc);LcdWRData(0xd3);LcdWRData(0xd3);LcdWRData(0xcd);
}
}
void timer11(void) interrupt 1
{ TH0=0x4c;
TL0=0x00;
times++;
if(times==20)
{times=0;tempD++;
if(tempD=='9'+1) //--------------------->>
{tempD='0';tempC++;
if(tempC=='5'+1) //--------------------->>
{tempC='0';tempB++;
if(tempB=='9'+1) //--------------------->>
{tempB='0';tempA++;
if(tempA=='5'+1)//--------------------->>
{tempA='0';temp9++;
if(temp9=='9'+1)//--------------------->>
{temp9='0';temp8++;
if(temp8=='3'+1)//--------------------->>
{temp8='0';//temp8++;
}
}
}
}
}
}
}
}
//******************************************************
void LcdInit(void)
{
LcdWRComm(0x30);LcdWRComm(0x0c);
LcdWRComm(0x01);LcdWRComm(0x06);
//LcdWRComm(0x40);
}
void LcdWRComm(uchar x)
{ LcdWComm=x;delay(2);
}
void LcdWRData(uchar x)
{ LcdWData=x;delay(2);
}
void delay(uchar j)
{uchar k;
while(j--)
for(k=0;k<125;k++);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -