当前位置:网站首页>TFTLCD display experiment of mini plate based on punctual atom stm32
TFTLCD display experiment of mini plate based on punctual atom stm32
2022-06-28 04:08:00 【Wanzhang light I】
This chapter will talk about TFTLCD Display experiments , Xiaobai sums up , If there is a mistake , Please give me your advice .
One 、TFTLCD brief introduction
1.TFT-LCD Thin film transistor liquid crystal display .TFT-LCD have : Good brightness 、 High contrast 、 Strong sense of hierarchy 、 Bright color and other characteristics . It's the most mainstream LCD Monitor . It is widely used in various electronic products .
Be careful : The module is 3.3V Powered by electricity , I won't support it 5V Of voltage MCU, If it is 5VMCU, The signal line must be connected in series 120 Ohm resistance is used .
2.2.8 " TFTLCD The schematic diagram of the module is as follows :

In the picture X-,Y-,Y+,X+ Should and XPT2046 Touch screen connection , The schematic diagram of touch screen is as follows :

The interfaces we may use are as follows :
1.CS:TFTLCD Piece of optional signal .
2.WR: towards TFTLCD Write data .
3.RD: from TFTLCD Reading data .
4.D[15:0]( Zero to fifteen means ):16 Bit bidirectional data line .
5.RST: Hard reset TFTLCD.
6.RS: command / Data signs (0, Read and write commands ;1, Read and write data ).
7.BL_CTR: Backlight control signal
8. Touch screen interface signal :T_MISO/T_MOSI/T_PEN/T_CS/T_CLK( These functions need to be determined , If not required, it is not necessary to set ).
3.TFTLCD Modular 8080 Read simultaneously / The process of writing :
1. First write... According to the need / The type of data read , Set up RS For the high ( data )/ low ( command ), And then pull down the selection , Choose ILI9341, And then we read the data , Or write the data set RD/WR For low , then :
(1) Reading data : stay RD The rising edge of , Read the data on the data line ;
(2) Writing data : stay WR The rising edge of , Write data to ILI9341 Inside .
4.TFTLCD The driving process of :

5.ILI9341 use RGB565 Format to store color data :

