群创AT070TN92,SSD1963-7寸屏,800X480.
存在问题,初始化后闪屏,显示取模图片的颜 {MOD}不自然,就像油画一样,好难看,大家板我分析一下是啥原因。
unsigned int HDP=799; //HS_Display_Area
unsigned int HT =1200; //(HS_Display_Area + HS_pulse_width + HS_Blanking + HS_Front_Porch)
unsigned int HPS=93; //(HS_pulse_width + HS_Blanking)
unsigned char HPW=40; //HS_pulse_width
unsigned int LPS=46;
unsigned int VDP=479; //VS_Display_Area
unsigned int VT =670; //(VS_Display_Area + VS_pulse_width + VS_Blanking + VS_Front_Porch)
unsigned int VPS=43; //(VS_pulse_width + VS_Blanking)
unsigned char VPW=20; //VS_pulse_width
unsigned int FPS=23;
#define LCD_RAM *(__IO uint16_t *) ((uint32_t)0x60020000) //disp Data ADDR
#define LCD_REG *(__IO uint16_t *) ((uint32_t)0x60000000) //disp Reg ADDR
//写寄存器
void LCD_WR_COM(u8 data)
{
LCD_REG = data; //数据输出
}
//写16位数据 如果是8位,彩 {MOD}图片会缺 {MOD}
void LCD_WR_DATA(u16 data)
{
LCD_RAM = data; /* GPIO_Write(GPIOE,data); */
}
uint16_t LCD_BGR2RGB(u16 Color)
{
u16 r, g, b, rgb;
b = (Color>>0) & 0x1f;
g = (Color>>5) & 0x3f;
r = (Color>>11) & 0x1f;
rgb = (b<<11) + (g<<5) + (r<<0);
return( rgb );
}
//LCD延时
void delay_time(unsigned int i)
{
unsigned int a;
unsigned int b;
for(b=0;b<i;b++)
for(a=0;a<1000;a++);
}
//LCD初始化
//初始化后存在闪屏问题。
void LCD_Init(void)
{
u8 brightness = 0x80;//0x80;//0x40;//亮度
u8 contrast = 0x80;//0x80;//0x70;//对比度
u8 saturation = 0x80;//0x80;//0x40;//饱和度
FSMC_GPIO_Configuration(); //FSMC引脚配置
FSMC_LCD_Init(); //FSMC配置使用FSMC的Bank1 NOR/PSRAM
LCD_WR_COM (0x00E2); //设置锁相环(PLL) 振荡器(OSC) = 10MHz (hardware), Multiplier N = 35, 250MHz < VCO < 800MHz = OSC*(N+1), VCO = 360MHz
LCD_WR_DATA(0x0010);
// LCD_WR_DATA(0x0023); //OSC = 10MHz (hardware), //参数1
// LCD_WR_DATA(0x002C); //OSC = 8MHz (hardware), //参数2
// LCD_WR_DATA(0x0036); //OSC = 6.5MHz (hardware),//参数3
LCD_WR_DATA(0x0001); //参数2 分配器 M = 2, PLL = 360/(M+1) = 120MHz
// LCD_WR_DATA(0x0054); //参数3 验证M和N值
LCD_WR_DATA(0x0004);
// LCD_WR_COM (0x00E3);
LCD_WR_COM (0x00E0); //启动锁相环(PLL)
LCD_WR_DATA(0x0001); //使能锁相环(PLL)
delay_time(1);
LCD_WR_COM (0x00E0); //再次启动锁相环(PLL)
LCD_WR_DATA(0x0003); //用锁相环输出系统时钟
delay_time(5);
// LCD_WR_COM (0x00E4); //再次启动锁相环(PLL)
LCD_WR_COM (0x0001); //软复位
delay_time(10);
/*****************************************************************
* 7" TFT model # TY700TFT800480
*****************************************************************/
//设置LSHIFT频率,如下, i.e. the DCLK 与 PLL 频率 120MHz 以前规定
//标准 DCLK 为 TY700TFT800480 是 33.3MHz(数据), 实验结果表明 30MHz 给一个稳定的结果
//30MHz = 120MHz*(LCDC_FPR+1)/2^20
//LCDC_FPR = 262143 (0x3FFFF)
//每行/ /时间 = (DISP_HOR_RESOLUTION+DISP_HOR_PULSE_WIDTH+DISP_HOR_BACK_PORCH+DISP_HOR_FRONT_PORCH)/30 us = 1056/30 = 35.2us
//9MHz = 120MHz*(LCDC_FPR+1)/2^20
//LCDC_FPR = 78642 (0x13332)
LCD_WR_COM (0x00E6); //根据分辨率设置PLCK(PLL)
// LCD_WR_DATA(0x000f); //0x0003
// LCD_WR_DATA(0x0033); //0x0033
// LCD_WR_DATA(0x0032); //0x0032
LCD_WR_DATA(0x000f);
LCD_WR_DATA(0x0093); //0x0033
LCD_WR_DATA(0x00e0); //0x0032
//设置液晶模式,不同于个别厂商
LCD_WR_COM (0x00B0); //LCD 规格
LCD_WR_DATA(0x0010); //0x10 // 设置 18-bit 为 7" 面板设置 TY700TFT800480
LCD_WR_DATA(0x0080); //TTL模式设置
// LCD_WR_DATA(0x0020); //0x10 // 设置 18-bit 为 7" 面板设置 TY700TFT800480
// LCD_WR_DATA(0x0000); //TTL模式设置
LCD_WR_DATA((HDP>>8)&0X00FF); // 设置液晶面板的大小(DISP_HOR_RESOLUTION = 800) H
LCD_WR_DATA(HDP&0X00FF); // 设置液晶面板的大小(DISP_HOR_RESOLUTION = 800) L
LCD_WR_DATA((VDP>>8)&0X00FF); // 设置液晶面板的大小(DISP_VER_RESOLUTION = 480) H
LCD_WR_DATA(VDP&0X00FF); // 设置液晶面板的大小(DISP_VER_RESOLUTION = 480) L
LCD_WR_DATA(0x0000); //0x00 // RGB序列
// LCD_WR_COM (0x00B1);
//设置水平段
LCD_WR_COM (0x00B4);
LCD_WR_DATA((HT>>8)&0X00FF); //Set HT
LCD_WR_DATA(HT&0X00FF);
LCD_WR_DATA((HPS>>8)&0X00FF); //Set HPS
LCD_WR_DATA(HPS&0X00FF);
LCD_WR_DATA(HPW); //Set HPW
LCD_WR_DATA((LPS>>8)&0X00FF); //Set HPS
LCD_WR_DATA(LPS&0X00FF);
LCD_WR_DATA(0x0000);
// LCD_WR_COM (0x00B5);
//设置垂直时期
LCD_WR_COM (0x00B6);
LCD_WR_DATA((VT>>8)&0X00FF); //Set VT
LCD_WR_DATA(VT&0X00FF);
LCD_WR_DATA((VPS>>8)&0X00FF); //Set VPS
LCD_WR_DATA(VPS&0X00FF);
LCD_WR_DATA(VPW); //Set VPW
LCD_WR_DATA(0x0000);
LCD_WR_DATA((FPS>>8)&0X00FF); //Set FPS
LCD_WR_DATA(FPS&0X00FF);
LCD_WR_COM (0x00B8); //设置GPIO配置
LCD_WR_DATA(0x000F); //GPIO3=output, GPIO[2:0]=output//GPIO is controlled by host; 4个IO设置成输出
LCD_WR_DATA(0x0001); //GPIO0 使用正常的IO功能
// LCD_WR_COM (0x00B7);
LCD_WR_COM (0x00BA); //设置GPIO配置
LCD_WR_DATA(0x0005); //图像颠倒显示 GPIO[3:0] out 1
LCD_WR_COM (0x0036); //旋转
LCD_WR_DATA(0x0000);
// LCD_WR_COM (0x003A); //设定像素格式, i.e. the bpp
// LCD_WR_DATA(0x0055); //设定 16bpp
LCD_WR_COM (0x00F0); //设置SSD1963同CPU接口为16bit 像素数据接口设置
LCD_WR_DATA(0x0003); //16-bit(565 format) data for 16bpp PIC32MX only
// LCD_WR_COM (0x00F1);
LCD_WR_COM (0x0021); //进入图形颜 {MOD}翻转模式
LCD_WR_COM (0x00BC); //重要
LCD_WR_DATA(brightness); //亮度值
LCD_WR_DATA(contrast); //对比度值
LCD_WR_DATA(saturation); //饱和度值
LCD_WR_DATA(0x0001); //处理机允许
delay_time(10);
LCD_Clear(WHITE); //显示器 清屏
LCD_WR_COM (0x0029); // 打开显示屏显示图像显示
//设置 PWM
LCD_WR_COM (0x00BE);
LCD_WR_DATA(0x000E); //PLL(120M)/(256*Value)/256=120Hz
LCD_WR_DATA(0x00FF); //duty=X/256
LCD_WR_DATA(0x0009); //DBC使能PWM使能
LCD_WR_DATA(0x00FF); //DBC手动亮度
LCD_WR_DATA(0x0000); //DBC最小亮度
LCD_WR_DATA(0x0000); //亮度前置分频器:关(系统频率/ Divcode / 32768)
LCD_WR_COM (0x00D4);
//TH1 = display width * display height * 3 * 0.1 /16
//480*272 * 3 * 0.1 /16 =990H
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x0009);
LCD_WR_DATA(0x0090);
//TH2 = display width * display height * 3 * 0.25 /16
//480*272 * 3 * 0.25 /16 =17E8H
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x0017);
LCD_WR_DATA(0x00E8);
//TH3 = display width * display height * 3 * 0.6 /16
//480*272 * 3 * 0.6 /16 =3960H
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x0039);
LCD_WR_DATA(0x0060);
//end of PWM
LCD_WR_COM (0x00D0); //
LCD_WR_DATA(0x000D); //PLL(120M)/(256*Value)/256=120Hz
}
//显示取模图片
void Disp_LCDBmp(uint16_t Xstar,uint16_t Ystar,uint16_t Xend,uint16_t Yend,const unsigned char* bmp)
{
u16 i=0,j=0;
u16 *bitbmp = (u16 *)bmp;
LCD_WR_COM(0x002A);
LCD_WR_DATA(Xstar>>8);
LCD_WR_DATA(Xstar&0x00ff);
LCD_WR_DATA(Xend-1>>8);
LCD_WR_DATA(Xend-1&0x00ff);
LCD_WR_COM(0x002b);
LCD_WR_DATA(Ystar>>8);
LCD_WR_DATA(Ystar&0x00ff);
LCD_WR_DATA(Yend-1>>8);
LCD_WR_DATA(Yend-1&0x00ff);
LCD_WR_COM(0x002c);
for(i=0;i<Yend;i++)
{
for(j=0;j<Xend;j++)
LCD_RAM = (LCD_BGR2RGB(*bitbmp++));
}
}
此帖出自
小平头技术问答
一周热门 更多>