当前位置:网站首页>LCD12864 (ST7565P) Chinese character display (STM32F103)
LCD12864 (ST7565P) Chinese character display (STM32F103)
2022-06-24 19:23:00 【Me-Space】
One 、 summary
LCD12864 Belongs to dot matrix graphics LCD module , Able to display characters 、 Chinese characters and graphics , It can be divided into two kinds: with Chinese character library and without Chinese character library . This routine is based on without Chinese character library 12864 LCD module , The mode of communication is 8080 parallel signal communication , The LCD module uses ST7565P Chip driver .
Two 、 Experimental materials
1、STM32F103C8T6 Minimum system .
2、LCD12864 LCD screen .
3、 There are several DuPont lines .
3、 ... and 、 Hardware connection

Four 、 Program code
1、GPIO initialization
void Lcd_Pin_Init(void)
{
GPIO_InitTypeDef GPIO_InitStrcurt;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |
RCC_APB2Periph_GPIOB,ENABLE);
//PA8 PA11
GPIO_InitStrcurt.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_InitStrcurt.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_11 ;
GPIO_InitStrcurt.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStrcurt);
//PB0 PB1 PB2
GPIO_InitStrcurt.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_InitStrcurt.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;
GPIO_InitStrcurt.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB,&GPIO_InitStrcurt);
// Data pins
GPIO_InitStrcurt.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_InitStrcurt.GPIO_Pin = 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_InitStrcurt.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB,&GPIO_InitStrcurt);
}
2、 Detect busy state
void Lcd_CheckBusy(void)
{
u8 signal;
LCD_RS = 0;
LCD_WR = 1;
do
{
LCD_RD = 0;
delay_us(2);
// read BF state
signal = BUSYIN;//PB15
delay_us(2);
LCD_RD = 1;
}while(signal);
}
3、 Writing data
void Lcd_Send_Data(int data)
{
Lcd_CheckBusy();// State judgement
LCD_RS = 1;
LCD_CS = 0;
LCD_RD = 1;
LCD_WR = 0;
delay_us(5);
// data
data=data<<8;
GPIOB->ODR=((GPIOB->ODR & 0x00FF)|(data&0xFF00));//PB15-8 It's data bits ,PB0-7 The data can't change
delay_us(5);
LCD_WR = 1;
}
4、 Write orders
void Lcd_Send_Cmd(int cmd)
{
Lcd_CheckBusy();// State detection
LCD_RS = 0;
LCD_CS = 0;
LCD_RD = 1;
LCD_WR = 0;
delay_us(5);
// data
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(5);
LCD_WR = 1;
}
5、 Clear the screen
void Lcd_Clear(int clear_data)
{
u8 i = 0, j = 0;
for(i = 0; i < 8; i++)
{
Lcd_Send_Cmd(0xB0 + i);// Page address
Lcd_Send_Cmd(0x10); // Column address
Lcd_Send_Cmd(0x00); // List the addresses
for(j = 0; j < 132; j++)
{
Lcd_Send_Data(clear_data);// Clear screen data
}
}
}
6、 The driver
void Lcd_Init(void)
{
Lcd_Pin_Init();
LCD_RESE = 0;
delay_ms(2);
LCD_CS = 0;
LCD_RESE = 1;
Lcd_Send_Cmd(0XE2);// Software initialization
Lcd_Send_Cmd(0XA0);// Segment direction selection 0XA0: Normal direction ( about ) 0XA1: In the opposite direction
Lcd_Send_Cmd(0XC8);//0XC8: Ordinary ( Up and down ) Direction 0XC0: Normal direction
Lcd_Send_Cmd(0XA6);//0XA6: The font is black , The background is white 0XA7: The font is white , Black background
Lcd_Send_Cmd(0XA4);//0XA4: The pixels are normal 0XA5: All pixels on
Lcd_Send_Cmd(0XA2);//0XA2: Bias 1/7 0XA3: Bias 1/9
Lcd_Send_Cmd(0XF8);// Double byte command 0XF8 00 Select boost 4x
Lcd_Send_Cmd(0X01);//0XF8 01 Select boost 5x
Lcd_Send_Cmd(0X81);// Double byte command
Lcd_Send_Cmd(0X23);// Set the background light contrast 0x00 To 0x3f
Lcd_Send_Cmd(0X25);// Choose to adjust the resistivity
Lcd_Send_Cmd(0X2F);// Power settings
Lcd_Send_Cmd(0X40);// Set display start position
Lcd_Send_Cmd(0XAF);
Lcd_Clear(0x00);// Clear the screen
}
7、 Set the display position
//page: page col: Column
void Lcd_Set_Add(int page, int col)
{
Lcd_Send_Cmd(0XB0 + page);
Lcd_Send_Cmd(0X10 + ((col & 0XF0) >> 4));// Column address
Lcd_Send_Cmd(0X00+ (col & 0X0F));// List the addresses
}
8、 Character display
//page: page col: Column ch: character
void Lcd_Display_Char(int page,int col,u8 ch)
{
int str = 0;
int i = 0;
str = ch - ' ';//ch Position in the character set
Lcd_Set_Add(page,col);// The first half
for(i = 0; i < 8; i++)
{
Lcd_Send_Data(Aciss_8X16[str * 16 + i]);
}
Lcd_Set_Add(page + 1,col);
for(i = 0; i < 8; i++)
{
Lcd_Send_Data(Aciss_8X16[str * 16 + 8 + i]);
}
}
9、 String display
//page: page col: Column *str: String array first address
void Lcd_Display_String(int page, int col,u8 *str)
{
while(*str != '\0')
{
Lcd_Display_Char(page,col,*str);
col += 8;
str++;
}
}
10、 Single Chinese character or picture display
//page: page col: Column width: Width high: Height *Chinese: The first address of a single Chinese character array
void Lcd_Display_Chinese(int page, int col,int width,int high,u8 *Chinese)
{
u8 i = 0, j = 0;
// Single display
for(i = 0; i < high / 8; i++)// page
{
Lcd_Set_Add(page + i,col);
for(j = 0; j < width; j++)// Column
{
Lcd_Send_Data(Chinese[width * i + j]);
}
}
}
11、 Multiple Chinese characters display
//page: page col: Column width: Width high: Height num: The number of Chinese characters *Chinese: First address of Chinese character array
void Lcd_Display_ChinStr(int page, int col, int width, int high, int num, u8 *Chinese)
{
u8 i = 0, j = 0,k = 0;
int temp = 0;
for(k = 0; k < num; k++)
{
for(i = 0; i < high / 8; i++)
{
Lcd_Set_Add(page + i,col);
for(j = 0; j < width; j++)
{
Lcd_Send_Data(Chinese[temp + j]);
}
temp += width;// Record the display position
}
col += width;// Add a word width to the column address
}
}
12、 The main program
int main(void)
{
u8 buf[] = {
"2021/2/4"};
Sys_Delay_Init();
Lcd_Init();
while(1)
{
// display string
Lcd_Display_String(6, 48,buf);
// Show single Chinese
Lcd_Display_Chinese(6,112,16,16,Chinese16X16);
// Show multiple Chinese
Lcd_Display_ChinStr(2,0,24,24,5,Chinese24X24);
}
}
Four 、 Experimental results