R5: There are five red ,G6: There are six green ,B5: There are five blue , Together it is RGB565 Format .
for example :0xf800 It is pure red .
6. Instruction Introduction :
(1)0xD3: It's a test LCD Models of tools , Because the model can be tested , Therefore, the portability of the code is enhanced .
(2)0x36: To store access control instructions , It can control the reading and writing direction of the memory , Realization GRAM Self increasing mode , Increase speed
(3)0x2A: From left to right , From top to bottom , Set up x Coordinates of .
(4)0x2B: From left to right , From top to bottom , Set up y Coordinates of .
(5)0x2C: Set the color data .
(6)0x2E: Read video memory , That is, the general color .
7. On hardware ,TFTLCD Module and MiniSTM32 Development board IO The oral correspondence is as follows :
LCD_LED Corresponding PC10;
LCD_CS Corresponding PC9;
LCD _RS Corresponding PC8;
LCD _WR Corresponding PC7;
LCD _RD Corresponding PC6;
LCD _D[17:1] Corresponding PB[15:0];
Two 、 software design
1. Let's first introduce a lcd An important structure of :
typedef struct
{
u16 width; //LCD Width
u16 height; //LCD Height
u16 id; //LCD ID
u8 dir; // Horizontal screen or vertical screen control :0, Vertical screen ;1, Horizontal screen .
u16 wramcmd; // Start writing gram Instructions
u16 setxcmd; // Set up x Coordinate command
u16 setycmd; // Set up y Coordinate command
}_lcd_dev;
//LCD Parameters
extern _lcd_dev lcddev; // management LCD Important parameter
2. Write data functions :
// Write data functions
#define LCD_WR_DATA(data){\
LCD_RS_SET;\
LCD_CS_CLR;\
DATAOUT(data);\
LCD_WR_CLR;\
LCD_WR_SET;\
LCD_CS_SET;\
}
3. Write register command function :
// Write register function
//data: Register values
void LCD_WR_REG(u16 data)
{
LCD_RS_CLR;// Write the address
LCD_CS_CLR;
DATAOUT(data);
LCD_WR_CLR;
LCD_WR_SET;
LCD_CS_SET;
}4. Read register data function :
// read LCD Register data
// Return value : The value read
u16 LCD_RD_DATA(void)
{
u16 t;
GPIOB->CRL=0X88888888; //PB0-7 Pull up input
GPIOB->CRH=0X88888888; //PB8-15 Pull up input
GPIOB->ODR=0X0000; // All output 0
LCD_RS_SET;
LCD_CS_CLR;
LCD_RD_CLR; // Reading data ( When reading registers , There is no need to read 2 Time )
if(lcddev.id==0X8989)delay_us(2);//FOR 8989, Time delay 2us
t=DATAIN;
LCD_RD_SET;
LCD_CS_SET;
GPIOB->CRL=0X33333333; //PB0-7 Pull up output
GPIOB->CRH=0X33333333; //PB8-15 Pull up output
GPIOB->ODR=0XFFFF; // All output high
return t;
} 5. LCD Register operation function
//LCD_Reg: Register number
//LCD_RegValue: Value to write
void LCD_WriteReg(u16 LCD_Reg,u16 LCD_RegValue)
{
LCD_WR_REG(LCD_Reg);
LCD_WR_DATA(LCD_RegValue);
}
// Read register
//LCD_Reg: Register number
// Return value : The value read
u16 LCD_ReadReg(u16 LCD_Reg)
{
LCD_WR_REG(LCD_Reg); // Write the register number to be read
return LCD_RD_DATA();
} 6. Set cursor function :
// Set cursor position
//Xpos: Abscissa
//Ypos: Ordinate
void LCD_SetCursor(u16 Xpos, u16 Ypos)
{
if(lcddev.id==0X9341||lcddev.id==0X5310)
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(Xpos>>8);
LCD_WR_DATA(Xpos&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(Ypos>>8);
LCD_WR_DATA(Ypos&0XFF);
}else if(lcddev.id==0X6804)
{
if(lcddev.dir==1)Xpos=lcddev.width-1-Xpos;// Horizontal screen processing
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(Xpos>>8);
LCD_WR_DATA(Xpos&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(Ypos>>8);
LCD_WR_DATA(Ypos&0XFF);
}else if(lcddev.id==0X5510)
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(Xpos>>8);
LCD_WR_REG(lcddev.setxcmd+1);
LCD_WR_DATA(Xpos&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(Ypos>>8);
LCD_WR_REG(lcddev.setycmd+1);
LCD_WR_DATA(Ypos&0XFF);
}else
{
if(lcddev.dir==1)Xpos=lcddev.width-1-Xpos;// The horizontal screen is actually turning x,y coordinate
LCD_WriteReg(lcddev.setxcmd, Xpos);
LCD_WriteReg(lcddev.setycmd, Ypos);
}
}Due to too much actual code , Commentable QQ, I'll send you the source file , I am writing 51 and 32 Writing code , You can have a private chat .
边栏推荐
- 门级建模—学习笔记
- 基于arm5718的Shell脚本参数传递的2种方法
- 美创入选“2022 CCIA中国网络安全竞争力50强”榜单
- English语法_形容词/副词3级-比较级_常用短语
- GCD maximum common divisor
- Chapter 1 Introduction to bash
- Introduction notes to machine learning
- Une seule pile dans l'ordre inverse avec des fonctions récursives et des opérations de pile
- 01 MongoDB的概述、应用场景、下载方式、连接方式和发展历史等
- 简单工厂模式
猜你喜欢

La norme européenne en 597 - 1 pour les meubles est - elle la même que les deux normes en 597 - 2 pour les ignifuges?

歐洲家具EN 597-1 跟EN 597-2兩個阻燃標准一樣嗎?

Particle theory of light (photoelectric effect / Compton effect)

一文告诉你什么是 Kubernetes

A Preliminary Study of Blackbody radiation

sqlserver 数据库之事物使用入门 案例

错排兼排列组合公式

GenICam GenTL 标准 ver1.5(2)

How to learn a programming language systematically| Dark horse programmer

02 MongoDB数据类型、重要概念以及shell常用指令
随机推荐
Introduction notes to machine learning
django. core. exceptions. ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3
光伏板怎么申请ASTM E108阻燃测试?
Open the field of maker education and creation
公司领导说,个人代码超10个Bug就开除,是什么体验?
Notes to friendship chain
电学基础知识整理(二)
僅用遞歸函數和棧操作逆序一個棧
English grammar_ Adjective / adverb Level 3 - Comparative_ Useful Expressions
Conversion between decimal and BCD codes in C language
Elk builds log analysis system + Zipkin service link tracking integration
双亲委派机制的理解学习
applicationContext. Getbeansoftype obtains the execution methods of all implementation classes under an interface or obtains the operation application scenarios such as implementation class objects. L
How to learn a programming language systematically| Dark horse programmer
黑体辐射初探
05 mongodb summary of various column operations
A solution to the inefficiency of setting debug mode in developing flask framework with pychar
Backtracking maze problem
02 mongodb data types, important concepts and common shell instructions
One article tells you what kubernetes is