Some experience about 1602 LCD

Publisher:WanderlustGlowLatest update time:2012-09-18 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
I started reviewing LCD today! Oh my god! It feels like I'm learning it all over again. I've forgotten a lot of things. It seems that I need to practice very hard to be proficient in it. You won't remember what you learn in a short time with temporary efforts! Not to mention being proficient in application!

Let me talk about today's summary! Although it was a bit difficult at the beginning, it was not as difficult as before to follow the video step by step! Today, I found two examples to write the LCD program, and I looked at the PDF data of 1602. At the beginning, I looked at the program and wrote it by myself according to the timing diagram, but I couldn't get any results. I tried to modify it little by little according to the example, and finally found that it was a small delay problem, that is, there should be a small delay after inputting instructions or data to the data port. However, the timing diagram shows that the EN terminal level has dropped, and the data port is still assigning values, but in fact, there is a delay of about 5 milliseconds after the assignment. I don't understand the specific reason!

Regarding the problem of LCD character positioning, a routine I saw used coordinate positioning, which made me dizzy and I couldn't get it. In fact, in my opinion, the 1602 LCD can only display those few characters, and you won't make mistakes even if you count on your fingers! So it's better to control it directly! Pay special attention to the fact that as long as you want the character at that position to be displayed, you must assign a value to it, even if it is a space, it is considered a character, otherwise garbled characters will appear!

Let's talk about the driver that controls the LCD (let's call it a driver for now, anyway, it controls the LCD)! In fact, it's very simple to control this small LCD! Give it an initialization function (that is, tell it: little brother, you are going to start working), prepare it, and write the specific function according to the supporting PDF materials! Another one is the function of sending instructions. First, assign a value to RS, RS=0, when the MPU performs a write module operation, it points to the instruction register, and when the MPU performs a read module operation, it points to the address counter. RS=1, whether the MPU reads or writes, it points to the data register. Then assign a value to RW, assigning a value of 1 for a write operation and 0 for a read operation. Then there is the EN terminal. In fact, because the data will only read the command or data at the falling edge of EN, pull it high first, and then send the instruction to the data port. Now is the most critical, you must let it have a slight delay, for example, 5 milliseconds! Then set EN=0! Okay, this completes the instruction input! As for the data input function, the format is the same as the instruction input function, but the RS assignment is different! As for what command controls what function, just check the supporting information yourself! There is also a busy check problem, but... I don't know how to use it for the time being. I wrote the busy check into the program, but it went on strike! My current level is to write a small program to achieve a small function. I don't use the busy check for the time being, so I'll talk about it later!

Attached is the LCD driver function I wrote myself! Among them, dat is the LCD data import!

void del(uint i)
{
char j;
for(;i>0;i--)
for(j=125;j>0;j--);
}

void writecom(uchar com)
{
rs=0;
rw=0;
en=1;
dat=com;
del(5);
en=0;

}
void writedat(uchar da)
{
rs=1;
rw=0;
en= 1;
dat=da;
del(5);
en=0;
}

void init()
{ del(15);
writecom(0x38);
del(5)
; writecom(0x38)
; del(5);
writecom(0x38);
del(10);
writecom(0x08);
writecom(0x0e);
writecom(0x06);
writecom(0x0c);
writecom(0x80);


}

Reference address:Some experience about 1602 LCD

Previous article:Design of a simple digital clock based on FPGA using VHDL language
Next article:Microcontroller technology positioning

Recommended ReadingLatest update time:2024-11-16 15:50

MCU: Matrix keyboard and LCD1602
1. Matrix keyboard                          1. Method for detecting buttons: (1) First, set all 1-4 to low level and 5-8 to high level. When a key is pressed, a point in 5-8 will be pulled low. (2) Then, set one of the positions 1-4 to 0 and the other positions to 1, and observe the corresponding return values ​​t
[Microcontroller]
MCU tutorial: 51 MCU infrared remote control and display on LCD1602
#include #include intrins.h typedef unsigned int uint; typedef  unsigned char uchar; sbit LCD_RS=P2^0; sbit LCD_RW=P2^1; sbit LCD_EN=P2^2; sbit IRINPUT=P3^2;   uchar code Display_LINE0 ={"VALUE FROM IR:   "}; uchar   Display_LINE1 ={"IR CODE:       H     "}; uchar IR_Input_Buffer ; uchar Display_Buffe
[Microcontroller]
Detailed explanation of 51 single chip microcomputer LCD1602 program
LCD1602  industrial character LCD. 1602 means the content displayed by the LCD is 16X2, that is, it can display two lines, 16 characters per line. Special interface description  RS: register selection input  RS=1: points to data register  RS=0: points to instruction register RW: Read/write control input  RW=0: write o
[Microcontroller]
C51 MCU Programming Skills: LCD1602 Programming Experience Sharing
Introduction: Let me first explain that the chip driver of the LCD1602 I am going to talk about below is HD44780. If your LCD1602 driver chip is not HD44780, then the following content is not applicable. This time I will share my LCD1602 programming experience: Let me first explain that the chip driver of the LCD160
[Microcontroller]
C51 MCU Programming Skills: LCD1602 Programming Experience Sharing
[51 MCU Quick Start Guide] 6.1: LCD1602 eight-line, four-line control and custom symbols, perfect compatibility with Proteus simulation
Puzhong 51-Single-core-A2 STC89C52 Windows 10 20H2 Proteus 8 Frofessional v8.9 SP2 Keil uVision V5.29.0.0 PK51 Prof.Developers Kit Version:9.60.0.0 Hard Knowledge        Excerpted from "General 1602 LCD Display Module User Manual", "LCD1602 (Chinese Data) - ball 2010-5-13" Display Features        Single 5V power s
[Microcontroller]
[51 MCU Quick Start Guide] 6.1: LCD1602 eight-line, four-line control and custom symbols, perfect compatibility with Proteus simulation
Electronic scale design using AT89C51+ADC0832+LCD1602
Electronic scale design, mainly used for electronic scales in vegetable markets. The price can be set and the amount can be calculated based on the price and weight. The design uses Proteus simulation software, uses AT89C51 as the main control, uses the ADC0832 chip for ADC conversion, and uses LCD1602 The display sho
[Microcontroller]
Electronic scale design using AT89C51+ADC0832+LCD1602
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号