See how the microcontroller controls the LCD module

Publisher:gamma13Latest update time:2011-08-01 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Reference address:See how the microcontroller controls the LCD module

Previous article:89Sxx Development Board Production Instructions
Next article:Design of a new infrared meter reading system based on microprocessor

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号