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
//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.
Previous article:Clock Interrupt in MCU Programming
Next article:Based on PIC microcontroller and 16-bit serial D/A conversion principle
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- CGD and Qorvo to jointly revolutionize motor control solutions
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Nidec Intelligent Motion is the first to launch an electric clutch ECU for two-wheeled vehicles
- Bosch and Tsinghua University renew cooperation agreement on artificial intelligence research to jointly promote the development of artificial intelligence in the industrial field
- GigaDevice unveils new MCU products, deeply unlocking industrial application scenarios with diversified products and solutions
- Advantech: Investing in Edge AI Innovation to Drive an Intelligent Future
- CGD and QORVO will revolutionize motor control solutions
- 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
- [SC8905 EVM Review] + Unboxing test and driver installation
- How to detect inductor saturation | Comment and win a gift!
- Optimizing EMC and Efficiency in High Power DC/DC Converters Part 2
- [McQueen Trial] + Line-following Driving + Ultrasonic Obstacle Avoidance
- Can the freewheeling diode be omitted when the MOS tube controls the solenoid valve?
- STEVAL-MKSBOX1V1 (SensorTile.box) firmware download via USB
- Gallium nitride is a key technology for realizing 5G
- STM32 output 4-20MA or 0-10V circuit sharing
- LIS2MDL array PCB engineering and code information for magnetic nail navigation AGV car
- Live Review: Rochester Electronics Semiconductor Full-Cycle Solutions (including videos, materials, Q&A)