AMPIRE12864 显示汉字(protues 仿真) 收藏 经过半天的努力,终于在PROTEUS 上让液晶屏显出汉字了 以下是源代码 /*******************************main.h******************************/ #ifndef _MAIN_H #define _MAIN_H #include #define LcdDataPort P0 //数据端口 #ifndef UCHAR_DEF #define UCHAR_DEF typedef unsigned char uchar; #endif sbit Reset = P2^0; //复位 sbit RS = P3^1; //指令数据选择 sbit E = P3^2; //指令数据控制 sbit CS1 = P2^5; //左屏幕选择,低电平有效 sbit CS2 = P2^4; //右屏幕选择 sbit RW = P2^7; //读写控制 sbit busy = P0^7; //忙标志 void SetOnOff(uchar onoff); //开关显示 void SelectScreen(uchar screen);//选择屏幕 void ClearScreen(uchar screen); //清屏 void Show1616(uchar lin,uchar colum,uchar *address);//显示一个汉字 void CheckState(); //判断状态 void LcdDelay(unsigned int time); //延时 void WriteData(uchar dat); //写数据 void SendCommand(uchar command); //写指令 void SetLine(uchar line); //置行地址 void SetColum(uchar colum);//置列地址 void SetStartLine(uchar startline);//置显示起始行 void InitLcd(); //初始化 void ResetLcd(); //复位 #endif /*********************************************************************/ /***********************************lcd.c****************************************/ #include "main.h" void CheckState() { E = 1; RS = 0; RW = 1; LcdDataPort = 0xff; while(!busy); } void LcdDelay(unsigned int time) { while(time --); } void WriteData(uchar dat) { CheckState(); E = 1; RS = 1; RW = 0; LcdDataPort = dat; E = 0; } void SendCommand(uchar command) { CheckState(); E = 1; RW = 0; RS = 0; LcdDataPort = command; E = 0; } void SelectScreen(uchar screen) //0-全屏,1—左屏,2-右屏 { switch(screen) { case 0 : CS1 = 0; LcdDelay(2); CS2 = 1; LcdDelay(2); break; case 1 : CS1 = 1; LcdDelay(2); CS2 = 0; LcdDelay(2); break; case 2 : CS1 = 0;...