1:配置与LCD相连的GPIO
GPICON = 0xaaaaaaaa; /* GPI0~GPI15用作lcd_vd[0~15] */
GPJCON = 0xaaaaaaa; /* GPJ0~GPJ7用作lcd_vd[16~23]
GPJ8 HSYNC
GPJ9 VSYNC
GPJ10 VDEN
GPJ11 VCLK
*/
GPFCON &= ~(0x3<<28);
GPFCON |= (1<<28); /* GPF14用作背光使能信号 */
GPECON &= ~(0xf);
GPECON |= (0x1); /* GPE0用作LCD的on/off信号 */
2:配置相关寄存器
2. 初始化6410的display controller
2.1 hsync,vsync,vclk,vden的极性和时间参数
2.2 行数、列数(分辨率),象素颜色的格式
2.3 分配显存(frame buffer),写入display controller
//下面两个由6410手册要求设置
MIFPCON &= ~(1<<3); /* Normal mode */
SPCON &= ~(0x3);
SPCON |= 0x1; /* RGB I/F style */
//配置输出格式和时钟
#if0
VIDCON0 &= ~((3<<26) |(3<<17) | (0xff<<6)); // RGBI/F, RGB Parallel format,
VIDCON0 |= ((2<<6) | (1<<4) |(0x3<<2));
// vclk== 27MHz Ext Clock input /(CLKVAL+1) = 27/3 = 9MHz */
#else
VIDCON0 &= ~((3<<26) |(3<<17) | (0xff<<6) |(3<<2));
//RGB I/F, RGB Parallelformat,
VIDCON0 |= ((14<<6) | (1<<4)); // vclk== HCLK / (CLKVAL+1) = 133/15= 9MHz
#endif
//视频输出及显示控制信号使能
VIDCON0 &= ~(0x3);
//配置时钟HSYNC VSYNC的极性
VIDCON1 &= ~((1<<7) |(1<<4)); /* 在vclk的下降沿获取数据 */
VIDCON1 |= ((1<<6) | (1<<5)); /* HSYNC高电平有效, VSYNC高电平有效 */
//配置时序规则
RGB 接口时序图:
参照4.3寸的LCD “Product Specifications”
定时(时序)规则:
由上面可以得出
VSPW =9
VBPD =1
LINEVAL=271
VFPD =1
HSPW =40
HBPD = 1
HOZVAL =479
HFPD = 1
VIDTCON0= (VBPD << 16) | (VFPD << 8) | (VSPW << 0);
VIDTCON1 = (HBPD << 16) | (HFPD<< 8) | (HSPW << 0);
VIDTCON2 = (LINEVAL << 11) | (HOZVAL<< 0);
//配置窗口0
WINCON0 &= ~(0xf << 2);
WINCON0|= (0xb<<2) | (1<<0);
/* unpacked 24 BPP (non-palletizedR:8-G:8-B:8 ) */
//配置窗口0的位置
LeftTopX =0
LeftTopY =0
RightBotX =479
RightBotY =271
VIDOSD0A = (LeftTopX<<11) |(LeftTopY << 0);
VIDOSD0B = ((RightBotX+1)<<11) |((RightBotY+1) << 0);
//窗口尺寸
VIDOSD0C = (LINEVAL + 1) * (HOZVAL + 1);
//设置显存在内存(帧缓冲地址)的首地址 与 尾地址
VIDW00ADD0B0= FRAME_BUFFER;
VIDW00ADD1B0 = (((HOZVAL + 1)*4 + 0) * (LINEVAL + 1)) &(0xffffff);
/* VBASEL = VBASEU + (LINEWIDTH+OFFSIZE) x(LINEVAL+1)
* = 0 + (480*4 + 0) * 272
* 注意只取了前24位
*/
VIDW00ADD2 = HOZVAL + 1;//可以不用