LCD12864汉字显示问题
时间:10-02
整理:3721RD
点击:
[img]F:\汇总\Docu
- #include<reg51.h>
- #include<intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- sbit CS1=P2^0;
- sbit CS2=P2^1;
- sbit rs=P2^2;
- sbit rw=P2^3;
- sbit e=P2^4;
- uchar code ni[]={0x10,0x01,0x10,0x01,0x10,0x01,0x88,0x7F,0x88,0x40,0x4C,
- 0x20,0x2C,0x04,0x0A,0x04,0x89,0x14,0x88,0x24,0x48,0x24,
- 0x48,0x44,0x28,0x44,0x08,0x04,0x08,0x05,0x08,0x02};
- void delay(uchar ms)
- {
- uchar i;
- while(ms--)
- {
- for(i=0;i<120;i++);
- }
- }
- uchar Busy_Check()
- {
- uchar LCD_Status;
- rs=0;
- rw=1;
- e=1;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- LCD_Status=P0&0x80;
- e=0;
- return LCD_Status;
- }
- void lcd_wcmd(uchar cmd)
- {
- while(Busy_Check());
- rs=0;
- rw=0;
- e=0;
- _nop_();
- _nop_();
- P0=cmd;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- e=1;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- e=0;
- }
- void lcd_wdat(uchar dat)
- {
- while(Busy_Check());
- rs=1;
- rw=0;
- e=0;
- P0=dat;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- e=1;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- e=0;
- }
- void set_page(uchar page)
- {
- page=0xb8|page;
- lcd_wcmd(page);
- }
- void set_line(uchar startline)
- {
- startline=0xc0|startline;
- lcd_wcmd(startline);
- }
- void set_lie(uchar lie)
- {
- lie=0x3f&lie;
- lie=0x40|lie;
- lcd_wcmd(lie);
- }
- void setonoff(uchar onoff)
- {
- onoff=0xce|onoff;
- lcd_wcmd(onoff);
- }
- void selectscreen(uchar screen)
- {
- switch(screen)
- {
- case 0: CS1=0;CS2=0;break;
- case 1: CS1=0;CS2=1;break;
- case 2: CS1=1;CS2=0;break;
- default:break;
- }
- }
- void clearscreen(uchar screen)
- {
- uchar i,j;
- selectscreen(screen);
- for(i=0;i<8;i++)
- {
- set_page(i);
- set_lie(0);
- for(j=0;j<64;j++)
- {
- lcd_wdat(j);
- }
- }
- }
- void initlcd()
- {
- while(Busy_Check());
- selectscreen(0);
- setonoff(0);
- selectscreen(0);
- setonoff(1);
- selectscreen(0);
- clearscreen(0);
- set_line(0);
- }
- void disp(uchar ss,uchar page,uchar lie,uchar *P )
- {
- uchar i;
- selectscreen(ss);
- set_page(page);
- set_lie(lie);
- for(i=0;i<16;i++)
- {
- lcd_wdat(P[i]);
- }
- set_page(page+1);
- set_lie(lie);
- for(i=0;i<16;i++)
- lcd_wdat(P[i+16]);
- }
- void main()
- {
- initlcd();
- clearscreen(0);
- set_line(0);
- disp(1,0,2*16,ni);
- delay(5);
- while(1);
-
- }
这是程序为什么仿真不显示汉字,求解
用什么仿真的,protues中的12864不支持汉字···