作者submarines ()
站內Electronics
標題[問題] 8051使用C語言LCD顯示問題
時間Sun Feb 4 01:52:40 2007
最近才剛開始學51…
寫到LCD時照著範例打只能顯示一行而已
我需要顯示兩行
但程式怎麼改就是無法呼叫第二行
以下附的是顯示一行的程式…
希望在這裡的高手能幫我解決一下…thanks
#include "AT89X51.H"
#define RS P2_0
#define RW P2_1
#define Enable P2_2
char one=0;
char zero=0;
void DELAY(int zzz)
{
int d;
for(d=zzz;d>0;d--);
}
void CheckBusy(void)
{
char i=0x80;
while(i&0x80)
{
RS=0;
RW=1;
Enable=1;
i=P3;
Enable=0;
DELAY(250);
}
}
void WriteData(char i)
{
RS=1;
RW=0;
Enable=1;
P3=i;
Enable=0;
CheckBusy();
}
void WriteString(count,MSG)
char count;
char MSG[];
{
char i;
for(i=0;i<count;i++)
WriteData(MSG[i]);
}
void WriteIns(char instruction)
{
RS=0;
RW=0;
Enable=1;
P3=instruction;
Enable=0;
CheckBusy();
}
void InitialLCD(void)
{
WriteIns(0x38);
WriteIns(0x08);
WriteIns(0x01);
WriteIns(0x0e);
WriteIns(0x06);
}
void main()
{
char MSG0[]="FIRLAB";
InitialLCD();
WriteString(6,MSG0);
while(1);
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.56.153.19
1F:推 mosquito520:兩列的LCD...第二列的記憶體位址好像是0xC0開始 02/04 01:56
2F:推 Magicx:之前實做記得是0x40....wh16xx系列的lcd 02/04 07:36
3F:推 Magicx:另外我記得範例裡的一個clear指令拿掉的話會比較正常運作喔 02/04 07:48
4F:推 beagle:話說這個程式並沒有移動讀寫游標的 function, 要自己寫 02/04 10:09