The 12,864-point array liquid crystal display module (LCM) is an array of 128-column *64 rows consisting of a 128*64 LCD display point. Each display point corresponds to a binary number, 1 for light, and 0 for off. The RAM that stores these lattice information is called the Display data memory. To display a graphic or Chinese character is to write the corresponding lattice information to the appropriate storage unit. The lattice information of a graphic or Chinese character is, of course, designed by itself, and the crux of the problem is the relationship between the position (rows and columns) of the display point on the LCD screen and its address in memory.
Since most of the LCD module drive circuit is composed of a row of drivers and two-column drivers, so the 12864 LCD screen is actually composed of the left and right two independent 64*64 LCD screen, each half screen has a 512*8 bits display data ram. The left and right half-screen drive circuit and memory are selected by CS1 and CS2 of the chip selection signal respectively. (A few manufacturers in order to simplify user design, in the module to increase the decoding circuit, so that the 128*64 LCD screen is a full screen, only a chip selection signal. )
The position of the display point on the 64*64 LCD is determined by the line number (line,0~63) and the column number (column,0~63). The address of a storage unit in 512*8 bits RAM is determined by the page address (XPAGE,0~7) and column address (yaddress,0~63). Each storage unit stores display information for 8 LCD dots.
In order to make the liquid crystal point location information and storage address of the corresponding relationship more intuitive off, the 64*64 LCD screen from top to bottom 8 divided into 8 display blocks, each block including 8 rows *64 list of dots. The 8-row lattice information in each column forms a 8bits binary number, stored in a storage unit. (Note: Binary's high-low-order and line-number correspondence vary by merchant) The Ram area that holds a display block is called a storage page. That is, the lattice information of the 64*64 LCD screen is stored in 8 storage pages, 64 bytes per page, and each byte stores a column (8 rows) of lattice information. Therefore, the storage cell address includes the page address (xpage,0~7) and the column address (yaddress,0~63).
For example, light 128*64 in the screen (20,30) position on the LCD point, because the column address 30 is less than 64, the point in the left half of the 29th column, so the CS1 is valid; line address 20 divided by 8 rounding 2, take more than 4, the point in RAM page address is 2, in bytes of the ordinal is 4; So the binary data 00010000 (also possibly 00001000, high and low order depending on the manufacturer) is written to the xpage=2,yaddress=29 in the storage unit that is lit (20,30) on the LCD point.
LCD12864 LCD test Program (passed)//////////////LCD Model: hj12864m-1/////////////////////////////////////////////////# Include <reg52.h> #define UCHAR unsigned char #define UINT unsigned int//8bit data access IO Port #define PART P0//p0 8-bit data cable//Control Data end Sbit lcd_rs=p2^5; Definition 12864 LCD RS terminal, register Select signal H: Data register L: instruction register sbit lcd_rw=p2^6; Definition 12864 LCD RW end, read/write signal H: Read L: Write Sbit lcd_en=p2^7; Define 12864 LCD Lcden end, chip selection signal falling edge trigger, latch data//sbit lcd_psb=p3^2; Definition 12864 LCD PSB end, H: Parallel L: serial sbit lcd_rst=p3^4; Definition 12864 LCD rst end, H: Do not reset L: Reset Uchar Code dis1[]={"before the Moon Light"}; Uchar code dis2[]={"Suspicion is ground frost"}; Uchar code dis3[]={"Jutou look at the Moon"}; Uchar code dis4[]={"Think Home"}; =====================================//Millisecond delay function void delay (UINT XMS) {UINT I,j; for (j=0;i<xms;j++) for (i=0;i<110;i++); }//====================================//LCD busy detection function bit lcd_busy () {bit result; lcd_rs=0; Lcd_rw=1; Lcd_en= 1; result= (Bit) (part & 0x80); lcd_en=0; return result; } //=====================================//LCD write command function void Lcd_write_cmd (Uchar com) {while (Lcd_busy ()); lcd_rs=0; Select the command register lcd_rw=0; Write lcd_en=0; part=com; The instruction value is assigned to P0 Port delay (5); Lcd_en=1; Delay (5); lcd_en=0; }//=====================================//LCD write a character data function void Lcd_write_dat (Uchar date) {while (Lcd_busy ()); Lcd_rs=1; Select data register lcd_rw=0; Write lcd_en=0; P0=date; The data value is assigned to P0 Port delay (5); Lcd_en=1; Delay (5); lcd_en=0; }//=====================================//LCD write a string function void Lcd_write_string (Uchar *str) {while (*str!= '} ')//not closed {Lcd_write_dat (*str++); Delay (5); }}//=====================================////liquid crystal display position function void Lcd_pos (Uchar X,uchar y)//Show {Uchar pos starting at the y position of line x) if (x==1)//First line {x=0x80;} else if (x==2)//second row {x=0x90;} else if (x==3)//third line {x=0x88;} else if (x==4)//fourth row {x=0x98;} Pos=x+y-1; The first address is 0x80 Lcd_write_cmd (POS); }//=====================================//LCD initialization function voidLcd_init () {lcd_psb=1; Parallel mode lcd_rst=1; No longer lcd_write_cmd (0x30); Delay (5); Lcd_write_cmd (0x0c); On display, the cursor delay (5) is not displayed; Lcd_write_cmd (0x06); After writing a character, the address pointer automatically adds 1 delay (5); Lcd_write_cmd (0x01); Clear screen delay (5); }//=====================================//main function function void Main () {//Uchar I; Lcd_init (); while (1) {lcd_pos (); Lcd_write_string (DIS1); Lcd_write_string ("The Moon Light before the bed"); Delay (5); Lcd_pos (2,1); Lcd_write_string (DIS2); Lcd_write_string ("Suspected ground frost"); Delay (5); Lcd_pos (3,1); Lcd_write_string (DIS3); Lcd_write_string ("Jutou looking at the moon"); Delay (5); Lcd_pos (4,1); Lcd_write_string (DIS4); Lcd_write_string ("Think Home"); Delay (500); } }
12,864-point Array LCD module principle and Example program (HJ12864M-1)