当前位置:网站首页>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
边栏推荐
- Codasip为RISC-V处理器系列增加Veridify安全启动功能
- go学习 ------jwt的相关知识
- String modification problem solving Report
- Data communication foundation smart_ Link_&_ Monitor_ Link
- Can gbase 8A view the location of SQL statement history?
- Huiyuan, 30, is going to have a new owner
- 如何将 DevSecOps 引入企业?
- Example project: simple hexapod Walker
- SQL injection sqllabs (basic challenges) 11-20
- 【 note 】 résoudre l'erreur de code IDE golang
猜你喜欢
vulnhub-Root_ this_ box
Bugku's Eval
19.[STM32]HC_SR04超声波测距_定时器方式(OLED显示)
Data communication foundation - dynamic routing protocol rip
【簡記】解决IDE golang 代碼飄紅報錯
CODING DevSecOps 助力金融企业跑出数字加速度
swiper. JS to achieve barrage effect
MySQL 巨坑:update 更新慎用影响行数做判断!!!
lv_font_conv离线转换
Write a go program with vscode in one article
随机推荐
lvgl 显示图片示例
vlunhub- BoredHackerBlog Social Network
Analytic hierarchy process of mathematical modeling (including Matlab code)
SQL Server learning notes
Misc Basic test method and knowledge points of CTF
queryRunner. Query method
Data communication foundation smart_ Link_&_ Monitor_ Link
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
Au - delà du PARM! La maîtrise de l'Université de Pékin propose diverse pour actualiser complètement le classement du raisonnement du NLP
Data communication foundation - route republication
数据库学习——数据库安全性
1330: [example 8.3] minimum steps
P6183 [USACO10MAR] The Rock Game S
Good article inventory
P1451 calculate the number of cells / 1329: [example 8.2] cells
Bugku's steganography
把 ”中台“ 的思想迁移到代码中去
go学习 ------jwt的相关知识
Appium自动化测试基础 — APPium基础操作API(二)
Write a go program with vscode in one article