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.
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
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【Child care machine】+ ESP32-S3-BOX+ESP32-S3-DevKitC-1 material unpacking and BOX basic demonstration
- [Free trial of Pingtouge Bluetooth Mesh Gateway Development Kit] + nRF Mesh and Light Experiment (Part 2)
- PCB learning
- Allwinner V853 development board Tina SDK LCD small resolution DCLK setting problem
- Unboxing
- How to choose resistors in circuit design?
- A time-delayed shutdown circuit
- Automotive 10V-80V Ultra-Wide Vin, 12V Vout Flyback Reference Design for 48V Car Battery
- Application of Single Pair Ethernet in Building Automation
- Small and exquisite open source Python learning board Mini SAM