您的位置 首页 技术

STM32单片机ILI9325系列TFT的驱动原理解析

STM32单片机ILI9325系列TFT的驱动原理解析-为了更好,更深入学习了解ILI9325系列TFT的驱动原理,自己做了一块TFT板子。为了方便测试,在上面集成了STM32芯片,到时候做实验的时候就焊接STM32测试,如果只是使用,就直接焊接TFT就行了。板子还在做,先上原理图与PCB。

为了更好,更深入学习了解ILI9325系列TFT的驱动原理,自己做了一块TFT板子。为了便利测验,在上面集成了STM32芯片,到时分做试验的时分就焊接STM32测验,假如仅仅运用,就直接焊接TFT就行了。板子还在做,先上原理图与PCB

STM32单片机ILI9325系列TFT的驱动原理解析

————————-等板子回来,再测验,总结持续————-

——–板子回来了,焊接好了,简略测验了一下!———–

———第二部分—————ili9320.h——————代码简略剖析——

#ifndef _ILI9320_H_

#define _ILI9320_H_

#include “stm32f10x.h”

#define DB0_7_RCC RCC_APB2Periph_GPIOB

#define DB_8_15_RCC RCC_APB2Periph_GPIOC

//——————————————-

#define nCsPin_RCC RCC_APB2Periph_GPIOC

#define nCsPin_Port GPIOC

#define nCsPin GPIO_Pin_11

#define RsPin_RCC RCC_APB2Periph_GPIOC

#define RsPin_Port GPIOC

#define RsPin GPIO_Pin_8

#define nWrPin_RCC RCC_APB2Periph_GPIOC

#define nWrPin_Port GPIOC

#define nWrPin GPIO_Pin_9

#define nRdPin_RCC RCC_APB2Periph_GPIOC

#define nRdPin_Port GPIOC

#define nRdPin GPIO_Pin_10

#define nRstPin_RCC RCC_APB2Periph_GPIOC

#define nRstPin_Port GPIOC

#define nRstPin GPIO_Pin_12

#define LightPin_RCC RCC_APB2Periph_GPIOB

#define LightPin_Port GPIOB

#define LightPin GPIO_Pin_0

//—————————————–

#define Set_nWrnCsPin_Port-》BSRR = nWrPin // GPIO_SetBits (nWrPin_Port, nWrPin)

#define Clr_nWrnCsPin_Port-》BRR = nWrPin // GPIO_ResetBits (nWrPin_Port, nWrPin)

#define Set_Cs nCsPin_Port-》BSRR = nCsPin // GPIO_SetBits (nCsPin_Port, nCsPin)

#define Clr_Cs nCsPin_Port-》BRR = nCsPin// GPIO_ResetBits (nCsPin_Port, nCsPin)

#define Set_Rs RsPin_Port-》BSRR = RsPin// GPIO_SetBits (RsPin_Port, RsPin)

#define Clr_Rs RsPin_Port-》BRR = RsPin // GPIO_ResetBits (RsPin_Port, RsPin)

#define Set_nRdnRdPin_Port-》BSRR = nRdPin// GPIO_SetBits (nRdPin_Port, nRdPin)

#define Clr_nRdnRdPin_Port-》BRR = nRdPin // GPIO_ResetBits (nRdPin_Port, nRdPin)

#define Set_RstnRstPin_Port-》BSRR = nRstPin// GPIO_SetBits (nRstPin_Port, nRstPin)

#define Clr_RstnRstPin_Port-》BRR = nRstPin // GPIO_ResetBits (nRstPin_Port, nRstPin)

#define Set_LightLightPin_Port-》BSRR = LightPin// GPIO_SetBits (LightPin_Port, LightPin)

#define Clr_LightLightPin_Port-》BRR = LightPin// GPIO_ResetBits (LightPin_Port, LightPin)

//———————————

#define White 0xFFFF

#define Black 0x0000

#define Grey 0xF7DE

#define Blue 0x001F

#define Blue2 0x051F

#define Red 0xF800

#define Magenta 0xF81F

#define Green 0x07E0

#define Cyan 0x7FFF

