当前位置:网站首页>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
边栏推荐
- Common MySQL interview questions (1) (written MySQL interview questions)
- Data communication foundation OSPF Foundation
- Database learning - Database Security
- How to introduce devsecops into enterprises?
- mapper. Comments in XML files
- Appium automation test foundation - appium basic operation API (I)
- Bugku easy_ nbt
- Data communication foundation - route republication
- MySQL表字段调整
- P6183 [USACO10MAR] The Rock Game S
猜你喜欢
随机推荐
示例项目:简单的六足步行者
SQL injection sqllabs (basic challenges) 1-10
String modification problem solving Report
How to introduce devsecops into enterprises?
机械臂速成小指南(九):正运动学分析
"Sequelae" of the withdrawal of community group purchase from the city
Ionic Cordova project modification plug-in
Stop B makes short videos, learns Tiktok to die, learns YouTube to live?
19.[STM32]HC_SR04超声波测距_定时器方式(OLED显示)
F. Weights assignment for tree edges problem solving Report
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
Noi / 1.3 01: a+b problem
Install PHP extension spoole
Data communication foundation ACL access control list
SQL injection sqllabs (basic challenges) 11-20
lvgl 显示图片示例
Surpass palm! Peking University Master proposed diverse to comprehensively refresh the NLP reasoning ranking
Hongmeng system -- Analysis from the perspective of business
20.[STM32]利用超声波模块和舵机实现智能垃圾桶功能
Temporary cramming before DFS examination