当前位置:网站首页>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 !
边栏推荐
- IBPS开源表单设计器有什么功能?
- Interprétation de la thèse (SR - gnn) Shift Robust GNNS: Overcoming the Limits of Localized Graph Training Data
- Volcano成Spark默认batch调度器
- Understanding openstack network
- Technology implementation | Apache Doris cold and hot data storage (I)
- Apifox与其他接口开发工具的博弈
- 微信小程序轮播图怎么自定义光标位置
- 西北工业大学遭黑客攻击?双因素认证改变局面!
- 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
- [leetcode] rotation series (array, matrix, linked list, function, string)
猜你喜欢
This is not safe
Necessary fault handling system for enterprise network administrator
Volcano becomes spark default batch scheduler
对国产数据库厂商提几个关于SQL引擎的小需求
模块五
60 divine vs Code plug-ins!!
程序员大部分时间不是写代码,而是。。。
Volcano成Spark默认batch调度器
Freeswitch uses origin to dialplan
Introduction and download tutorial of administrative division vector data
随机推荐
Working for 6 years with a monthly salary of 3W and a history of striving for one PM
Sr-gnn shift robot gnns: overlapping the limitations of localized graph training data
Xiaodi class massive data processing business short chain platform
The sharp sword of API management -- eolink
试驾 Citus 11.0 beta(官方博客)
Sr-gnn shift robot gnns: overlapping the limitations of localized graph training data
High dimension low code: component rendering sub component
1: Mosaic of 100W basic geographic information data
Nokov motion capture system makes it possible for multi field cooperative UAV to build independently
Several ways of connecting upper computer and MES
If the programmer tells the truth during the interview
Xiaobai, let me ask you guys, is MySQL binlog extracted by CDC in strict order
IBPS开源表单设计器有什么功能?
NFT pledge liquidity mining system development technology
8 challenges of BSS application cloud native deployment
Zadig + 洞态 IAST:让安全溶于持续交付
subject may not be empty [subject-empty]
R language 4.1.0 software installation package and installation tutorial
Introduction to alos satellite
ls 常用参数