聯(lián)系人:劉小姐,李小姐,王小姐
Tel:010-62000662,62051209
Fax:010-82036512
Mobile:13701081790
Email:bjqingda@126.com
Web:www.tsingtek.com
QQ:453189731
微信:13701081790
地址:北京市海淀區(qū)花園東路32號(hào)花園公寓A402室中文液晶模塊 240128 RA8822主控 樣例程序
RA8822是一款帶中文字庫(kù)的液晶模塊驅(qū)動(dòng)控制器,廣泛應(yīng)用于液晶模塊的驅(qū)動(dòng)控制,清達(dá)光電HG2401288采用了這種主控IC。
中文液晶模塊 240128 RA8822主控 樣例程序:
//本程序?yàn)镠G2401288 模塊的基本驅(qū)動(dòng)程序
//程序的顯示結(jié)果為:
//“
//清達(dá)光電科技有限公司 ”
//“
//HG2401288
#include<stdio.h>
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define lcd_bus P1
//sbit _CS=P3^2;
sbit _CS=P3^3;
sbit RS=P3^4;
sbit _WR=P3^0;
sbit _RD=P3^1;
sbit _RST=P3^5;
sbit buzy=P3^6;
sbit x=P3^3;
//----------------------------
//忙
//----------------------------
void busy()
{
while(buzy==1);
}
//----------------------------
//延時(shí)子程序
//----------------------------
void Delay(uint m)
{
uint i;
uint j;
for(i=0;i<m;i++)
for(j=0;j<109;j++);
}
//----------------------------
//寫入寄存器地址或參數(shù)
//----------------------------
void writecom(uchar command)
{
busy();
lcd_bus =command;
_CS=0;
RS=0;
_WR=0;
_WR=1;
RS=1;
_CS=1;
}
//----------------------------
//寫入數(shù)據(jù)
//----------------------------
void writedat(uchar ddata)
{
busy();
lcd_bus =ddata;
_CS =0;
RS=1;
_WR=0;
_nop_();_nop_();_nop_(); _nop_();
_WR=1;
RS=0;
_CS=1;
}
//----------------------------
//顯示文本
//----------------------------
void ShowText(uchar *text)
{
while(*text>0)
{
writedat(*text);
text++;
}}
/**********************************************
地址定義 ,x為一個(gè)字節(jié),y為一行
********************************************/
void xy(uchar x,uchar y)
{
uchar i;
writecom(0x60);writecom(0x3f&x);
writecom(0x70);writecom(0xff&y);
_nop_();
}
//----------------------------
//顯示文本
//----------------------------
void writeText(uchar x,uchar y,uchar *text)
{
xy(x,y);
while(*text>0)
{
writedat(*text);
text++; Delay(100);
}
}
void writeText1(uchar x,uchar y,uchar *text)
{
xy(x,y);
while(*text>0)
{
writedat(*text);
text++;
}
}
/*********************************************
初始化
**********************************************/
void Init()
{
_RST= 0;
buzy=1;
Delay(25);
buzy=0;
_RST= 1;
Delay(100);
writecom(0x00);writecom(0xcd); //開(kāi)電源,文本模式,開(kāi)顯示,不閃爍,不反白
writecom(0x01);writecom(0xf1); // CLK_OUT 致能控制, 高觸發(fā),4M
writecom(0x02);writecom(0x10); //60ns的讀取速度
writecom(0x03);writecom(0x80); //byte正常,com and seg不卷動(dòng)
writecom(0x10);writecom(0x68); //中英問(wèn)對(duì)齊,字體正常
writecom(0x11);writecom(0x10); // 光標(biāo)高度為一,行距為0
writecom(0x12);writecom(0x91); //水平移動(dòng),選擇DDRAM1,
writecom(0x20);writecom(0x1d); // 工作窗右邊 29*8=232
writecom(0x30);writecom(0x7f); // 工作窗低邊 127
writecom(0x40);writecom(0x00); // 工作窗左邊 00
writecom(0x50);writecom(0x00); // 工作窗頂邊 00
writecom(0x21);writecom(0x1d); // 顯示窗右邊 29*8=232
writecom(0x31);writecom(0x80); // 顯示窗低邊 127
writecom(0x41);writecom(0x00); // 顯示窗左邊 00
writecom(0x51);writecom(0x00); // 顯示窗頂邊 00
//writecom(0x80);writecom(0x33); //光標(biāo)閃爍時(shí)間設(shè)定,默認(rèn)值
writecom(0x81);writecom(0x40); // 刷新頻率 ,默認(rèn)值
//writecom(0x81);writecom(0x00); // 刷新頻率
//writecom(0x91);writecom(0x00); // 刷新頻率 ,默認(rèn)值
//writecom(0xd0);writecom(0x00); //LCD 亮度控制(DAC 功能)
//writecom(0x90);writecom(0x0a);
writecom(0x90);writecom(0x12); //XCK 訊號(hào)周期
//writecom(0xf0);writecom(0x08); //**命令 ,*好不用
//writecom(0xe0);writecom(0x00);
}
//----------------------------
//清屏
//----------------------------
void CleanScreen1(uchar m)
{
uchar i,j;
writecom(0x00);writecom(0xc5); //開(kāi)電源,圖形模式,開(kāi)顯示,不閃爍,不反白
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x00);
for(i=0;i<1;i++)
{ for(j=0;j<1;j++)
writedat(m);
}
Delay(500);
writecom(0x00);writecom(0xcd); //開(kāi)電源,文本模式,開(kāi)顯示,不閃爍,不反白
}
//----------------------------
//清屏
//----------------------------
void CleanScreen(uchar m)
{
uchar i,j;
writecom(0x00);writecom(0xc5); //開(kāi)電源,圖形模式,開(kāi)顯示,不閃爍,不反白
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x00);
for(i=0;i<128;i++)
{for(j=0;j<30;j++)
writedat(m);
}
Delay(500);
writecom(0x00);writecom(0xcd); //開(kāi)電源,文本模式,開(kāi)顯示,不閃爍,不反白
}
//----------------------------
//隔點(diǎn)
//----------------------------
void dotScreen(uchar m)
{
uchar i,j;
writecom(0x00);writecom(0xc5); //開(kāi)電源,圖形模式,開(kāi)顯示,不閃爍,不反白
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x00);
for(j=0;j<64;j++)
{
for(i=0;i<30;i++)
writedat(m);
for(i=0;i<30;i++)
writedat(~m);
}
Delay(500);
writecom(0x00);writecom(0xcd); //開(kāi)電源,文本模式,開(kāi)顯示,不閃爍,不反白
}
//----------------------------
//邊框
//----------------------------
void biank()
{
uchar i,j;
writecom(0x00);writecom(0xc5);//開(kāi)電源,圖形模式,開(kāi)顯示,不閃爍,不反白
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x00);
for(i=0;i<30;i++)
{
writedat(0xff);
}
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x7f);
for(i=0;i<30;i++)
{
writedat(0xff);
}
writecom(0x12);writecom(0x11); //先垂直移動(dòng)再水平移動(dòng)
writecom(0x60);writecom(0x00);
writecom(0x70);writecom(0x01);
for(i=0;i<126;i++)
{
writedat(0x80);
}
writecom(0x60);writecom(0x3d);
writecom(0x70);writecom(0x01);
for(i=0;i<126;i++)
{
writedat(0x01);
}
writecom(0x12);writecom(0x91);
writecom(0x00);writecom(0xcd); //開(kāi)電源,文本模式,開(kāi)顯示,不閃爍,不反白
}
/*******************************************************
文本寫入
*******************************************************/
void text()
{
//biank();
writecom(0xf1);writecom(0x1f);
writecom(0x60);writecom(0x04);
writecom(0x70);writecom(0x20);
ShowText("清達(dá)光電");
writecom(0xf1);writecom(0x0f);
writecom(0x60);writecom(0x0c);
writecom(0x70);writecom(0x30);
ShowText("科技有限公司");
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x5f);
writecom(0x10);writecom(0x79);
writecom(0x60);writecom(0x06);
writecom(0x70);writecom(0x40);
ShowText("HG2401288");
Delay(600);
/*
writecom(0x00);writecom(0xcc); // 文本 反白顯示
Delay(600);
writecom(0x03);writecom(0xc4); // 設(shè)定Common 的自動(dòng)卷動(dòng)
Delay(60000);
writecom(0x00);writecom(0xcd);
writecom(0xf1);writecom(0x0f);
writecom(0x60);writecom(0x08);
writecom(0x70);writecom(0x70);
ShowText("杭州佳顯科技有限公司HANGZHOU.");
Delay(6000);
*/
}
void tx11 () interrupt 3 using 2
{
if(~x)
{
Delay(60000);
}
}
/*******************************************************
向下卷動(dòng)
************************************************************/
void lcd_up()
{
uchar i;
for(i=0;i<240;i++)
{
writecom(0x03);writecom(0xc4); // 設(shè)定Common 的自動(dòng)卷動(dòng)
Delay(400);}
}
/*******************************************************
向左卷動(dòng)
************************************************************/
void lcd_left()
{
uchar i,j;
for(j=0;j<30;j++)
{
writecom(0x03);writecom(0xc3); // 設(shè)定seg 的自動(dòng)卷動(dòng)
Delay(600);}
}
/*****************只能向左和想下卷動(dòng)*****************************/
//----------------------------
//主程序
//----------------------------
main()
{
uchar i;
IE=0X88;
IP=0X08;
IT0=0;
Init();
while(1)
{
CleanScreen(0x00);i=0;
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x0f);
writeText(0,0,"清達(dá)光電提供內(nèi)置中文字庫(kù)產(chǎn)品:直接提取中文和西文,控制器RA8822是一個(gè)雙圖層(Two Pages)中英文文字與繪圖模式的點(diǎn)矩陣液晶顯示(LCD)控制器,內(nèi)建512K Byte 的字型碼,可以顯示中文字形,英日歐文字等字母,產(chǎn)品型號(hào)為:");
writecom(0xf1);writecom(0x4f);
writeText1(0,112,"HG2401288-F-LWH");
Delay(1200);
do
{
CleanScreen(0x00);
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x4f);
writeText1(2,0,"水平放大演示");
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x4f);
writeText1(2,50,"豎直放大演示");
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x0f);
writeText1(0,25,"2401288");
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x4f);
writeText1(2,70,"2 4 0 1 2 8 8");
Delay(1200);
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x4f);
writeText1(0,25,"2401288");
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x5f);
writeText1(2,70,"2 4 0 1 2 8 8");
Delay(1200);
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x8f);
writeText1(0,25,"2401288");
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x6f);
writeText1(2,70,"2 4 0 1 2 8 8");
Delay(1200);
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0xcf);
writeText1(0,25,"2401288");
writecom(0xf0);writecom(0xa0);
writecom(0xf1);writecom(0x7f);
writeText1(2,70,"2 4 0 1 2 8 8");
Delay(1200);i++;}while(i<5);
}}