不带字库的12864液晶汉字显示程序
菜鸟学习51单片机之12864液晶(无字库)
/* 选择屏幕来清屏 */
菜鸟学习 51 单片机
while(1)世界
void Lcd12864Clear(uint8 selet)
{
uint8 i,j;
Lcd12864SeletScreen(selet); //选择屏,分左屏和又屏,这个函数在程序中有
for(i = 0;i < 8 ;i++)
二.写入地址
void Lcd12864Point(uint8 page,uint8 x,uint8 y)
{
Lcd12864Write(CMD,0xb8 + page);
//确定页
Lcd12864Write(CMD,0xC0 + x);
//设定起始行
Lcd12864Write(CMD,0x40 + y);
菜鸟学习 51 单片机
while(1)世界
现在开始讲解如何使用,看这篇讲解前,请先到网盘去下载本教 程的仿真图和程序,结合起来更容易明白。
上图是仿真的结果。 在仿真软件中找出的 12864 液晶是没有字库的,对于仿真软件中 液晶的控制和平常的有点不同。一块液晶是由两块 64×64 的液晶显 示模块组合而成。下面是各管脚的介绍。
//有 8 页,循环 8 次
{
Lcd12864Point(i,0,0); //这个就是上面讲到的函数,确定位置
for(j = 0 ;j < 64;j++) //每一块液晶显示模块有 64 列
{
Lcd12864Write(DAT,0x00); //写入 0x00 来清屏
}
}
}
具体的使用如下:初始化函数中调用了清全屏 Lcd12864Clear(3); //清全屏
protues中无字库12864汉字显示程序
lie1=0;
}
page=5;
lie1=0;
for(i=0;i<8;i++)
{
if(i<4)
screen(0);
else
screen(1);
show1616(page,lie1,address);
lie1+=16;
if(lie1>63)
lie1=0;
address+=32;
}
screen(2);
{
uchar i;
page(pa);
lie(li);
for(i=0;i<16;i++)
dat(*(add++));
page(pa+1);
lie(li);
for(i=0;i<16;i++)
dat(*(add++));
}
void main()
{
uchar i,page,lie1;
uchar *address;
}
void line(uchar line)
{
line=line&0x3f;
line=line|0xc0;
com(line);
}
void onoff(uchar onoff)
{
if(onoff==1)
com(0x3f);
else
com(0x3e);
}
void reset()
{
reset1=0;
delay(2);
0x80,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x80,0x00,
LCD12864显示中文及图片C程序
/****************************************屏幕显示驱动*****************************************/#include "GT23L24T3Y.h"#include "print.h"#include <stdio.h>#include <string.h>#include "bmp_picture.h"#include "lcd_12864.h"#include "..\user\rtc.h"u8 comTable[]={4,5,6,7,3,2,1,0};extern void Setlcd_Addr ( u8 row,u8 column );//外部函数调用声明extern u8 Num_Code[];//字库获得函数extern u8 Big_Num_Code[];//字库获得函数extern u8 Picture_Code[];//字库获得函数extern u8 arrow1[];extern u8 arrow2[];u8 testlcd[]="测试数据";/************************************************************************//显示中文输出//函数名:print_16//功能:显示16x16点阵字符串。
// 函数名:print_16// 功能:显示16点阵字符串// 形参:// row:x轴// column:y轴// *lcd:显示字符串// logic:显示取反// wei.显示位值// len长度*************************************************************************/void _print_15 ( u8 row,u8 column,const char *lcd,u8 logic ,u8 wei,u8 len){u8 w=0,x=0,y=0,l=0,read_data=0;u8 Length=0;GT_cs1;//字库片选至高for ( l=len; l>0; l=l-2 ) //总字节{w=*lcd;if ( w&0x80 ) //为1则为汉字,为0则为ASCII码{GT_cs0; //字库片选选定GT23_Write ( GT23_write_15 ( lcd ) ); //写入字库指令以及文字地址for ( x=0; x<2; x++ ){Setlcd_Addr (row,column);for(y=0;y<16;y++){read_data=GT23_Read();if(logic == true){// read_data = ~read_data;}WriteData(read_data );}row++;}GT_cs1;//字库片选至高row-=2;column+=16;if(column>=128){row+=2;column=0;}lcd=lcd+2;}}}/************************************************************************//描述:显示中文输出//使用:顶层函数调用参数:row 行column 列*lcd 字符串logic 反白*************************************************************************/ void print_15 ( u8 row,u8 column,const char *lcd,u8 logic ){u8 c=strlen ( lcd );_print_15(row,column,lcd,logic,0,c);}/************************************************************************ //描述:显示图片输出//使用:顶层函数调用参数:row 行column 列*lcd 字符串logic 反白*************************************************************************/ void print_array(u16 row,u16 column,u16 size_x,u16 size_y,const u8 *ptr, u8 logic){u8 w=0,x=0,y=0,l=0,read_data=0;u8 Length=0;for( x=0;x<size_x/8;x++){Setlcd_Addr (row,column);for(y=0;y<size_y;y++){read_data=*( ptr + (y+x*size_y) );if(logic == true){read_data = ~read_data;}WriteData1(read_data);// WriteData1(0XFF);}row++;}}u8 OpMgsCode[][10] ={"病人信息","循环播放","房号与床号","从机音量","对比度","广播""恢复","音乐","主机音量","时间"};u8 DayCode[][7]={"星期天","星期一","星期二","星期三","星期四","星期五","星期六"};void PrintMainFace(time mytime,u8 PeopleNum){//待机界面函数u8 Hrd,Ten,One;Lcd_Clr();//清屏print_15 ( 0,16, "月",false );print_15 ( 0,48, "日",false );print_15 ( 0,70, &DayCode[mytime.day][0],false );//显示星期//日期显示Ten=mytime.month/10;One=mytime.month%10;print_array(0 , 0, 16 , 7 , &Num_Code[Ten*14], false);print_array(0 , 8, 16 , 7 , &Num_Code[One*14], false);Ten=mytime.date/10;One=mytime.date%10;print_array(0 , 32, 16 , 7 , &Num_Code[Ten*14], false);print_array(0 , 40, 16 , 7 , &Num_Code[One*14], false);//时间显示Ten=mytime.hour/10;One=mytime.hour%10;print_array(2 , 20, 32 , 21 , &Big_Num_Code[Ten*84], false);print_array(2 , 42, 32 , 21 , &Big_Num_Code[One*84], false);Ten=mytime.minute/10;One=mytime.minute%10;print_array(2 , 68, 32 , 21 , &Big_Num_Code[Ten*84], false);print_array(2 , 90, 32 , 21 , &Big_Num_Code[One*84], false);//住院人数显示print_15 ( 6,32, "住院人数",false );Hrd=PeopleNum/100;PeopleNum=PeopleNum%100;Ten=PeopleNum/10;One=PeopleNum%10;if(Hrd ){print_array(6 , 96, 16 , 7 , &Num_Code[Hrd*14], false);}print_array(6 , 102, 16 , 7 , &Num_Code[Ten*14], false);print_array(6 , 110, 16 , 7 , &Num_Code[One*14], false);}void PrintPictureFace(u8 Index){time mytime;Lcd_Clr();//清屏mytime.month = 10;mytime.date = 16;mytime.hour = 12;mytime.minute = 15;mytime.day =3;PrintMainFace(mytime,96);//print_array(0 , 10, 48 , 8 , arrow1, false);//左箭头显示// print_array(0,38 ,48 ,48 , &Picture_Code[288*Index], false);//图片显示// print_array(0,108, 48 , 8 , arrow2, false); //右箭头显示//print_15 ( 6,33, &OpMgsCode[0][Index],false );//提示信息显示}。
12864并行显示中文
以下是我写的12864LCD并行口显示程序,矩阵键盘接的是P1口,P0口接LCD上DB0~ DB7。
/***************头文件******************************/#define _12864_h/*****包含头文件**************/#include<reg51.h>/********定义I/0口**********/#define LCD12864_DATA P0#define GPIO_KEY P1sbit LCD12864_E = P2^7;sbit LCD12864_RW = P2^5;sbit LCD12864_RS = P2^6;sbit LCD12864_RET= P2^0;sbit LCD12864_PSB =P2^2;/*声明全局变量*/extern unsigned char keyvalue;/******声明全局函数*********/void Delay1ms(unsigned int); //声明延时函数unsigned char KeyDown(void);void BusyChk_12864(void); //声明忙检测函数void WrCom(unsigned char); //声明写入命令函数//unsigned char ReDat(void); //声明读数据函数void WrDat(unsigned char); //声明写数据函数void LcdInit(void); //12864初始化函数void SetAddress(unsigned char ,unsigned char); //设置地址转换void DisplayString(unsigned char ,unsigned char,unsigned char *p);//行显示字符#endif//***************************12864.c文件*****************************//#include"12864.h"#include<reg51.h>#include"string.h"#define LCM_ST7920_FIRST_LINE_ADDRESS 0x80#define LCM_ST7920_SECOND_LINE_ADDRESS 0x90#define LCM_ST7920_THIRD_LINE_ADDRESS 0x88#define LCM_ST7920_FOURTH_LINE_ADDRESS 0x98/*定义全局变量*/unsigned char keyvalue=0;/****************************************************************************** ** 函数名: Delay1ms* 函数功能: 延时函数,延时1ms* 输入: c* 输出 e : 无* 说名: 该函数是在12MHZ晶振下,12分频单片机的延时。
不带字库12864程序实例
/******************************************************************** *************************///程序部分开始///******************************************************************** *************************//头文件定义///******************************************************************** *************************/#include <reg52.h> // 包含头文件#include <string.h> //用于指针/******************************************************************** *************************//接口定义///******************************************************************** *************************/#define LCM12864_DB7_DB0 P0 // 定义LCM12864的数据总线sbit LCM12864_RS = P2 ^ 3; // 定义LCM12864的RS控制线sbit LCM12864_RW = P2 ^ 4; // 定义LCM12864的RW控制线sbit LCM12864_E = P2 ^ 2; // 定义LCM12864的E控制线sbit LCM12864_CS1 = P2 ^ 7; // 定义LCM12864的CS1控制线sbit LCM12864_CS2 = P2 ^ 6; // 定义LCM12864的CS2控制线sbit LCM12864_RESET = P2 ^ 5; // 定义LCM12864的RESET控制线sbit LCM12864_LEDK = P2 ^ 0; // 定义LCM12864的LEDK(BLK)控制线/******************************************************************** *************************//数据定义//定义LCM12864的命令字/******************************************************************** *************************/#define LCM12864_DISP_ON 0x3f // 打开LCM12864显示#define LCM12864_DISP_OFF 0x3e // 关闭LCM12864显示#define LCM12864_START_ROW 0xc0 // 显示起始行0,可以用LCM12864_START_ROW+x设置起始行。
无字库12864液晶屏滚动显示程序共17页文档
无字库12864液晶屏滚动显示程序[转] #include<reg52.h>#include<intrins.h>#include<absacc.h>#define Lcd_Bus P0 //MCU P0<------> LCM#define Disp_On 0x3f//开显示#define Disp_Off 0x3e//关显示#define Col_Add 0x40//列地址#define Page_Add 0xb8//页地址#define Start_Line 0xc0//起始页sbit cs1=P2^3; //Master chip enablesbit cs2=P2^4; //Slave chip enablesbit Enable=P2^2; // mode Enable singlesbit Di=P2^0; //Data or Instrument Selectsbit RW=P2^1; //Write or Readsbit Lcd_Rst=P2^5; //Lcm reset/*****************************字模,此字体下对应的点阵为:宽x高=16x16*****************************/unsigned char code Chinese_character[][32]={{0x02,0xF2,0x12,0x12,0x12,0xFE,0x12,0x12,0x12,0xFE,0x12,0x12,0x 12,0xF2,0x02,0x00 ,0x00,0x7F,0x28,0x24,0x22,0x21,0x20,0x20,0x20,0x21,0x22 ,0x22,0x22,0x7F,0x00,0x00},/*"西",0*/{0x80,0x90,0x8C,0x84,0x84,0xF4,0xA5,0x86,0x84,0x84,0x84,0x84,0x 94,0x8C,0x84,0x00,0x80,0x80,0x80,0x40,0x47,0x28,0x28,0x10,0x28,0x24,0x43 ,0xC0,0x40,0x00,0x00,0x00},/*"安",1*/{0x00,0x42,0x62,0x5A,0xC6,0x10,0x54,0x54,0x54,0xFF,0x54,0x54,0x 7C,0x10,0x10,0x00,0x40,0x23,0x14,0x08,0x17,0x28,0x29,0x49,0x49,0x7F,0x49 ,0x49,0x49,0x49,0x40,0x00},/*"建",2*/{0x10,0x48,0x47,0xCC,0x54,0x44,0x14,0xE8,0x27,0x24,0x2C,0xF4,0x 04,0x04,0x04,0x00,0x10,0x30,0x10,0x0F,0x88,0x48,0x30,0x0F,0x01,0x06,0x00 ,0x3F,0x40,0x40,0x70,0x00},/*"筑",3*/{0x10,0x12,0x92,0x72,0xFE,0x51,0x91,0x00,0x22,0xCC,0x00,0x00,0x FF,0x00,0x00,0x00,0x04,0x02,0x01,0x00,0xFF,0x00,0x04,0x04,0x04,0x02,0x02 ,0x02,0xFF,0x01,0x01,0x00},/*"科",4*/{0x08,0x08,0x88,0xFF,0x48,0x28,0x00,0xC8,0x48,0x48,0x7F,0x48,0x C8,0x48,0x08,0x00,0x01,0x41,0x80,0x7F,0x00,0x40,0x40,0x20,0x13,0x0C,0x0C ,0x12,0x21,0x60,0x20,0x00},/*"技",5*/{0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x7F,0xA0,0x20,0x20,0x20,0x 20,0x20,0x20,0x00,0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x01,0x06,0x08 ,0x30,0x60,0xC0,0x40,0x00},/*"大",6*/{0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x 57,0x32,0x10,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02 ,0x02,0x02,0x02,0x02,0x00},/*"学",4*/{0x00,0x02,0x1C,0xE8,0x00,0x40,0x60,0x58,0x47,0x22,0x20,0x28,0x 30,0xE0,0x40,0x00,0x02,0x02,0x7F,0x00,0x00,0x00,0x7F,0x21,0x21,0x21,0x21 ,0x21,0x7F,0x00,0x00,0x00},/*"冶",0*/{0x40,0x40,0x20,0x20,0x50,0x48,0x44,0xC3,0x44,0x48,0x50,0x50,0x 20,0x60,0x20,0x00,0x40,0x40,0x42,0x42,0x4A,0x72,0x42,0x7F,0x42,0x62,0x5A ,0x42,0x42,0x40,0x40,0x00},/*"金",1*/{0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x 02,0x02,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x00},/*"工",2*/{0x10,0x12,0xD2,0xFE,0x91,0x11,0x80,0xBF,0xA1,0xA1,0xA1,0xA1,0x BF,0x80,0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44 ,0x44,0x44,0x44,0x40,0x00},/*"程",3*/{0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x 57,0x32,0x10,0x00,0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02 ,0x02,0x02,0x02,0x02,0x00},/*"学",4*/{0xFE,0x02,0x32,0x4A,0x86,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x 24,0x0C,0x04,0x00,0xFF,0x00,0x02,0x04,0x83,0x41,0x31,0x0F,0x01,0x01,0x7F ,0x81,0x81,0x81,0xF1,0x00},/*"院",5*/{0x10,0x10,0xD0,0xFE,0x50,0x90,0x00,0x10,0x10,0x10,0xD0,0xFE,0x 10,0x10,0x10,0x00,0x08,0x06,0x01,0xFF,0x00,0x01,0x10,0x08,0x04,0x43,0x80 ,0x7F,0x00,0x00,0x00,0x00},/*"材",0*/{0x20,0x24,0xA8,0x70,0xFF,0x68,0xA4,0x20,0x42,0x8C,0x00,0x00,0x FF,0x00,0x00,0x00,0x08,0x06,0x01,0x00,0xFF,0x00,0x01,0x02,0x02,0x03,0x02 ,0x02,0xFF,0x01,0x01,0x00},/*"料",1*/{0x00,0x08,0x08,0x08,0xFF,0x08,0x08,0xF8,0x00,0xF8,0x08,0x 08,0x08,0xF8,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x20,0x40,0x3F,0x00,0x7F,0x10 ,0x10,0x10,0x3F,0x00,0x00},/*"加",2*/{0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x 02,0x02,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x00},/*"工",4*/{0x00,0x00,0x02,0x02,0x02,0x02,0x02,0xFE,0x02,0x02,0x02,0x02,0x 02,0x02,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0x20 ,0x20,0x20,0x20,0x20,0x00},/*"工",4*/{0x10,0x12,0xD2,0xFE,0x91,0x11,0x80,0xBF,0xA1,0xA1,0xA1,0xA1,0x BF,0x80,0x00,0x00,0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44 ,0x44,0x44,0x44,0x40,0x00},/*"程",5*/};unsigned char code E[][16]={{0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00},/*"C",0*/{0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x 20,0x00,0x01,0x00},/*"r",1*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x 22,0x22,0x3F,0x20},/*"a",2*/{0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x 24,0x24,0x19,0x00},/*"s",3*/{0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x 18,0x06,0x01,0x00},/*"y",4*/{0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x 20,0x11,0x0E,0x00},/*"b",5*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x 20,0x20,0x1F,0x00},/*"o",6*/{0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x 18,0x06,0x01,0x00},/*"y",7*/{0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x 22,0x22,0x13,0x00},/*"e",8*/};/***********************延时子程序***********************/ void delay(unsigned int k){unsigned int i;unsigned int j;for(i=0;i<k;i++)for(j=0;j<20;j++);}/***********************写命令左***********************/ void write_cmd_1(unsigned char command){cs1=1;cs2=0;Di=0;RW=0;Lcd_Bus=command; //P0口delay(0);Enable=1;delay(0);Enable=0;}/***********************写命令右***********************/ void write_cmd_2(unsigned char command){cs1=0;cs2=1;Di=0;RW=0;Lcd_Bus=command;delay(0);Enable=1;delay(0);Enable=0;}/***********************写数据左***********************/ void write_data_1(unsigned char dis_data){cs1=1;cs2=0;Di=1;RW=0;Lcd_Bus=dis_data;delay(0);Enable=1;delay(0);Enable=0;}/***********************写数据右***********************/ void write_data_2(unsigned char dis_data){cs1=0;cs2=1;Di=1;RW=0;Lcd_Bus=dis_data;delay(0);Enable=1;delay(0);Enable=0;}/***********************清内存左***********************/ void clear_1(void){unsigned char j,k;cs1=1;cs2=0;write_cmd_1(Page_Add+0);write_cmd_1(Col_Add+0);for(k=0;k<8;k++){write_cmd_1(Page_Add+k);for(j=0;j<64;j++)write_data_1(0x00);}}/***********************清内存右***********************/ void clear_2(void){unsigned char j,k;cs1=0;cs2=1;write_cmd_2(Page_Add+0);write_cmd_2(Col_Add+0);for(k=0;k<8;k++){write_cmd_2(Page_Add+k);for(j=0;j<64;j++)write_data_2(0x00);}}/***********************显示汉字16*16左************************/void Chinese_disp_1(unsigned char pag,unsigned char col,unsigned char n){unsigned char i=0;unsigned char j=0;cs1=1;cs2=0;for(i=0;i<2;i++){write_cmd_1(Page_Add+pag+i);write_cmd_1(Col_Add+col);for(j=0;j<16;j++)write_data_1(Chinese_character[n][16*i+j]);}}/***********************显示汉字16*16右***********************/ void Chinese_disp_2(unsigned char pag,unsigned char col,unsigned char n){unsigned char i=0;unsigned char j=0;cs1=0;cs2=1;for(i=0;i<2;i++){write_cmd_2(Page_Add+pag+i);write_cmd_2(Col_Add+col);for(j=0;j<16;j++)write_data_2(Chinese_character[n][16*i+j]);}}/***********************显示英文16*8左************************/ void E_disp_1(unsigned char pag,unsigned char col,unsigned char n) {unsigned char i=0;unsigned char j=0;cs1=1;cs2=0;for(i=0;i<2;i++){write_cmd_1(Page_Add+pag+i);write_cmd_1(Col_Add+col);for(j=0;j<8;j++)write_data_1(E[n][8*i+j]);}}/***********************显示英文16*8右***********************/ void E_disp_2(unsigned char pag,unsigned char col,unsigned char n) {unsigned char i=0;unsigned char j=0;cs1=0;cs2=1;for(i=0;i<2;i++){write_cmd_2(Page_Add+pag+i);write_cmd_2(Col_Add+col);for(j=0;j<8;j++)write_data_2(E[n][8*i+j]);}}/***********************液晶屏初始化***********************/ void init_lcd(){Lcd_Rst=0;delay(100);Lcd_Rst=1;delay(100);write_cmd_1(Disp_Off); write_cmd_2(Disp_Off);write_cmd_1(Page_Add+0); write_cmd_2(Page_Add+0);write_cmd_1(Start_Line+0); write_cmd_2(Start_Line+0);write_cmd_1(Col_Add+0); write_cmd_2(Col_Add+0);write_cmd_1(Disp_On); write_cmd_2(Disp_On);}/***********************LCD显示子程序***********************/ void display(void){unsigned char i;for(i=Start_Line;i<0xff;i++){Chinese_disp_1(0,0, 0);Chinese_disp_1(0,16,1);Chinese_disp_1(0,32,2);Chinese_disp_1(0,48,3);Chinese_disp_2(0,0, 4);Chinese_disp_2(0,16,5);Chinese_disp_2(0,32,6);Chinese_disp_2(0,48,7);//西安建筑科技大学Chinese_disp_1(2,16,8);Chinese_disp_1(2,32,9);Chinese_disp_1(2,48,10);Chinese_disp_2(2,0,11);Chinese_disp_2(2,16,12);Chinese_disp_2(2,32,13);//冶金工程学院Chinese_disp_1(4,16,14);Chinese_disp_1(4,32,15);Chinese_disp_1(4,48,16);Chinese_disp_2(4,0,17);Chinese_disp_2(4,16,18);Chinese_disp_2(4,32,19);//材料加工工程E_disp_1(6,24,0);E_disp_1(6,32,1);E_disp_1(6,40,2);E_disp_1(6,48,3);E_disp_1(6,56,4);E_disp_2(6,0,5);E_disp_2(6,8,6);E_disp_2(6,16,7);E_disp_2(6,24,8);//Crasyboyewrite_cmd_1(i);write_cmd_2(i);delay(3000);//调整滚动速度}//delay(60000);}/***********主程序************/ void main(void){ init_lcd();clear_1();clear_2();while(1){display();}}希望以上资料对你有所帮助,附励志名言3条:1、宁可辛苦一阵子,不要苦一辈子。
LCD12864(不带字库)
LCD12864(不带字库)LCD12864(不带字库)其实看了本版的1602教程以后很容易就可以掌握12864了。
刚才看到有网友要12864教程,俺就把博客里以前练习的一个程序弄过来,算作参考吧。
不足之处请见谅。
这个程序浪费了我很多时间,因为我一直没有找到datasheet,12864的型号实在太多了。
为了这个程序,我在网上找了很多相关的例程,但大多都是C语言写的,可惜俺没学过C,用起来不顺手,遂将其转成汇编,但是转后,程序运行不正常,郁闷啊。
好不容易找个汇编的吧,又写得很乱,没有头绪,没有datasheet,看起来很费劲,最后终于找到一个相关的datasheet,这才完成这个程序。
总结一下:与其费力分析别人的程序,不如看datasheet自己写。
下面总结一下datasheet。
→↑←ONE→且看datasheet:12864点阵型LCD简介12864是一种图形点阵液晶显示器,它主要由行驱动器/列驱动器及128×64全点阵液晶显示器组成。
可完成图形显示,也可以显示8×4个(16×16点阵)汉字。
在使用12864LCD前先必须了解以下功能器件才能进行编程。
12864内部功能器件及相关功能如下:1. 指令寄存器(IR)IR是用于寄存指令码,与数据寄存器数据相对应。
当D/I=0时,在E信号下降沿的作用下,指令码写入IR。
2.数据寄存器(DR)DR是用于寄存数据的,与指令寄存器寄存指令相对应。
当D/I=1时,在下降沿作用下,图形显示数据写入DR,或在E信号高电平作用下由DR读到DB7∽DB0数据总线。
DR和DDRAM之间的数据传输是模块内部自动执行的。
3.忙标志:BFBF标志提供内部工作情况。
BF=1表示模块在内部操作,此时模块不接受外部指令和数据。
BF=0时,模块为准备状态,随时可接受外部指令和数据。
利用STATUS READ指令,可以将BF读到DB7总线,从检验模块之工作状态。
12864无字库液晶显示程序
{'l',0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},*/
{'m',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F}, /*
{'b',0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00},
{'c',0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00},
2012 年 07 月 04 日(改)*//
//*****************************************************************************
**********//
#include<reg51.h> #include<intrins.h> #define NOP _nop_() #define DAT P0 #define uint unsigned int #define uchar unsigned char
{'h',0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20},
{'i',0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00},
无字库LCD12864(无时钟芯片显示时间)
/************************************************************************** 在无字库的12864LCD上显示时、分、秒;没有用时钟芯片MCU:STC89C52晶振:11.0592MHz作者:罗元俊时间:2014.06.25**************************************************************************/ #include <reg52.h>typedef unsigned char uchar;typedef unsigned int uint;#define Port P0 // 数据端口#define Disp_On 0x3f // 开显示#define Disp_Off 0x3e // 关显示#define Col_Add 0x40 // 列地址#define Page_Add 0xb8 // 页地址#define Start_Line 0xc0 // 起始页sbit RS = P2^6;sbit RW = P2^5;sbit EN = P2^7;sbit CS1 = P3^2;sbit CS2 = P3^3;uint t = 0; //全局变量:秒表(用于计数时间的增量)uchar sec,min,hour; // 全局变量:秒、分、时uchar a,b,c,d,e,f; // 秒、分、时的个位和十位uchar code HZ_tab[][32] = {{/*-- 文字: 潜--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x20,0xC2,0x0C,0x80,0x10,0x94,0x54,0x3F,0x54,0x90,0x54,0x3F,0x54,0x94,0x10,0x00,0x04,0x04,0x7E,0x01,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x01,0x00},{/*-- 文字: 龙--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x10,0x10,0x10,0x10,0xFF,0x10,0x10,0xF0,0x10,0x11,0x16,0xD0,0x10,0x10,0x00,0x80,0x40,0x20,0x18,0x06,0x41,0x20,0x10,0x3F,0x44,0x42,0x41,0x40,0x40,0x78,0x00},{/*-- 文字: 花--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x04,0x04,0x04,0x84,0x6F,0x04,0x04,0x04,0xE4,0x04,0x8F,0x44,0x24,0x04,0x04,0x00,0x04,0x02,0x01,0xFF,0x00,0x10,0x08,0x04,0x3F,0x41,0x40,0x40,0x40,0x40,0x78,0x00},{/*-- 文字: 园--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0xFE,0x02,0x42,0x4A,0xCA,0x4A,0x4A,0xCA,0x4A,0x4A,0x42,0x02,0xFE,0x00,0x00,0x00,0xFF,0x40,0x50,0x4C,0x43,0x40,0x40,0x4F,0x50,0x50,0x5C,0x40,0xFF,0x00,0x00},{/*-- 文字: 输--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x88,0x68,0x1F,0xC8,0x08,0x10,0xC8,0x54,0x52,0xD1,0x12,0x94,0x08,0xD0,0x10,0x00,0x09,0x19,0x09,0xFF,0x05,0x00,0xFF,0x12,0x92,0xFF,0x00,0x5F,0x80,0x7F,0x00,0x00},{/*-- 文字: 入--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x00,0x00,0x00,0x00,0x00,0x01,0xE2,0x1C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x03,0x0C,0x30,0x40,0x80,0x80,0x00},{/*-- 文字: 密--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x10,0x8C,0x44,0x04,0xE4,0x04,0x95,0xA6,0x44,0x24,0x14,0x84,0x44,0x94,0x0C,0x00,0x02,0x02,0x7A,0x41,0x41,0x43,0x42,0x7E,0x42,0x42,0x42,0x43,0xF8,0x00,0x00,0x00},{/*-- 文字: 码--*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x04,0x84,0xE4,0x5C,0x44,0xC4,0x00,0x02,0xF2,0x82,0x82,0x82,0xFE,0x80,0x80,0x00,0x02,0x01,0x7F,0x10,0x10,0x3F,0x00,0x08,0x08,0x08,0x08,0x48,0x88,0x40,0x3F,0x00}};uchar code SZ_tab[][16] = {{/*-- 文字: 0 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00}, //0 {/*-- 文字: 1 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00}, //1 {/*-- 文字: 2 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00}, //2 {/*-- 文字: 3 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00}, //3 {/*-- 文字: 4 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00}, //4{/*-- 文字: 5 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00}, //5 {/*-- 文字: 6 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00}, //6 {/*-- 文字: 7 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00}, //7 {/*-- 文字: 8 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00}, //8 {/*-- 文字: 9 --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00}, //9 {/*-- 文字: - --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, //10 {/*-- 文字: : --*//*-- 新宋体12; 此字体下对应的点阵为:宽x高=8x16 --*/0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00} //11 };void delayms(uint xms) //延时子程序{uint x,y;for(x = xms;x > 0;x--)for(y = 2;y > 0;y--);}void DetBusybit(void) //忙位检测子程序{Port = 0xff; //读状态值时,先给数据端口赋高电平RS = 0;RW = 1;EN = 1;while(Port & 0x80); //如果LCD处于忙状态,程序就此停止delayms(2);EN = 0;}void LCD_WrCom_L(uchar com) // 写左半屏指令子程序{DetBusybit();CS1 = 1; CS2 = 0;RS = 0;RW = 0;EN = 1;Port = com;delayms(5);EN = 0;}void LCD_WrCom_R(uchar com) // 写右半屏指令子程序{DetBusybit();CS1 = 0; CS2 = 1;RS = 0;RW = 0;EN = 1;Port = com;delayms(5);EN = 0;}void LCD_WrDat_L(uchar dat) // 写左半屏数据子程序{DetBusybit();CS1 = 1; CS2 = 0;RS = 1;RW = 0;EN = 1;Port = dat;delayms(5);EN = 0;}void LCD_WrDat_R(uchar dat) // 写右半屏数据子程序{DetBusybit();CS1 = 0; CS2 = 1;RS = 1;RW = 0;EN = 1;Port = dat;delayms(5);EN = 0;}void Clear_L(void) // 左半屏清屏{uchar i,j;CS1 = 1; CS2 = 0;LCD_WrCom_L(Page_Add + 0);LCD_WrCom_L(Col_Add + 0);for(j = 0; j < 8; j++)LCD_WrCom_L(Page_Add + j);for(i = 0; i < 64; i++)LCD_WrDat_L(0x00);}void Clear_R(void) // 右半屏清屏{uchar i,j;CS1 = 0; CS2 = 1;LCD_WrCom_R(Page_Add + 0);LCD_WrCom_R(Col_Add + 0);for(j = 0; j < 8; j++)LCD_WrCom_R(Page_Add + j);for(i = 0; i < 64; i++)LCD_WrDat_R(0x00);}void Disp_HZ_L(uchar pag,uchar col,uchar n) // 显示左半屏汉字16*16 {uchar i = 0,j = 0;CS1 = 1; CS2 = 0;for(i = 0; i < 2; i++){LCD_WrCom_L(Page_Add + pag + i);LCD_WrCom_L(Col_Add + col);for(j = 0; j < 16; j++)LCD_WrDat_L(HZ_tab[n][16*i+j]);}}void Disp_SZ_L(uchar pag,uchar col,uchar n) // 显示左半屏数字8*16 {uchar i = 0,j = 0,k = 0;CS1 = 1; CS2 = 0;for(i = 0; i < 2; i++){LCD_WrCom_L(Page_Add + pag + i);LCD_WrCom_L(Col_Add + col);for(j = 0; j < 8; j++){LCD_WrDat_L(SZ_tab[n][8*i+j]);}}}void Disp_HZ_R(uchar pag,uchar col,uchar n) // 显示右半屏汉字16*16 {uchar i = 0,j = 0;CS1 = 0; CS2 = 1;for(i = 0; i < 2; i++){LCD_WrCom_R(Page_Add + pag + i);LCD_WrCom_R(Col_Add + col);for(j = 0; j < 16; j++)LCD_WrDat_R(HZ_tab[n][16*i+j]);}}void Disp_SZ_R(uchar pag,uchar col,uchar n) // 显示右半屏数字8*16 {uchar i = 0,j = 0;CS1 = 0; CS2 = 1;for(i = 0; i < 2; i++){LCD_WrCom_R(Page_Add + pag + i);LCD_WrCom_R(Col_Add + col);for(j = 0; j < 8; j++){LCD_WrDat_R(SZ_tab[n][8*i+j]);}}}void TimerInit(void) //定时器初始化函数{TMOD = 0x02; //设置定时器0为工作模式2TH0 = 0x47; //装初值TL0 = 0x47; //设定时间为0.2msEA = 1;ET0 = 1;TR0 = 1; //启动定时器0}void LCD_Init(void) // LCD初始化子程序{delayms(10);LCD_WrCom_L(Disp_Off); LCD_WrCom_R(Disp_Off);LCD_WrCom_L(Page_Add + 0); LCD_WrCom_R(Page_Add + 0);LCD_WrCom_L(Start_Line + 0); LCD_WrCom_R(Start_Line + 0);LCD_WrCom_L(Col_Add + 0); LCD_WrCom_R(Col_Add + 0);LCD_WrCom_L(Disp_On); LCD_WrCom_R(Disp_On); }void main(void){LCD_Init();TimerInit();Clear_L();Clear_R();while(1){sec = t%60; //秒钟分离min = (t/60)%60; //分钟分离hour = (t/3600)%60; //时钟分离a = sec%10; //秒钟个位分离b = (sec/10)%10; //秒钟十位分离c = min%10; //分钟个位分离d = (min/10)%10; //分钟十位分离e = hour%10; //时钟个位分离f = (hour/10)%10; //时钟十位分?Disp_HZ_L(0,32,0); // 第0页,第16列,第0个字Disp_HZ_L(0,48,1);Disp_HZ_R(0,0,2);Disp_HZ_R(0,16,3);Disp_SZ_L(2,24,2);Disp_SZ_L(2,32,0);Disp_SZ_L(2,40,1);Disp_SZ_L(2,48,4);Disp_SZ_L(2,56,10);Disp_SZ_R(2,0,0);Disp_SZ_R(2,8,6);Disp_SZ_R(2,16,10);Disp_SZ_R(2,24,2);Disp_SZ_R(2,32,7);Disp_SZ_L(4,32,f);Disp_SZ_L(4,40,e);Disp_SZ_L(4,48,11);Disp_SZ_L(4,56,d);Disp_SZ_R(4,0,c);Disp_SZ_R(4,8,11);Disp_SZ_R(4,16,b);Disp_SZ_R(4,24,a);Disp_HZ_L(6,0,4);Disp_HZ_L(6,16,5);Disp_HZ_L(6,32,6);Disp_HZ_L(6,48,7);Disp_SZ_R(6,0,11);}}void timer0(void) interrupt 1{uint i;i++;if(i == 5000) //1s时间到{t++; //秒表计时开始i = 0;}}。
LCD 12864液晶显示汉字程序
/*--文字: --*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
/*--文字: --*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x04,0x04,0x04,0x04,0x44,0x84,0x7E,0x05,0x04,0x04,0x04,0x04,0x04,0x04,0x00,
/*--文字: --*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x20,0x10,0x0E,0x10,0x20,0x3F,0x44,0x44,0x44,0x44,0x44,0x40,0x40,0x00,
/*--文字:地--*/
/*--宋体12;此字体下对应的点阵为:宽x高=16x16 --*/
不带字库12864仿真
} //显示一个数字 void display_a_char(uchar lcd,uchar p ,uchar c,uchar b,uchar *m) {
uchar i; select_lcd(lcd); set_page(p); set_column(c);
for(i=0;i<8;i++) {
write_data(m[i+16*b]); } set_page(p+1); set_column(c); for(i=0;i<8;i++) {
0x00,0x00,0xFF,0x00,0x80,0x81,0x45,0x29,0x11,0x2F,0x41,0x41,0x81,0x81,0x80,0x00
};
uchar code yong[] =
{
0x00,0x00,0xFE,0x22,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0xFE,0x00,0x00,0x00,
0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,
rd=1;cs=1;//停止 A/D 读取 return(i); }
uint temper(void)//ADC0804 读出的数据处理 {
uint i=0; uchar x; for(x=0;x<10;x++) { i=adc0804()+i; } i=i*2; return(i);
12864的液晶显示程序(无字库)
12864的液晶显示程序(无字库)12864.h#ifndef __12864_H__#define __12864_H__#include#include/***************************************利用I/O口模拟点阵液晶所需时序点阵液晶控制端口定义,需根据硬件适当改变****************************************/sbit LCD_RS = P2^0;//控制端口定义sbit LCD_RW = P2^1;sbit LCD_E = P2^2;sbit LCD_CSA = P2^3;//H选通,即高电平有效sbit LCD_CSB = P2^4;#define LCD_Data P0//LCD数据端口8位#define R 1#define L 2/*****************************************函数声明*****************************************/void ReadStatusLCD(unsigned char select);//从LCD读出忙标志位unsigned char ReadDataLCD(unsigned char select);//从LCD 读出数据void WriteDataLCD(unsigned char WDLCD,unsigned char select);//向LED写入数据void WriteCommandLCD(unsigned char WCLCD , unsigned char BusyC,unsigned char select);//向LCD写入命令void LcdReset(void) ;//初始化函数,完成液晶模块的初始设置void clear_LCD(unsigned char select);//清屏函数void Clr_All_Lcd(void);//全清屏函数void set_XY(unsigned char Column,unsigned char Page);//设置数据写入或读出的地址,通过页号和列数可以唯一确定一个地址void xy_Write(unsigned char Column,unsigned char Page,unsigned char dataW);//向指定行列写数据void LcmPutDots(unsigned char Column,unsigned char Page, unsigned char DotByte );//显示点void whiteword(unsigned char Column,unsigned char Page, const unsigned char puts[][16] );//显示16×16点阵的编码void WhiteWord_Com(unsigned char Column,unsigned char Page,unsigned char C_num,unsigned char V_num, unsigned char * puts );//通用的显示函数void Drawing_dot(unsigned char x,unsigned char y);void Drawing_line_vertical(unsigned x);#endif12864.c/****************************************************LCD12864点阵液晶屏,通过I/O口直接控制,采用模拟时序控制****************************************************/#include"12864.h"#include/*********************************************************** 功能:从LCD读取状态位变量:select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/ void ReadStatusLCD(unsigned char select){switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_Data = 0xff;//置位输入口,已实现输入LCD_RS=0;LCD_RW=1;LCD_E=1;//高电平读取数据//_nop_(); //若晶振速度高,可在此作延时处理while(LCD_Data&0x80);//最高位为忙标志,检测忙信号状态LCD_E=0;//_nop_(); //若晶振速度高,可在此作延时处理}/*********************************************************** 功能:从LCD读取数据变量:select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/ unsigned char ReadDataLCD(unsigned char select){unsigned char dataR;LCD_Data = 0xff;//置位输入口,已实现输入switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_RW=1;LCD_RS=1;LCD_E = 1;// 操作允许脉冲信号,高电平读出//_nop_(); //若晶振速度高,可在此作延时处理dataR = LCD_Data;LCD_E= 0;return dataR;}/***********************************************************功能:向LCD写入数据参数:WDLCD待写入的字符数据select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/void WriteDataLCD(unsigned char WDLCD,unsigned char select){switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}ReadStatusLCD(select);//检测忙标志LCD_RS = 1;LCD_RW = 0;LCD_Data = WDLCD;LCD_E = 1;//_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 0; //下降沿写入数据//_nop_(); //若晶振速度高,可在此作延时处理}/***********************************************************功能:向LCD写入命令参数:WDLCD待写入的字符数据BusyC是否要检查忙标志位选择标志,1为进行,0为不检测select用于选择LCD屏的左右,1选择左屏,2选择右屏***********************************************************/void WriteCommandLCD(unsigned char WCLCD , unsigned char BusyC,unsigned char select) {if(BusyC) ReadStatusLCD(select);//根据需要检测忙switch(select){case 1:{LCD_CSA=1;LCD_CSB=0;break;}//左case 2:{LCD_CSA=0;LCD_CSB=1;break;}//右default: break;}LCD_Data = WCLCD;LCD_RS = 0;LCD_RW = 0;LCD_E = 1;//_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 0;}/************************************************************** **************** 功能:清显示RAM区(清屏)参数:select为驱动控制器选择1为左2为右*************************************************************** **************** */void clear_LCD(unsigned char select){unsigned char i,j;for(i=0;i<8;i++){ //8页,换页清零WriteCommandLCD( 0xb8|i,1 ,select);//页面地址设置,并分别写入左右模块中WriteCommandLCD( 0x40,1 ,select);//列地址设置,设置为0列,并分别写入左右三个模块中for(j=0;j<64;j++){ //页内清零WriteDataLCD( 0 ,select);}}}/************************************************************** *************** 功能:清LCD左右屏*************************************************************** **************/ void Clr_All_Lcd(void){clear_LCD(1);clear_LCD(2);}/************************************************************** **************** 功能:LCD初始化,分为左,右模块初始化参数:select为驱动控制器选择1为左2为右*************************************************************** **************** */void LcdReset(void){unsigned char i;for(i=0;i<5;i++){WriteCommandLCD( 0xc0,0 ,R);//设置显示起始行为第一行,并分别写入左右模块中,不检测忙标志WriteCommandLCD( 0xc0,0 ,L);//_nop_(); //若晶振速度高,可在此作延时处理}WriteCommandLCD( 0xc0,1 ,R);//设置显示起始行为第一行,并分别写入左右模块中,检测忙标志WriteCommandLCD( 0xc0,1 ,L);WriteCommandLCD( 0x3f,1 ,R);//开显示设置,并分别写入左右模块中WriteCommandLCD( 0x3f,1 ,L);clear_LCD(R);//清左屏clear_LCD(L);//清右屏}/************************************************************** **************** 功能:设置数据写入或读出的地址,通过页号和列数可以唯一确定一个地址参数:Column表示列号,Page表示页号*************************************************************** **************** */void set_XY(unsigned char Column,unsigned char Page){unsigned char x,y;unsigned char select;switch (Column&0x40) //完成左右屏的判断,根据列号完成区分,<64为左屏,>=64为右屏{case 0x00: {select = 1;ReadStatusLCD(select);break;}/*为左区*/case 0x40: {select = 2;ReadStatusLCD(select);break;}/*为右区*/}x = Column&0x3F|0x40; /* col.and.0x3f.or.Set Y Address*/ y = Page&0x07|0xB8; /* row.and.0x07.or.set Page */WriteCommandLCD( y,1 ,select);//设置页面地址WriteCommandLCD( x,1 ,select);//设置列地址}/************************************************************** **************** 功能:根据地址值(页数和列号),写入数据,即写入显示缓冲区,便可以显示在LCD屏上参数:Column表示列号,Page表示页号,dataW表示待写入的数据*************************************************************** **************** */void xy_Write(unsigned char Column,unsigned char Page,unsigned char dataW){set_XY(Column,Page);LCD_RW=0;LCD_RS=1;_nop_();//若晶振速度高,可在此作延时处理LCD_Data = dataW;// 送数据_nop_(); //若晶振速度高,可在此作延时处理LCD_E = 1;_nop_(); //若晶振速度高,可在此作延时处理LCD_E= 0; // 操作允许脉冲信号,下降沿写入}/************************************************************** **************** 功能:用于显示点阵参数:Column表示列号,Page表示页号,*************************************************************** **************** */void LcmPutDots(unsigned char Column,unsigned char Page, unsigned char DotByte ){unsigned char i;i=Column;for(;Page<8;Page++){for(;Column<128;Column++){xy_Write(Column,Page,DotByte);//DotByte = ~DotByte;}Column=i;}}/************************************************************** **************** 功能:在指定列,指定页显示待显示的点阵编码,用于显示16*16点阵码参数:Column表示列号,Page表示页号,puts待显示的点阵编码首指针*************************************************************** **************** */void whiteword(unsigned char Column,unsigned char Page, const unsigned char puts[][16] ){unsigned char i,j;for(i=0;i<2;i++)//此处的2为控制点阵行数,实际点阵行数为2*8=16行,此处的16(对应的点行数)应为8的倍数{for(j=0;j<16;j++)//此处控制每行显示的列数{xy_Write(Column+j,Page+i,puts[i][j]);}}}/****************************************************************************** 功能:在指定列,指定页显示待显示指定点阵的编码参数:Column表示列号,Page表示页号,C_num为显示点阵的行数(物理行8的倍数),V_num 为列(物理列)puts待显示的点阵编码首指针*************************************************************** **************** */void WhiteWord_Com(unsigned char Column,unsigned char Page,unsigned char C_num,unsigned char V_num, unsigned char * puts){unsigned char i,j;for(i=0;i<(C_num/8);i++)//此处的2为控制点阵行数,实际点阵行数为2*8=16行,此处的16(对应的点行数)应为8的倍数{for(j=0;j<="">{xy_Write(Column+j,Page+i,*(puts+i*V_num+j));//注意地址的变化规律}}}/************************************************************** **************** 功能:绘点参数:Column表示列号,Page表示页号,C_num为显示点阵的行数(物理行8的倍数),V_num 为列(物理列)puts待显示的点阵编码首指针*************************************************************** **************** */void Drawing_dot(unsigned char x,unsigned char y){unsigned char y_byte,x_bit,y_bit,reverse_y;//此处y_byte为page,y_bit为具体行号,x_bit 为行号unsigned char dot;reverse_y=63-y;x_bit=x;y_byte=reverse_y/8;y_bit=y%8;// for(;x_bit<128;x_bit++)if(y_bit==0) dot=0x80;if(y_bit==1) dot=0x40;if(y_bit==2) dot=0x20;if(y_bit==3) dot=0x10;if(y_bit==4) dot=0x08;if(y_bit==5) dot=0x04;if(y_bit==6) dot=0x02;if(y_bit==7) dot=0x01;xy_Write(x_bit,y_byte,dot);/* reverse_y=64-y;if(y_bit==7) y_byte=y_byte-1;y_bit=y%8;if(y_byte==(-1)) break;*/}/************************************************************** **************** 功能:绘垂直直线参数:x表示列号*************************************************************** **************** */void Drawing_line_vertical(unsigned char x){xy_Write(x,0,0xff);xy_Write(x,1,0xff);xy_Write(x,2,0xff);xy_Write(x,3,0xff);xy_Write(x,4,0xff);xy_Write(x,5,0xff);xy_Write(x,6,0xff);xy_Write(x,7,0xff);}主程序.c/************************************************************** **************** ****************12864液晶屏上显示"南京绝妙科技发展有限公司,025-******** 开发板欢迎使用","0~9",刷新后重显。
12864液晶显示汉字程序
/*=============================程序说明=============================== 项目名称: 显示汉字作者:创建日期:修改说明:程序说明:(1)CPU 型号:(2)时钟频率:(3)实现功能:(4)程序概述:===================================================================*/ //==========================头文件加载=============================== #include <mega16.h>#include <delay.h>#include "music.h"//===========================端口声明================================ #define LcdRS PORTB.0 //#define LcdRSDDR DDRB.0 //#define LcdRW PORTB.1 //#define LcdRWDDR DDRB.1 //#define LcdEN PORTB.4 //#define LcdENDDR DDRB.4 //#define LcdRST PORTB.6 //#define LcdRSTDDR DDRB.6 //#define LcdIoIn PORTA //#define LcdIoOut PINA //#define LcdIoDDR DDRA //#define LcdIn() LcdIoDDR = 0xff //调整输入输出#define LcdOut() LcdIoDDR = 0x00//=========================全局常量声明============================== //=========================全局变量声明==============================//===========================函数声明================================ void Lcd_init(void);void Lcd_CheckBusy(void);void Lcd_WriteCommand(uint8 com);void Lcd_WriteDat(uint8 Dat);void Lcd_writeStringRom(uint8 Add, uint8 flash String[]);//============================主函数================================= void main()//主函数{//---------------------------系统初始化--------------------------Lcd_init();music_init();Lcd_writeStringRom(0x80, "梁成颂");while(1){}}//===========================功能子函数================================ void Lcd_init(void){LcdRS = 1;LcdRSDDR = 1;LcdRW = 1;LcdRWDDR = 1;LcdEN = 1;LcdENDDR = 1;LcdRST = 1; //LcdRSTDDR = 1;LcdIoIn = 1; //LcdIoDDR = 1;LcdIoIn = 0xff; //LcdIn(); //LcdRST = 0;delay_ms(20);LcdRST = 1;delay_ms(50);Lcd_WriteCommand(0x38); //系统设置delay_ms(1);Lcd_WriteCommand(0x38); //系统设置Lcd_WriteCommand(0x08); //开显示Lcd_WriteCommand(0x01); //清屏Lcd_WriteCommand(0x06); //光标设置Lcd_WriteCommand(0x0c); //开显示Lcd_WriteCommand(0x01); //清屏}void Lcd_CheckBusy(void) //怕忙检测{LcdOut();LcdRS = 0;LcdRW = 1;LcdEN = 1;while((LcdIoOut & 0x80) == 0x80);LcdEN = 0;}void Lcd_WriteCommand(uint8 com) //写指令{Lcd_CheckBusy();LcdIn();LcdRS = 0;LcdRW = 0;LcdEN = 1;LcdIoIn = com;LcdEN = 0;}void Lcd_WriteDat(uint8 Dat) //写指令{Lcd_CheckBusy();LcdIn();LcdRS = 1;LcdRW = 0;LcdEN = 1;LcdIoIn = Dat;LcdEN = 0;}void Lcd_writeStringRom(uint8 Add, uint8 flash String[]) {uint16 i = 0;Lcd_WriteCommand(Add);while(String[i] != '\0'){Lcd_WriteDat(String[i]);i++;}}。
JLX12864G-086-PN中文说明书
JLX12864G-086-PN 使用说明书(不带字库IC)目录1.概述晶联讯电子专注于液晶屏及液晶模块的研发、制造。
所生产JLX12864G-086 型液晶模块由于使用方便、显示清晰,广泛应用于各种人机交流面板。
JLX12864G-086 可以显示128 列*64 行点阵单色图片,或显示16*16 点阵的汉字8 个*4 行,或显示8*16 点阵的英文、数字、符号16 个*4 行。
或显示5*8 点阵的英文、数字、符号21 个*8 行。
本产品可选择带中文字库IC 与不带中文字库IC 两种。
2.JLX12864G-086 图像型点阵液晶模块的特性2.1 结构轻、薄、带背光。
2.2 IC 采用UC1701X,功能强大,稳定性好2.3 功耗低:当电压为3.3V 时,功耗低:不带背光1mW(3.3V*0.3mA),带背光不大于150mW (3.3V*45mA);2.4 显示内容:(1)128*64 点阵单色图片,或其它小于128*64 点阵的单色图片;(2)可选用16*16 点阵或其他点阵的图片来自编汉字,按照16*16 点阵汉字来计算可显示8 字*4 行;(3)按照12*12 点阵汉字来计算可显示10 字*4 行;(4)按照 8*16 点阵汉字来计算可显示16 字*4 行;(5)按照 5*8 点阵汉字来计算可显示21 字*8 行;2.5 指令功能强.2.6 接口简单方便:采用4 线SPI 串行接口。
2.7 工作温度宽:-20℃ - 70℃;3.外形尺寸及接口引脚功能模块的接口引脚功能表1:模块的接口引脚功能4.基本原理4.1 液晶屏(LCD)在LCD 上排列着128×64 点阵,128 个列信号与驱动IC 相连,64 个行信号也与驱动IC 相连,IC 邦定在LCD 玻璃上(这种加工工艺叫COG).4.2 工作电图:图2 是JLX12864G-0086 图像点阵型模块的电路框图,它由驱动IC ST7565R 及几个电阻电容组成。
12864显示汉字程序
液晶TS12864-3驱动程序,可流水显示汉字#include<reg52.h>#define uchar unsigned char#define uint unsigned int#define DataPort P3#define N 800sbit E=P2^0;sbit RW=P2^1;sbit RS=P2^2;sbit PSB=P2^3;int num;uint i=0;uint l=0;uint b;uchar a[]="我爱我家09abcdefg,今天是2007年8月8日星期三,太热了!~_~"; uchar d[]={0x98,0x90,0x88,0x80};/**************延时1ms*count*****************/void delay(int count){int x,y;for(x=0;x<count;x++)for(y=0;y<120;y++);}/**************延时1us***********************//*void delayuS(uchar buf){while(buf--);}*//***********忙检测********************/void Busy(){DataPort=0xFF;RS=0;RW=1;while (1){E =1;if (P0^7==0) break;}E=0;}/***********写指令子程序****************/void Write_Com(uchar command){Busy(); //检测忙标志位RS=0;RW=0;DataPort=command; //写入指令E=1;delay(1);E=0;}/***********写数据子程序***************/void Write_Data(uchar Data){Busy();RS=1;RW=0;DataPort=Data;E=1;delay(1);E=0;}/***********LCD初始化*******************/void Init_LCD(void){PSB=0;delay(1);PSB=1; //将PSB置1,通信方式为8位数据并口delay(1);Write_Com(0x30);//30H--基本指令操作Write_Com(0x0c);//开显示,关光标,不闪烁。