最近接了个项目涉及到使用HDG12864F-3 即128*64分辨率显示屏的使用.
抽时间顺便谢谢博客吧~
- first step: 分析篇
百度显示屏技术手册:
https://wenku.baidu.com/view/049ff3c5da38376bae1fae0d.html
(百度仅有的技术手册…有点老,凑合着用吧)
教大家一下芯片手册正确的打开步骤:
1.查看芯片结构及引脚图:
2.查看技术手册:
由此我们大概知道各个引脚对应得功能了
3.查看时序图:
从中时序通讯即可了解 PS:注意时序图的规定时序时间
4.查看推荐电路图
最后由上绘制初步电路图:
。。(为什么P0口要接上拉电阻? ---因为P0口内部没有上拉,所以需要人为上拉)
至此,芯片分析完毕,下面进入程序篇! (*^▽^*)
.
.
.
.
**
- second step: 程序篇
**
有小伙伴说显示不了? 我就白给了吧,(我之前是好使得),看清楚显示屏型号哦
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
/************************************************************************************/
#define LCD P0
sbit A0=P2^6; //指令OR数据输入选择
sbit RW=P2^5; //读写选择
sbit EN=P2^7; //(时钟)使能选择
sbit RES=P3^2; //复位引脚,低电平有效 (电路直接给高)
/************************************************************************************/
//字模
uchar buf1[]={0x00,0x08,0x88,0x48,0x28,0x18,0x0F,0xE8,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,
0x08,0x08,0x09,0x09,0x09,0x09,0x09,0xFF,0x09,0x09,0x09,0x09,0x09,0x08,0x08,0x00};
/************************************************************************************/
void delay(uint x) //延时1ms函数
{
uint i,j;
for(i=0;i<x;i++)
{
for(j=0;j<110;j++);
}
}
/*
@Function: 12864命令输入函数
*/
void lcd_write(uchar cmd)
{
A0=0;
RW=0;
delay(5);
LCD=cmd;
delay(5);
EN=1;
delay(5);
EN=0;
}
/*
@Function: 12864数据输入函数
*/
void lcd_date(uchar dat)
{
A0=1;
RW=0;
delay(5);
LCD=dat;
delay(5);
EN=1;
delay(5);
EN=0;
}
/*
@function: initiate the module
*/
void init() //12864初始化
{
RES=1;
lcd_write(0xaf);
delay(5);
lcd_write(0xa1);
delay(5);
}
/*
@Function: display 16*16 character to the designate position
@input: a 对应页 b 对应列的高四位 c 待显示字模数组
@字模绘制格式 : 从下往上自高到低 从上到下按列扫描,共16列 16行
**** 即倒序纵向取模 ****
*/
void display(int a,int b,char *c)
{
int n;
for(n=0;n<=15;n++)
{
lcd_write(a); //选择页
delay(5);
lcd_write(b);
delay(5);
lcd_write(0x00+n);
delay(5);
lcd_date(c[n]);
delay(20);
lcd_write(a+1); //选择下一页页
delay(5);
lcd_write(b);
delay(5);
lcd_write(0x00+n);
delay(5);
lcd_date(c[n+16]);
delay(20);
}
}
void main()
{
init();
while(1){
display(0xB0,0x00,buf1);
}
}
***最后,Hope you ENJOY~***(*^▽^*)