源码 5 -- LCD 1602 显示字符
itLCD_Busy(void)
{
DataPort = 0xFF;
RS = 0;
RW = 1;
EN = 0;
_nop_();
EN = 1;// 读操作是 EN = 1 驱动
return(bit)(DataPort & 0x80);// 强制转换到 bit 时,除非原数据等于 0,bit = 0,否则 bit = 1
}
voidLCD_Clear(void)
{
LCD_Write_Com(0x01);
Delay_ms(5);
}
voidLCD_Set_Argument(unsigned charDL,unsigned charN,unsigned charF)
{
DL <= 4;// 指令格式决定了要移位,具体看指令格式要求
N <= 3;
F <= 2;
LCD_Write_Com(0x20 | DL | N | F);
Delay_ms(5);
}
voidLCD_Set_InputMode(unsigned charID,unsigned charS)
{
ID <= 1;
LCD_Write_Com(0x04 | ID | S);
Delay_ms(5);
}
voidLCD_Set_DisplayMode(unsigned charD,unsigned charC,unsigned charB)
{
D <= 2;
C <= 1;
LCD_Write_Com(0x08 | D | C | B);
Delay_ms(5);
}
voidLCD_Write_Char(unsigned charrow,unsigned charcol,unsigned charc)
{
if(row == 1) LCD_Write_Com(0x80 + col - 0x01); // 由指令格式可知,DB7 = 1,因此要加上 80H
else if(row == 2) LCD_Write_Com(0xC0 + col - 0x01);
LCD_Write_Data(c);
}
voidLCD_Write_String(unsigned charrow,unsigned charcol,unsigned char*s)
{
if(row == 1) LCD_Write_Com(0x80 + col - 0x01);
else if(row == 2) LCD_Write_Com(0xC0 + col - 0x01);
while(*s) {
LCD_Write_Data(*s);
s++;
}
}
voidDelay(unsigned intt)
{
while(t--);
}
voidDelay_ms(unsigned intt)// 根据测试,可以相当近似的表示 t ms
{
while(t--) {
Delay(245);
Delay(245);
}
}
C51LCD1602显示字 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)