//8051 and 1602 communication in bus mode//the main implementation function of this program is to send a string of strings to 1602, and display it#include<reg52.h>#include<absacc.h>#defineUchar unsigned char#defineUINT unsigned int#defineLcdddata XBYTE[0XFFFF]//Read Data address#defineLcdxdata XBYTE[0XFDFF]//Write Data address#defineLcddcom Xbyte[0xfeff]//Read Command#defineLcdxcom XBYTE[0XFCFF]//Write CommandsUchar idata s_good[5]={'W','D','J','X',0x00};uchar idata s_good1[]={'2','0','1','6','-','0','7','-','2','2',0x00};sbit Bflag=acc^7;voidWaitvoid){ Do{acc=lcddcom;} while(bflag==1);}voidINIT_LCD (void) {lcdxcom=0x38;//Setup Modewait (); Lcdxcom=0x0f;//display switch and cursor settingswait (); Lcdxcom=0x06;//display switch and cursor settingswait (); Lcdxcom=0x01;//Clear Screenwait ();}voidD_char (Uchar a)//Write Data function{lcdxdata=A; Wait ();}voidDisplay (Uchar x, Uchar idata *s)//Display function The first variable is an address such as 0x80 or 0x80+0x40 the second is the data{Uchar I=0; Lcdxcom=x; Wait (); while(s[i]!=0x00) {D_char (s[i]); I++; }} voidMainvoid) {INIT_LCD (); Display (0x80+0x01, S_good); Display (0x80+0x40, S_GOOD1); while(1); }//Reprint please indicate the source
Associated Emulator Address:
Http://pan.baidu.com/s/1bGuyaa
51 Learning notes to achieve 1602 and 8051 connections in bus mode