是28pin引线的那种COG,MCU通过一个74HC164进行传并转换,连接LCD。我是用示波器检测的。 以下是读写: void write_LCD_command(uchar dat){ uchar i; LCD_WR=0; LCD_RS=0;//command write. LCD_CS=0; LCD_RD=1; for(i=0; i<8; i++) { LCD_SCLK=0; _nop_(); if(dat&0x80) LCD_DATA=1; else LCD_DATA=0; dat<<=1; _nop_(); _nop_(); LCD_SCLK=1; } LCD_RD=0; //WRITE NOW! _nop_(); LCD_CS=1; LCD_RS=1; }void write_LCD_data(uchar dat){ uchar i; LCD_WR=0; LCD_RS=1;//DATA write. LCD_CS=0; LCD_RD=1; for(i=0; i<8; i++) { LCD_SCLK=0; _nop_(); if(dat&0x80) LCD_DATA=1; else LCD_DATA=0; dat<<=1; _nop_(); _nop_(); LCD_SCLK=1; } LCD_RD=0; //WRITE NOW! _nop_(); LCD_CS=1; LCD_RS=0; }
以下是初始化代码 void iniLCD(void){ LCD_RES=1; delay_ms(500); LCD_RES= 0 ; delay_ms(500); LCD_RES=1; delay_ms(500); write_LCD_command(0xe2); /*reset by software*/ delay_ms(500); write_LCD_command(0x48); //SET DUTY write_LCD_command(0x50); write_LCD_command(0xA0); /* ADC SELECT A0:NORMAL A1:REVERSE */ write_LCD_command(0xC0); //SHL SELECT C0:NORMAL C1:REVERSE write_LCD_command(0xAB); //OSC START write_LCD_command(0x67); /* SELECT DC-DC STEP-UP 0x64~0x67 */ write_LCD_command(0x27); /* Regulator Select 0x20-0x27 */ write_LCD_command(0x81); /*Set Reference Voltage Select Mode */ write_LCD_command(0x3F); //Set Reference Voltage Register 0x00-0x3F write_LCD_command(0x54); /* lcd bias */ write_LCD_command(0x2c); /* V/C on, V/R on, V/F on */ delay_ms(500);//Delay 1S write_LCD_command(0x2e); /* V/C on, V/R on, V/F on */ delay_ms(500); write_LCD_command(0x2f); /* V/C on, V/R on, V/F on */ ——问题1:到这句屏会全黑,正常?? delay_ms(500); write_LCD_command(0x40); /* display start first line */ write_LCD_command(0x00); delay_ms(500); write_LCD_command(0x44); /* COM0 */ write_LCD_command(0x00); delay_ms(500); write_LCD_command(0xaf); /* display on */ ——问题2:到这句上部1/4熄灭,其余全亮(黑) } 下面是清屏函数,但运行没任何效果。 void clear_disp(void) { uchar page=0xb0,column; for (page=0xb0;page<0xbe;page++) { write_LCD_command(page); //set page adress write_LCD_command(0x00); //set start column adress write_LCD_command(0x10); for(column=0;column<=160;column++) { write_LCD_data(0x0); write_LCD_data(0x0); } } } |