LPC2114 LCD1602驱动问题,很纠结。求高手指导
学ARM两个周,想吧以前51的程序移植过来,发现1602虽然能驱动显示,但是无法显示小写字母,送入的字符串明明是小写,显示的却是大写,并且符号类的字符包括空格都显示乱码先献上代码,希望有人帮我:#include "config.h"
#define LCD_RS (1<<8)
#define LCD_RW (1<<9)
#define LCD_E (1<<10)
#define LCD_BUSY (1<<7)
void delay(uint32 n)
{
uint32 i;
for(i=0; i<n; i++);
}
void LCD_ChkBusy(void)
{
IO0DIR=0x000007ff;
IO0CLR=LCD_RS;
IO0SET=LCD_RW;
IO0SET=LCD_E;
while((IO0PIN&LCD_BUSY)!=0);
delay(400);
IO0CLR=LCD_E;
IO0DIR=0x000007ff;
}
void LCD_write_command(uint8 dat, uint8 busy)
{
if(busy) LCD_ChkBusy();
IO0CLR=LCD_E;
IO0CLR=LCD_RS;
IO0CLR=LCD_RW;
IO0CLR=0x000000ff;
IO0SET=dat;
IO0SET=LCD_E;
delay(400);
IO0CLR=LCD_E;
}
void LCD_write_data(uint8 dat)
{
// LCD_ChkBusy();
delay(400);
IO0CLR=LCD_E;
IO0SET=LCD_RS;
IO0CLR=LCD_RW;
IO0CLR=0x000000ff;
IO0SET=dat;
IO0SET=LCD_E;
delay(400);
IO0CLR=LCD_E;
}
void LCD_disp_string(uint8 x, uint8 y, uint8 *dat)
{
uint8 addr;
if(y==1)
addr=0x80+x;
else
addr=0xc0+x;
LCD_write_command(addr,0);
while(*dat)
{
LCD_write_data(*dat);
dat++;
}
}
void LCD_init()
{
delay(1000);
LCD_write_command(0x38,0);
delay(400);
LCD_write_command(0x38,0);
delay(400);
LCD_write_command(0x38,0);
delay(2800);
LCD_write_command(0x38,0);
delay(2800);
LCD_write_command(0x08,0);
delay(2800);
LCD_write_command(0x0c,0);//整体显示,关光标,不闪烁
delay(2800);
LCD_write_command(0x06,0);//设定输入方式,增量不移位
delay(2800);
LCD_write_command(0x01,0);//清除屏幕显示
delay(2800);
}
int main (void)
{
uint8 str[]="Hello World!";
PINSEL0=0x00000000;
IO0DIR=0x000007ff;
LCD_init();
while(1)
{
LCD_disp_string(0,1,str);
}
return 0;
}
补充一点,程序在proteus上仿真是通过了的,如下图:
http://cache.amobbs.com/bbs_upload782111/files_34/ourdev_599231SFZOTS.png
(原文件名:ARM_LCD.png)
实际效果如下:
http://cache.amobbs.com/bbs_upload782111/files_34/ourdev_599232U6RMDM.jpg
(原文件名:IMG0253A.jpg)
再补充一点:程序中如果加入了检测忙就无法显示 都没人帮我分析分析吗?自己顶起 求指点,求回答,困扰我很久了。。。 检查一下,D5数据线是不是虚焊、对地短路、或者那个IO口坏了
大写、小写字符的区别就是在于D5位,空格跟“!”也受D5位影响 回复【3楼】20061002838
检查一下,d5数据线是不是虚焊、对地短路、或者那个io口坏了
大写、小写字符的区别就是在于d5位,空格跟“!”也受d5位影响
-----------------------------------------------------------------------
焊接应该没问题,我在51的板子上都运行正常,可能我这线不行,为了避免排线头互相端接我是用透明胶布缠的,热塑管没有了,这也是无奈之举啊 问题解决了吗?
检查一下D5的电平吧,看看程序运行的时候D5电平有没有变化,没变化肯定是这条数据线出了问题了 上示波器呀!
每次遇到问题我都这么跟同事说的!哈!
页:
[1]