微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 51单片机-240128液晶程序与调试

51单片机-240128液晶程序与调试

时间:11-13 来源:互联网 点击:
今天终于把金鹏OCMJ8X15D-2液晶(240128点阵带字库无触屏液晶)调好了。这块液晶能显示8行15个汉字,还有放大字形,从16*16点放大到32*32点的功能。对于觉得12864的4行8列内容过少,或者觉得0.5*0.5mm的点的大小过于粗糙的情况来说,这款液晶是很适合的,它的点大小为0.33*0.33mm。

可能是习惯了12864这样的液晶,结果在硬件连接上就出来了一个重大错误,结果弄了好久也只显示条形点阵,而且对比度很差。这个错误就是240128液晶的对比度调节电位器,两端一端接地,另一端接VOUT(22脚)!而我习惯性的接到了5V!在曹老师的提醒下才发现了这个问题,在手册的角落里发现了硬件连接图:

调试效果图:

最后附上调试好的程序:

//=============================================

//控制器:51单片机

//液晶: OCMJ8X15D-2(240128)带字库

//模式: 默认8080系列接口

//时间: 2013.2.26

//=============================================

#include

sbit lcd_rs =P2^0;

sbit lcd_wr =P2^1;

sbit lcd_rd =P2^2;

sbit lcd_cs1 =P2^3;

sbit lcd_cs2 =P2^4;

sbit lcd_busy =P2^5;

sbit lcd_int =P2^6;

sbit lcd_rst =P2^7;

#define lcd_regname P1

#define lcd_regdata P1

#define lcd_regnada P1

#define lcd_data P1

#define lcd_control P2

#define uchar unsigned char

#define uint unsigned int

//=============================================

void lcd_regwr(uchar regnada) small;

void delay(int k);

void gotoxy(uchar x,uchar y) small;

//=============================================

uchar code tab1[]={

" 华 中 科 技 大 学 "

" 光 电 国 家 实 验 室 "

"湖北省武汉市洪山区珞瑜路1037号"

" 黄鹤楼-崔颢 "

"昔人已乘黄鹤去,此地空余黄鹤楼"

"黄鹤一去不复返,白云千载空悠悠"

"晴川历历汉阳树,芳草萋萋鹦鹉洲"

"日暮乡关何处是,烟波江上使人愁"};

uchar code tab2[]={

" "

" "

" 欢迎访问我的网易博客 "

"http://suneleo.blog.163.com "

" 欢迎给我留言或者发邮件交流 "

" mail:suneleo@163.com "

" "

" "};

uchar code tab3[]={

/*-- 调入了一幅图像:C:\Users\Administrator\Desktop\240128 tuzki.bmp --*/

/*-- 宽度x高度=240x128 --*/

0x00,0x38,0x00,0x00,0xFB,0xFC,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,

0x00,0x01,0xFF,0xFE,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2E,0x00,0x01,

0x3F,0xFF,0x60,0x1A,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,0x0F,0xFF,

0xA0,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x8F,0xC0,0x07,

0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x1F,0xF0,0x00,0x00,0x00,0x01,0x10,0x00,0x00,0x0F,0xB3,0xE8,0x07,0xE0,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,

0xF0,0x04,0x00,0x00,0x1F,0x3C,0x00,0x00,0x0F,0x03,0xEC,0x00,0x78,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0xFF,0xF8,0x0F,

0x08,0x00,0x08,0x06,0x00,0x00,0x0F,0x01,0xF4,0x00,0x78,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x1D,0xFF,0xF8,0x07,0x03,0xFF,

0x17,0xF8,0x00,0x00,0x0F,0x80,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0xC1,0x00,0x00,0x00,0x00,0x03,0xFC,0xF8,0x00,0x1F,0xFF,0x0F,0xFF,

0x40,0x00,0x0F,0xB0,0xF8,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x28,

0x1E,0x7E,0xE2,0x00,0x00,0x00,0x0F,0xFA,0xFA,0x05,0x3F,0xFF,0x0F,0xFF,0xDC,0x00,

0x0F,0xB0,0xF8,0x1D,0xC1,0x90,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,

0x60,0x00,0x00,0x00,0x1F,0xF6,0xFA,0x07,0xFF,0xFF,0x1F,0xFF,0xFC,0x00,0x07,0xD0,

0x7C,0x0F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top