Introduction to the interface application between single chip microcomputer and liquid crystal display

Publisher:陈晨5566Latest update time:2011-08-26 Source: EEWORLD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

Liquid crystal display (LCD) has the advantages of low operating voltage, low power consumption, large amount of displayed information and convenient interface. It has been widely used in fields such as computers and digital instruments, and has become an important tool for displaying measurement results and human-computer dialogue. LCDs can be divided into three categories according to their functions: pen segment LCD, character dot matrix LCD and graphic dot matrix LCD. The first two can display numbers, characters and symbols, while graphic dot matrix LCD can also display Chinese characters and arbitrary graphics, achieving the effect of both pictures and texts, and its application is becoming more and more extensive.

GTG240128 LCD display module:

1. Module Features

The dot matrix size of GTG240128 graphic dot matrix LCD is 240×128, with backlight function. It has a built-in T6963C LCD controller and 5 KS0086 drivers. The LCD module has the following features.

● 8-bit parallel bus interface, can be directly connected to 80 series microprocessors;

● Can display numbers, letters, Chinese characters and graphics, etc.;

● CGROM, a 5×8 dot matrix ASCII character font library with 128 types;

● It has 64kb display memory (which can be divided into text display area, graphic display area, text attribute area and custom character library area) and allows the MCU to access it at any time;

● It can be displayed in graphic mode, text mode or graphic and text combined mode.

2 Module interface pin functions

The interface between the GTG240128 LCD display module and the microprocessor has a total of 21 pins, and the functions of each pin are shown in Table 1.

3. Introduction to module instruction set

The GTG240128 LCD module uses hardware initialization settings, so that its command functions are focused on the display function settings, thereby enhancing the display capabilities. The module's commands can have one or two parameters, or no parameters. If the command contains parameters, the parameters must be entered before the command. Before each data or command write operation and data read operation, the status word detection must be performed. Only when it is not "busy", the MCU's operation on the module is valid. The meaning of its status bits from low to high is shown in Table 2.

When the MCU writes instructions or reads/writes data at one time, S0 and S1 must be valid at the same time; when the MCU uses the automatic read/write function, S2 and S3 will replace S0 and S1 as busy flags, and the MCU must then determine whether it is valid; S6 is a flag for examining the execution of the T6963C screen read or screen copy instructions; S5 and S7 represent the internal operating status of the module and are generally not used.

Interface circuit with AT89C55

The interface between GTG240128 and AT89C55 has two access modes: direct access and indirect access. The direct access mode is to directly hang the display module on the MCU bus as a memory or I/O device; the indirect access mode is to connect the display module to a certain I/O interface of the MCU, and the MCU indirectly controls the module by operating the I/O port. This article adopts the direct access mode, and the hardware connection circuit is shown in Figure 1.

The data line of the LCD module is connected to the data bus of AT89C55. The chip select signal is provided by the address lines A7 and A0, and the register select signal is provided by the address lines A7 and A1 (the instruction channel address is 0xf1, and the data channel address is 0xf3). The read and write operations are controlled by the read and write operation signals of AT89C55; the potentiometer connected to the Vo terminal of the module is used to adjust the contrast of the LCD.

Software Design

The software is developed in Keil C51 language and mainly includes three parts: the first part is the driver program for LCD display module hardware, such as writing instructions and writing data; the second part includes general subroutines such as LCD display module initialization and screen clearing; the third part is the display program of Chinese characters, letters and graphics.

1. Write instruction and write data subroutine

This part is the driver program of the LCD module. All operations on the LCD module are realized by calling this part of the program. The instruction channel address of the LCD module is 0xf1, and the data channel address is 0xf3. The specific driver program is as follows.

#definition LCD_Cmd 0xf1 //module command channel address

#definition LCD_Data 0xf3 //Module data channel address

//Write instruction subroutine

void Write_LCD_Cmd(unsigned char cmd)

while ((PBYTE[LCD_Cmd]&3)!=3);

PBYTE[LCD_Cmd]=cmd;

//Write data subroutine

void Write_LCD_Data(unsigned char dat)

while ((PBYTE[LCD_Cmd]&3)!=3);

PBYTE[LCD_Data]=dat;

2 Initialization subroutine

This part of the program is necessary before the LCD module displays, including setting the text page header address, graphic page header address, text page address, graphic page address, initialization and screen clearing subroutines. In this article, the display memory of the LCD module is divided into 16 text pages and 6 graphic pages. The start and end addresses of the text page are 0x00000~0x1ffff; the start and end addresses of the graphic page are 0x2000~0x7ffff.

