当前位置:网站首页>LCD1602 string display (STM32F103)
LCD1602 string display (STM32F103)
2022-06-24 19:23:00 【Me-Space】
One 、 summary
1602 Liquid crystal is 5V Voltage driven , With backlight , Two lines can be displayed , Each row 16 Characters , Chinese characters cannot be displayed , built-in 1128 A character ASCII Character set , Parallel communication mode . This test is passed STM32F103C8T6 The minimum system drives the LCD to display a string of characters .
Two 、 Experimental materials
1、STM32F103C8T6 Minimum system
2、LCD1602 liquid crystal
3、 There are several DuPont lines
3、 ... and 、 Basic operation sequence
| state | Input | Output |
|---|---|---|
| Read status | RS=L,RW=H,E=H | D0-D7= state |
| Write instructions | RS=L,RW=L,D0-D7= Instruction code ,E= High pulse | nothing |
| Reading data | RS=H,RW=H,E=H | D0-D7= data |
| Writing data | RS=H,RE=L,D0-D7= data ,E= High pulse | nothing |
Four 、 Hardware connection

5、 ... and 、 Program code
1、GPIO initialization
void Lcd1602_Pin_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_8 |
GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 |
GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB,&GPIO_InitStruct);
}
2、LCD1602 initialization
void Lcd1602_Init(void)
{
Lcd1602_Pin_Init();
delay_ms(15);
Lcd1602_Write_Cmd(0X38);
Lcd1602_Write_Cmd(0X0C);// On display does not display the cursor
Lcd1602_Write_Cmd(0X06);// Write a pointer plus 1
Lcd1602_Write_Cmd(0X01);// Clear the screen
Lcd1602_Write_Cmd(0X80);// Set data pointer start point
}
3、 Detect busy state
void Lcd1602_Check_Busy(void)
{
u8 signal;
LCD_RS = 0;
LCD_RW = 1;
do
{
LCD_EN = 1;
signal = LCD_BUSY;
LCD_EN = 0;
}while(signal);
}
4、 Write instructions
void Lcd1602_Write_Cmd(int cmd)
{
Lcd1602_Check_Busy();// Detect busy state
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 0;
cmd=cmd<<8;
GPIOB->ODR=((GPIOB->ODR & 0x00FF)|(cmd&0xFF00));//PB15-8 It's data bits ,PB0-7 The data can't change
delay_us(2);
LCD_EN = 1;
delay_us(2);
LCD_EN = 0;
delay_ms(15);
}
5、 Writing data
void Lcd1602_Write_Data(int data)
{
Lcd1602_Check_Busy();// Detect busy state
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 0;
data<<= 8;
GPIOB->ODR = ((GPIOB->ODR & 0X00FF) | (data& 0XFF00));
delay_us(2);
LCD_EN = 1;
delay_us(2);
LCD_EN = 0;
delay_ms(15);
}
6、 Show characters
// @u8 row: That's ok
// @u8 col: Column
// @int ch: character
void Lcd1602_DisplayChar(u8 row,u8 col,int ch)
{
// Display position
int add = 0;
// Judgment is that line
if(row == 2)
{
// The first address on the second line 0x40
add += 0x40;
}
// The first address on the first line 0x80
add += 0x80 + col - 1;
Lcd1602_Write_Cmd(add);
// According to the content
Lcd1602_Write_Data(ch);
}
7、 display string
// @u8 row: That's ok
// @u8 col: Column
// @u8 *str: String first address
void Lcd1602_DisplayString(u8 row,u8 col,u8 *str)
{
while(*str != '\0')
{
Lcd1602_DisplayChar(row,col,*str);
col += 1;
str++;
}
}
8、 The main program
int main(void)
{
u8 buf[] = {
"I Love You!"};
u8 date[] = {
"2021/2/7"};
u8 author[] = {
"Qing"};
Sys_Delay_Init();
Lcd1602_Init();
// Single character
// Lcd1602_DisplayChar(2,2,'A');
// character string
Lcd1602_DisplayString(1,1,buf);
Lcd1602_DisplayString(2,1,date);
Lcd1602_DisplayString(2,13,author);
while(1)
{
}
}
6、 ... and 、 Experimental results

Complete procedure and LCD1602 LCD related information :
link :https://pan.baidu.com/s/1Ok-P7IACpib_vLQX57ikVg
Extraction code :hcyp
If there is any mistake, please point out , thank you !
边栏推荐
- Pingcap was selected as the "voice of customers" of Gartner cloud database in 2022, and won the highest score of "outstanding performer"
- Freeswitch使用originate转dialplan
- BSS应用程序云原生部署的8大挑战
- How do programmers do we media?
- [computer talk club] Lecture 3: how to raise key issues?
- starring开发HttpJson接入点+数据库
- 一次 MySQL 误操作导致的事故,高可用都不顶不住!
- 怎么使用R包ggtreeExtra绘制进化树
- Volcano成Spark默认batch调度器
- How to select the ECS type and what to consider?
猜你喜欢

AI时代生物隐私如何保护?马德里自治大学最新《生物特征识别中的隐私增强技术》综述,全面详述生物隐私增强技术

通过SCCM SQL生成计算机上一次登录用户账户报告

How to customize cursor position in wechat applet rotation chart

网络安全审查办公室对知网启动网络安全审查

Volcano成Spark默認batch調度器

Programmers spend most of their time not writing code, but...

Introduction and download of nine npp\gpp datasets

Interpreting harmonyos application and service ecology

Necessary fault handling system for enterprise network administrator

starring V6平台开发接出点流程
随机推荐
Multi segment curve temperature control FB (SCL program) of PLC function block series
Freeswitch使用originate转dialplan
Php OSS file read and write file, workerman Generate Temporary file and Output Browser Download
Power supply noise analysis
How to use JWT authentication in thinkphp6
建立自己的网站(8)
System design idea of time traceability
cdc+mysql connector从维表中join的日期时间字段会被+8:00,请问阿里云托管的
The script implements the automated deployment of raid0
程序员如何做自媒体?
小白请教下各位大佬,cdc抽取mysql binlog是严格顺序的吗
「碎语杂记」这事儿不安全
多云模式并非“万能钥匙”
60 divine vs Code plug-ins!!
Starring develops httpjson access point + Database
Preliminary study nuxt3
Ls common parameters
Volcano devient l'ordonnanceur de lots par défaut Spark
The cdc+mysql connector joins the date and time field from the dimension table by +8:00. Could you tell me which one is hosted by Alibaba cloud
Volcano成Spark默认batch调度器