#define Yellow 0xFFE0

void Lcd_ConfiguraTIon(void); //初始化GPIO

void LCD_ili9320_IniTIalizTIon(void); //初始化ILI9320—uCGUI需求运用–1

void LCD_ili9320_Reset(void);

void LCD_ili9320_BackLight(u8 status); //背光

void LCD_ili9320_SetCursor(u16 x,u16 y); //设置坐标—uCGUI需求运用–2

void LCD_ili9320_SetWindows(u16 StartX,u16 StartY,u16 EndX,u16 EndY); //设置窗体

void LCD_ili9320_DrawPicture(u16 StartX,u16 StartY,u16 EndX,u16 EndY,u16 *pic);//画图片

void LCD_ili9320_SetPoint(u16 x,u16 y,u16 point);//画点—uCGUI需求运用–3

u16 LCD_ili9320_GetPoint(u16 x,u16 y); //读取点颜色—uCGUI需求运用–4

void LCD_ili9320_PutChar(u16 x,u16 y,u8 c,u16 charColor,u16 bkColor); //显现字符–需求字体头文件

void LCD_ili9320_Clear(u16 dat); //清屏

void LCD_ili9320_Delay(u32 nCount);

void LCD_ili9320_Test(void);

void LCD_ili9320_WriteData(u16 dat); //写数据

void LCD_ili9320_WriteIndex(u16 idx); //写地址

u16 LCD_ili9320_ReadData(void); //读数据

u16 LCD_ili9320_ReadRegister(u16 index); //读寄存器

void LCD_ili9320_WriteRegister(u16 index,u16 dat); //写寄存器

u16 LCD_ili9320_BGR2RGB(u16 c); //转化颜色格局

u16 LCD_ili9320_Color565(u32 RGB); // RGB颜色转为16位(565)

void LCD_ili9320_DrawHLine(uint16_t usX1 , uint16_t usY1 , uint16_t usX2 , uint16_t usColor);//水平线—uCGUI需求运用–5

void LCD_ili9320_DrawVLine(uint16_t usX1 , uint16_t usY1 , uint16_t usY2 , uint16_t usColor);//笔直线—uCGUI需求运用–6

void LCD_ili9320_FillRect(u16 x0, u16 y0, u16 x1, u16 y1,u16 color);//填充矩形—uCGUI需求运用–7

void LCD_ili9320_Line(u16 x0, u16 y0, u16 x1, u16 y1,u16 color); // 画恣意直线线

void LCD_ili9320_Circle(u16 cx,u16 cy,u16 r,u16 color,u8 fill); // 画园

void LCD_ili9320_Rectangle(u16 x0, u16 y0, u16 x1, u16 y1,u16 color,u8 fill); // 画矩形–填充或许不填充

void LCD_ili9320_Square(u16 x0, u16 y0, u16 with, u16 color,u8 fill); // 画正方形–填充或许不填充

void LCD_ili9320_Text(u16 x, u16 y, u8 *str, u16 len,u16 Color, u16 bkColor); //简略测验–显现渐变色条

#endif

———第三部分—————-ili9320.c——代码剖析——

#include “ili9320.h”

#include “ili9320_font.h”

void Lcd_ConfiguraTIon(void)

{

GPIO_InitTypeDef GPIO_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB “ RCC_APB2Periph_GPIOC, ENABLE); //初始化数据引脚 —DB0~~DB7是PB8~~PB15 DB8~~DB15是PC0~~PC7———-//

