Generally speaking, the control of LCD module is finally completed by MCU operating the internal register and video memory of LCD module; here we design three basic timing control programs, namely:
write register function (LCD_RegWrite)
data write function (LCD_DataWrite)
data read function (LCD_DataRead)
These three functions need to be written strictly according to the timing required by LCD. You can see the timing diagram of MzL02 module below:
Figure 3.2 6800 timing diagram of MzL02 module
Note: The above figure is the original timing diagram in the control IC data of the module. In fact, some of the diagrams are not very safe (the requirements of the RW line signal are not marked), or not very rigorous, but these will not be discussed, please see the analysis; and the effective trigger edge of EP in the figure is likely to be incorrectly indicated, and the actual measurement is a rising edge. The signal of CS1B (CS2) in the figure is the chip select CS, RS is the data/register selection port A0 signal, and E is EP; when writing register data, A0 must first be set low to notify
the LCD
module that the operation to be performed is to operate the register; and the RW line needs to be set low to indicate that the operation to be performed is a write operation; then the chip select CS signal is set low to load the data to the bus, and then a rising edge is generated on the EP line to trigger the LCD module to finally load the data on the bus; after the previous operation is completed, the status of each signal line will generally be restored. The operation timings for writing data (video memory) and reading data are also similar, so we will not introduce them in detail here. You can directly refer to the example program.
//========================================================
// Function: void LCD_RegWrite(unsigned char Command)
// Description: Write one byte of data to the control register in the LCD
// Parameter: Command data to be written, the lower eight bits are valid (byte)
// Return: None
//===============================================================
void LCD_RegWrite(unsigned char Command)
{
LCD_A0 = 0; //A0 is set low, indicating a register operation
LCD_RW = 0; //RW is set low, indicating a write operation
LCD_EP = 0; //EP is set low first to generate a transition edge later
LCD_CS = 0; //Chip select CS set low
DAT_PORT = Command; //Load data set bus
LCD_EP = 1; //Generate a valid jump edge
LCD_CS = 1; //Chip select set high
}
The data writing and reading function source code is as follows:
//==============================================================
// Function: void LCD_DataWrite(unsigned char Dat)
// Description: Write one byte of display data to the display
buffer
RAM in the LCD
// Parameter: Data The data to be written
// Return: None
//= ...
Dat)
{
LCD_A0 = 1; //A0 is set high, indicating that the display memory data operation is being performed
LCD_RW = 0; //RW is set low, indicating that a write operation is being performed
LCD_EP = 0; //EP is set low first to generate a transition edge later
LCD_CS = 0; //Chip select CS is set low
DAT_PORT = Dat; //Load data and set the bus
LCD_EP = 1; //Generate a valid transition edge
LCD_CS = 1; //Chip select is set high
}
//==============================================================
// Function: unsigned char LCD_DataRead(void)
// Description: Read a byte of display data from the display buffer RAM in the LCD
// Parameter: None
// Return: The read data,
//===================================================================
unsigned char LCD_DataRead(void)
{
unsigned char Read_Data;
DAT_PORT = 0xff; //Before inputting data to port 51, all ports must be set to 1 first
LCD_A0 = 1; //A0 is set high, indicating that the display memory data operation is to be performed
LCD_RW = 1; //RW is set high, indicating that the read operation is to be performed
LCD_EP = 0; //EP is set low first to generate a transition edge later
LCD_CS = 0; //Chip select CS is set low
LCD_EP = 1; //Generate a valid transition edge
LCD_EP = 0;
Read_Data = DAT_PORT; //Read data
LCD_CS = 1; //Chip select is set high
return Read_Data; //Return the read data
}
The above are the most basic timing operation procedures to be introduced. They are almost the codes that deal with the underlying hardware in the entire LCD driver. In this way, when you want to change the MCU port that drives the LCD or use another MCU to drive the LCD, you basically only need to make some modifications in these codes.
About reading LCD status
In general LCD modules, there is another equally important function, which is to read the LCD status. This operation can be used to obtain the busy status of the current LCD module and some related status information. When the LCD module is in a busy state, it is not suitable to write or read data to it (many older LCD controllers stipulate that data cannot be written or read when it is busy).
Therefore, in many LCD drivers, codes for reading the LCD status and judging the busy status are added before register writing and data writing/reading operations; this can be referred to many LCD drivers circulating on the Internet. However, for newer LCD controllers such as MzL02, the busy status is not very important, or the impact is very small or even non-existent; so we did not add such code in the previous code. As for whether it is necessary to add the code for reading the status to judge the busy, it depends on the specific LCD controller.
About the time requirements of
timing A very important data of timing is the time length requirement like tAS88 marked in the above figure, but the above figure does not mark their specific maximum and minimum requirements; but they are still very important when writing such timing interface programs, of course, it also depends on the port operation speed of the MCU and the instruction execution speed of the MCU. For example, some timings will require the level of certain signals to maintain a minimum width, and if the instruction execution speed of the MCU and the port operation speed are very fast, it is necessary to add an appropriate amount of delay between the codes of continuous port operations (generally replaced by empty operations, the specific number and duration depends on the specific MCU and LCD controller) to ensure that the pulse width of the signal meets the requirements.
Previous article:89Sxx Development Board Production Instructions
Next article:Design of a new infrared meter reading system based on microprocessor
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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- A video to understand common electrical interfaces and principles_SPI I2C UART 8080 6800 sram sdram----The key is free
- How do I convert 51 code to STM32 driver code?
- Please help, how does this circuit work?
- EEWORLD University ---- PLC Programming Introduction Video Tutorial
- BBC: Driver package for microbit infrared remote control
- How to eliminate the current in IO after power failure
- FPGA_100 Days Tour_Arbitrary Frequency Divider
- [Shanghai Hangxin ACM32F070 development board + touch function evaluation board evaluation] + UART and ultrasonic ranging
- iMX6 Series Application Notes - One article teaches you how to use iMX6Q GPIO functions
- After pressing the left mouse button to select a section of content, after releasing the left mouse button, you will find that the selected area is still changing with the cursor position.