当前位置:网站首页>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 !
边栏推荐
- Development of NFT dual currency pledge liquidity mining system
- three. Basic framework created by JS
- Huawei machine learning service speech recognition function enables applications to paint "sound" and color
- 为什么生命科学企业都在陆续上云?
- php OSS文件读取和写入文件,workerman生成临时文件并输出浏览器下载
- How to select the ECS type and what to consider?
- mysql binlog 数据源配置文档麻烦分享一下
- Programmers spend most of their time not writing code, but...
- Volcano成Spark默认batch调度器
- Set up your own website (8)
猜你喜欢

Interpreting harmonyos application and service ecology

Php OSS file read and write file, workerman Generate Temporary file and Output Browser Download

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

Introduction and download tutorial of administrative division vector data

Apifox与其他接口开发工具的博弈

How to use R package ggtreeextra to draw evolution tree

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

Why are life science enterprises on the cloud in succession?

TKDE2022:基于知识增强采样的对话推荐系统

A detailed explanation of the implementation principle of go Distributed Link Tracking
随机推荐
LabView之MQTT协议使用
Will the CDC read out of order when I use SQL
At present, only CDC monitors Mysql to get the data of new columns. Sqlserver can't, can it
###脚本实现raid0自动化部署
Php OSS file read and write file, workerman Generate Temporary file and Output Browser Download
我链接mysql 报这个错 是啥意思呀?
Dataworks development ODPs SQL development production environment automatic completion of ProjectName
Why is nodejs so fast?
Internet of things? Come and see Arduino on the cloud
Xiaodi class massive data processing business short chain platform
R language 4.1.0 software installation package and installation tutorial
数字孪生行业案例:智慧港口数字化
企业网络管理员必备的故障处理系统
論文解讀(SR-GNN)《Shift-Robust GNNs: Overcoming the Limitations of Localized Graph Training Data》
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
Mqtt protocol usage of LabVIEW
Why useevent is not good enough
工作6年,月薪3W,1名PM的奋斗史
Application scenarios of channel of go question bank · 11
小滴课堂海量数据处理商用短链平台大课