当前位置:网站首页>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
边栏推荐
- go语言编程规范梳理总结
- MySQL table field adjustment
- Definition of episodic and batch
- 【 note 】 résoudre l'erreur de code IDE golang
- Bugku's Eval
- Go language programming specification combing summary
- 记录一下树莓派搭建环境中遇到的坑。。。
- Data communication foundation - route republication
- Verilog realizes the calculation of the maximum common divisor and the minimum common multiple
- Vulnhub-Moneybox
猜你喜欢
随机推荐
Creation and optimization of MySQL index
[brief notes] solve the problem of IDE golang code red and error reporting
Maximum common subsequence
Bugku's eyes are not real
verilog实现计算最大公约数和最小公倍数
Good article inventory
Advanced level of static and extern
Number protection AXB function! (essence)
Arduino控制微小的六足3D打印机器人
Bugku's Ping
六种常用事务解决方案,你方唱罢,我登场(没有最好只有更好)
Go language programming specification combing summary
Lesson 4 knowledge summary
SQL Server learning notes
Ionic Cordova project modification plug-in
Appium automation test foundation - appium basic operation API (I)
Data communication foundation - routing communication between VLANs
Redis' transaction mechanism
Noi / 1.5 06: element maximum span value of integer sequence
Appium automation test foundation - appium basic operation API (II)









