Proteus仿真 基于51单片机的 HDG12864F-1和HDG12864F-3的显示

写在前面!LCD12864和HDG12864F-x系列是不同的!

emmm现在感觉也还是不太能明白这个神奇的液晶显示模块,就是可能大概会用,找网上的模块之类的,但是对于它们是基于啥控制器??啥指令集??之类的还是很混乱!
一开始去完成作业的时候其实不清楚LCD12864和HDG12864F-x系列是不同的,就直接去搜了12864,搜到的结果就很混乱,我都去瞅了瞅,那感觉就是吃多了吃杂了,根本消化不了,笑死,根本理不清!一个月以后,昨天问同学(啊!好厉害噢!!)似乎??终于??理清楚了?笑死,我的猪脑子!

LCD12864

因为作业是基于HDG12864F-x系列完成的,我并没有去实现基于LCD12864的液晶显示仿真(似乎Proteus里面没有LCD12864?)不过在CSDN看见了写得很好!解决了我很多疑惑的!博客!!
LCD12864百度百科
LCD12864资料汇总

  • 详解LCD12864显示屏的使用(并行控制)
    在这篇博客里面的代码,写入逻辑是——选择一个地址以后,8bit循环写进,8bit是最小单元横着写的,然后往下竖着写满对应16行,如果是ASCII码8* 16就写好了,如果是汉字16*16,Y地址自动增加(就是横着的那个……俺混乱了!),重复一次,这样就写好了一个汉字or一个ASCII码字符;如果是字符序列,Y地址依然自动增加,就能写完所有字符;
    需要注意的是,一行最多16个ASCII字符,8个汉字字符,横坐标+1不会进位,就是写满一行以后,另一行的选择要代码更改,写入的示意图大概如下:
    Proteus仿真 基于51单片机的 HDG12864F-1和HDG12864F-3的显示_第1张图片

  • LCD12864(带字库的)使用教程
    这篇博客的代码里,写入逻辑是——最小单位8bit横着写,写了以后继续横着写 下一个8bit,一行128bit就需要循环16次(168=128)!这样就写满一行了,12864的DDRAM有64行,再加一个外层循环写满64行,写入的示意图大概如下:
    Proteus仿真 基于51单片机的 HDG12864F-1和HDG12864F-3的显示_第2张图片
    上面两个代码里面的写入逻辑是不一样的,这与你取模的方式有关,或者说自己取模的时候和代码里怎么写进入要对应!!

基于51单片机 HDG12864F-3显示图片的Proteus仿真

一开始完成作业就是参考的这篇博客!proteus中 基于STC89C51的HDG12864F-3显示器仿真
但是不知道博主最后写地址的时候,y那里是不是写错liao。
我是看的这个数据手册:HDG12864F-3中文资料
HDG12864F-3是并行的,数据是8bit并行传输的,比较重要的引脚是A0、RW(组合有读写指令/数据)、E(使能):
Proteus仿真 基于51单片机的 HDG12864F-1和HDG12864F-3的显示_第3张图片
这里是指令集合——

关于黄色框里面的指令——主要是在写入要显示的取模矩阵时,要设置地址的一些指令:(是自己的理解,如果有不对,还望斧正)
首先要先放一张DDRAM的图:
Proteus仿真 基于51单片机的 HDG12864F-1和HDG12864F-3的显示_第4张图片

将128*64的DDRAM分页,分成8页,一页8行,一行128bit,需要注意的是!!HDG12864的最小单元(8bit)是竖着写的!!

  • Display Start Line Set:起始行设置——如上图所示,给page编号,从上往下就是0-1-2-3-4-5-6-7,但是如果设置起始行从32开始(写入指令0x60),那么页的序号就会变成4-5-6-7-0-1-2-3,就相当于从设置的那一行开始往下依次8行算一页;

  • Page Address Set:页的选择——写入指令0x80+x(x即为行的序号);

  • Column Address Set Upper bit+Colunm Address Set Lower bit:列的高位+低位选择,因为一页有128列,需要7位,所以就用列的高位选择和低位选择两条指令来确定某一列(这也体现了HDG12864是竖着写的!)
    HDG12864F-3的初始化、读/写数据/指令函数、显示图片的代码如下:

