The Path of Learning for a Newbie in Single-Chip Microcomputers (Part 41) --- Understanding LCD1602 Liquid Crystal

Publisher:科技舞者Latest update time:2020-03-30 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Objective: Understand the working principle of LCD1602 liquid crystal


1. LCD1602 Introduction

1602 LCD is also called 1602 character LCD. It can display 2 lines of character information, and each line can display 16 characters, so it is referred to as 1602. It is a dot matrix LCD module specially used to display letters, numbers and symbols.

It is composed of several 5x7 or 5x10 dot matrix character bits. Each dot matrix character bit can be used to display a character. There is a dot spacing between each bit and there is also a spacing between each line, which serves the role of character spacing and line spacing. Because of this, it cannot display pictures well.

13367077-9261e6aba44b9025.png

1602

13367077-0e1404ce0cded604.png

Pin Function

  • VL is the LCD bias signal. If the screen is too dark or too bright, you can adjust this voltage to adjust the brightness.

  • RS is high level for data option, low level for command option

  • R/W means high level is read operation, low level is write operation

  • E is the enable signal

  • D0 ~ D7 are data I/O ports. The microcontroller can transmit data to make the LCD display different data.

  • BLA is the positive pole of the backlight source (A means positive), BLK is the negative pole of the backlight source (K means negative). If there is no backlight, the data is difficult to see clearly.


LCD1602 contains 80 bytes of DDRAM, which is used to store display characters.
The corresponding relationship between its address and screen is as follows:

13367077-f491270eda441dce.PNG

DDRAM


DDRAM can display 80 bytes, divided into 2 rows, 40 bytes on the top and 40 bytes on the bottom, but the LCD we use has only 16 bytes in one row, and the rest is not used.

The following are the corresponding addresses, but the real address is each plus 0x80 to get our real address, such as 00 corresponding to the address 0x00 + 0x80 = 0x80


2. LCD1602 Common Commands
(1) Clear Screen Command

13367077-2fa5ab69cbaa12ff.png

Clear screen command


  • The input command is 0x01

  • RS is low level is the input command

  • R/W low level indicates writing

  • Clear the LCD display, that is, fill all the contents of DDRAM with "blank" ASCII code 20H;

  • After clearing the screen, the cursor returns to the upper left corner of the LCD screen.

  • Set the address counter (AC) to 0, which is the topmost corner.

(2) Mode setting instructions


13367077-c4729cacac6862ac.png

Mode Setting Instructions

Function:
Set the cursor shift direction after writing 1 bit of data each time, and set whether to move each character written.

I/D: 0 = The cursor moves to the left after writing new data; 1 = The cursor moves to the right after writing new data; usually 1, but when the cursor is at the rightmost point, the cursor moves to the left, which is like a scrolling effect
S: 0 = The display screen does not move after writing new data; 1 = The display screen moves right by 1 character after writing new data; usually 0

(3) Display switch control instructions


13367077-aa7b16af3ab44063.png

Display switch control

Function:
Control the display on/off, cursor on/off, and whether the cursor flashes.

D: 0 = display function off; 1 = display function on
C: 0 = no cursor; 1 = cursor
B: 0 = cursor flashing; 1 = cursor not flashing

(4) Function setting instructions


13367077-16a8a6c64e84233b.png

Function setting command

Function:
Set the number of data bus bits, the number of displayed lines and the font.

DL: 0 = data bus is 4 bits; 1 = data bus is 8 bits; ours is 8 bits;
N: 0 = display 1 line; 1 = display 2 lines
F: 0 = 5×7 dots/each character; 1 = 5×10 dots/each character
X: represents random value


3. LCD1602 operation steps

(1) Initialization (set the cursor above)
(2) Write command (RS=L), set display coordinates
(3) Write data (RS=H)


LCD1602 write operation timing diagram:


13367077-778d757a76ea03a6.png

Timing diagram

Let's first look at the RS pin and R/W pin of the read operation timing. These two pins change first. Because it is a read operation, the R/W pin must be set to a high level first, regardless of what it was originally. Reading instructions or reading data are both read operations, and both are possible, so the RS pin may be set to a high level or a low level. Please pay attention to the drawing method in the figure. After RS ​​and R/W change for such a long time Tsp1, the enable pin E can change from a low level to a high level.
After the enable pin E is pulled high for such a long time tD, the data output by LCD1602 DB is valid data, and we can read the data of DB. After reading, we must first pull the enable E low. After a period of time, RS, R/W and DB can change to continue to prepare for the next read and write.
The difference between the write operation timing and the read operation timing is that the write operation timing, the change of DB is completed by our microcontroller, so it must be operated before the change of the enable pin E. You can compare the other differences by yourself.

Careful students will find that there are many time labels on this timing diagram, such as the rise time tR of E, the fall time tF, the length period tC from one rising edge to the next rising edge of the enable pin E, the time interval tHD1 between the change of R/W and RS after the falling edge of enable E, and many other time requirements. How do you view these requirements?

13367077-816922087b3625df.png

Timing parameters

