6572点RGB屏幕闪烁
时间:10-02
整理:3721RD
点击:
最近在调试ili9841的rgb屏幕,显示都是OK的,只有在短信或者拨号等白色界面的时候从侧面看屏幕底部会有水波纹闪动。之前调试过别的一款MCU的屏幕也会有这个问题,当时修改了一些背景色跳过了,FAE过来搞了搞也没给出什么好的办法,是不是平台这端有些要设置的?还是因为需要调硬件,大家有遇到过么,给点意见吧,谢谢。驱动代码如下:#ifndef BUILD_LK
#include <linux/string.h>
#endif
#ifdef BUILD_LK
#include <platform/mt_GPIO.h>
#include <platform/mt_pMIC.h>
#elif (defined BUILD_UBOOT)
#include <asm/arch/MT6577_gpio.h>
#else
#include <mach/mt_gpio.h>
#include <mach/mt_pm_ldo.h>
#endif
#include "LCM_drv.h"
#define FRAME_WIDTH (320)
#define FRAME_HEIGHT (480)
static LCM_UTIL_FUNCS lcm_util = {0};
#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
#define UDELAY(n) (lcm_util.udelay(n))
#define MDELAY(n) (lcm_util.mdelay(n))
#define SPI_CS(flag) (lcm_util.set_gpio_out(GPIO60,flag))
#define SPI_SDA(flag) (lcm_util.set_gpio_out(GPIO129,flag))
#define SPI_SCL(flag) (lcm_util.set_gpio_out(GPIO128,flag))
#define DPI_EN(flag) (lcm_util.set_gpio_out(GPIO56,flag))
#define SPI_CS_H SPI_CS(1)
#define SPI_CS_L SPI_CS(0)
#define SPI_SCLK_H SPI_SCL(1)
#define SPI_SCLK_L SPI_SCL(0)
#define SPI_DATA_H SPI_SDA(1)
#define SPI_DATA_L SPI_SDA(0)
static __inline void send_ctrl_cmd(unsigned int cmd)
{
}
static __inline void send_data_cmd(unsigned int data)
{
}
static __inline void set_lcm_register(unsigned int regIndex,
unsigned int regData)
{
send_ctrl_cmd(regIndex);
send_data_cmd(regData);
}
static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
{
meMCPy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
}
static int SPI_Gpio_init(void)
{
lcm_util.set_gpio_mode(GPIO60, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO60, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO60, GPIO_OUT_ONE);
lcm_util.set_gpio_mode(GPIO128, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO128, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO128, GPIO_OUT_ONE);
lcm_util.set_gpio_mode(GPIO129, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO129, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO129, GPIO_OUT_ONE);
return 0;
}
void SPI_Write_Cmd(unsigned long cmd)
{
unsigned long i,j;
SPI_CS_H;
SPI_CS_L;
j=0x7000+cmd;
for(i=0;i<16;i++)
{
SPI_SCLK_L;
if((j&0x8000)!=0)
{
SPI_DATA_H;
}
else
{
SPI_DATA_L;
}
SPI_SCLK_H;
j=j<<1;
}
SPI_CS_H;
}
void SPI_Write_Data(unsigned long data)
{
unsigned long i,j;
SPI_CS_H;
SPI_CS_L;
j=0x7200+data;
for(i=0;i<16;i++)
{
SPI_SCLK_L;
if((j&0x8000)!=0)
{
SPI_DATA_H;
}
else
{
SPI_DATA_L;
}
SPI_SCLK_H;
j=j<<1;
}
SPI_CS_H;
}
void LCD_ILI9488_CMD(unsigned char cmd)
{
unsigned long i,j;
SPI_CS_H;
SPI_CS_L;
SPI_DATA_L;
SPI_SCLK_H;
j=cmd;
for(i=0;i<8;i++)
{
SPI_SCLK_L;
if((j&0x80)!=0)
{
SPI_DATA_H;
}
else
{
SPI_DATA_L;
}
SPI_SCLK_H;
j=j<<1;
}
SPI_CS_H;
}
void LCD_ILI9488_INDEX(unsigned char data_h )
{
unsigned long i,j;
SPI_CS_H;
SPI_CS_L;
SPI_DATA_H;
SPI_SCLK_H;
j=data_h;
for(i=0;i<8;i++)
{
SPI_SCLK_L;
if((j&0x80)!=0)
{
SPI_DATA_H;
}
else
{
SPI_DATA_L;
}
SPI_SCLK_H;
j=j<<1;
}
SPI_CS_H;
}
static __inline void Set_LCD_8B_REG(unsigned long regIndex,
unsigned long regData)
{
SPI_Write_Cmd(regIndex);
SPI_Write_Data(regData);
}
void init_lcm_registersCTP(void)
{
if(SPI_Gpio_init()<0)return;
MDELAY(10);
LCD_ILI9488_CMD(0XF7);
LCD_ILI9488_INDEX(0xA9);
LCD_ILI9488_INDEX(0x51);
LCD_ILI9488_INDEX(0x2C);
LCD_ILI9488_INDEX(0x82);
//power Control 1
LCD_ILI9488_CMD(0xC0);
LCD_ILI9488_INDEX(0x11); //Verg1out =4.52
LCD_ILI9488_INDEX(0x11); //Vreg2out = -4.12
//Power Control 2
LCD_ILI9488_CMD(0xC1); //VGH=14.17,VGL =-9.42
LCD_ILI9488_INDEX(0x41);
LCD_ILI9488_CMD(0XC5);
LCD_ILI9488_INDEX(0x00);
LCD_ILI9488_INDEX(0x10);
LCD_ILI9488_INDEX(0x80);
LCD_ILI9488_CMD(0xB1); //Frame rate
LCD_ILI9488_INDEX(0xB0); //70Hz
LCD_ILI9488_INDEX(0x11);
LCD_ILI9488_CMD(0xB4); //Display Inversion Control
LCD_ILI9488_INDEX(0x02); //2-dot
LCD_ILI9488_CMD(0xB6); // Interface Mode Control
LCD_ILI9488_INDEX(0x02); //RGB/MCU Interface Control //RGB
LCD_ILI9488_INDEX(0x02);
LCD_ILI9488_CMD(0x55);
LCD_ILI9488_INDEX(0x00);
LCD_ILI9488_CMD(0xE9);
LCD_ILI9488_INDEX(0x01); //00=18BIT,01=24BIT
LCD_ILI9488_CMD(0x36);
LCD_ILI9488_INDEX(0x48);
LCD_ILI9488_CMD(0x3A); //Interface Pixel Format
LCD_ILI9488_INDEX(0x55);
LCD_ILI9488_CMD(0xE0);
LCD_ILI9488_INDEX(0x00);
LCD_ILI9488_INDEX(0x06);
LCD_ILI9488_INDEX(0x06);
LCD_ILI9488_INDEX(0x08);
LCD_ILI9488_INDEX(0x18);
LCD_ILI9488_INDEX(0x0c);
LCD_ILI9488_INDEX(0x41);
LCD_ILI9488_INDEX(0x9b);
LCD_ILI9488_INDEX(0x4f);
LCD_ILI9488_INDEX(0x07);
LCD_ILI9488_INDEX(0x0e);
LCD_ILI9488_INDEX(0x0c);
LCD_ILI9488_INDEX(0x1c);
LCD_ILI9488_INDEX(0x1c);
LCD_ILI9488_INDEX(0x0F);
LCD_ILI9488_CMD(0XE1);
LCD_ILI9488_INDEX(0x00);
LCD_ILI9488_INDEX(0x1b);
LCD_ILI9488_INDEX(0x1e);
LCD_ILI9488_INDEX(0x03);
LCD_ILI9488_INDEX(0x0e);
LCD_ILI9488_INDEX(0x04);
LCD_ILI9488_INDEX(0x35);
LCD_ILI9488_INDEX(0x24);
LCD_ILI9488_INDEX(0x49);
LCD_ILI9488_INDEX(0x04);
LCD_ILI9488_INDEX(0x0f);
LCD_ILI9488_INDEX(0x0e);
LCD_ILI9488_INDEX(0x37);
LCD_ILI9488_INDEX(0x3a);
LCD_ILI9488_INDEX(0x0F);
LCD_ILI9488_CMD(0x11);
MDELAY(120);
LCD_ILI9488_CMD(0x29);
}
void ILI9488_EnterSleep_Code(void)
{
LCD_ILI9488_CMD(0x28); //Display off
MDELAY(40);
LCD_ILI9488_CMD(0x10); //Sleep In
MDELAY(140);
}
static void init_lcm_registers(void)
{
if(SPI_Gpio_init()<0)return;
MDELAY(10);
Set_LCD_8B_REG(0x2E,0x89); //GDOFF
Set_LCD_8B_REG(0x29,0x8F); //RTN
Set_LCD_8B_REG(0x2B,0x02); //DUM
Set_LCD_8B_REG(0xE2,0x00); //VREF
Set_LCD_8B_REG(0xE4,0x01); //EQ
Set_LCD_8B_REG(0xE5,0x10); //EQ
Set_LCD_8B_REG(0xE6,0x01); //EQ
Set_LCD_8B_REG(0xE7,0x10); //EQ
Set_LCD_8B_REG(0xE8,0x70); //OPON
Set_LCD_8B_REG(0xF2,0x00); //GEN
Set_LCD_8B_REG(0xEA,0x00); //PTBA
Set_LCD_8B_REG(0xEB,0X20); //PTBA
Set_LCD_8B_REG(0xEC,0x3C); //STBA
Set_LCD_8B_REG(0xED,0xC8); //STBA
Set_LCD_8B_REG(0xE9,0x38); //OPON1
Set_LCD_8B_REG(0xF1,0x01); //OTPS1B
//Gamma 2.2 Setting
Set_LCD_8B_REG(0x40,0x00); //
Set_LCD_8B_REG(0x41,0x00); //
Set_LCD_8B_REG(0x42,0x00); //
Set_LCD_8B_REG(0x43,0x14); //
Set_LCD_8B_REG(0x44,0x12); //
Set_LCD_8B_REG(0x45,0x38); //
Set_LCD_8B_REG(0x46,0x01); //
Set_LCD_8B_REG(0x47,0x56); //
Set_LCD_8B_REG(0x48,0x00); //
Set_LCD_8B_REG(0x49,0x13); //13
Set_LCD_8B_REG(0x4A,0x18); //18
Set_LCD_8B_REG(0x4B,0x18); //18
Set_LCD_8B_REG(0x4C,0x16); //
Set_LCD_8B_REG(0x50,0x07); //
Set_LCD_8B_REG(0x51,0x2d); //
Set_LCD_8B_REG(0x52,0x2b); //
Set_LCD_8B_REG(0x53,0x3F); //
Set_LCD_8B_REG(0x54,0x3F); //
Set_LCD_8B_REG(0x55,0x3F); //
Set_LCD_8B_REG(0x56,0x29); //
Set_LCD_8B_REG(0x57,0x7e); //
Set_LCD_8B_REG(0x58,0x09); //
Set_LCD_8B_REG(0x59,0x07); //07
Set_LCD_8B_REG(0x5A,0x07); //07
Set_LCD_8B_REG(0x5B,0x0c); //0c
Set_LCD_8B_REG(0x5C,0x1F); //
Set_LCD_8B_REG(0x5D,0xFF); //
//Power Voltage Setting
Set_LCD_8B_REG(0x1B,0x1B);
Set_LCD_8B_REG(0x1A,0x02);
Set_LCD_8B_REG(0x24,0x61);
Set_LCD_8B_REG(0x25,0x5C);
//VCOM offset///
Set_LCD_8B_REG(0x23,0x6B);//7B
//Power on Setting
Set_LCD_8B_REG(0x18,0x37); //RADJ 70Hz
Set_LCD_8B_REG(0x19,0x01); //OSC_EN=1
Set_LCD_8B_REG(0x1F,0x88); // GAS=1, VOMG=00, PON=0, DK=1, XDK=0, DVDH_TRI=0, STB=0
MDELAY(5);
Set_LCD_8B_REG(0x1F,0x80); // GAS=1, VOMG=00, PON=0, DK=0, XDK=0, DVDH_TRI=0, STB=0
MDELAY(5);
Set_LCD_8B_REG(0x1F,0x90); // GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0
MDELAY(5);
Set_LCD_8B_REG(0x1F,0xD4); // GAS=1, VOMG=10, PON=1, DK=0, XDK=1, DDVDH_TRI=0, STB=0
MDELAY(5);
//262k/65k color selection
Set_LCD_8B_REG(0x17,0x06); //default 0x06 262k color // 0x05 65k color
//SET PANEL
Set_LCD_8B_REG(0x36,0x09); //SS_P, GS_P,REV_P,BGR_P
//Display ON Setting
Set_LCD_8B_REG(0x28,0x38); //GON=1, DTE=1, D=1000
MDELAY(40);
Set_LCD_8B_REG(0x28,0x3C); //GON=1, DTE=1, D=1100
Set_LCD_8B_REG(0X31,0X02); //RCM[1:0]='10' RGB .00 SYSTEM CPU
//Set GRAM Area
Set_LCD_8B_REG(0x02,0x00);
Set_LCD_8B_REG(0x03,0x00); //Column Start
Set_LCD_8B_REG(0x04,0x00);
Set_LCD_8B_REG(0x05,0xEF); //Column End
Set_LCD_8B_REG(0x06,0x00);
Set_LCD_8B_REG(0x07,0x00); //Row Start
Set_LCD_8B_REG(0x08,0x01);
Set_LCD_8B_REG(0x09,0x3F); //Row End
}
static void lcm_get_params(LCM_PARAMS *params)
{
mEMSet(params, 0, sizeof(LCM_PARAMS));
params->type = LCM_TYPE_DPI;
params->ctrl = LCM_CTRL_NONE;
params->width = FRAME_WIDTH;
params->height = FRAME_HEIGHT;
params->io_select_mode = 0;
/* RGB interface configurations
Pixel Clock Frequency = 26MHz * mipi_pll_clk_div1
/ (mipi_pll_clk_ref + 1)
/ (2 * mipi_pll_clk_div2)
/ dpi_clk_div
*/
params->dpi.mipi_pll_clk_ref = 0; //the most important parameters: set pll clk to 66Mhz and dpi clk to 33Mhz
params->dpi.mipi_pll_clk_div1 = 42;//25 yqf modify 2013-6-22(14:21:15) 31 24 27/31(25M) 28(100M)43
params->dpi.mipi_pll_clk_div2 = 10; //yqf 4 4
params->dpi.dpi_clk_div = 2; //yqf 2 2
params->dpi.dpi_clk_duty = 1; //yqf 1 1
#if 0
params->dpi.clk_pol = LCM_POLARITY_RISING;
params->dpi.de_pol = LCM_POLARITY_RISING;
params->dpi.vsync_pol = LCM_POLARITY_FALLING;
params->dpi.hsync_pol = LCM_POLARITY_FALLING;
#else
params->dpi.clk_pol = LCM_POLARITY_RISING;
params->dpi.de_pol = LCM_POLARITY_RISING;
params->dpi.vsync_pol = LCM_POLARITY_FALLING;
params->dpi.hsync_pol = LCM_POLARITY_RISING;
#endif
params->dpi.hsync_pulse_width = 5;
params->dpi.hsync_back_porch = 8;
params->dpi.hsync_front_porch = 8;
params->dpi.vsync_pulse_width = 2;
params->dpi.vsync_back_porch = 6;
params->dpi.vsync_front_porch = 6;
params->dpi.format = LCM_DPI_FORMAT_RGB666;
params->dpi.rgb_order = LCM_COLOR_ORDER_RGB;
params->dpi.is_serial_output = 0;
params->dpi.intermediat_buffer_num = 2;
params->dpi.io_driving_current = LCM_DRIVING_CURRENT_4MA;
}
void spi_8bit_command(unsigned int tx)
{
unsigned int i;
SPI_CS_H;
SPI_CS_L;
UDELAY(3);
SPI_SCLK_L;
UDELAY(3);
SPI_DATA_L;
UDELAY(3);
SPI_SCLK_H;
UDELAY(3);
for(i=0;i<8;i++)
{
SPI_SCLK_L;
UDELAY(3);
if(tx & 0x80)
SPI_DATA_H;
else
SPI_DATA_L;
UDELAY(3);
SPI_SCLK_H;
UDELAY(3);
tx <<= 1;
}
UDELAY(3);
SPI_CS_H;
}
void spi_8bit_data(unsigned int tx)
{
unsigned int i;
SPI_CS_L;
UDELAY(3);
SPI_SCLK_L;
UDELAY(3);
SPI_DATA_H;
UDELAY(3);
SPI_SCLK_H;
UDELAY(3);
for(i=0;i<8;i++)
{
SPI_SCLK_L;
UDELAY(3);
if(tx & 0x80)
SPI_DATA_H;
else
SPI_DATA_L;
UDELAY(3);
SPI_SCLK_H;
UDELAY(3);
tx <<= 1;
}
UDELAY(3);
SPI_CS_H;
}
void LCD_KD035C_init()
{
if(SPI_Gpio_init()<0)return;
MDELAY(10);
spi_8bit_command(0xE0);
spi_8bit_data(0x00);
spi_8bit_data(0x04);
spi_8bit_data(0x0E);
spi_8bit_data(0x08);
spi_8bit_data(0x17);
spi_8bit_data(0x0A);
spi_8bit_data(0x40);
spi_8bit_data(0x79);
spi_8bit_data(0x4D);
spi_8bit_data(0x07);
spi_8bit_data(0x0E);
spi_8bit_data(0x0A);
spi_8bit_data(0x1A);
spi_8bit_data(0x1D);
spi_8bit_data(0x0F);
spi_8bit_command(0xE1);
spi_8bit_data(0x00);
spi_8bit_data(0x1B);
spi_8bit_data(0x1F);
spi_8bit_data(0x02);
spi_8bit_data(0x10);
spi_8bit_data(0x05);
spi_8bit_data(0x32);
spi_8bit_data(0x34);
spi_8bit_data(0x43);
spi_8bit_data(0x02);
spi_8bit_data(0x0A);
spi_8bit_data(0x09);
spi_8bit_data(0x33);
spi_8bit_data(0x37);
spi_8bit_data(0x0F);
spi_8bit_command(0xC0);
spi_8bit_data(0x18);
spi_8bit_data(0x16);
spi_8bit_command(0xC1);
spi_8bit_data(0x41);
spi_8bit_command(0xC5);
spi_8bit_data(0x00);
spi_8bit_data(0x1E); //VCOM
spi_8bit_data(0x80);
spi_8bit_command(0x36);
spi_8bit_data(0x48);
spi_8bit_command(0x3A); //Interface Mode Control
spi_8bit_data(0x66); //18BIT
spi_8bit_command(0xB1); //Frame rate 70HZ
spi_8bit_data(0xB0);
spi_8bit_command(0xB4);
spi_8bit_data(0x02);
spi_8bit_command(0xE9);
spi_8bit_data(0x00);
spi_8bit_command(0XF7);
spi_8bit_data(0xA9);
spi_8bit_data(0x51);
spi_8bit_data(0x2C);
spi_8bit_data(0x82);
//**********set rgb interface mode******************
spi_8bit_command(0XB0); //Interface Mode Control
spi_8bit_data(0x00); //set DE,HS,VS,PCLK polarity
spi_8bit_command(0xB6);
spi_8bit_data(0X30); //30 set rgb
spi_8bit_data(0x02); //GS,SS 02,42
spi_8bit_data(0x3B);
/**************************************************/
spi_8bit_command(0x2A); //Frame rate control
spi_8bit_data(0x00);
spi_8bit_data(0x00);
spi_8bit_data(0x01);
spi_8bit_data(0x3F);
spi_8bit_command(0x2B); //Display function control
spi_8bit_data(0x00);
spi_8bit_data(0x00);
spi_8bit_data(0x01);
spi_8bit_data(0xDF);
spi_8bit_command(0x11);
MDELAY(110);
spi_8bit_command(0x29); //display on
MDELAY(110);
spi_8bit_command(0x2c);
}
static void lcm_init(void)
{
#if 0
#ifdef BUILD_LK
printf( "=====ZHR=====LK_ILI9481_init\n");
lcm_util.set_gpio_mode(GPIO59, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO59, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ONE);
MDELAY(10);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ZERO);
MDELAY(50);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ONE);
MDELAY(100);
// LCD_KD035C_init();
init_lcm_registersCTP();
#else
printk("=====ZHR=====Ker_ILI9481_init\n");
lcm_util.set_gpio_mode(GPIO59, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO59, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ONE);
MDELAY(10);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ZERO);
MDELAY(50);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ONE);
MDELAY(100);
DPI_EN(1);
// LCD_KD035C_init();
init_lcm_registersCTP();
#endif
lcm_util.set_gpio_mode(GPIO139, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO139, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO139, GPIO_OUT_ONE);
#endif
}
static void lcm_suspend(void)
{
lcm_util.set_gpio_mode(GPIO139, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO139, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO139, GPIO_OUT_ZERO);
lcm_util.set_gpio_mode(GPIO59, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO59, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ZERO);
}
static void lcm_resume(void)
{
lcm_util.set_gpio_mode(GPIO59, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO59, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ONE);
MDELAY(10);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ZERO);
MDELAY(50);
lcm_util.set_gpio_out(GPIO59, GPIO_OUT_ONE);
MDELAY(100);
LCD_KD035C_init();
lcm_util.set_gpio_mode(GPIO139, GPIO_MODE_00);
lcm_util.set_gpio_dir(GPIO139, GPIO_DIR_OUT);
lcm_util.set_gpio_out(GPIO139, GPIO_OUT_ONE);
}
LCM_DRIVER kd035c_rgb_ili9841_lcm_drv =
{
.name = "kd035c_rgb_ili9841",
.set_util_funcs = lcm_set_util_funcs,
.get_params = lcm_get_params,
.init = lcm_init,
.suspend = lcm_suspend,
.resume = lcm_resume,
};
有偿解决
看看~