#include
#define uchar unsigned char 
#define uint unsigned int 
/************************************************************************************/
#define LCD P1
sbit A0=P3^5;	    //指令OR数据输入选择
sbit RW1=P3^4;		//读写选择
sbit EN=P3^3;		//(时钟)使能选择
sbit RES=P3^6;		//复位引脚,低电平有效 (电路直接给高)
/************************************************************************************/
//图片取模数组
uchar code mypic[]={ 
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,0X40,
0X00,0X00,0X00,0X00,0X00,0X10,0X10,0X00,0X00,0X08,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,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X04,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X10,0X00,0X00,0X20,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,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X40,0X40,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X04,0X04,0X38,0X18,0X00,0X00,0X00,0X07,0X07,
0X00,0X00,0X00,0X00,0X00,0X3E,0X3C,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X08,0X10,0X10,0X20,0X20,0X00,0X04,0X04,
0X18,0X18,0X00,0X00,0X00,0X70,0XF8,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X01,0X00,0X02,0X00,0X04,0X08,0X00,0X10,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,0X00,0X00,0X10,0X00,0X00,
0X01,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0XF8,0XF8,0XFC,0XFC,0XFC,0XF8,0XF0,0XFA,0XFE,0XFE,0XFC,
0XFC,0XF8,0XF8,0XE0,0XE0,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0XE0,0XE0,0XF0,0XF8,0XF8,0XE0,0XE0,0XE0,0XF0,0XFC,0XF8,0XF8,
0XF0,0XF0,0XC0,0XC0,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,0X01,
0X00,0X04,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X08,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,0X07,0X0F,0X1F,0X3F,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0XFF,0X3F,0X1E,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X07,0X07,0X3F,0X7F,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,
0XFF,0XFF,0XFF,0XFF,0XFF,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,0X01,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X20,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X08,0X78,0XF8,0XF0,
0XE0,0XE0,0XC0,0XC0,0XC0,0X80,0X80,0X80,0X00,0X00,0X00,0X00,0X00,0X01,0X01,0X01,
0X01,0X01,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X01,0X01,0X03,0X03,0X03,
0X03,0X03,0X01,0X01,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X80,
0X80,0X80,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X02,0X00,0X10,0X40,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X03,
0X07,0X0F,0X1F,0X1F,0X3F,0X7F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFE,0XFE,0XFE,0XFE,
0XFE,0XFC,0XFC,0XFC,0XFC,0XFC,0XFC,0XFC,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,
0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XF8,0XFC,
0XFC,0XFC,0XFC,0XFC,0XFC,0XFC,0XFC,0XFE,0XFE,0XFE,0X7E,0X7E,0X1F,0X1F,0X0F,0X0F,
0X03,0X01,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X80,
0X00,0X00,0X08,0X08,0X01,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,
0X01,0X00,0X00,0X08,0X00,0X10,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X01,0X03,0X03,0X07,0X07,0X07,0X07,
0X0F,0X0F,0X0F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X3F,0X3F,0X3F,0X3F,0X3F,0X3F,
0X3F,0X3F,0X3F,0X3F,0X3F,0X3F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X1F,0X0F,0X0F,0X0F,
0X07,0X07,0X07,0X07,0X03,0X03,0X01,0X01,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X80,0X00,0X40,0X20,0X00,0X00,0X00,0X00,0X02,0X02,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,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,0X02,0X02,0X00,
0X00,0X00,0X00,0X08,0X00,0X00,0X00,0X00,0X00,0X00,0X20,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,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X20,0X00,0X00,0X10,0X00,0X00,0X08,0X00,0X00,0X04,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,0X00
};