//Set the text page header address subroutine

void Text_Home_Address(unsigned char tpage)

Write_LCD_Data(0);

Write_LCD_Data(tpage*0x02);

Write_LCD_Cmd(0x40); }

//Set the graphics page header address subroutine

void Graph_Home_Address(unsigned char gpage)

gpage+= 2;

Write_LCD_Data(0);

Write_LCD_Data(gpage*0x10);

Write_LCD_Cmd(0x42); }

//Set text page address subroutine

void Text_Address(unsigned char x, unsigned char y)

extern unsigned char textpage;

unsigned int xy;

xy=y*32+x+textpage*0x0200;

Write_LCD_Data(xy&0xff);

Write_LCD_Data(xy/256);

Write_LCD_Cmd(0x24);

Introduction to the interface application between single chip microcomputer and liquid crystal display

Time: 2011-06-28 23:39:07 Source: Author:

//Set the graphics page address subroutine

void Graph_Address(unsigned char x,

unsigned char y)

extern unsigned char graphpage; unsigned int xy;

graphpage+=2;

xy=y*32+x+graphpage*0x1000;

Write_LCD_Data(xy&0xff);

Write_LCD_Data(xy/256);

Write_LCD_Cmd(0x24);

// Initialization subroutine

void Init_LCD(void)

Write_LCD_Cmd(0x90);

Write_LCD_Data(0x20);

Write_LCD_Data(0x00);

Write_LCD_Cmd(0x41);

Write_LCD_Data(0x20);

Write_LCD_Data(0x00);

Write_LCD_Cmd(0x43);

Write_LCD_Cmd(0x89);

Write_LCD_Cmd(0xa1);

Write_LCD_Data(0x0F);

Write_LCD_Data(0x00);

Write_LCD_Cmd(0x22);

Write_LCD_Cmd(0x9c);

3. Display program for Chinese characters, symbols and graphics

By calling the driver, initialization and screen clearing programs written previously, the display of Chinese characters, characters and graphics can be easily realized. This article takes the display of Chinese characters as an example to introduce the compilation of the display program. Chinese characters can be displayed in text mode or in graphics mode. When displaying in text mode, the Chinese character font must be written into the CGRAM of the LCD display module every time the computer is turned on, which wastes time. In addition, since the capacity of CGRAM is only 2 KB, the displayed Chinese characters are limited, so Chinese characters are generally displayed in graphics mode. When displaying in graphics mode, the Chinese character font is first written in the Flash memory, and then taken out from the Flash memory when displaying. In this way, the Chinese character font does not need to be written every time the computer is turned on, which saves time and displays more Chinese characters. The following is a general subroutine for displaying Chinese characters in graphics mode. The Chinese character font is stored in the Flash memory.

void put_hanzi (char c)

unsigned char kk=c;

unsigned int order;

unsigned int aaa;

static unsigned char previous=0x00;

if(previous==0) previous=c;

else

order=((unsigned int)

(previous-0xa1)*94+kk-0xa1);

previous=order%8;

aaa=32*previous;

order=order/8;

SCON=0;

SBUF=concode[0x52];

kk=order/128;

wvile(!TI);

SCON=0;

SBUF=concode[kk]; kk=order%128;

kk<<=1;

wvile(!TI);

SCON=0;

The

wvile(!TI);

SCON=0;

Hi everyone!

wvile(!TI);

SCON=0;

SBUF=concode[0xff]; }

wvile(!TI);

SCON=0x10;

for (kk=0;kk<16;kk++)

Graph_Address(x,y*8+kk);

while(!RI);

previous=SBUF;

SCON=0x10;

write_lcd(concode[previous]);

ctrl(0xc0);

while(!RI);

previous=SBUF;

SCON=0x10;

write_lcd(concode[previous]);

ctrl(0xc0);

previous=0x00;

Conclusion

The LCD module introduced in this paper has been successfully applied in a portable rail head section laser detector. It has a wide range of application value due to its advantages such as convenient interface with MCU, strong display function and simple programming.

Reference address:Introduction to the interface application between single chip microcomputer and liquid crystal display

Previous article:Clock Interrupt in MCU Programming
Next article:Based on PIC microcontroller and 16-bit serial D/A conversion principle

Latest Industrial Control Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号