Project download
1.0 Circuit Diagram
2.0 Program
Or just post the driver, the complete routine can be downloaded above.
#include <intrins.h> #include<ziku.c> #define uchar unsigned char #define uint unsigned int uchar num[] = "0123456789"; sbit REST = P2^0; //Reset signal, active"L" sbit C_D = P2^1; //L:data H:code sbit C_E = P2^2; //Chip enable signal, active"L" sbit R_D = P2^3; //read signal, active"L" sbit W_R = P2^4; //write signal, active"L" #define width 15 //display area width #define Graphic 1 #define TXT 0 #define LcmLengthDots 128 #define LcmWidthDots 64 /****************************Correlation function of 12864 liquid crystal****************** ****/ void delay_nms(uint i) { while(i) i--; } void write_commond(uchar com) //Write a command to the LCD { C_E = 0; C_D = 1; R_D = 1; P0 = with; W_R = 0; // write _nop_(); W_R = 1; // disable write C_E = 1; C_D = 0; } void write_date(uchar dat) //Write a data to the LCD { C_E = 0; C_D = 0; R_D = 1; P0 = that; W_R = 0; _nop_(); W_R = 1; C_E = 1; C_D = 1; } void write_dc(uchar com, uchar dat) //Write an instruction and a data { write_date(dat); write_commond(com); } //Write one instruction and two data void write_ddc (uchar com, uchar dat1, uchar dat2) { write_date(dat1); write_date(dat2); write_commond(com); } //LCD initialization function void F12864_init(void) { REST = 0; delay_nms(2000); REST = 1; write_ddc(0x40,0x00,0x00); //Set the first address of the text display area write_ddc(0x41,128/8,0x00); //Set the width of the text display area write_ddc(0x42,0x00,0x08); //Set the first address of the graphics display area to 0x0800 write_ddc(0x43,128/8,0x00); //Set the width of the graphic display area write_commond(0xA0); //Set the cursor shape to 8x8 square write_commond(0x80); //Display mode setting text and graphics (XOR) write_commond(0x92); //Set the cursor write_commond(0x9F); //Display switch setting text on, graphics on, cursor blinking off } //****************************//Clear display memory function void F12864_clear(void) { unsigned int i; write_ddc(0x24,0x00,0x00); //Set the address pointer to start from zero write_commond(0xb0); //Auto write for(i = 0;i < 128 * 64 ;i++)write_date(0x00); //清一屏 write_commond(0xb2); //Automatic write end write_ddc(0x24,0x00,0x00); //Reset the address pointer } //Set the displayed address void goto_xy (uchar x, uchar y, uchar mode) { uint temp; temp = 128 / 8 * y + x; if(mode) //mode = 1为Graphic { //If the graphics mode needs to add the first address of the graphics area to 0x0800 temp = temp + 0x0100; } write_ddc(0x24,temp & 0xff,temp / 256); //address pointer location } //Display an ASCII code function void Putchar (flying x, flying y, flying Charbyte) { goto_xy(x,y,TXT); write_dc(0xC4,Charbyte-32); //Data one read and write method //Check character rom } void display_string (uchar x, uchar y, uchar * p) { while(*p != 0) { if(x > 15 ) //Auto wrap 128*64 { x = 0; y++; } Putchar(x,y,*p); ++x; ++p; } } void display_num (flying x, flying y, flying z) { flying z1, z2; z1 = num[z / 10]; z2 = num[z % 10]; Putchar(x,y,z1); Putchar(x+1,y,z2); } //Display a string of Chinese characters, j = k + n is (n is the number of words to be displayed), k is the word to choose from void dprintf_hanzi_string_1(struct typFNT_GB16 code *GB_16,uint X_pos,uint Y_pos,uchar j,uchar k) { unsigned int address; unsigned char m,n; while(k < j) { m = 0; address = LcmLengthDots / 8 * Y_pos + X_pos + 0x0800; for(n = 0;n < 16;n++) //count value 16 { write_ddc(0x24,(uchar)(address),(uchar)(address>>8)); //Set the display memory address write_dc(0xc0,GB_16[k].Mask[m++]); //Write the left part of the Chinese character model write_dc(0xc0,GB_16[k].Mask[m++]); //Write the right part of the Chinese character model address = address + 128/8; //Modify the display memory address and display the next column (16 columns in total) } X_pos += 2; k++; } }