/************************************************************************************/
void delay(uint x)				//延时1ms函数
{
	uint i,j;
	for(i=0;i<x;i++)
	{
		for(j=0;j<110;j++);
	}
}
//12864命令输入函数
void lcd_cmd(uchar cmd)		
{
	A0=0;
	RW1=0;	
	delay(5);
	LCD=cmd;
	delay(5);
	EN=1;
	delay(5);
	EN=0;
	
}
//12864数据输入函数
void lcd_date(uchar dat)	 
{
	A0=1;
	RW1=0;
	delay(5);
	LCD=dat;
	delay(5);
	EN=1;
	delay(5);
	EN=0;
}
//initiate the module
void init()				//12864初始化
{
	RES=1;	
	lcd_cmd(0xaf);
	delay(5);	
	lcd_cmd(0xa1);
	delay(5);

}
/*
@Function:  display 128*64 character to the designate position
@input: 待显示字模数组
@字模绘制格式 :	倒序纵向取模
*/
void display(char *c)
{
    int i,j,k;
	for(i=0;i<8;i++){   //8page
	  for(k=0;k<8;k++)  //列高四位
	  { 
	   for(j=0;j<16;j++)//列的低位选择
	   {
	   lcd_cmd(0xB0+i);				//选择page
	   //delay(5);	
	   lcd_cmd(0x10+k);             //选择列的高四位
	   //delay(5);	
	   lcd_cmd(0x00+j);             //选择列的低四位
	   //delay(5);	
	   lcd_date(c[16*k+j+128*i]);   //确定对应的数据
	  // delay(20);	
	   }
	  }
	}
}

void main()
{
	init();

	while(1){

	display(mypic);
	}
}

