Introduction and application of interface between single chip microcomputer and liquid crystal display

Publisher:chenxiaohong68Latest update time:2012-09-24 Source: 21ic Keywords:MCU 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

voidWrite_LCD_Cmd(unsigned char cmd)

{

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

PBYTE[LCD_Cmd]=cmd;

}

//Write data subroutine

voidWrite_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 chart page)

{

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 c har y)

{

external 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);

}[page]

//Set the graphics page address subroutine

void Graph_Address(unsigned char x,

unsigned char y)

{

extern unsigned char graph page; 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 preview=0x00;

if(previews==0) ​​previews=c;

else

{

order=((unsigned int)

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

preee=oreee8;

aaa=32*previous;

order=order/8;

SCON = 0;

SBUF=concode[0x52];

[page]

kk=order/128;

wiee(!TI);

SCON = 0;

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

kk<<=1;

wiee(!TI);

SCON = 0;

SBUF=concode[kk]; kk=aaa%256;

wiee(!TI);

SCON = 0;

SBUF=concode[kk]; for(kk=0;kk<4;kk++)

{

wiee(!TI);

SCON = 0;

SBUF=concode[0xff]; }

wiee(!TI);

SCON=0x10;

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

{

Graph_Address(x,y*8+kka);

wiee(!RI);

preview=SBUF;

SCON=0x10;

write_lcd(concode[previous]);

ctrl(0xc0);

wiee(!RI);

preview=SBUF;

SCON=0x10;

write_lcd(concode[previous]);

ctrl(0xc0);

}

preview=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.

Keywords:MCU Reference address:Introduction and application of interface between single chip microcomputer and liquid crystal display

Previous article:Application of Clock Interrupt in MCU Programming
Next article:Circuit Design of Single Chip Microcomputer Timing Counter

Recommended ReadingLatest update time:2024-11-16 16:36

51 MCU Experiment - Hexadecimal Counter
1. Experimental topic: Use P0.0- P0.03 to design a hexadecimal counter that automatically counts between 0-15, and each number lasts 0.2s. The code uses SWITCH statements and for loops to implement the hexadecimal counter design. The LED lights connected to the four IO ports count in the binary change sequence of 0000
[Microcontroller]
51 MCU Experiment - Hexadecimal Counter
Design of portable anti-theft password input device based on single chip microcomputer
1. Project Overview 1.1 Introduction In today's information age, passwords need to be entered in many situations. Due to the limitations of input methods and devices using keys, the password input method becomes open, posing a threat to the security of the password. Although there are many patents in this field, m
[Power Management]
A method to realize LCD multi-level menu in single chip C language
0 Preface       Due to the structure and modularity of C language, programs written in C language are easy to read and maintain, and have good portability. This paper introduces a method of implementing LCD multi-level menus in C language, which has been successfully applied to coal mine safety monitoring equipment.
[Microcontroller]
Unity+VS2012+CodeWarrior v5.x (MCU is MC9S12XEP100) development environment configuration
Preface In this series, we will talk about the practical application of embedded TDD. I will talk about the entire process of my current embedded TDD development (excluding the version management part, although I actually use VCS to review what I have done step by step). It is definitely not the best practice and is s
[Microcontroller]
Unity+VS2012+CodeWarrior v5.x (MCU is MC9S12XEP100) development environment configuration
Design of railway crossing monitoring system in mining area using single chip microcomputer and GPRS
This paper designs a railway crossing monitoring system with Atmega128 and MC55 as the core , realizing the automation, digitization and networking of railway crossing monitoring management. This is of great significance to ensure the normal production of mining areas, improve the economic benefits of mi
[Microcontroller]
Design of railway crossing monitoring system in mining area using single chip microcomputer and GPRS
Application of Serial Communication of 87C196CA Single Chip Microcomputer Based on CAN Bus
1 Introduction CAN is a widely used field bus in the world. The MCS96 series microcontroller is an embedded controller that is widely used in the industry. Its 87C196CA microcontroller core itself has a CAN controller, which supports standard and extended information frames, that is, it follows the CAN2.0A and CAN2
[Microcontroller]
Application of Serial Communication of 87C196CA Single Chip Microcomputer Based on CAN Bus
Thermistor temperature measurement using MSP430 microcontroller
Thermistors are generally used as sensors to measure temperature. The measurement methods include R-V conversion voltage measurement method and R-F conversion frequency measurement method. The circuits of these two methods are complex and costly, and many components in the circuit directly affect the measurement accura
[Microcontroller]
Thermistor temperature measurement using MSP430 microcontroller
1602.c and 1602.h header files, perfect version of 51 MCU 1602 LCD driver
This file can perfectly drive the 1602 LCD screen. For detailed calling methods, please see:   http://www.51hei.com/bbs/dpj-24670-1.html   . There are two files 1602.c and 1602.h header files (behind). 1602.c file //******************************** #include stc12c5a.h #include intrins.h #define uchar unsigned char #
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号