GPIO_InitStructure.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_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin =GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 |GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(GPIOC, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(nCsPin_RCC, ENABLE); // 操控脚 CS ——PC11—-//

GPIO_InitStructure.GPIO_Pin = nCsPin;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(nCsPin_Port, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(RsPin_RCC, ENABLE); // 操控脚 RS ——-PC8—//

GPIO_InitStructure.GPIO_Pin = RsPin;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(RsPin_Port, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(nWrPin_RCC, ENABLE); // 操控脚 WR —-PC9–//

GPIO_InitStructure.GPIO_Pin = nWrPin;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(nWrPin_Port, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(nRdPin_RCC, ENABLE); // 操控脚 RD —PC10–//

GPIO_InitStructure.GPIO_Pin = nRdPin;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(nRdPin_Port, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(nRstPin_RCC, ENABLE); // 操控脚 RST —PC12–//

GPIO_InitStructure.GPIO_Pin = nRstPin;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(nRstPin_Port, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(LightPin_RCC, ENABLE); // 操控脚背光 –PB00—//

GPIO_InitStructure.GPIO_Pin = LightPin;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(LightPin_Port, &GPIO_InitStructure);

}

void delayms(int count) // X1ms

{

int i,j;

for(i=0;i for(j=0;j《1000;j++);

}

void LCD_ili9320_Initializtion (void) //–功 能:初始化 ILI9320 操控器

{

volatile u16 i, j, k;

u32 DeviceCode = 0;

Lcd_Configuration();

LCD_ili9320_BackLight(0); //关背光

delayms(200);

Clr_Rst;

delayms(200);

LCD_ili9320_WriteData(0xffff);

Set_Rst; Set_nWr; Set_Cs; Set_Rs; Set_nRd; Set_Rst;

delayms(200);

LCD_ili9320_WriteRegister(0x0000,0x0001); // Start OCS

delayms(200);

DeviceCode = LCD_ili9320_ReadRegister(0x0000); // 读操控器类型 ILI9320

if(DeviceCode == 0x9320||0x9300)

{

LCD_ili9320_WriteRegister(0x00,0x0000);

LCD_ili9320_WriteRegister(0x01,0x0100);//驱动器输出操控

LCD_ili9320_WriteRegister(0x02,0x0700);//LCD驱动波形操控-回转

LCD_ili9320_WriteRegister(0x03,0x1030);//进入形式–F-

LCD_ili9320_WriteRegister(0x04,0x0000);//从头调整操控寄存器巨细—缩放

LCD_ili9320_WriteRegister(0x08,0x0202);//Display Contral 2.(0x0207)

LCD_ili9320_WriteRegister(0x09,0x0000);//Display Contral 3.(0x0000)

LCD_ili9320_WriteRegister(0x0a,0x0000);//Frame信号输出距离

LCD_ili9320_WriteRegister(0x0c,(1《《0)); //RGB显现接口操控1–16位

LCD_ili9320_WriteRegister(0x0d,0x0000);//帧符号的方位

LCD_ili9320_WriteRegister(0x0f,0x0000); //RGB显现接口操控1

delayms(5);

LCD_ili9320_WriteRegister(0x07,0x0101);//Display Contral.

delayms(5);

LCD_ili9320_WriteRegister(0x10,(1《《12)|(0《《8)|(1《《7)|(1《《6)|(0《《4));//Power Control 1.(0x16b0)

LCD_ili9320_WriteRegister(0x11,0x0007); //Power Control 2.(0x0001)

LCD_ili9320_WriteRegister(0x12,(1《《8)|(1《《4)|(0《《0));//Power Control 3.(0x0138)

LCD_ili9320_WriteRegister(0x13,0x0b00);//Power Control 4.

LCD_ili9320_WriteRegister(0x29,0x0000); //Power Control 7.

LCD_ili9320_WriteRegister(0x2b,(1《《14)|(1《《4));//帧速率和颜色操控—70

LCD_ili9320_WriteRegister(0x50,0);//Set X Star240*320

LCD_ili9320_WriteRegister(0x51,239); //水平GRAM停止方位Set X End.

LCD_ili9320_WriteRegister(0x52,0);//Set Y Star

LCD_ili9320_WriteRegister(0x53,319);//Set Y End.t.

LCD_ili9320_WriteRegister(0x60,0x2700);//门扫描操控器

LCD_ili9320_WriteRegister(0x61,0x0001);//Driver Output Control.

LCD_ili9320_WriteRegister(0x6a,0x0000); //Vertical Srcoll Control.

LCD_ili9320_WriteRegister(0x80,0x0000); //部分印象操控器1

LCD_ili9320_WriteRegister(0x81,0x0000); //部分印象操控器1–开始地址

LCD_ili9320_WriteRegister(0x82,0x0000); //部分印象操控器1–停止地址

LCD_ili9320_WriteRegister(0x83,0x0000); //Displsy Position? Partial Display 2.

LCD_ili9320_WriteRegister(0x84,0x0000); //RAM Address Start? Partial Display 2.

LCD_ili9320_WriteRegister(0x85,0x0000); //RAM Address End? Partial Display 2.

LCD_ili9320_WriteRegister(0x90,(0《《7)|(16《《0)); //平板接口操控器1(0x0013)

LCD_ili9320_WriteRegister(0x92,0x0000);//Panel Interface Contral 2.(0x0000)

LCD_ili9320_WriteRegister(0x93,0x0001); //Panel Interface Contral 3.

LCD_ili9320_WriteRegister(0x95,0x0110); //Frame Cycle Contral.(0x0110)

LCD_ili9320_WriteRegister(0x97,(0《《8)); //

LCD_ili9320_WriteRegister(0x98,0x0000); //Frame Cycle Contral.

LCD_ili9320_WriteRegister(0x07,0x0173);//(0x0173)

}

else if(DeviceCode==0x9325||DeviceCode==0x9328)//ILI9325

{

LCD_ili9320_WriteRegister(0x00e7,0x0010);

LCD_ili9320_WriteRegister(0x0000,0x0001); //敞开内部时钟

LCD_ili9320_WriteRegister(0x0001,0x0100);

LCD_ili9320_WriteRegister(0x0002,0x0700); //电源敞开

LCD_ili9320_WriteRegister(0x0003,(1《《12)|(3《《4)|(0《《3) ); //65K

LCD_ili9320_WriteRegister(0x0004,0x0000);

LCD_ili9320_WriteRegister(0x0008,0x0207);

LCD_ili9320_WriteRegister(0x0009,0x0000);

LCD_ili9320_WriteRegister(0x000a,0x0000);//display setting

LCD_ili9320_WriteRegister(0x000c,0x0001); //display setting

LCD_ili9320_WriteRegister(0x000d,0x0000);//0f3c

LCD_ili9320_WriteRegister(0x000f,0x0000);

//电源装备

LCD_ili9320_WriteRegister(0x0010,0x0000);

LCD_ili9320_WriteRegister(0x0011,0x0007);

LCD_ili9320_WriteRegister(0x0012,0x0000);

LCD_ili9320_WriteRegister(0x0013,0x0000);

delayms(5);

LCD_ili9320_WriteRegister(0x0010,0x1590);

LCD_ili9320_WriteRegister(0x0011,0x0227);

delayms(5);

LCD_ili9320_WriteRegister(0x0012,0x009c);

delayms(5);

LCD_ili9320_WriteRegister(0x0013,0x1900);

LCD_ili9320_WriteRegister(0x0029,0x0023);

LCD_ili9320_WriteRegister(0x002b,0x000e);

delayms(5);

LCD_ili9320_WriteRegister(0x0020,0x0000);

LCD_ili9320_WriteRegister(0x0021,0x013f);

delayms(5);

//伽马校对

LCD_ili9320_WriteRegister(0x0030,0x0007);

LCD_ili9320_WriteRegister(0x0031,0x0707);

LCD_ili9320_WriteRegister(0x0032,0x0006);

LCD_ili9320_WriteRegister(0x0035,0x0704);

LCD_ili9320_WriteRegister(0x0036,0x1f04);

LCD_ili9320_WriteRegister(0x0037,0x0004);

LCD_ili9320_WriteRegister(0x0038,0x0000);

LCD_ili9320_WriteRegister(0x0039,0x0706);

LCD_ili9320_WriteRegister(0x003c,0x0701);

LCD_ili9320_WriteRegister(0x003d,0x000f);

delayms(5);

LCD_ili9320_WriteRegister(0x0050,0x0000); //水平GRAM开始方位

LCD_ili9320_WriteRegister(0x0051,0x00ef);//水平GRAM停止方位

LCD_ili9320_WriteRegister(0x0052,0x0000); //笔直GRAM开始方位

LCD_ili9320_WriteRegist

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/xinpin/jishu/346851.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部