代码中写入逻辑如下:(注意图片取模要与自己的代码对应!
Proteus仿真 基于51单片机的 HDG12864F-1和HDG12864F-3的显示_第5张图片

仿真显示:
Proteus仿真 基于51单片机的 HDG12864F-1和HDG12864F-3的显示_第6张图片

基于51单片机 HDG12864F-1显示数字的(ASCII码)Proteus仿真

参考了很多这篇博客:使用Proteus模拟操作HDG12864F-1液晶屏
数据手册:HDG12864F-1
因为HDG12864F-x系列的内部控制器是一样的,所以指令集也是一样的,写入方式当然也是一样的,就是8bit是竖着写的,感觉大概都是差不多滴!
关于所以ASCII码(8*6)纵向取模后的数组:

uchar code BMP[][6]=
{
//字符显示对应的二维十六进制数组
//每个字符对应8*6的点阵
{0x00,0x00,0x00,0x00,0x00,0x00}, //   0位  显示空白
{0x00,0x00,0x00,0x00,0x00,0x00}, //   1
{0x00,0x00,0x00,0x00,0x00,0x00}, //   2
{0x00,0x00,0x00,0x00,0x00,0x00}, //   3
{0x00,0x00,0x00,0x00,0x00,0x00}, //   4
{0x00,0x00,0x00,0x00,0x00,0x00}, //   5
{0x00,0x00,0x00,0x00,0x00,0x00}, //   6
{0x00,0x00,0x00,0x00,0x00,0x00}, //   7
{0x00,0x00,0x00,0x00,0x00,0x00}, //   8
{0x00,0x00,0x00,0x00,0x00,0x00}, //   9
{0x00,0x00,0x00,0x00,0x00,0x00}, //   10
{0x00,0x00,0x00,0x00,0x00,0x00}, //   11
{0x00,0x00,0x00,0x00,0x00,0x00}, //   12
{0x00,0x00,0x00,0x00,0x00,0x00}, //   13
{0x00,0x00,0x00,0x00,0x00,0x00}, //   14
{0x00,0x00,0x00,0x00,0x00,0x00}, //   15
{0x00,0x00,0x00,0x00,0x00,0x00}, //   16
{0x00,0x00,0x00,0x00,0x00,0x00}, //   17
{0x00,0x00,0x00,0x00,0x00,0x00}, //   18
{0x00,0x00,0x00,0x00,0x00,0x00}, //   19
{0x00,0x00,0x00,0x00,0x00,0x00}, //   20
{0x00,0x00,0x00,0x00,0x00,0x00}, //   21
{0x00,0x00,0x00,0x00,0x00,0x00}, //   22
{0x00,0x00,0x00,0x00,0x00,0x00}, //   23
{0x00,0x00,0x00,0x00,0x00,0x00}, //   24
{0x00,0x00,0x00,0x00,0x00,0x00}, //   25
{0x00,0x00,0x00,0x00,0x00,0x00}, //   26
{0x00,0x00,0x00,0x00,0x00,0x00}, //   27
{0x00,0x00,0x00,0x00,0x00,0x00}, //   28
{0x00,0x00,0x00,0x00,0x00,0x00}, //   29
{0x00,0x00,0x00,0x00,0x00,0x00}, //   30
{0x00,0x00,0x00,0x00,0x00,0x00}, //   31
{0x00,0x00,0x00,0x00,0x00,0x00}, // sp 32
{0x00,0x00,0x2f,0x00,0x00,0x00},   // ! 33
{0x00,0x07,0x00,0x07,0x00,0x00},   // " 34 
{0x14,0x7f,0x14,0x7f,0x14,0x00},   // # 35
{0x24,0x2a,0x7f,0x2a,0x12,0x00},   // $ 36
{0xc4,0xc8,0x10,0x26,0x46,0x00},   // % 37
{0x36,0x49,0x55,0x22,0x50,0x00},   // & 38 
{0x00,0x05,0x03,0x00,0x00,0x00},   // ' 39
{0x00,0x1c,0x22,0x41,0x00,0x00},   // ( 40
{0x00,0x41,0x22,0x1c,0x00,0x00},   // ) 41
{0x14,0x08,0x3E,0x08,0x14,0x00},   // * 42
{0x08,0x08,0x3E,0x08,0x08,0x00},   // + 43
{0x00,0x00,0x50,0x30,0x00,0x00},   // , 44
{0x10,0x10,0x10,0x10,0x10,0x00},   // - 45
{0x00,0x60,0x60,0x00,0x00,0x00},   // . 46
{0x20,0x10,0x08,0x04,0x02,0x00},   // / 47
{0x3E,0x51,0x49,0x45,0x3E,0x00},   // 0 48
{0x00,0x42,0x7F,0x40,0x00,0x00},   // 1 49
{0x42,0x61,0x51,0x49,0x46,0x00},   // 2 50
{0x21,0x41,0x45,0x4B,0x31,0x00},   // 3 51
{0x18,0x14,0x12,0x7F,0x10,0x00},   // 4 52
{0x27,0x45,0x45,0x45,0x39,0x00},   // 5 53
{0x3C,0x4A,0x49,0x49,0x30,0x00},   // 6 54
{0x01,0x71,0x09,0x05,0x03,0x00},   // 7 55
{0x36,0x49,0x49,0x49,0x36,0x00},   // 8 56
{0x06,0x49,0x49,0x29,0x1E,0x00},   // 9 57
{0x00,0x36,0x36,0x00,0x00,0x00},   // : 58
{0x00,0x56,0x36,0x00,0x00,0x00},   // ; 59
{0x08,0x14,0x22,0x41,0x00,0x00},   // < 60
{0x14,0x14,0x14,0x14,0x14,0x00},   // = 61
{0x00,0x41,0x22,0x14,0x08,0x00},   // > 62
{0x02,0x01,0x51,0x09,0x06,0x00},   // ? 63
{0x32,0x49,0x59,0x51,0x3E,0x00},   // @ 64
{0x7E,0x11,0x11,0x11,0x7E,0x00},   // A 65
{0x7F,0x49,0x49,0x49,0x36,0x00},   // B 66
{0x3E,0x41,0x41,0x41,0x22,0x00},   // C 67
{0x7F,0x41,0x41,0x22,0x1C,0x00},   // D 68
{0x7F,0x49,0x49,0x49,0x41,0x00},   // E 69
{0x7F,0x09,0x09,0x09,0x01,0x00},   // F 70
{0x3E,0x41,0x49,0x49,0x7A,0x00},   // G 71
{0x7F,0x08,0x08,0x08,0x7F,0x00},   // H 72
{0x00,0x41,0x7F,0x41,0x00,0x00},   // I 73
{0x20,0x40,0x41,0x3F,0x01,0x00},   // J 74
{0x7F,0x08,0x14,0x22,0x41,0x00},   // K 75
{0x7F,0x40,0x40,0x40,0x40,0x00},   // L 76
{0x7F,0x02,0x0C,0x02,0x7F,0x00},   // M 77
{0x7F,0x04,0x08,0x10,0x7F,0x00},   // N 78
{0x3E,0x41,0x41,0x41,0x3E,0x00},   // O 79
{0x7F,0x09,0x09,0x09,0x06,0x00},   // P 80
{0x3E,0x41,0x51,0x21,0x5E,0x00},   // Q 81
{0x7F,0x09,0x19,0x29,0x46,0x00},   // R 82
{0x46,0x49,0x49,0x49,0x31,0x00},   // S 83
{0x01,0x01,0x7F,0x01,0x01,0x00},   // T 84
{0x3F,0x40,0x40,0x40,0x3F,0x00},   // U 85
{0x1F,0x20,0x40,0x20,0x1F,0x00},   // V 86
{0x3F,0x40,0x38,0x40,0x3F,0x00},   // W 87
{0x63,0x14,0x08,0x14,0x63,0x00},   // X 88
{0x07,0x08,0x70,0x08,0x07,0x00},   // Y 89
{0x61,0x51,0x49,0x45,0x43,0x00},   // Z 90
{0x00,0x7F,0x41,0x41,0x00,0x00},   // [ 91
{0x55,0x2A,0x55,0x2A,0x55,0x00},   //55 92
{0x00,0x41,0x41,0x7F,0x00,0x00},   // ] 93
{0x04,0x02,0x01,0x02,0x04,0x00},   // ^ 94
{0x40,0x40,0x40,0x40,0x40,0x00},   // _ 95
{0x00,0x01,0x02,0x04,0x00,0x00},   // ' 96
{0x20,0x54,0x54,0x54,0x78,0x00},   // a 97
{0x7F,0x48,0x44,0x44,0x38,0x00},   // b 98
{0x38,0x44,0x44,0x44,0x20,0x00},   // c 99
{0x38,0x44,0x44,0x48,0x7F,0x00},   // d 100
{0x38,0x54,0x54,0x54,0x18,0x00},   // e 101
{0x08,0x7E,0x09,0x01,0x02,0x00},   // f 102 
{0x0C,0x52,0x52,0x52,0x3E,0x00},   // g 103 
{0x7F,0x08,0x04,0x04,0x78,0x00},   // h 104
{0x00,0x44,0x7D,0x40,0x00,0x00},   // i 105
{0x20,0x40,0x44,0x3D,0x00,0x00},   // j 106
{0x7F,0x10,0x28,0x44,0x00,0x00},   // k 107
{0x00,0x41,0x7F,0x40,0x00,0x00},   // l 108
{0x7C,0x04,0x18,0x04,0x78,0x00},   // m 109
{0x7C,0x08,0x04,0x04,0x78,0x00},   // n 110
{0x38,0x44,0x44,0x44,0x38,0x00},   // o 111
{0x7C,0x14,0x14,0x14,0x08,0x00},   // p 112
{0x08,0x14,0x14,0x18,0x7C,0x00},   // q 113
{0x7C,0x08,0x04,0x04,0x08,0x00},   // r 114
{0x48,0x54,0x54,0x54,0x20,0x00},   // s 115
{0x04,0x3F,0x44,0x40,0x20,0x00},   // t 116
{0x3C,0x40,0x40,0x20,0x7C,0x00},   // u 117
{0x1C,0x20,0x40,0x20,0x1C,0x00},   // v 118
{0x3C,0x40,0x30,0x40,0x3C,0x00},   // w 119
{0x44,0x28,0x10,0x28,0x44,0x00},   // x 120
{0x0C,0x50,0x50,0x50,0x3C,0x00},   // y 121
{0x44,0x64,0x54,0x4C,0x44,0x00},   // z 122
{0xD5,0x01,0x80,0x01,0x80,0xAB},  // <50        123
{0xFF,0x81,0x81,0x81,0x81,0xFF},  //50<= <100   124
{0xFF,0x81,0xBD,0xBD,0x81,0xFF},  //100<= <150  125
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},  //>=150       126
{0x00,0x00,0x00,0x00,0x00,0x00}   // sp         127
 
};

