找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

帖子
查看: 5463|回復(fù): 4
打印 上一主題 下一主題
收起左側(cè)

請(qǐng)教 12864液晶顯示字符問(wèn)題

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:21334 發(fā)表于 2010-1-25 12:32 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
fyd12864-0204b 液晶  st7920控制器  程序燒進(jìn)去 ,本來(lái)輸入的是 “ 床前明月光,疑是地上霜。舉頭望明月,低頭思故鄉(xiāng)�!� 可是卻顯示 “ 黨潛明彰廣一 由飼蒂上雙。摳頭望明彰一 低頭私顧?quán)l(xiāng)�!蔽覄倢W(xué)單片機(jī),在此請(qǐng)教大家了。以下是我用的程序,字?jǐn)?shù)對(duì),位置也對(duì),就是字錯(cuò)。
#include<reg52.h>
#include<intrins.h>
//#include<stdlib.h>  //rand();
#define uint unsigned int
#define uchar unsigned char

#define LCD_data P0;
sbit LCD_RS =P2^6;
sbit LCD_RW =P2^5;
sbit LCD_EN =P2^7;
sbit LCD_PSB = P3^2;
sbit wela =P1^2;
sbit dula=P1^3;

//uchar dis1[10];
uchar code dis1[]={"床前明月光,"};
uchar code dis2[]={"疑是地上霜。"};
uchar code dis3[]={"舉頭望明月,"};
uchar code dis4[]={"低頭思故鄉(xiāng)。"};
void delay_1ms(uint x)
{
uint i,j;
for(j=0;j<x;j++)
  for(i=0;i<110;i++);
}
void write_cmd(uchar cmd)
{
LCD_RS=0;
LCD_RW=0;
LCD_EN=0;
P0=cmd;
delay_1ms(5);
LCD_EN = 1;
delay_1ms(5);
LCD_EN= 0;                           
}

void write_dat(uchar dat)
{
LCD_RS = 1;
LCD_RW= 0;
LCD_EN= 0;
P0=dat;
delay_1ms(5);
LCD_EN= 1;
delay_1ms(5);
LCD_EN= 0;
}

void lcd_pos(uchar X,uchar Y)
{
uchar pos;
if(X==0)
{X=0x80;}
else if(X==1)
{X=0x90;}
else if(X==2)
{X=0x88;}
else if(X==3)
{X=0x98;}
pos= X+Y;
write_cmd(pos);
}



void lcd_init()
{
LCD_PSB=1;
write_cmd(0x30);
delay_1ms(5);
write_cmd(0x0c);
delay_1ms(5);
write_cmd(0x01);
delay_1ms(5);
}

void main()
{
uchar i;
wela=0;
dula=0;
delay_1ms(5);
lcd_init();

while(1)
{
  lcd_pos(0,0);
  i=0;
  while(dis1!='\0')
  {
   write_dat(dis1);
   i++;
  }

lcd_pos(1,0);
i=0;
while(dis2!='\0')
{
  write_dat(dis2);
  i++;
}
delay_1ms(10);


lcd_pos(2,0);
i=0;
while(dis3!='\0')
{
  write_dat(dis3);
  i++;
}
delay_1ms(10);


lcd_pos(3,0);
i=0;
while(dis4!='\0')
{
  write_dat(dis4);
  i++;
}
delay_1ms(10);
}


//delay_1ms(10);


}
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:21265 發(fā)表于 2010-1-25 13:05 | 只看該作者
現(xiàn)在沒有時(shí)間,回家找時(shí)間板你看看,
回復(fù)

使用道具 舉報(bào)

板凳
ID:2724 發(fā)表于 2010-1-26 03:23 | 只看該作者
你這個(gè)問(wèn)題比較怪,你把標(biāo)點(diǎn)符號(hào)去掉看看,或者換一個(gè)keil版本
回復(fù)

使用道具 舉報(bào)

地板
ID:82476 發(fā)表于 2015-6-9 11:06 | 只看該作者
原因可能是:12864本身自帶的中文字庫(kù)是不全的,有些中文字顯示不了。這里不能顯示這么多漢字,不大可能是這個(gè)原因。,
回復(fù)

使用道具 舉報(bào)

5#
ID:7485 發(fā)表于 2015-6-9 21:26 | 只看該作者
標(biāo)點(diǎn)符號(hào)也要用全角字符才行。
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表