当前位置:网站首页>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--);
}
边栏推荐
- Simulation volume leetcode [general] 1314 Matrix area and
- Qt:无法定位程序输入点XXXXX于动态链接库。
- MySQL之基础知识
- Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
- (中)苹果有开源,但又怎样呢?
- Simulation volume leetcode [general] 1405 Longest happy string
- JDBC Requset 对应内容及功能介绍
- Customize the gateway filter factory on the specified route
- Properties file
- Redis core technology and basic architecture of actual combat: what does a key value database contain?
猜你喜欢
Career advancement Guide: recommended books for people in big factories
Play video with Tencent video plug-in in uni app
Properties file
在uni-app中使用腾讯视频插件播放视频
【MQTT从入门到提高系列 | 01】从0到1快速搭建MQTT测试环境
JDBC requset corresponding content and function introduction
(中)苹果有开源,但又怎样呢?
基于JEECG-BOOT制作“左树右表”交互页面
MySQL is sorted alphabetically
JWT-JSON WEB TOKEN
随机推荐
黑猫带你学UFS协议第4篇:UFS协议栈详解
一文揭开,测试外包公司的真 相
Engineering organisms containing artificial metalloenzymes perform unnatural biosynthesis
把el-tree选中的数组转换为数组对象
黑猫带你学eMMC协议第10篇:eMMC读写操作详解(read & write)
Resttemplate and feign realize token transmission
模拟卷Leetcode【普通】1219. 黄金矿工
Simulation volume leetcode [general] 1447 Simplest fraction
Luogu p2141 abacus mental arithmetic test
LeetCode 739. Daily temperature
Simulation volume leetcode [general] 1143 Longest common subsequence
Simulation volume leetcode [general] 1414 The minimum number of Fibonacci numbers with a sum of K
MySQL is sorted alphabetically
[postman] dynamic variable (also known as mock function)
Delete the variables added to watch1 in keil MDK
二维码的前世今生 与 六大测试点梳理
F - true liars (category and search set +dp)
Web界面元素的测试
基于JEECG-BOOT制作“左树右表”交互页面
Oscp raven2 target penetration process