?? lcd.c
字號:
/*
連線定義:
C51 ~~ LCD
P0 = DB (P00--P07=D0-D7)
P20 = RW
P21 = RS
P22 = E
*/
#include <c51.h>
sbit LCD_RW= P2^0;
sbit LCD_RS= P2^1;
sbit LCD_E = P2^2;
#define LCD_DB P0
sbit LCD_DB0= P0^0;
sbit LCD_DB1= P0^1;
sbit LCD_DB2= P0^2;
sbit LCD_DB3= P0^3;
sbit LCD_DB4= P0^4;
sbit LCD_DB5= P0^5;
sbit LCD_DB6= P0^6;
sbit LCD_DB7= P0^7;
unsigned char lcdStatus() // no delay at all. get AC & busy flage(BF)
{
unsigned char d;
LCD_RS=0;
LCD_RW=1;
LCD_E=1; //????
d=LCD_DB;
LCD_E=0; //????
return (d);
}
void lcdWrRAM(unsigned char dat)
{
while(lcdIsBusy());
LCD_RS=1;
LCD_RW=0;
LCD_E=1;
LCD_DB=dat;
delay(72);
LCD_E=0;
}
unsigned char lcdRdRAM()
{
unsigned char d;
while(lcdIsBusy());
LCD_RS=0;
LCD_RW=0;
LCD_E=1;
delay(72);
d=LCD_DB;
LCD_E=0;
return d;
}
void lcdIdleMode() //ex Function
{
LCD_RS=0;
LCD_RW=0;
LCD_DB=1;
LCD_E=1;
delay(72);
LCD_E=0;
}
void lcdInstruction(unsigned char ins)
{
while(lcdIsBusy());
LCD_RS=0;
LCD_RW=0;
LCD_E=1;
LCD_DB=ins;
delay(72);
LCD_E=0;
}
void lcdInit()
{
delay(40000);
lcdInstruction(0x30);
delay(120);
lcdInstruction(0x30);
delay(40);
lcdInstruction(0x0e);
delay(120);
lcdInstruction(0x01);
delay(10000);
lcdInstruction(0x06);
delay(100);
}
void lcdPrts(char *str)
{
char *s;
s=str;
while (*s)
{
lcdWrRAM(*s);
s++;
};
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -