单片机实验板2011_V1.1-LCD12864液晶显示
/***********************************************************/
/*模块名 :LCD12864控制显示 */
/*创建人 :ClimberWin 日期:2011-03-12 */
/***********************************************************/
#include
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
sbit LCD_CS = P1^5;//片选 高电平有效 单片LCD使用时可固定高电平 rs
sbit LCD_SID = P1^6;//数据 r/w
sbit LCD_SCLK = P1^7;//时钟 e
ucharcode HEX_[] ={"0123456789ABCDEF"};
uchar BUFFER[6] = {0};
uchar K_NUM;
void DELAY(uchar t);
void LCD_SEND(uchar date);
void LCD_SCOM(bit st,uchar date);
void LCD_DELAY(void);
void LCD_INIT(void);
void LCD_write(uchar *p);
void LCD_LOCAL(uchar x,uchar y,uchar *p);
void LCD_cblank(uchar x,uchar y);
void LCD_count(long s,uchar x1,uchar y1,uchar x,uchar y,uchar *p);
void LCD_bai();
void Delay1ms(unsigned int count);
/***************************1秒延时子程序start***************************/
void Delay1ms(unsigned int count)
{
unsigned int i,j;
for(i=0;i
}
/***************************1秒延时子程序end***************************/
void DELAY(uchar t)
{
while(--t);
}
void LCD_SEND(uchar date)
{
uchar i;
LCD_SCLK=0;
for(i=0;i<8;i++)
{
LCD_SID=date&0x80;
LCD_SCLK=1;
LCD_SCLK=0;
date<=1;
}
}
void LCD_SCOM(bit st,uchar date)
{
uchar st_temp,hdate,ldate;
if(st)
st_temp=0xfa;
else st_temp=0xf8;
hdate=date&0xf0;
ldate=date&0x0f;
ldate <= 4;
LCD_CS = 1;
LCD_SEND(st_temp);
LCD_SEND(hdate);
LCD_SEND(ldate);
LCD_CS = 0;
DELAY(38);
}
void LCD_DELAY(void)
{ uchar s;
s=10;
while(--s)
DELAY(250);
}
void LCD_INIT(void)
{
LCD_SCOM(0,0x30);
LCD_DELAY();
LCD_SCOM(0,0x0c);
LCD_DELAY();
LCD_SCOM(0,0x01); //清屏,将DDRAM的地址计数器归零
LCD_DELAY();
}
void LCD_write(uchar *p)
{
while(*p)
{
LCD_SCOM(1,*p);
p++;
}
}
void LCD_LOCAL(uchar x,uchar y,uchar *p) //lcd string (x,y) write!
{
switch (x)
{
case 1:LCD_SCOM(0,0x7f+y); LCD_write(p);break;
case 2:LCD_SCOM(0,0x8f+y); LCD_write(p);break;
case 3:LCD_SCOM(0,0x87+y); LCD_write(p);break;
case 4:LCD_SCOM(0,0x97+y); LCD_write(p);break;
default :LCD_SCOM(0,0x7f+y); LCD_write(p);
}
}
void LCD_cblank(uchar x,uchar y)
{
switch (x)
{
case 1:LCD_SCOM(0,0x7f+y); LCD_SCOM(0,0x0d);break;
case 2:LCD_SCOM(0,0x8f+y); LCD_SCOM(0,0x0d);break;
case 3:LCD_SCOM(0,0x87+y); LCD_SCOM(0,0x0d);break;
case 4:LCD_SCOM(0,0x97+y); LCD_SCOM(0,0x0d);break;
default :LCD_SCOM(0,0x7f+y); LCD_SCOM(0,0x0d);
}
}
/*******************************************/
/********************************************/
main()
{ //main start
Delay1ms(1000);
LCD_INIT();
Delay1ms(1000);
LCD_LOCAL(1,1,"单片机教学实验板");
LCD_LOCAL(2,1,"LCD12864显示程序");
LCD_LOCAL(3,1,"版本:V1.1 ");
LCD_LOCAL(4,1,"2011年03月12日 ");
while(1);
}
单片机LCD12864液晶显 相关文章:
- PIC单片机驱动LCD12864液晶显示闪动字体程序(12-02)
- 基于51单片机运用LCD12864液晶显示(11-22)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)