当前位置:网站首页>Lecture 8: 1602 LCD (Guo Tianxiang)
Lecture 8: 1602 LCD (Guo Tianxiang)
2022-07-06 06:25:00 【Lin Jiazhan】
explain : This article is just some records of my learning process , If there is any infringement , Please contact me to delete , There are inevitably omissions and mistakes in the article , Welcome to point out .
One 、1602 Liquid crystal introduction
LCD belongs to extended content , however , It's used a lot of times , After all, you need a visual result to provide to users , So we need to master the use of LCD .
1602 Model LCD , among 16 Express 1 Rows can show 16 Characters ,02 Expressing common ownership 2 That's ok .
Allied , also 1601、0801、0802...
Some models are 12864、12232 This kind of graphic liquid crystal , for example 12864 It's horizontal 128 A little bit , Vertical yes 64 A little bit , These points form a graph . And the character LCD mentioned above , Only characters can be displayed . These can be learned in the description document .
notes : The teacher said , Now that you have learned liquid crystal , Then try not to use digital tubes if you can use LCD , Because by comparison , LCD is simpler , And more interesting .
Two 、 Learn how to operate through documents 1602 liquid crystal
1. There is a Chinese document in the material sent by the teacher , First look at the LCD pin function :
Look at the connection diagram of the development board :
You can see the 5 The pin is directly connected to the ground , Because here we only need to write data into the LCD , There is no need to read data . So just manipulate the 4 And the 6 Pin can be .
2. Next, let's look at the detailed interface description :
The reason to make sure STA7 = 0, Because STA7 It is the read-write operation enable , Only in the allowed position , To read and write . Because the frequency of crystal oscillator is not very high in MCU , Therefore, there is no need to think too much . It mainly takes time for LCD to write data , But in the use of DSP、 When embedded chips are running at high speed , Sometimes the LCD didn't display completely last time , The next display request is coming , And if the read / write operation is enabled , It may cause the loss of display data . Therefore, we should carry out corresponding processing through read-write detection .
notes :
High pulse : From low to high to low is a high pulse .
Low pulse : In turn, , High and low is a low pulse .
3. Next, let's look at the sequence of write operations in detail :
We know from the previous documentation ,RS The difference of represents the difference between writing instructions and writing data .
and R/W We have defaulted to grounding . So by right RS、E The operation of can realize the writing of instructions or data .
So we write two functions , Used to write instructions and write data respectively :
The write instruction function is as follows :
void write_com(uchar com)// Write instructions / command
{
lcdrs = 0;
//RW = 0;// The development board has been grounded by default
P0 = com;//com For instructions
delay(5);
lcden = 1;
delay(5);
lcden = 0;
}
The function of writing data is as follows :
void write_data(uchar date)// Writing data
{
lcdrs = 1;
//RW = 0;// The development board has been grounded by default
P0 = date;//date For data
delay(5);
lcden = 1;
delay(5);
lcden = 0;
}
Because the requirement of real-time is not high , So the timing parameters are only simple delay Function substitution , The actual development process may need attention .
There is also the read-write detection mentioned above , In a simple single-chip program, it can also be omitted , We just need simple delay Function delay , The delay time is greater than the speed of LCD writing .
4.RAM Address map
Each box represents an address , Write data content to the address , Then the content will be displayed in this place . And the first line in the back 10 To 27 And the second line 50 To 67 Not part of the display , But we can choose to write the content behind this first , Then move the whole screen , Move the content behind this to the screen .
5. Instructions :
Send instructions before you start , To set the display mode . There is only one mode in Chinese documents , There should be other instructions in the detailed English document , In actual development, we should try to write the program according to the original file .
Then there is the display switch and cursor setting .
Notice the top N=1 When reading or writing a character, add one to the address pointer , Because of the data pointer that will be mentioned later , We need to set the data pointer , Then the content will be displayed at the position pointed by the data pointer , When we want to write a row of data , We need to set multiple data pointers , And if the address pointer will automatically add 1, We don't need to set , Just write the data .
Setting of data pointer , Preparation before writing data .
Other settings , There are many, many settings , You can find... In the documentation .
3、 ... and 、 Use 1602 liquid crystal , First line display “I AM hong!”, The second line shows “I LIKE MCU!”
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit lcden = P3^4;
sbit lcdrs = P3^5;
sbit dula = P2^6;
sbit wela = P2^7;
void delay(uint z);
uchar num;
uchar code table[]="I AM hong!";
uchar code table1[]="I LIKE MCU!";
void write_com(uchar com)// Write instructions / command
{
lcdrs = 0;
//RW = 0;// The development board has been grounded by default
P0 = com;
delay(5);
lcden = 1;
delay(5);
lcden = 0;
}
void write_data(uchar date)// Writing data
{
lcdrs = 1;
//RW = 0;// The development board has been grounded by default
P0 = date;
delay(5);
lcden = 1;
delay(5);
lcden = 0;
}
void init()
{
dula = 0;
wela = 0;// Turn off the nixie tube
lcden = 0;
write_com(0x38);// Display mode settings
write_com(0x0c);// Show on / Turn off cursor setting
write_com(0x06);// Address pointer plus 1,N=1,S=0
write_com(0x01);// The display is clear , Because there is a data in it by default , There is a black block on the screen
write_com(0x80);// Data pointer setting
}
void main()
{
init();
for(num = 0;num < 10;num++)
{
write_data(table[num]);
delay(200);
}
write_com(0x80+0x40);// The second line
for(num = 0;num < 11;num++)
{
write_data(table1[num]);
delay(200);
}
while(1);
}
void delay(uint z) // The time delay function ,z The value of is the delay of this function ms Count , Such as delay(200); About time delay 200ms.
{ //delay(500); About time delay 500ms.
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
边栏推荐
- Black cat takes you to learn UFS Protocol Part 8: UFS initialization (boot operation)
- LeetCode 729. My schedule I
- 模拟卷Leetcode【普通】1091. 二进制矩阵中的最短路径
- Database - current read and snapshot read
- Simulation volume leetcode [general] 1405 Longest happy string
- 【Tera Term】黑猫带你学TTL脚本——嵌入式开发中串口自动化神技能
- Black cat takes you to learn EMMC Protocol Part 10: EMMC read and write operation details (read & write)
- Career advancement Guide: recommended books for people in big factories
- [postman] dynamic variable (also known as mock function)
- Summary of anomaly detection methods
猜你喜欢
基于JEECG-BOOT的list页面的地址栏参数传递
二维码的前世今生 与 六大测试点梳理
[postman] test script writing and assertion details
MFC关于长字符串unsigned char与CString转换及显示问题
LeetCode 729. My schedule I
Isam2 operation process
[C language] string left rotation
MySQL之基础知识
University of Manchester | dda3c: collaborative distributed deep reinforcement learning in swarm agent systems
[web security] nodejs prototype chain pollution analysis
随机推荐
模拟卷Leetcode【普通】1249. 移除无效的括号
Pat (Grade B) 2022 summer exam
Simulation volume leetcode [general] 1062 Longest repeating substring
[Tera term] black cat takes you to learn TTL script -- serial port automation skill in embedded development
MySQL is sorted alphabetically
这些年用Keil遇到的坑
Customize the gateway filter factory on the specified route
模拟卷Leetcode【普通】1414. 和为 K 的最少斐波那契数字数目
D - How Many Answers Are Wrong
Selenium source code read through · 9 | desiredcapabilities class analysis
一文揭开,测试外包公司的真 相
How to extract login cookies when JMeter performs interface testing
通过修改style设置打印页样式
sourceInsight中文乱码
Simulation volume leetcode [general] 1091 The shortest path in binary matrix
Properties file
[wechat applet] build a development tool environment
基于JEECG-BOOT的list页面的地址栏参数传递
数据库-当前读与快照读
黑猫带你学UFS协议第8篇:UFS初始化详解(Boot Operation)