As a commonly used display device, the LCD module has the characteristics of low power consumption, rich display content, and flexible control. Among the medium-sized graphic LCD display modules, the LCD module with built-in T6963C controller is currently the more commonly used built-in controller type graphic LCD display module. The module can be initialized and set by hardware circuits, so it can save software overhead. In terms of software, the T6963C controller also provides a rich instruction set, and the control method is flexible and diverse. The 32-bit microprocessor with ARM as the core has the characteristics of high performance and low power consumption, and is widely used in the field of industrial control. Therefore, for the low-end ARM7 chip without LCD interface, its general purpose input and output (GPIO) pins can be used to connect to the LCD and control the LCD to realize its display function.
1 LCD hardware interface design
The T6963C controller can be connected to the row and column drivers and display buffer RAM of the LCD module, and the LCD screen structure (single or dual screen), display window length, width, font, etc. can be set through this hardware connection method. The principle block diagram of the single-screen structure dot matrix graphic LCD display module with built-in T6963C is shown in Figure 1.
In Figure 1, the data bus and the control bus are directly connected to the IO port line of the CPU. The liquid crystal can use the SMG240128A dot matrix graphic liquid crystal display module; and the CPU can use the 32-bit microprocessor chip LPC2134 based on the ARM7TD-MI-S core. The chip is designed based on the principle of RISC, and the instructions and decoding are simple and convenient. It adopts three-level pipeline technology, the CPU operating frequency can reach up to 60MHz, and it has 47 general I/O ports. At the same time, it contains rich peripheral resources, which is very suitable for use in the field of industrial measurement and control. The interface circuit between the liquid crystal module and LPC2134 is shown in Figure 2.
The liquid crystal module in Figure 2 adopts data parallel transmission mode and is connected to LPC2134 through two driver chips 74L3245 and 74HC14. Among them, 74LS245 is an eight-bit bidirectional bus transceiver, which can connect the data bus of the LCD module to the eight lines of the CPU's P0 port, is responsible for controlling the transmission of data, and has data latching and buffering functions: 74HC14 is a six-input inverting driver that can drive the four control lines of the LCD module. Pin 21 of the LCD module is the backlight ground terminal, which is controlled by p0.23 to turn the backlight on and off. The backlight brightness can be adjusted by potentiometer W2, and the contrast of the LCD display can be controlled by potentiometer W1. The FG pin is the frame ground and must be grounded to prevent static electricity and lightning strikes. The FS pin is grounded to control the font to 8x8 dot matrix.
2 Implementation of display function
The LCD display function can be realized by controlling the LCD controller T6963C by LPC2134. The T6963C controller has a rich set of built-in instructions, and the display function can be set by instructions. Instructions can have one or two parameters, or no parameters. The execution of each instruction is to first enter the parameters and then the instruction code. Before each operation, the status word needs to be detected. [page]
At the program level, whether it is the detection of status words or the transmission of parameters and instruction codes, it involves the read and write operations of the LCD controller. According to the read and write timing provided in the T6963C manual and combined with the hardware design of this system, the read and write timing diagram shown in Figure 3 can be obtained.
When designing a program, you can simulate the read and write timing diagram of the LPC2134 GPIO pin to achieve data transmission. According to the data and read and write types, four underlying sub-functions can be designed to complete the transmission function. The functional description is listed in Table 1.
The source codes of the write command word sub-function and the read data sub-function are as follows:
Define the following constants in the header file in advance:
#define WR 1<<25 // p0.25 write control bit
#define CD 1<<17 // p1.17 data instruction selection control bit
#define RD 1<<26 // p0.26 read control bit
#define CE 1<<27 // p0.27 LCD chip select
#define DIR 1<<22 // p1.22 74LS245 data transfer direction control bit
#define DPT0xOff<<16 // data port
// Write command word sub-function complete source code
void LCD_WriteCommand(uint8 command)
{
uint32 com=0; // define temporary storage unit
com=command;
IOODIR=IOODIR | DPT; // set output data
IOOSET=IOOSET | CD; // command attribute
IOOSET=IOOSET | WR:
IOOSET=IOOSET | RD;
IO1CLR=I01CLR | DIR;
//Data transmission direction setting
IOOSET=(IOOSET&(~DPT))|(com<<16);
//Data write entry line
IOOCLR=(IOOCLR&(-DPT)|(((-com)&(0xOff)<<16);
IOOCLR=IOOCLR | CE; //Select LCD
IOOCLR=IOOCLR | WR; //Write valid
IOOSET=IOOSET | WR; //Write completed, write low
IOOSET=IOOSET | CE;
}[page]
//Complete source code of read data sub-function
uint8 LCD_ReadData 0
{
uint8 data;
IO0DIR=IOODIR&(~DPT); //Input data
I01CLR=I01CLR | CD; //Data attribute
IO0SET=IO0SET | WR;
IO0SET=IO0SET | RD;
IO1SET=IO1SET | DIR;
//Data transmission direction setting
IO0CLR=IO0CLR | CE;
IO0CLR=IO0CLR | RD; //Read valid
data=(IO0PIN&DPT)>>16;
//Read data from pin status register
IOOSET=IOOSET | RD; //Read invalid
IO0SET=IO0SET | CE;
return (data); //The return value is the read data
}
As for the writing of read status and write data sub-functions, you can refer to this sub-function to complete it during design.
2.2 Driver layer implementation
Next, we need to use the instructions of T6963C to complete the setting of the driver layer display function. The definitions of some basic instructions are listed in Table 2. In fact, the writing of driver layer sub-functions can be achieved by calling write command, write data, and read status sub-functions.
The source code of the LCD initialization setting function is as follows:
void LCD_Initialize(void)
{
LCD_WriteTCommand3(LCD_TXT_STP, 0x00, 0x00); //Text mode RAM starting address
LCD_WriteTCommand3(LCD_TXT_WID, 30, 0x00); //Set the width of the text mode, the width is N/6 or N/8, N is the number of width dots, such as 240
LCD_WriteTCommand3(LCD_GRH_STP, 0x00, 0x00); //Graphics mode RAM starting address
LCD_WriteTCommand3(LCD_GRH_WID, 30, 0x00); //Set the width of the graphics mode, the width is N/6 or N/8, N is the number of width dots, such as 240
LCD_WriteTCommand 1(LCD_MOD_OR); //Set the display mode to "or"
LCD_WriteTCommandl(LCD_DIS_SW |0x08); //Set pure graphic display mode
}
2.3 Chinese character reading and writing program design
After initializing the LCD, you can set the display area, display mode and display status. Next, the font data of the characters to be displayed should be written into the display buffer to realize the display function. For the text mode, you can first write the font data into the display buffer and establish CGRAM, then determine the character code by the data storage location, and then display the character by writing the corresponding code; for the graphic display mode, you need to write the font data byte by byte into the graphic display buffer to realize the display function. The two have their own characteristics, among which the text mode has a fast display speed. The built-in CGROM contains 128 ASCII characters, which can be called directly, but CGRAM must be established first, and the capacity is limited, and only 2K bytes of data can be managed, which is more suitable for occasions where not many characters are displayed; while the graphic mode has a relatively slow display speed, but there is no need to establish CGRAM. Users only need to write the font data in bytes into the graphic display area, which is suitable for occasions where more content needs to be displayed. In general engineering applications, the display of Chinese characters is a relatively important content, so this article mainly introduces the program design of Chinese character display. [page]
The horizontal coordinate x on this LCD screen ranges from 0 to 29, and the vertical coordinate y ranges from 0 to 127. The font data is provided by the font creation software. The order of writing the font data should correspond to the structural position of the character it represents. When reading and writing display data, please note that the address pointer will automatically increase by one each time it is read and written. When modifying its value, you must first end the current read and write operation, and then modify the address, so that it will be effective. The writing of other sub-functions is the same as the Chinese character display sub-function. Characters of different fonts only have different font data volumes. Continuous writing can be achieved by calling a separate write function multiple times, or the corresponding byte data of all characters can be written in each line. As for the realization of the reverse function, you can first read the data byte of the corresponding character, invert it, and then rewrite it.
3 Conclusion
This paper realizes the interface design with the LCD display module with built-in T6963C through the GPIO of the ARM7 microprocessor chip LPC2134, and realizes its basic display function in software, thus meeting the requirements of engineering design. This paper systematically explains the design process of the LCD display program, and gives the source code for reference for the difficulties in the design. The program has good portability and can be applied to LPC213x series chips, other ARM7 chips and different models of LCD display modules with built-in T6963C.
Previous article:Embedded data acquisition and remote transmission control system based on LabVIEW and ARM
Next article:Design and implementation of pulse monitor system based on ARM
Recommended ReadingLatest update time:2024-11-16 21:27
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
- What is Wi-Fi 6 and why do we need it?
- Sharing: Design of an outdoor switching power supply_Simulation and experimental research
- Watch the video to win a JD card | PI Brushless DC Motor Learning Center is officially launched
- GD32L233C-START Review-(Last) Radar Overall Demonstration
- LPS22HB code porting
- Automotive electronics popular data download collection
- TI TMS320C6678 Evaluation Module
- 2018 EEWORLD technical live broadcast replay summary ~ 40+ sessions including multiple hot topics, stay at home to know the forefront of the industry
- [MPS Mall Big Offer Experience Season] Unboxing
- Please recommend a cheap RF transmitter with variable frequency of 415M~475M and price <10 yuan