为什么我的proteus仿真出来是这样的
1、 LCD12864显示驱动程序 //--------------------------LCD_12864.c------------------------- // 名称 :12864LCD显示驱动程序(不带字库) //----------------------------------------------------------------- #include #include #define uchar unsigned char #define uint unsigned int #define LCD_DB_PORT P0 // 液晶数据线端口DB0-DB7 #define LCD_START_ROW 0xc0 //起始行命令 #define LCD_PAGE 0xB8 // 页指令 #define LCD_COL 0x40 // 列指令 bit Reverse_Display=0;//是否反相显示(白底黑字/黑底白字) //液晶引脚定义 sbit DI=P2^0; sbit RW=P2^1; sbit E=P2^2; sbit CS1=P2^3; sbit CS2=P2^4; sbit RST=P2^5; //--------------------------------------------------------------- // 检查LCD是否忙 //-------------------------------------------------------------- bit LCD_IS_BUSY() { LCD_DB_PORT=0xFF; RW=1; _nop_(); DI=0; E=1; _nop_(); E=0; return (bit)(P0&0x80); } //--------------------------------------------------------------- // 向LCD写入一个字节(一般用于发送命令) //-------------------------------------------------------------- void Write_Byte_To_LCD(uchar comand) { while(LCD_IS_BUSY()); LCD_DB_PORT=0xFF; RW=0; _nop_(); DI=0; LCD_DB_PORT=comand; E=1; _nop_(); E=0; } //--------------------------------------------------------------- // 向LCD写入数据 //-------------------------------------------------------------- void Write_Data_To_LCD(uchar dat) { while(LCD_IS_BUSY()); LCD_DB_PORT=0xFF; RW=0; _nop_(); DI=1; if(!Reverse_Display) //根据Reverse_Display决定是否反相显示 LCD_DB_PORT=dat; else LCD_DB_PORT=~dat; E=1; _nop_(); E=0; } //--------------------------------------------------------------- // 初始化LCD //-------------------------------------------------------------- void LCD12864_Initialization() { CS1=1; CS2=1; Write_Byte_To_LCD(0x38); Write_Byte_To_LCD(0x0F); Write_Byte_To_LCD(0x01); Write_Byte_To_LCD(0x06); Write_Byte_To_LCD(LCD_START_ROW); } //--------------------------------------------------------------- // 通用显示函数 从第P页第L列显示W个字节数据,具体显示的数据在r所指的数组中 //-------------------------------------------------------------- void LCD_Show(uchar P,uchar L,uchar W,uchar *r) reentrant { uchar i; if(L<64) { CS1=1; CS2=0; Write_Byte_To_LCD(LCD_PAGE+P); Write_Byte_To_LCD(LCD_COL+L); if(L+W<64) { for(i=0;i Write_Data_To_LCD(r); } else { for(i=0;i<64-L;i++) Write_Data_To_LCD(r); CS1=0; CS2=1; Write_Byte_To_LCD(LCD_PAGE+P); Write_Byte_To_LCD(LCD_COL); for(i=64-L;i Write_Data_To_LCD(r); } } else { CS1=0; CS2=1; Write_Byte_To_LCD(LCD_PAGE+P); Write_Byte_To_LCD(LCD_COL+L-64); for(i=0;i Write_Data_To_LCD(r); } } //--------------------------------------------------------------- // 显示一个8×16点阵字符 //-------------------------------------------------------------- void Display_char(uchar P1,uchar L1,uchar *M) reentrant { LCD_Show(P1,L1,8,M); LCD_Show(P1+1,L1,8,M+8); } //-------------------------------------------------------------------- // 显示一个16×16点阵字符 (汉字上半部分与下半部分分别处在相邻两页中) //---------------------------------------------------------------------- void Display_Word(uchar P2,uchar L2,uchar *M) reentrant { LCD_Show(P2,L2,16,M); LCD_Show(P2+1,L2,16,M+16); }
|