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);
}
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
- Popular Resources
- Popular amplifiers
- Single-chip microcomputer C language programming and simulation
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- stm32+lcd1602 example
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
- Open source Linux phone designed with KiCad
- MSP430F5529 MCP4725 Program
- [STM32WB55 Review] This Nucleo is a little special
- HIFU ultrasonic knife (high energy focusing control circuit)
- ARM transplantation encounters a long wait for a solution
- Single bus temperature sensor DS18B20 reading and writing example
- Using C language editor
- Why does this error always occur in the joint simulation of Xilinx 12.4 and modelsim?
- 【K210 Series】3. Core board connection
- The problem of repeated declaration of global variables in embedded C programming