全部代码:

#include  
#include 
#include
#include 
#include  

#define NOP    _nop_()
#define uint unsigned int
#define uchar unsigned char

sbit LCD_SI=P2^0;//串行数据输入、输出端
sbit LCD_SCL=P2^1;//时钟         
sbit LCD_A0=P2^2;//选择命令还是数据
sbit LCD_RST=P2^3;//复位
sbit LCD_CS=P2^4;//片选

/*****************************************************************
                   LCD写函数
            void LCD_write(数据或者命令,A0选择)
****************************************************************/
void LCD_write(uchar data_command,uchar dc) 
{//参数dc=0时表示发命令,dc=1时表示发送数据
  uchar i;
  LCD_A0=dc;
  LCD_CS=0;  
  for(i=0;i<8;i++)
  {
   	LCD_SCL=0;
   	LCD_SI=(data_command&0x80)==0?0:1;
   	data_command<<=1;
   	LCD_SCL=1;
  }
  LCD_CS=1;  
}

//时序里面SCL是先0之后1,这样写进去!

/**************************************************************
                    LCD初始化函数
****************************************************************/
void LCD_Init(void) 
{	uchar i;
	LCD_RST=0;  //LCD(低电平)复位
	for(i=100;i>0;i--);
	LCD_RST=1;     // RES置高
	for(i=100;i>0;i--);
	LCD_write(0xa2,0);// LCD偏压设置:1/9 BIAS
	LCD_write(0xa1,0);//列地址选择为从右到左对应0~127;0xa1:列地址从左到右;0xa0:列地址从右到左
	LCD_write(0xc0,0);// 行地址从上到下为0~63;0xc0:行地址从上到下;0xc8:行地址从下到上
	LCD_write(0x26,0);// V5电压内部电阻调整设置
	LCD_write(0x81,0);//亮度调整命令0~63(暗到亮)
	LCD_write(0x10,0);   //亮度调节为双字节命令,前一个参数控制字的深浅
	LCD_write(0x2f,0); //上电控制,打开调压器、稳压器和电压跟随
	LCD_write(0xaf,0); //set display off。0xaf:set display on

	LCD_write(0x40,0);//起始行设置(0x40+x)-x对应起始行
}


