|
#include "Config.h"
#include <intrins.h>
sbit RS = P2^0;
sbit RW = P2^1;
sbit E= P2^2;
void LCD1602_delay_10us(unsigned char i)
{
unsigned char j;
while(i--)
for(j=0;j<10; j++)
;
}
void LCD1602_delay_1ms(unsigned char i)
{
unsigned char j;
while(i--)
;
for(j=0;j<125;j++)
;
}
void LCD1602_Write_Cmd(unsigned char cmd)
{
LCD1602_delay_10us(5);
E=0;
RS=0;
RW=0;
LCD_PORT=cmd;
LCD1602_delay_10us(5); //>40us
E=1;
LCD1602_delay_1ms(2); //>150us
E=0;
LCD1602_delay_10us(4); //>25+10us?
}
void LCD1602_Write_Dat(unsigned char dat)
{
LCD1602_delay_10us(5);
E=0;
RS=1;
RW=0;
LCD_PORT = dat;
LCD1602_delay_10us(5);
E=1;
LCD1602_delay_10us(5);
E=0;
LCD1602_delay_10us(4);
}
void LCD1602_Addr_x_y(unsigned char x,bit y)
{
unsigned char temp=0x80;
if(y)
{
temp|=0x40;
}
temp|=x;
LCD1602_Write_Cmd(temp);
}
void LCD1602_Show_Char(unsigned char x,bit y,unsigned char p)
{
LCD1602_Addr_x_y(x,y);
LCD1602_Write_Dat(p);
}
void LCD1602_Show_String(unsigned char x,bit y,char *ptr,unsigned char data_len)
{
unsigned char i;
for (i=0;i<data_len;i++)
{
LCD1602_Show_Char(x++,y,*(ptr+i));
}
}
void LCD1602_Init(void)
{
LCD1602_delay_1ms(1500);
LCD1602_Write_Cmd(0x38);
LCD1602_delay_1ms(5);
LCD1602_Write_Cmd(0x38);
LCD1602_delay_1ms(5);
LCD1602_Write_Cmd(0x38);
LCD1602_delay_1ms(5);
LCD1602_Write_Cmd(0x38);
LCD1602_Write_Cmd(0x08);
LCD1602_Write_Cmd(0x06);
LCD1602_Write_Cmd(0x0c);
LCD1602_Write_Cmd(0x01);
}
實錄視頻連接
鏈接:https://pan.baidu.com/s/1c1lEja-Kx6IEvJIS74ZpPQ
提取碼:m66j
復制這段內容后打開百度網盤手機App,操作更方便哦
|
-
1602.jpg
(152.96 KB, 下載次數: 114)
下載附件
2019-3-14 10:16 上傳
仿真電路圖
評分
-
查看全部評分
|