#include //调用头文件
#include
__CONFIG(0x3F32); //芯片装备字
//__CONFIG(HS&UNPROTECT&PWRTEN&BORDIS&WDTDIS);//芯片装备字
//__CONFIG(0x3FFD&0x3FFF&0x3FF7&0x3FBF&0x3FFB);//芯片装备字
#define uchar unsigned char
#define uint unsigned int
#define ulint unsigned long int
#define LCD_DATA_PORT PORTD //界说LCD的D0-D7地点端口
#define LCD_DATA_POUT TRISD=0x00 //界说LCD数据端口为输出
#define LCD_DATA_PIN TRISD=0xFF //界说LCD数据端口为输入(在读LCD状况时用到)
#define LCD_Control_IN TRISB|=0XFF
#define LCD_Control_OUT TRISB&=0X00
#define LCD_EN_1 RB0=1
#define LCD_EN_0 RB0=0
//LCD读写操控引脚
#define LCD_RW_1 RB1=1
#define LCD_RW_0 RB1=0
//LCD指令或数据挑选引脚
#define LCD_RS_1 RB2=1
#define LCD_RS_0 RB2=0
void nus_delay(uint nus);
void nms_delay(uint nms);
void mcu_io_init(void);
void lcd_init(void);
void LCD_en_write(void);
void wait_LCD_Ready(void);
void set_LCD_xy(uchar x, uchar y );
void LCD_write_onechar(uchar COMM,uchar DAT);
void LCD_write_string(uchar X,uchar Y,uchar *string);
void main(void)
{
uchar START_DISPLAY1[]={“mcu.2000”};
uchar START_DISPLAY2[]={“TEL: 12345678901”};
mcu_io_init();
lcd_init();
nms_delay(10);
LCD_write_string(0,0,START_DISPLAY1);
LCD_write_string(0,1,START_DISPLAY2);
while(1);
}
void mcu_io_init(void)
{
LCD_DATA_PORT=0xff;
LCD_DATA_POUT; //LCD数据口设为输出
LCD_EN_1;
LCD_RW_1;
LCD_RS_1;
LCD_Control_IN;
}
void lcd_init(void)
{
nms_delay(15);
LCD_DATA_POUT;
LCD_Control_OUT;
LCD_write_onechar(0x38,0);
nms_delay(1);
LCD_write_onechar(0x38,0);
nms_delay(1);
LCD_write_onechar(0x38,0);
nms_delay(1);
LCD_write_onechar(0x38,0);
LCD_write_onechar(0x08,0);
LCD_write_onechar(0x01,0);
LCD_write_onechar(0x06,0);
nms_delay(1);;
LCD_write_onechar(0x0C,0);
}
void LCD_en_write(void)
{
LCD_EN_1;
nus_delay(150); //E脉冲周期最小150ns
LCD_EN_0;
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/ziliao/260713.html