/*****************************************************************
                       显示一个数字8*8点阵
*****************************************************************/
void Draw_word(uchar d_where,uchar page_f,uchar column_f )
{
//参数:d_where要显示的数字字符
//page_f显示在哪一行,从上到下为0-1-2-3-4-5-6-7共8行
//column_f显示列起始位置
  uchar i,j,page=0xb0;//指向首页命令
  for(i=page_f;i<1+page_f;i++)
   { 
   		LCD_write(page+i,0); 
     	LCD_write(0x10|((0xf0&column_f)>>4),0);//设定列地址高4位为0
     	LCD_write(0x04|(0x0f&column_f),0);    //设定列地址低4位为0
     	for(j=0;j<6;j++)
      		{
    			LCD_write(BMP[d_where][j],1);
   			}
   }
}
/*ADC0831延时函数*/
void Delayms(uint x )
{
	uint t; 
	while(x--) 
		for (t= 0; t<120; t++);
}

//主函数
void main(void)
{
   LCD_Init();
   while(1)
	{
	  Draw_word('H',2,8);
	  Delayms(10);
	  Draw_word('D',2,16);
	  Delayms(10);
	  Draw_word('G',2,24);
	  Delayms(10);
	  Draw_word('1',2,32);
	  Delayms(10);
	  Draw_word('2',2,40);
	  Delayms(10);
	  Draw_word('8',2,48);
	  Delayms(10);
	  Draw_word('6',2,56);
	  Delayms(10);
	  Draw_word('4',2,64);
	  Delayms(10);
	  Draw_word('F',2,72);
	  Delayms(10);
	  Draw_word('-',2,80);
	  Delayms(10);
	  Draw_word('1',2,88);
	  Delayms(10);
	 
    }	
}







仿真结果:
Proteus仿真 基于51单片机的 HDG12864F-1和HDG12864F-3的显示_第7张图片

啊!结束啦!!不知道理清楚没有!(救命!好费时间!!)

你可能感兴趣的:(单片机,嵌入式)