当前位置:网站首页>17. [stm32] use only three wires to drive LCD1602 LCD
17. [stm32] use only three wires to drive LCD1602 LCD
2022-07-05 15:48:00 【According to point_ DW】
Author's brief introduction : Hello, everyone , My name is DW, Share some of my new knowledge every day , Look forward to making progress with you
Series column :STM32
Small experimental target : Three wire drive LCD1602 liquid crystal
If there is anything that is not well written, you are welcome to correctDevelopment board : The punctual atoms STM32F103Mini edition
Creation time :2022 year 6 month 4 Japan
Whether it is driven in serial mode LCD1602 LCD is also driven in parallel LCD1602 liquid crystal , Will occupy STM32 Too much IO mouth , So is there any way to reduce SCM IO What about the use of mouth ? The answer is yes .
We can put two pieces 74HC595 The chip is driven in a cascaded manner LCD1602, This method only uses the 3 individual IO The mouth can drive LCD1602 了 .
It has been introduced in detail in the article of four digit nixie tube 74HC595 How to use this chip , See the article for details :15.[STM32] An article teaches you to use 75HC595 The chip drives the four digit nixie tube
Add a function to write bytes on the basis of this article .
Write byte function
// Write byte function
void LCD1602_Write_Byte(u8 dat,u8 dat1){
for(u8 i=0;i<8;i++){
((dat<<i)&0x80) ? DIO_High:DIO_Low;
SCK_High;
SCK_Low;
}
for(u8 i=0;i<8;i++){
((dat1<<i)&0x80) ? DIO_High:DIO_Low;
SCK_High;
SCK_Low;
}
RCK_High;
RCK_Low;
}
Tips : Two pieces of 74HC595 Adopt cascade mode , So you need to send data twice .
Next, write a function to write instructions and data , This function is the focus of this routine . What we need to write is 8 Bit data , But we only need to be in place :RS、RW、EN( Corresponding bit 0~2), position 3~7 by 0.
When we need to write data E、RW、RS by :001, Therefore, the instructions to be written are 0000 0001(0x01) Next, you need to write the data to the bus , When E For high level, the data will be sent to the LCD , Therefore, the instructions to be written are :0000 0101(0x05), Need to be released later EN, So it needs to be rewritten 0x01;
When we need to write instructions E、RW、RS by :000, Therefore, the instructions to be written are 0000 0000(0x00), Next, you need to write instructions to the bus , When E For high level, the data will be sent to the LCD , Therefore, the instructions to be written are :0000 0100(0x04), Need to be released later EN, So it needs to be rewritten 0x00;
Functions that write instructions and data
void LCD1602_Write_Cmd_Data(u8 cmd,u8 data){
if(cmd){ //1 data
LCD1602_Write_Byte(data,0x01); //0000 0001 // E = 0 RW = 0 RS = 1
delay_ms(3);
LCD1602_Write_Byte(data,0x05); //0000 0101 // E = 1 RW = 0 RS = 1
delay_ms(3);
LCD1602_Write_Byte(data,0x01); //0000 0001 // E = 0 RW = 0 RS = 1
}
else{ //0 Instructions
LCD1602_Write_Byte(data,0x00); //0000 0000 // E = 0 RW = 0 RS = 0
delay_ms(3);
LCD1602_Write_Byte(data,0x04); //0000 0100 // E = 1 RW = 0 RS = 0
delay_ms(3);
LCD1602_Write_Byte(data,0x00); //0000 0000 // E = 0 RW = 0 RS = 0
}
}
Tips :
RS = 1: Writing data RS = 0: Write instructions
RW = 1: Read operations RW = 1: Write operations
EN: Read operation is highly effective EN: Highly effective
Next, look at the hardware connection diagram .
First piece 74HC595 Chip 11、12、14 The pins are respectively connected with the MCU PB0~PB2 Connected to a ,74HC595 Of 15、1、2 Pins and LCD1602 Of RS、R/W、E Pin to pin .
Second piece 74HC595 Chip QA~QH Pin and LCD1602 Of D0~D7 Connected to a .
Tips :
Of the first chip 9 Pin and the second chip 14 The pins are connected to each other
Two chip RCK、SCK Connect with each other
Let's take the last one DS18B20 The routines of the article are added , You can go to LCD1602 The temperature is displayed on the , Let's take a look at the experimental results .
Today's sharing is here , Thank you for your patience in reading , If you find it useful, give me
This chapter ends , I'll see you in the next chapter
Reference material :
1.STM32 Firmware library manual
2. The punctual atoms STM32 Incomplete manual _ Library function version
3. Reference video
4. Fundamentals of digital electronic technology
Data uploaded , You need to take it yourself
边栏推荐
- SQL Server learning notes
- Can gbase 8A view the location of SQL statement history?
- episodic和batch的定义
- 示例项目:简单的六足步行者
- P6183 [USACO10MAR] The Rock Game S
- The elimination strategy of redis
- Redis distributed lock principle and its implementation with PHP (2)
- Bugku's Ping
- 21.[STM32]I2C协议弄不懂,深挖时序图带你编写底层驱动
- vlunhub- BoredHackerBlog Moriarty Corp
猜你喜欢
Reasons and solutions for redis cache penetration and cache avalanche
OSI 七层模型
Ten billion massage machine blue ocean, difficult to be a giant
lv_ font_ Conv offline conversion
Bugku's Ah Da
keep-alive
数学建模之层次分析法(含MATLAB代码)
OSI seven layer model
Appium自动化测试基础 — APPium基础操作API(二)
Codasip为RISC-V处理器系列增加Veridify安全启动功能
随机推荐
18.[STM32]读取DS18B20温度传感器的ROM并实现多点测量温度
Where is the operation of convertible bond renewal? Is it safer and more reliable to open an account
go学习 ------jwt的相关知识
Interval DP (gravel consolidation)
复现Thinkphp 2.x 任意代码执行漏洞
mapper. Comments in XML files
Your childhood happiness was contracted by it
超越PaLM!北大碩士提出DiVeRSe,全面刷新NLP推理排行榜
[brief notes] solve the problem of IDE golang code red and error reporting
Calculate weight and comprehensive score by R entropy weight method
Object. defineProperty() - VS - new Proxy()
vlunhub- BoredHackerBlog Social Network
Example project: simple hexapod Walker
"Sequelae" of the withdrawal of community group purchase from the city
ICML 2022 | explore the best architecture and training method of language model
具有倍数关系的时钟切换
Codasip为RISC-V处理器系列增加Veridify安全启动功能
Common PHP interview questions (1) (written PHP interview questions)
Summary of the third class
OSI 七层模型