Complete procedure and ST7565P Information :
link :https://pan.baidu.com/s/1Jk2jZoc63668NLPsqvZM4Q
Extraction code :cjx6
If there is any mistake, please point out , thank you !
边栏推荐
- 微信小程序轮播图怎么自定义光标位置
- Nokov motion capture system makes it possible for multi field cooperative UAV to build independently
- Starring V6 platform development take out point process
- MySQL binlog data source configuration document, please share
- SaltStack State状态文件配置实例
- R语言corrplot相关热图美化实例分析
- How to customize cursor position in wechat applet rotation chart
- High dimension low code: component rendering sub component
- Preliminary study nuxt3
- What do I mean when I link Mysql to report this error?
猜你喜欢

论文解读(SR-GNN)《Shift-Robust GNNs: Overcoming the Limitations of Localized Graph Training Data》

A detailed explanation of the implementation principle of go Distributed Link Tracking

Freeswitch uses origin to dialplan

R语言 4.1.0软件安装包和安装教程

Introduction and download tutorial of administrative division vector data

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

Experience of MDM master data project implementation for manufacturing projects

How to customize cursor position in wechat applet rotation chart

敏捷之道 | 敏捷开发真的过时了么?

How to protect biological privacy in the AI era? Overview of the latest "privacy enhancement technology in biometrics" of the Autonomous University of Madrid, comprehensively detailing the biometric p
随机推荐
Ask a question. Adbhi supports the retention of 100 databases with the latest IDs. Is this an operation like this
Fabric 账本数据块结构解析(一):如何解析账本中的智能合约交易数据
物联网?快来看 Arduino 上云啦
[computer talk club] Lecture 3: how to raise key issues?
为什么生命科学企业都在陆续上云?
How to select the ECS type and what to consider?
目前是不是只cdc 监控mysql 可以拿到新增列的数据 sqlserver不行是吧
three. Basic framework created by JS
Application DDoS attack principle and defense method
我链接mysql 报这个错 是啥意思呀?
我用sql形式的会出现cdc读取乱序吗
数字孪生行业案例:智慧港口数字化
Server lease error in Hong Kong may lead to serious consequences
程序员大部分时间不是写代码,而是。。。
一次 MySQL 误操作导致的事故,高可用都不顶不住!
The group offsets of the Kafka of the Flink SQL. If the specified groupid is not mentioned
特尔携手微软发挥边云协同势能,推动AI规模化部署
###脚本实现raid0自动化部署
The script implements the automated deployment of raid0
Why useevent is not good enough