#include #include #define uchar unsigned char #define uint unsigned int sbit LCD_RS = P3^0; sbit LCD_RW = P3^1; sbit LCD_EN = P3^2; uchar code dis1[] = {" CHINESE "}; uchar code dis2[] = {" NEW YEAR "}; /*******************************************************************/ /* */ /* 延时子程序 */ /* */ /*******************************************************************/ 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 = 0; LCD_EN = 0; P0 = dat; _nop_(); _nop_(); _nop_(); _nop_(); LCD_EN = 1; _nop_(); _nop_(); _nop_(); _nop_(); LCD_EN = 0; } /******************************************************...