tC: refers to the shortest time from the current rising edge to the next rising edge of the enable pin E, which is 400ns. However, because our microcontroller is slow, one machine cycle is more than 1us, and a C language instruction must be one or several machine cycles, so this condition is fully met.
tPW: refers to the shortest duration of the high level of the enable pin E is 150ns. Since our microcontroller is slow, this condition is also fully met.
tR, tF: refers to the rising edge time and falling edge time of the enable pin E, which cannot exceed 25ns. This time limit has a large space. We used an oscilloscope to measure the rising and falling edge time of this pin on our development board, which is about 10ns to 15ns, which is fully met.
tSP1: refers to the enable pin E can only become a high level after the RS and R/W pins are enabled and maintained for at least 30ns. This condition is fully met.
tHD1: refers to the enable pin E can only change after it becomes a low level and remains for at least 10ns. This condition is fully met.
tD: It means that after our enable pin E becomes high, 100ns later, 1602 will send out the data, so we can read the status or data normally.
tHD2: It means that during the read operation, after the enable pin E becomes low, it must be kept for at least 20ns before the DB data bus can change. This condition is fully met. tSP2
: It means that after the DB data bus is ready, it must be kept for at least 40ns before the enable pin E can change from low to high. This condition is fully met. tHD2:
It means that during the write operation, after the pin E becomes low, it must be kept for at least 10ns before the DB data bus can change. This condition is fully met.


After reading this, do you feel that it is simpler than you thought and not as difficult as you thought? You also have to learn to read this kind of timing diagram and table slowly. In future studies, this ability is particularly important. If you switch to other types of microcontrollers in the future, then evaluate whether your program meets the timing requirements based on the execution speed of the microcontroller. Generally speaking, devices have a maximum speed limit, but no minimum speed limit, so when switching to a high-speed microcontroller, it is usually necessary to insert software delays between each step to meet the slower timing requirements.


4. LCD1602 liquid crystal interface circuit

13367077-0d6bc9a7fd1603de.png

Circuit Module


VO changes the voltage through the sliding resistor below

Keywords:MCU Reference address:The Path of Learning for a Newbie in Single-Chip Microcomputers (Part 41) --- Understanding LCD1602 Liquid Crystal

Previous article:Microcontroller Learning Journey for Beginners (Part 43) --- LCD12864 Liquid Crystal Display
Next article:The road to learning MCU for beginners (Part 27) --- Understanding EEPROM-IIC bus (Part 2)

Recommended ReadingLatest update time:2024-11-16 08:51

51 MCU (Thirteen) - Watchdog Function Test
1. Introduction to Watchdog         In a system composed of a single-chip microcomputer, the operation of the single-chip microcomputer may be interfered by the external electromagnetic field, causing the program to run away and fall into an infinite loop. The normal operation of the program is interrupted, and the sy
[Microcontroller]
51 MCU (Thirteen) - Watchdog Function Test
Does the 51 microcontroller need a pull-up resistor?
Students who have studied engineering have all learned single-chip microcomputers. The most common single-chip microcomputer in the study of single-chip microcomputers is the 51 single-chip microcomputer. The 51 single-chip microcomputer is a general term for all single-chip microcomputers compatible with the Intel 80
[Microcontroller]
Does the 51 microcontroller need a pull-up resistor?
The crisis of automotive chip supply interruption brings opportunities to domestic manufacturers
The shortage of automotive chips has created opportunities for domestic MCU manufacturers.   Volkswagen discontinued production? Fake.   Automotive chip shortage? Really.   After rumors of "Volkswagen's impending production suspension" continued to ferment, Volkswagen China, SAIC Volkswagen, and FAW-Volkswagen respond
[Embedded]
The crisis of automotive chip supply interruption brings opportunities to domestic manufacturers
Top ten filtering algorithms commonly used in microcontroller AD sampling
The top ten filtering methods commonly used in microcontroller ADCs, you no longer have to worry about data processing! 1. Limiting filtering 1. Method Determine the maximum allowable deviation value A between two samplings based on experience Judge each time a new value is taken: if the difference between this va
[Microcontroller]
CoreShine Technology launches China Mobile's first RISC-V low-power, high-capacity MCU chip
On December 17, at the first Dishui Lake China RISC-V Industry Forum, Wang Bin, MCU Product Manager of CoreSheng Technology Co., Ltd., introduced the company's CM32M43xR series of products, which is China Mobile's first RISC-V low-power, large-capacity MCU chip. According to Wang Bin, Xinsheng Technology is a wholly-o
[Mobile phone portable]
CoreShine Technology launches China Mobile's first RISC-V low-power, high-capacity MCU chip
[Self-study 51 MCU] 10 -- PWM introduction, 51 MCU RAM area division
1. PWM Introduction PWM (Pulse Width Modulation), also known as pulse width modulation in Chinese, can use digital signals to achieve the effect of an analog signal. Pulse width modulation is to change the pulse width to achieve different effects. See Figure 10-1 for three groups of pulse signals. It is a waveform w
[Microcontroller]
[Self-study 51 MCU] 10 -- PWM introduction, 51 MCU RAM area division
2023, raging automotive MCU
"Traditional cars use about 70 units per vehicle, while electric vehicles use about 300 units per vehicle." "Standing at the center of the chip shortage storm." “When there is a price increase due to core shortages, the price of some models increases by dozens of times, and tens of dollars turn into thousands of d
[Automotive Electronics]
2023, raging automotive MCU
Introduction to AVR microcontrollers: structure and application of microcontroller embedded systems
Single-chip microcomputer, full name of single-chip microcontroller, single-chip microcomputer (Single-Chip Microcomputre), also known as embedded microcontroller (Embedded Microcontroller). The embedded system composed of single-chip microcomputer as the main control core is called single-chip microcomputer embedded
[Microcontroller]
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号