概述
基于STM32的4.3寸TFTLCD的使用
在这里,我们只剖析NT35510部分的代码。
LCD显示方向设置函数
代码示例
//设置LCD显示方向
//dir:0,竖屏;1,横屏
void LCD_Display_Dir(u8 dir)
{
if(dir==0) //竖屏
{
lcddev.dir=0; //竖屏
if(lcddev.id==0x5510)
{
lcddev.wramcmd=0X2C00;
lcddev.setxcmd=0X2A00;
lcddev.setycmd=0X2B00;
lcddev.width=480;
lcddev.height=800;
}
} else //横屏
{
lcddev.dir=1; //横屏
if(lcddev.id==0x5510)
{
lcddev.wramcmd=0X2C00;
lcddev.setxcmd=0X2A00;
lcddev.setycmd=0X2B00;
lcddev.width=800;
lcddev.height=480;
}
}
LCD_Scan_Dir(DFT_SCAN_DIR); //默认扫描方向
}
代码解析
这部分代码用于配置X轴的填充上下限,Y轴的填充上下限并且填充RGB565颜色数据。
- 列地址设置:0X2A00~0X2A03
我们的4.3寸LCD的分辨率为480*800,因此根据NT35510给出的X,Y轴坐标的限制,X,Y坐标取值范围如下:
参数读写如下所示:
图中,1st,2nd,3rd,4th分别表示接下来所要输入的4个参数,正好是4个指令对应4个输入参数,对应关系如下:
在默认扫描方式时,这4个指令用于设置x坐标,每条指令带有1个参数,实际上总共就是2个坐标值:SC和EC(SC和EC都是16位的,由2个8位组成),即列地址的起始值和结束值,SC必须小于等于EC,且0≤SC/EC≤479。一般在设置x坐标的时候,我们只需要0X2A00和0X2A01两条指令即可,也就是设置SC即可,因为如果EC没有变化,我们只需要设置一次即可(在初始化NT35510的时候设置),从而提高速度。
设置后,坐标自增的效果如下所示:
- 行地址设置:0X2B00~0X2B03
我们的4.3寸LCD的分辨率为480*800,因此根据NT35510给出的X,Y轴坐标的限制,X,Y坐标取值范围如下:
参数读写如下所示:
图中,1st,2nd,3rd,4th分别表示接下来所要输入的4个参数,正好是4个指令对应4个输入参数,对应关系如下:
在默认扫描方式时,这4个指令用于设置y坐标,每条指令带有1个参数(这一点与ILI9341不同),实际上总共就是2个坐标值:SP和EP(SP和EP都是16位的,由2个8位组成),即页地址的起始值和结束值,SP必须小于等于EP,且0≤SP/EP≤799。一般在设置y坐标的时候,我们只需要带0X2B00和0X2B01两条指令即可,也就是设置SP即可,因为如果EP没有变化,我们只需要设置一次即可(在初始化NT35510的时候设置),从而提高速度。
设置后,坐标自增的效果如下所示:
- 在指定坐标位置填充颜色:0X2C00
当我们输入指令0X2C00之后,我们可以肆无忌惮地输入颜色数据,GRAM会按照我们既定好的扫描顺序对颜色点进行填充。当达到(Xmax,Ymax)时,GRAM会回到(X=0,Y=0)重新进行自增并进行颜色填充操作。
其实我们可以将3,4,5布看作一整个配置步骤,总的配置流程如下:
RAWAR是“RAMWrite”的缩写。
第一步:先配置颜色自增时的X轴的上下界;
第二步:然后,配置颜色自增时的Y轴的上下界;
第三步:最后,当我们不断写入RGB565的数据,GRAM会按照我们配置的既定自增方式进行颜色填充。其中,16位颜色数据=5位R+6位G+5位B。
LCD扫描函数
代码示例
void LCD_Scan_Dir(u8 dir)
{
u16 regval=0;
u16 dirreg=0;
u16 temp;
if(lcddev.id==0X5510)
{
switch(dir)
{
case L2R_U2D://从左到右,从上到下
regval|=(0<<7)|(0<<6)|(0<<5);
break;
case L2R_D2U://从左到右,从下到上
regval|=(1<<7)|(0<<6)|(0<<5);
break;
case R2L_U2D://从右到左,从上到下
regval|=(0<<7)|(1<<6)|(0<<5);
break;
case R2L_D2U://从右到左,从下到上
regval|=(1<<7)|(1<<6)|(0<<5);
break;
case U2D_L2R://从上到下,从左到右
regval|=(0<<7)|(0<<6)|(1<<5);
break;
case U2D_R2L://从上到下,从右到左
regval|=(0<<7)|(1<<6)|(1<<5);
break;
case D2U_L2R://从下到上,从左到右
regval|=(1<<7)|(0<<6)|(1<<5);
break;
case D2U_R2L://从下到上,从右到左
regval|=(1<<7)|(1<<6)|(1<<5);
break;
}
if(lcddev.id==0X5510)dirreg=0X3600;
if(lcddev.id==0X5510)
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setxcmd+1);
LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setxcmd+2);
LCD_WR_DATA((lcddev.width-1)>>8);
LCD_WR_REG(lcddev.setxcmd+3);
LCD_WR_DATA((lcddev.width-1)&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setycmd+1);
LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setycmd+2);
LCD_WR_DATA((lcddev.height-1)>>8);
LCD_WR_REG(lcddev.setycmd+3);
LCD_WR_DATA((lcddev.height-1)&0XFF);
}
}
}
代码解析
① 设置扫描填充方向,刷新方向,图像反转设置
LCD扫描函数主要使用的是NT35510的0X3600指令:
可以控制NT35510存储器的读写方向,简单的说,就是在连续写GRAM的时候,可以控制GRAM指针的增长方向,从而控制显示方式(读GRAM也是一样)。除了读写存储器的方向,该寄存器也可以控制GRAM扫描刷新的方向。
返回参数含义如下:
表格1
参数名称 | 参数含义 |
MY | 这3位控制接口到内存的写入/读取方向。图案更改后立即显示。 |
MX | |
MV | |
ML | 控制TFTLCD的垂直刷新方向 |
RGB | 控制R,G,B的排列顺序,0(RGB)/1(BGR) |
MH | 水平刷新方向 |
RSMX | 左右反转图像(高电平有效) |
RSMY | 上下反转图像(高电平有效) |
- MH控制效果:
- ML控制效果:
- MY,MX,MV控制效果:
这个参数到底有什么用呢?我们在显示一张方形图片时,图片的填充肯定按照一定方向,就例如BMP图像,解码BMP(显示BMP)就是从图片的左下角开始,慢慢显示到右上角,如果设置LCD扫描方向为从左到右,从下到上,那么我们只需要设置一次坐标,然后就不停的往LCD填充颜色数据即可,这样可以大大提高显示速度。
② 设置X,Y轴填充的上下限
设置Xmin=0,Xmax=480-1:
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setxcmd+1);
LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setxcmd+2);
LCD_WR_DATA((lcddev.width-1)>>8);
LCD_WR_REG(lcddev.setxcmd+3);
LCD_WR_DATA((lcddev.width-1)&0XFF);
设置Ymin=0,Ymax=800-1:
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setycmd+1);
LCD_WR_DATA(0);
LCD_WR_REG(lcddev.setycmd+2);
LCD_WR_DATA((lcddev.height-1)>>8);
LCD_WR_REG(lcddev.setycmd+3);
LCD_WR_DATA((lcddev.height-1)&0XFF);
最终效果图如下:
LCD初始化函数
代码示例
由于太多,因此详见附录
代码解析
① 配置引脚和FSMC
配置原理详见:TFTLCD之FSMC详解_超级霸霸强的博客-CSDN博客
② 读TFTLCD的ID:
首先,读ID部分代码如下所示:
LCD_WR_REG(0XDA00);
lcddev.id=LCD_RD_DATA(); //读回0X00
LCD_WR_REG(0XDB00);
lcddev.id=LCD_RD_DATA(); //读回0X80
lcddev.id<<=8;
LCD_WR_REG(0XDC00);
lcddev.id|=LCD_RD_DATA(); //读回0X00
③ 执行LCD的初始化序列:
根据ID执行对应厂家提供的初始化序列进行初始化(NT35510的初始化序列在“正点原子/资料盘A/硬件资料/液晶资料/NT35510/NT35510_AN_for_CMI_4p02_IPS,pdf”中)。
④ 设置颜色填充方向,初始坐标位置,屏幕方向(横/竖),X,Y轴的填充范围:
LCD_Display_Dir(0); //默认为竖屏
⑤ 点亮背光并且清屏:
LCD_LED=1; //点亮背光
LCD_Clear(WHITE);
LCD显示开/关函数
代码示例
//LCD开启显示
void LCD_DisplayOn(void)
{
if(lcddev.id==0X9341||lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X29); //开启显示
else if(lcddev.id==0X5510)LCD_WR_REG(0X2900); //开启显示
else LCD_WriteReg(0X07,0x0173); //开启显示
}
//LCD关闭显示
void LCD_DisplayOff(void)
{
if(lcddev.id==0X9341||lcddev.id==0X6804||lcddev.id==0X5310||lcddev.id==0X1963)LCD_WR_REG(0X28); //关闭显示
else if(lcddev.id==0X5510)LCD_WR_REG(0X2800); //关闭显示
else LCD_WriteReg(0X07,0x0);//关闭显示
}
代码解析
4.3寸LCD显示是写NT35510的0X2900指令,指令详细如下:
官方文档中说:写入0X2900之后帧存储器输出使能,而且0X2900这个命令后面不跟任何参数。
同理,我们写入0X2800之后,4.3寸LCD帧存储器输出失能,也就是我们说的“显示关闭”:
从上述两个寄存器的图像化说明中可以得知:
帧存储器中存储的是我们的像素点信息,但是只要帧存储器输出不使能,我们在LCD屏幕上是看不到任何图像信息的。
LCD设置光标函数
代码示例
//设置光标位置
//Xpos:横坐标
//Ypos:纵坐标
void LCD_SetCursor(u16 Xpos, u16 Ypos)
{
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);
}
}
代码解析
其实,这个也是使用了0X2A00~0X2A03, 0X2B00~0X2B03, 0X2C00的指令来设置初始坐标位置,与之前不同的是:进设置了X,Y轴的填充的起始点,终值点还是保留在(480-1,800-1),效果图如下所示:
我们一定要清楚:行地址和列地址的X,Y坐标是16位的,因此我们要分两次传输,一次传输一个字节,先传输高八位,在传输第八位。
LCD清屏函数
代码示例
//清屏函数
//color:要清屏的填充色
void LCD_Clear(u16 color)
{
u32 index=0;
u32 totalpoint=lcddev.width;
totalpoint*=lcddev.height; //得到总点数
LCD_SetCursor(0x00,0x0000); //设置光标位置
LCD_WriteRAM_Prepare(); //开始写入GRAM
for(index=0; index<totalpoint; index++)
{
LCD->LCD_RAM=color;
}
}
代码解析
LCD_WriteRAM_Prepare()这个函数与FSMC有关,要弄懂这个函数详见:TFTLCD之FSMC详解_超级霸霸强的博客-CSDN博客 这个函数的功能就是将0X2C00写入NT35510中,接下来我们要想NT35510写入16位的RGB565颜色帧数据了,具体有关0X2C00指令的信息如下所示:
当我们输入指令0X2C00之后,我们可以肆无忌惮地输入颜色数据,GRAM会按照我们既定好的扫描顺序对颜色点进行填充。当达到(Xmax,Ymax)时,GRAM会回到(X=0,Y=0)重新进行自增并进行颜色填充操作。
其实我们可以将3,4,5布看作一整个配置步骤,总的配置流程如下:
RAWAR是“RAMWrite”的缩写。
第一步:先配置颜色自增时的X轴的上下界;
第二步:然后,配置颜色自增时的Y轴的上下界;
第三步:最后,当我们不断写入RGB565的数据,GRAM会按照我们配置的既定自增方式进行颜色填充。其中,16位颜色数据=5位R+6位G+5位B。
代码中有这样一个变量:totalpoint,该变量表示480*800,即屏幕的分辨率/屏幕总的颜色点。然后我们运用for循环向每个颜色点数据写入我们指定的清屏颜色数据(以16位RGB565格式写入)。
LCD单一颜色填充函数
代码示例
//在指定区域内填充单个颜色
//(sx,sy),(ex,ey):填充矩形对角坐标,区域大小为:(ex-sx+1)*(ey-sy+1)
//color:要填充的颜色
void LCD_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u16 color)
{
u16 i,j;
u16 xlen=0;
u16 temp;
xlen=ex-sx+1;
for(i=sy; i<=ey; i++)
{
LCD_SetCursor(sx,i); //设置光标位置
LCD_WriteRAM_Prepare(); //开始写入GRAM
for(j=0; j<xlen; j++)LCD->LCD_RAM=color; //显示颜色
}
}
代码解析
其实这个函数的操作与LCD清屏函数大同小异,无非就是向指定区域的数据点填充颜色数据罢了,但是清屏函数是将(0,0)至(480-1,800-1)区域,即整个屏幕,填充我们制定的颜色color;LCD颜色填充函数则是在(sx,sy)至(ex,ey)区域内填充我们指定的颜色数据。
注意:我们这里并没有使用0X2A02~0X2A03,0X2B02~0X2B03指令来改变填充区域的X,Y轴填充的下界,而是使用了软件层面来实现(计算出我们要填充区域的长度和宽度,然后使用for循环实现)。
软件层面实现的原理:
① 设置X,Y坐标;
② 在该坐标位置填充颜色数据;
LCD颜色块填充函数
代码示例
//在指定区域内填充指定颜色块
//(sx,sy),(ex,ey):填充矩形对角坐标,区域大小为:(ex-sx+1)*(ey-sy+1)
//color:要填充的颜色
void LCD_Color_Fill(u16 sx,u16 sy,u16 ex,u16 ey,u16 *color)
{
u16 height,width;
u16 i,j;
width=ex-sx+1; //得到填充的宽度
height=ey-sy+1; //高度
for(i=0; i<height; i++)
{
LCD_SetCursor(sx,sy+i); //设置光标位置
LCD_WriteRAM_Prepare(); //开始写入GRAM
for(j=0; j<width; j++)LCD->LCD_RAM=color[i*width+j]; //写入数据
}
}
代码解析
这个函数与上个LCD单一颜色填充函数的区别就在于输入参数color,单一颜色填充数据的color参数是u16类型的,即我们在(sx,sy)至(ex,ey)这个方形区间内填充单一16位格式的RGB565颜色数据。但是这个函数中color参数是(ex-sx)*(ey-ex)维度的二维数组,每个数组元素color[i,j]代表着(X,Y)=(sx+i-1,sy+j-1)位置颜色点的颜色数据(用16位RGB565格式表示)。
画点函数
代码示例
//画点
//x,y:坐标
//POINT_COLOR:此点的颜色
void LCD_DrawPoint(u16 x,u16 y)
{
LCD_SetCursor(x,y); //设置光标位置
LCD_WriteRAM_Prepare(); //开始写入GRAM
LCD->LCD_RAM=POINT_COLOR;
}
代码解析
① 画点之前,必须得知道我们要在哪里画点,即(X,Y)坐标位置;
② 写入0X2C00指令,开始写入RGB565格式的颜色数据;
注意:POINT_COLOR为定义在lcd.c中的全局变量,表征着“写入LCD的GRAM的默认颜色数据“,即普通画点函数调用之前必须先设置好POINT_COLOR全局变量。
快速画点函数
代码示例
//快速画点
//x,y:坐标
//color:颜色
void LCD_Fast_DrawPoint(u16 x,u16 y,u16 color)
{
if(lcddev.id==0X5510)
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(x>>8);
LCD_WR_REG(lcddev.setxcmd+1);
LCD_WR_DATA(x&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(y>>8);
LCD_WR_REG(lcddev.setycmd+1);
LCD_WR_DATA(y&0XFF);
}
LCD->LCD_REG=lcddev.wramcmd;
LCD->LCD_RAM=color;
}
代码解析
“快速“画点函数究竟快在哪里呢?我们知道函数调用是需要花费时间的,因此快速画点函数就是将”设置写入点的坐标“,”写入0X2C00指令“,”将RGB565颜色数据写入GRAM中“都写入一个函数中,以空间换时间。这个函数相较于”简单画点函数“的优点在于:该函数可以自定义写入点的颜色(普通画点函数调用之前必须先设置POINT_COLOR全局变量)。
LCD字符显示函数
代码示例
//在指定位置显示一个字符
//x,y:起始坐标
//num:要显示的字符:" "--->"~"
//size:字体大小 12/16/24
//mode:叠加方式(1)还是非叠加方式(0)
void LCD_ShowChar(u16 x,u16 y,u8 num,u8 size,u8 mode)
{
u8 temp,t1,t;
u16 y0=y;
u8 csize=(size/8+((size%8)?1:0))*(size/2); //得到字体一个字符对应点阵集所占的字节数
num=num-' ';//得到偏移后的值(ASCII字库是从空格开始取模,所以-' '就是对应字符的字库)
for(t=0; t<csize; t++)
{
if(size==12)temp=asc2_1206[num][t]; //调用1206字体
else if(size==16)temp=asc2_1608[num][t]; //调用1608字体
else if(size==24)temp=asc2_2412[num][t]; //调用2412字体
else return; //没有的字库
for(t1=0; t1<8; t1++)
{
if(temp&0x80)LCD_Fast_DrawPoint(x,y,POINT_COLOR);
else if(mode==0)LCD_Fast_DrawPoint(x,y,BACK_COLOR);
temp<<=1;
y++;
if(y>=lcddev.height)return; //超区域了
if((y-y0)==size)
{
y=y0;
x++;
if(x>=lcddev.width)return; //超区域了
break;
}
}
}
}
代码解析
在该函数中,涉及到计算字符所用字节数的公式,公式推导如下:
字体大小分为1608,2412,1206三种形式,例如1608代表字符长16个位宽8个位,如下所示:
在正点原子给lcd.c中有个函数位LCD_ShowChar,这个函数是最基本的显示字符的函数,他是显示一切ASCII字符串的“鼻祖”,其中有个计算ASCII字符所占字节个数的代码如下所示:
u8 csize=(size/8+((size%8)?1:0))*(size/2); //得到字体一个字符对应点阵集所占的字节数
我们可以这样来看:
size是整形变量,表示一个ASCII字符的长度,由于整型变量相除还是整型变量,C语言默认向0取整,因此size/8+(size%8?1:0)代表了1列也就是16个位所需的字节数,然后我们知道宽=列/2,因此size/2代表了一行共有多少列,因此列数*每列所需的字节数=一个ASCII字符显示所需的字节数。
我们以1608类型的ASCII字符“1”写入方式为例进行说明:
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xCC,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00}
一共16个字节,每个字节代表着从上到下的8个像素点的状态(亮/灭):
注意这个函数的参数mode,mode:叠加方式(1)还是非叠加方式(0),这里的叠加方式/非叠加方式又是什么呢?我们以“在图片上写文字”进行举例说明:
覆盖方式就意味着我们要在16*8的区域中先填充我们的背景色,然后我们再在填充色上写字:
而非覆盖方式则更加简单,我们不用在16*8的区域上填充背景色,只需在16*8的区域上将我们的文字显示出来即可:
num=num-' ';//得到偏移后的值(ASCII字库是从空格开始取模,所以-' '就是对应字符的字库)
这句代码的含义在于确定我们想要显示的字符在font.h的二维数组中的行号,第一个ASCII字符是” “空格,我们求解字符在font.h的二维数组中的行号无非就是确定字符相对于首个ASCII字符的行偏移量。
LCD可调节亮度的背光设置函数
本人由于能力有限看不太懂NT35510数据手册中PWM部分说明,下述代码的功能为:“使用PWM控制LCD背光亮度”。PWM值为0~255,数值越大亮度越亮。
//SSD1963 背光设置
//pwm:背光等级,0~100.越大越亮.
void LCD_SSD_BackLightSet(u8 pwm)
{
LCD_WR_REG(0xBE); //配置PWM输出
LCD_WR_DATA(0x05); //1设置PWM频率
LCD_WR_DATA(pwm*2.55);//2设置PWM占空比
LCD_WR_DATA(0x01); //3设置C
LCD_WR_DATA(0xFF); //4设置D
LCD_WR_DATA(0x00); //5设置E
LCD_WR_DATA(0x00); //6设置F
}
LCD开窗函数
代码示例
//设置窗口,并自动设置画点坐标到窗口左上角(sx,sy).
//sx,sy:窗口起始坐标(左上角)
//width,height:窗口宽度和高度,必须大于0!!
//窗体大小:width*height.
void LCD_Set_Window(u16 sx,u16 sy,u16 width,u16 height)
{
u16 twidth,theight;
twidth=sx+width-1;
theight=sy+height-1;
if(lcddev.id==0X5510)
{
LCD_WR_REG(lcddev.setxcmd);
LCD_WR_DATA(sx>>8);
LCD_WR_REG(lcddev.setxcmd+1);
LCD_WR_DATA(sx&0XFF);
LCD_WR_REG(lcddev.setxcmd+2);
LCD_WR_DATA(twidth>>8);
LCD_WR_REG(lcddev.setxcmd+3);
LCD_WR_DATA(twidth&0XFF);
LCD_WR_REG(lcddev.setycmd);
LCD_WR_DATA(sy>>8);
LCD_WR_REG(lcddev.setycmd+1);
LCD_WR_DATA(sy&0XFF);
LCD_WR_REG(lcddev.setycmd+2);
LCD_WR_DATA(theight>>8);
LCD_WR_REG(lcddev.setycmd+3);
LCD_WR_DATA(theight&0XFF);
}
}
代码解析
这个函数也好理解,就是使用0X2A00~0X2A03,0X2B00~0X2B03指令设置了X,Y轴填充上下限,这个设置的是硬件层面的填充上下限,不用我们软件层面的For循环就可以实现“当我们一直不断写入颜色点时,坐标X,Y不断自增当达到X,Y下界时,再返回至X,Y上界从新开始不断自增坐标进行颜色点的填充“。
相较于软件实现(设置X,Y坐标->写入颜色数据),硬件实现(无需设置坐标,仅仅不断填入颜色数据即可)更加简单速度更快。
附录
//初始化lcd
//该初始化函数可以初始化各种ILI93XX液晶,但是其他函数是基于ILI9320的!!!
//在其他型号的驱动芯片上没有测试!
void LCD_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef readWriteTiming;
FSMC_NORSRAMTimingInitTypeDef writeTiming;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC,ENABLE); //使能FSMC时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE|RCC_APB2Periph_GPIOG,ENABLE);//使能PORTB,D,E,G以及AFIO复用功能时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; //PB0 推挽输出 背光
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
//PORTD复用推挽输出
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_14|GPIO_Pin_15; // //PORTD复用推挽输出
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
//PORTE复用推挽输出
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15; // //PORTD复用推挽输出
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOE, &GPIO_InitStructure);
// //PORTG12复用推挽输出 A0
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_12; // //PORTD复用推挽输出
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOG, &GPIO_InitStructure);
readWriteTiming.FSMC_AddressSetupTime = 0x01; //地址建立时间(ADDSET)为2个HCLK 1/36M=27ns
readWriteTiming.FSMC_AddressHoldTime = 0x00; //地址保持时间(ADDHLD)模式A未用到
readWriteTiming.FSMC_DataSetupTime = 0x0f; // 数据保存时间为16个HCLK,因为液晶驱动IC的读数据的时候,速度不能太快,尤其对1289这个IC。
readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
readWriteTiming.FSMC_CLKDivision = 0x00;
readWriteTiming.FSMC_DataLatency = 0x00;
readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A; //模式A
writeTiming.FSMC_AddressSetupTime = 0x00; //地址建立时间(ADDSET)为1个HCLK
writeTiming.FSMC_AddressHoldTime = 0x00; //地址保持时间(A
writeTiming.FSMC_DataSetupTime = 0x03; 数据保存时间为4个HCLK
writeTiming.FSMC_BusTurnAroundDuration = 0x00;
writeTiming.FSMC_CLKDivision = 0x00;
writeTiming.FSMC_DataLatency = 0x00;
writeTiming.FSMC_AccessMode = FSMC_AccessMode_A; //模式A
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;// 这里我们使用NE4 ,也就对应BTCR[6],[7]。
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; // 不复用数据地址
FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_SRAM;// FSMC_MemoryType_SRAM; //SRAM
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;//存储器数据宽度为16bit
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Disable;// FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; // 存储器写使能
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; // 读写使用不同的时序
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming; //读写时序
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &writeTiming; //写时序
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); //初始化FSMC配置
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE); // 使能BANK1
delay_ms(50); // delay 50 ms
lcddev.id=LCD_ReadReg(0x0000); //读ID(9320/9325/9328/4531/4535等IC)
if(lcddev.id<0XFF||lcddev.id==0XFFFF)
{
LCD_WR_REG(0XDA00);
lcddev.id=LCD_RD_DATA(); //读回0X00
LCD_WR_REG(0XDB00);
lcddev.id=LCD_RD_DATA(); //读回0X80
lcddev.id<<=8;
LCD_WR_REG(0XDC00);
lcddev.id|=LCD_RD_DATA(); //读回0X00
if(lcddev.id==0x8000)lcddev.id=0x5510;//NT35510读回的ID是8000H,为方便区分,我们强制设置为5510
if(lcddev.id!=0X5510) //也不是NT5510,尝试看看是不是SSD1963
{
LCD_WR_REG(0XA1);
lcddev.id=LCD_RD_DATA();
lcddev.id=LCD_RD_DATA(); //读回0X57
lcddev.id<<=8;
lcddev.id|=LCD_RD_DATA(); //读回0X61
if(lcddev.id==0X5761)lcddev.id=0X1963;//SSD1963读回的ID是5761H,为方便区分,我们强制设置为1963
}
}
printf(" LCD ID:%xrn",lcddev.id); //打印LCD ID
if(lcddev.id==0x5510)
{
LCD_WriteReg(0xF000,0x55);
LCD_WriteReg(0xF001,0xAA);
LCD_WriteReg(0xF002,0x52);
LCD_WriteReg(0xF003,0x08);
LCD_WriteReg(0xF004,0x01);
//AVDD Set AVDD 5.2V
LCD_WriteReg(0xB000,0x0D);
LCD_WriteReg(0xB001,0x0D);
LCD_WriteReg(0xB002,0x0D);
//AVDD ratio
LCD_WriteReg(0xB600,0x34);
LCD_WriteReg(0xB601,0x34);
LCD_WriteReg(0xB602,0x34);
//AVEE -5.2V
LCD_WriteReg(0xB100,0x0D);
LCD_WriteReg(0xB101,0x0D);
LCD_WriteReg(0xB102,0x0D);
//AVEE ratio
LCD_WriteReg(0xB700,0x34);
LCD_WriteReg(0xB701,0x34);
LCD_WriteReg(0xB702,0x34);
//VCL -2.5V
LCD_WriteReg(0xB200,0x00);
LCD_WriteReg(0xB201,0x00);
LCD_WriteReg(0xB202,0x00);
//VCL ratio
LCD_WriteReg(0xB800,0x24);
LCD_WriteReg(0xB801,0x24);
LCD_WriteReg(0xB802,0x24);
//VGH 15V (Free pump)
LCD_WriteReg(0xBF00,0x01);
LCD_WriteReg(0xB300,0x0F);
LCD_WriteReg(0xB301,0x0F);
LCD_WriteReg(0xB302,0x0F);
//VGH ratio
LCD_WriteReg(0xB900,0x34);
LCD_WriteReg(0xB901,0x34);
LCD_WriteReg(0xB902,0x34);
//VGL_REG -10V
LCD_WriteReg(0xB500,0x08);
LCD_WriteReg(0xB501,0x08);
LCD_WriteReg(0xB502,0x08);
LCD_WriteReg(0xC200,0x03);
//VGLX ratio
LCD_WriteReg(0xBA00,0x24);
LCD_WriteReg(0xBA01,0x24);
LCD_WriteReg(0xBA02,0x24);
//VGMP/VGSP 4.5V/0V
LCD_WriteReg(0xBC00,0x00);
LCD_WriteReg(0xBC01,0x78);
LCD_WriteReg(0xBC02,0x00);
//VGMN/VGSN -4.5V/0V
LCD_WriteReg(0xBD00,0x00);
LCD_WriteReg(0xBD01,0x78);
LCD_WriteReg(0xBD02,0x00);
//VCOM
LCD_WriteReg(0xBE00,0x00);
LCD_WriteReg(0xBE01,0x64);
//Gamma Setting
LCD_WriteReg(0xD100,0x00);
LCD_WriteReg(0xD101,0x33);
LCD_WriteReg(0xD102,0x00);
LCD_WriteReg(0xD103,0x34);
LCD_WriteReg(0xD104,0x00);
LCD_WriteReg(0xD105,0x3A);
LCD_WriteReg(0xD106,0x00);
LCD_WriteReg(0xD107,0x4A);
LCD_WriteReg(0xD108,0x00);
LCD_WriteReg(0xD109,0x5C);
LCD_WriteReg(0xD10A,0x00);
LCD_WriteReg(0xD10B,0x81);
LCD_WriteReg(0xD10C,0x00);
LCD_WriteReg(0xD10D,0xA6);
LCD_WriteReg(0xD10E,0x00);
LCD_WriteReg(0xD10F,0xE5);
LCD_WriteReg(0xD110,0x01);
LCD_WriteReg(0xD111,0x13);
LCD_WriteReg(0xD112,0x01);
LCD_WriteReg(0xD113,0x54);
LCD_WriteReg(0xD114,0x01);
LCD_WriteReg(0xD115,0x82);
LCD_WriteReg(0xD116,0x01);
LCD_WriteReg(0xD117,0xCA);
LCD_WriteReg(0xD118,0x02);
LCD_WriteReg(0xD119,0x00);
LCD_WriteReg(0xD11A,0x02);
LCD_WriteReg(0xD11B,0x01);
LCD_WriteReg(0xD11C,0x02);
LCD_WriteReg(0xD11D,0x34);
LCD_WriteReg(0xD11E,0x02);
LCD_WriteReg(0xD11F,0x67);
LCD_WriteReg(0xD120,0x02);
LCD_WriteReg(0xD121,0x84);
LCD_WriteReg(0xD122,0x02);
LCD_WriteReg(0xD123,0xA4);
LCD_WriteReg(0xD124,0x02);
LCD_WriteReg(0xD125,0xB7);
LCD_WriteReg(0xD126,0x02);
LCD_WriteReg(0xD127,0xCF);
LCD_WriteReg(0xD128,0x02);
LCD_WriteReg(0xD129,0xDE);
LCD_WriteReg(0xD12A,0x02);
LCD_WriteReg(0xD12B,0xF2);
LCD_WriteReg(0xD12C,0x02);
LCD_WriteReg(0xD12D,0xFE);
LCD_WriteReg(0xD12E,0x03);
LCD_WriteReg(0xD12F,0x10);
LCD_WriteReg(0xD130,0x03);
LCD_WriteReg(0xD131,0x33);
LCD_WriteReg(0xD132,0x03);
LCD_WriteReg(0xD133,0x6D);
LCD_WriteReg(0xD200,0x00);
LCD_WriteReg(0xD201,0x33);
LCD_WriteReg(0xD202,0x00);
LCD_WriteReg(0xD203,0x34);
LCD_WriteReg(0xD204,0x00);
LCD_WriteReg(0xD205,0x3A);
LCD_WriteReg(0xD206,0x00);
LCD_WriteReg(0xD207,0x4A);
LCD_WriteReg(0xD208,0x00);
LCD_WriteReg(0xD209,0x5C);
LCD_WriteReg(0xD20A,0x00);
LCD_WriteReg(0xD20B,0x81);
LCD_WriteReg(0xD20C,0x00);
LCD_WriteReg(0xD20D,0xA6);
LCD_WriteReg(0xD20E,0x00);
LCD_WriteReg(0xD20F,0xE5);
LCD_WriteReg(0xD210,0x01);
LCD_WriteReg(0xD211,0x13);
LCD_WriteReg(0xD212,0x01);
LCD_WriteReg(0xD213,0x54);
LCD_WriteReg(0xD214,0x01);
LCD_WriteReg(0xD215,0x82);
LCD_WriteReg(0xD216,0x01);
LCD_WriteReg(0xD217,0xCA);
LCD_WriteReg(0xD218,0x02);
LCD_WriteReg(0xD219,0x00);
LCD_WriteReg(0xD21A,0x02);
LCD_WriteReg(0xD21B,0x01);
LCD_WriteReg(0xD21C,0x02);
LCD_WriteReg(0xD21D,0x34);
LCD_WriteReg(0xD21E,0x02);
LCD_WriteReg(0xD21F,0x67);
LCD_WriteReg(0xD220,0x02);
LCD_WriteReg(0xD221,0x84);
LCD_WriteReg(0xD222,0x02);
LCD_WriteReg(0xD223,0xA4);
LCD_WriteReg(0xD224,0x02);
LCD_WriteReg(0xD225,0xB7);
LCD_WriteReg(0xD226,0x02);
LCD_WriteReg(0xD227,0xCF);
LCD_WriteReg(0xD228,0x02);
LCD_WriteReg(0xD229,0xDE);
LCD_WriteReg(0xD22A,0x02);
LCD_WriteReg(0xD22B,0xF2);
LCD_WriteReg(0xD22C,0x02);
LCD_WriteReg(0xD22D,0xFE);
LCD_WriteReg(0xD22E,0x03);
LCD_WriteReg(0xD22F,0x10);
LCD_WriteReg(0xD230,0x03);
LCD_WriteReg(0xD231,0x33);
LCD_WriteReg(0xD232,0x03);
LCD_WriteReg(0xD233,0x6D);
LCD_WriteReg(0xD300,0x00);
LCD_WriteReg(0xD301,0x33);
LCD_WriteReg(0xD302,0x00);
LCD_WriteReg(0xD303,0x34);
LCD_WriteReg(0xD304,0x00);
LCD_WriteReg(0xD305,0x3A);
LCD_WriteReg(0xD306,0x00);
LCD_WriteReg(0xD307,0x4A);
LCD_WriteReg(0xD308,0x00);
LCD_WriteReg(0xD309,0x5C);
LCD_WriteReg(0xD30A,0x00);
LCD_WriteReg(0xD30B,0x81);
LCD_WriteReg(0xD30C,0x00);
LCD_WriteReg(0xD30D,0xA6);
LCD_WriteReg(0xD30E,0x00);
LCD_WriteReg(0xD30F,0xE5);
LCD_WriteReg(0xD310,0x01);
LCD_WriteReg(0xD311,0x13);
LCD_WriteReg(0xD312,0x01);
LCD_WriteReg(0xD313,0x54);
LCD_WriteReg(0xD314,0x01);
LCD_WriteReg(0xD315,0x82);
LCD_WriteReg(0xD316,0x01);
LCD_WriteReg(0xD317,0xCA);
LCD_WriteReg(0xD318,0x02);
LCD_WriteReg(0xD319,0x00);
LCD_WriteReg(0xD31A,0x02);
LCD_WriteReg(0xD31B,0x01);
LCD_WriteReg(0xD31C,0x02);
LCD_WriteReg(0xD31D,0x34);
LCD_WriteReg(0xD31E,0x02);
LCD_WriteReg(0xD31F,0x67);
LCD_WriteReg(0xD320,0x02);
LCD_WriteReg(0xD321,0x84);
LCD_WriteReg(0xD322,0x02);
LCD_WriteReg(0xD323,0xA4);
LCD_WriteReg(0xD324,0x02);
LCD_WriteReg(0xD325,0xB7);
LCD_WriteReg(0xD326,0x02);
LCD_WriteReg(0xD327,0xCF);
LCD_WriteReg(0xD328,0x02);
LCD_WriteReg(0xD329,0xDE);
LCD_WriteReg(0xD32A,0x02);
LCD_WriteReg(0xD32B,0xF2);
LCD_WriteReg(0xD32C,0x02);
LCD_WriteReg(0xD32D,0xFE);
LCD_WriteReg(0xD32E,0x03);
LCD_WriteReg(0xD32F,0x10);
LCD_WriteReg(0xD330,0x03);
LCD_WriteReg(0xD331,0x33);
LCD_WriteReg(0xD332,0x03);
LCD_WriteReg(0xD333,0x6D);
LCD_WriteReg(0xD400,0x00);
LCD_WriteReg(0xD401,0x33);
LCD_WriteReg(0xD402,0x00);
LCD_WriteReg(0xD403,0x34);
LCD_WriteReg(0xD404,0x00);
LCD_WriteReg(0xD405,0x3A);
LCD_WriteReg(0xD406,0x00);
LCD_WriteReg(0xD407,0x4A);
LCD_WriteReg(0xD408,0x00);
LCD_WriteReg(0xD409,0x5C);
LCD_WriteReg(0xD40A,0x00);
LCD_WriteReg(0xD40B,0x81);
LCD_WriteReg(0xD40C,0x00);
LCD_WriteReg(0xD40D,0xA6);
LCD_WriteReg(0xD40E,0x00);
LCD_WriteReg(0xD40F,0xE5);
LCD_WriteReg(0xD410,0x01);
LCD_WriteReg(0xD411,0x13);
LCD_WriteReg(0xD412,0x01);
LCD_WriteReg(0xD413,0x54);
LCD_WriteReg(0xD414,0x01);
LCD_WriteReg(0xD415,0x82);
LCD_WriteReg(0xD416,0x01);
LCD_WriteReg(0xD417,0xCA);
LCD_WriteReg(0xD418,0x02);
LCD_WriteReg(0xD419,0x00);
LCD_WriteReg(0xD41A,0x02);
LCD_WriteReg(0xD41B,0x01);
LCD_WriteReg(0xD41C,0x02);
LCD_WriteReg(0xD41D,0x34);
LCD_WriteReg(0xD41E,0x02);
LCD_WriteReg(0xD41F,0x67);
LCD_WriteReg(0xD420,0x02);
LCD_WriteReg(0xD421,0x84);
LCD_WriteReg(0xD422,0x02);
LCD_WriteReg(0xD423,0xA4);
LCD_WriteReg(0xD424,0x02);
LCD_WriteReg(0xD425,0xB7);
LCD_WriteReg(0xD426,0x02);
LCD_WriteReg(0xD427,0xCF);
LCD_WriteReg(0xD428,0x02);
LCD_WriteReg(0xD429,0xDE);
LCD_WriteReg(0xD42A,0x02);
LCD_WriteReg(0xD42B,0xF2);
LCD_WriteReg(0xD42C,0x02);
LCD_WriteReg(0xD42D,0xFE);
LCD_WriteReg(0xD42E,0x03);
LCD_WriteReg(0xD42F,0x10);
LCD_WriteReg(0xD430,0x03);
LCD_WriteReg(0xD431,0x33);
LCD_WriteReg(0xD432,0x03);
LCD_WriteReg(0xD433,0x6D);
LCD_WriteReg(0xD500,0x00);
LCD_WriteReg(0xD501,0x33);
LCD_WriteReg(0xD502,0x00);
LCD_WriteReg(0xD503,0x34);
LCD_WriteReg(0xD504,0x00);
LCD_WriteReg(0xD505,0x3A);
LCD_WriteReg(0xD506,0x00);
LCD_WriteReg(0xD507,0x4A);
LCD_WriteReg(0xD508,0x00);
LCD_WriteReg(0xD509,0x5C);
LCD_WriteReg(0xD50A,0x00);
LCD_WriteReg(0xD50B,0x81);
LCD_WriteReg(0xD50C,0x00);
LCD_WriteReg(0xD50D,0xA6);
LCD_WriteReg(0xD50E,0x00);
LCD_WriteReg(0xD50F,0xE5);
LCD_WriteReg(0xD510,0x01);
LCD_WriteReg(0xD511,0x13);
LCD_WriteReg(0xD512,0x01);
LCD_WriteReg(0xD513,0x54);
LCD_WriteReg(0xD514,0x01);
LCD_WriteReg(0xD515,0x82);
LCD_WriteReg(0xD516,0x01);
LCD_WriteReg(0xD517,0xCA);
LCD_WriteReg(0xD518,0x02);
LCD_WriteReg(0xD519,0x00);
LCD_WriteReg(0xD51A,0x02);
LCD_WriteReg(0xD51B,0x01);
LCD_WriteReg(0xD51C,0x02);
LCD_WriteReg(0xD51D,0x34);
LCD_WriteReg(0xD51E,0x02);
LCD_WriteReg(0xD51F,0x67);
LCD_WriteReg(0xD520,0x02);
LCD_WriteReg(0xD521,0x84);
LCD_WriteReg(0xD522,0x02);
LCD_WriteReg(0xD523,0xA4);
LCD_WriteReg(0xD524,0x02);
LCD_WriteReg(0xD525,0xB7);
LCD_WriteReg(0xD526,0x02);
LCD_WriteReg(0xD527,0xCF);
LCD_WriteReg(0xD528,0x02);
LCD_WriteReg(0xD529,0xDE);
LCD_WriteReg(0xD52A,0x02);
LCD_WriteReg(0xD52B,0xF2);
LCD_WriteReg(0xD52C,0x02);
LCD_WriteReg(0xD52D,0xFE);
LCD_WriteReg(0xD52E,0x03);
LCD_WriteReg(0xD52F,0x10);
LCD_WriteReg(0xD530,0x03);
LCD_WriteReg(0xD531,0x33);
LCD_WriteReg(0xD532,0x03);
LCD_WriteReg(0xD533,0x6D);
LCD_WriteReg(0xD600,0x00);
LCD_WriteReg(0xD601,0x33);
LCD_WriteReg(0xD602,0x00);
LCD_WriteReg(0xD603,0x34);
LCD_WriteReg(0xD604,0x00);
LCD_WriteReg(0xD605,0x3A);
LCD_WriteReg(0xD606,0x00);
LCD_WriteReg(0xD607,0x4A);
LCD_WriteReg(0xD608,0x00);
LCD_WriteReg(0xD609,0x5C);
LCD_WriteReg(0xD60A,0x00);
LCD_WriteReg(0xD60B,0x81);
LCD_WriteReg(0xD60C,0x00);
LCD_WriteReg(0xD60D,0xA6);
LCD_WriteReg(0xD60E,0x00);
LCD_WriteReg(0xD60F,0xE5);
LCD_WriteReg(0xD610,0x01);
LCD_WriteReg(0xD611,0x13);
LCD_WriteReg(0xD612,0x01);
LCD_WriteReg(0xD613,0x54);
LCD_WriteReg(0xD614,0x01);
LCD_WriteReg(0xD615,0x82);
LCD_WriteReg(0xD616,0x01);
LCD_WriteReg(0xD617,0xCA);
LCD_WriteReg(0xD618,0x02);
LCD_WriteReg(0xD619,0x00);
LCD_WriteReg(0xD61A,0x02);
LCD_WriteReg(0xD61B,0x01);
LCD_WriteReg(0xD61C,0x02);
LCD_WriteReg(0xD61D,0x34);
LCD_WriteReg(0xD61E,0x02);
LCD_WriteReg(0xD61F,0x67);
LCD_WriteReg(0xD620,0x02);
LCD_WriteReg(0xD621,0x84);
LCD_WriteReg(0xD622,0x02);
LCD_WriteReg(0xD623,0xA4);
LCD_WriteReg(0xD624,0x02);
LCD_WriteReg(0xD625,0xB7);
LCD_WriteReg(0xD626,0x02);
LCD_WriteReg(0xD627,0xCF);
LCD_WriteReg(0xD628,0x02);
LCD_WriteReg(0xD629,0xDE);
LCD_WriteReg(0xD62A,0x02);
LCD_WriteReg(0xD62B,0xF2);
LCD_WriteReg(0xD62C,0x02);
LCD_WriteReg(0xD62D,0xFE);
LCD_WriteReg(0xD62E,0x03);
LCD_WriteReg(0xD62F,0x10);
LCD_WriteReg(0xD630,0x03);
LCD_WriteReg(0xD631,0x33);
LCD_WriteReg(0xD632,0x03);
LCD_WriteReg(0xD633,0x6D);
//LV2 Page 0 enable
LCD_WriteReg(0xF000,0x55);
LCD_WriteReg(0xF001,0xAA);
LCD_WriteReg(0xF002,0x52);
LCD_WriteReg(0xF003,0x08);
LCD_WriteReg(0xF004,0x00);
//Display control
LCD_WriteReg(0xB100, 0xCC);
LCD_WriteReg(0xB101, 0x00);
//Source hold time
LCD_WriteReg(0xB600,0x05);
//Gate EQ control
LCD_WriteReg(0xB700,0x70);
LCD_WriteReg(0xB701,0x70);
//Source EQ control (Mode 2)
LCD_WriteReg(0xB800,0x01);
LCD_WriteReg(0xB801,0x03);
LCD_WriteReg(0xB802,0x03);
LCD_WriteReg(0xB803,0x03);
//Inversion mode (2-dot)
LCD_WriteReg(0xBC00,0x02);
LCD_WriteReg(0xBC01,0x00);
LCD_WriteReg(0xBC02,0x00);
//Timing control 4H w/ 4-delay
LCD_WriteReg(0xC900,0xD0);
LCD_WriteReg(0xC901,0x02);
LCD_WriteReg(0xC902,0x50);
LCD_WriteReg(0xC903,0x50);
LCD_WriteReg(0xC904,0x50);
LCD_WriteReg(0x3500,0x00);
LCD_WriteReg(0x3A00,0x55); //16-bit/pixel
LCD_WR_REG(0x1100);
delay_us(120);
LCD_WR_REG(0x2900);
}
LCD_Display_Dir(0); //默认为竖屏
LCD_LED=1; //点亮背光
LCD_Clear(WHITE);
}
最后
以上就是迷路学姐为你收集整理的基于战舰V3的LCD显示实验详解和剖析基于STM32的4.3寸TFTLCD的使用的全部内容,希望文章能够帮你解决基于战舰V3的LCD显示实验详解和剖析基于STM32的4.3寸TFTLCD的使用所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复