Home > other >  Screen can only display 12864 hang, how to solve
Screen can only display 12864 hang, how to solve

Time:04-22

This is my program
.h files
# # ifndef _LCD12864_H_
# define _LCD12864_H_
# define LCD_PORT P3
Sbit lcd_rs P1=^ 0;
Sbit lcd_rw=p ^ 2;
Sbit lcd_e P1=^ 3;
Sbit lcd_rst=P2 ^ 5;
Sbit lcd_change=P2 ^ 7;

Extern void busy ();
Extern void cmd_write12864 uchar (CMD);
Extern void dat_write12864 uchar (dat);
Extern void LCD12864_Init ();
Extern void display_12864 (uchar y, uchar x, uchar * z);
Extern void displayDigital_12864 (uchar y, uchar x, uchar shu);
# endif

.c file
//check busy
Void busy ()
{
Lcd_rs=0; Lcd_rw=1; Lcd_e=1;
Delayms (5);
While ((LCD_PORT & amp; 0 x80)==0 x80);
Lcd_e=0;
}
Write command/* * */
Void cmd_write12864 uchar (CMD)
{
Busy ();

Lcd_rs=0;//RS port s
Lcd_rw=0;//RW port s
Lcd_e=0;
LCD_PORT=CMD;
Lcd_e=1;//E port buy 1
Delayms (10);//delay

Lcd_e=0;//E port s
}

/* * */write data
Void dat_write12864 uchar (dat)
{
Busy ();

Lcd_rs=1;//RS port buy 1
Lcd_rw=0;//RW port s
Lcd_e=0;//E port s
LCD_PORT=dat;//fill data
Lcd_e=1;//E port buy 1
Delayms (10);

Lcd_e=0;//E port s
}


Void LCD12864_Init ()
{
Lcd_change=1;
Lcd_rst=0;
LCD_PORT=0;
Delayms (15);
Lcd_rst=1;
Cmd_write12864 (0 x30);//select basic instruction operation
X0c cmd_write12864 (0);//display on and off the cursor
Cmd_write12864 (0 x01);//remove LCD12864 display content
}





/* * * * * * * * * * * * * * * * * * * * * * * * * * * * shows part of the * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//LCD display digital program
Void displayDigital_12864 (uchar y, uchar x, uchar shu)
{
Uchar a, b, Address;
A=shu/10;
B=shu % 10;
If (y==1) {Address=0 x80 + x; }//Y determine how many lines, X determine which columns, 0 x80 line for LCD initial address
If (y==2) {Address=0 x90 + x; }
If (y==3) {Address=0 x88 + x; }
If (y==4) {Address=0 x98 + x; }
Cmd_write12864 (Address);//write address command to LCD12864
Dat_write12864 (0 x30 + a);
Dat_write12864 (0 x30 + b);

}
//LCD display program
Void display_12864 (uchar y, uchar x, uchar * z)
{
Uchar Address;
If (y==1) {Address=0 x80 + x; }//Y determine how many lines, X determine which columns, 0 x80 line for LCD initial address
If (y==2) {Address=0 x90 + x; }
If (y==3) {Address=0 x88 + x; }
If (y==4) {Address=0 x98 + x; }
Cmd_write12864 (Address);//write address command to LCD12864
While (* z!='\ 0')//write the size of the display data
{
Z++ dat_write12864 (*);//writes data to the display LCD12864
}
}

Void main () {

LCD12864_Init ();

Display_12864 (3, 1, "");
While (1);

}

CodePudding user response:

Add that the time delay function
Void delayus (uint t)//delay subtle function
{
While (t -);
}
Void delayms (uint t)//delay millisecond function
{
Uint I, j;
For (I=t; I> 0; I -)
for(j=0; J<120; j++);
}
And there's lcd_change PSB feet

CodePudding user response:

CodePudding user response:

According to others to copy
  • Related