/*****************************************************************/ /* */ /*名称: 12864 液晶移动显示 */ /*功能: 12864 液晶移动显示 */ /* E-mail:******************* */ /*编写日期: 2009.07 */ /*****************************************************************/ #include #include #define uchar unsigned char #define uint unsigned int sbit LCD_RS = P2^0; sbit LCD_RW = P2^1; sbit LCD_EN = P2^2; uchar code dis1[] = {"I LOVE 8051 MCU"}; ucharcodedis2[]={"TEL:138****1069"}; /*******************************************************************/ /* /* 延时子程序 /* /*******************************************************************/ void delay(int ms) { int i; while(ms--) { for(i = 0; i< 250; i++) { _nop_(); _nop_(); _nop_(); _nop_(); } } } /*******************************************************************/ /* /*检查LCD 忙状态 /*lcd_busy 为1 时,忙,等待。lcd-busy 为0 时,闲,可写指令与数据。 /* /*******************************************************************/ bit lcd_busy() { bit result; LCD_RS = 0; LCD_RW = 1; LCD_EN = 1; _nop_(); _nop_(); _nop_(); _nop_(); result = (bit)(P0&0x80); LCD_EN = 0; return result; } /*******************************************************************/ /* /*写指令数据到 LCD /*RS=L,RW=L,E=高脉冲,D0-D7=指令码。 /* /*******************************************************************/ void lcd_wcmd(uchar cmd) { while(lcd_busy()); LCD_RS = 0; LCD_RW = 0; LCD_EN = 0; _nop_(); _nop_(); P0 = cmd; _nop_(); _nop_(); _nop_(); _nop_(); LCD_EN = 1; _nop_(); _nop_(); _nop_(); _nop_(); LCD_EN = 0; } /*******************************************************************/ /* /*写显示数据到LCD /*RS=H,RW=L,E=高脉冲,D0-D7=数据。 /* /*******************************************************************/ void lcd_wdat(uchar dat) { while(lcd_busy()); LCD_RS = 1; LCD_RW...