如图所示,选取了一副220*205的图片,16-BPP输出,但是在屏幕上没有完全显示,查阅了许多博客,根据他们的配置做了许多修改依然没有解决问题,感觉对LCD的配置还没有理解到位,希望小伙伴们可以指点下,附件有代码,有兴趣的可以帮忙看看哪里配置还存在缺陷,感激不尽。
代码 图片.rar
(212.81 KB, 下载次数: 19)
- #define GPICON (*(volatile unsigned long *)0x7F008100) //LCD Data Port VD[0:15]
- #define GPJCON (*(volatile unsigned long *)0x7F008120) //LCD Data Port VD[16:23]
- #define VIDCON0 (*(volatile unsigned long *)0x77100000) //Video control 0 register
- #define VIDCON1 (*(volatile unsigned long *)0x77100004) //Video control 1 register
- #define VIDCON2 (*(volatile unsigned long *)0x77100008) //Video control 2 register
- #define VIDTCON0 (*(volatile unsigned long *)0x77100010) //Video time control 0 register
- #define VIDTCON1 (*(volatile unsigned long *)0x77100014) //Video time control 1 register
- #define VIDTCON2 (*(volatile unsigned long *)0x77100018) //Video time control 2 register
- #define WINCON0 (*(volatile unsigned long *)0x77100020) //Window control 0 register
- #define VIDOSD0A (*(volatile unsigned long *)0x77100040) //Video Window 0's position control register
- #define VIDOSD0B (*(volatile unsigned long *)0x77100044) //Video Window 0's position control register
- #define VIDOSD0C (*(volatile unsigned long *)0x77100048) //Video Window 0's size control register
- #define VIDW00ADD0B0 (*(volatile unsigned long *)0x771000A0) //Window 0's buffer start address register, buffer 0
- #define VIDW00ADD1B0 (*(volatile unsigned long *)0x771000D0) //Window 0's buffer end address register, buffer 0
- #define VIDW00ADD2 (*(volatile unsigned long *)0x77100100) //Window 0's buffer size register
- #define WPALCON (*(volatile unsigned long *)0x771001A0) //Window Palette control register
- #define MIFPCON (*(volatile unsigned long *)0x7410800C) //Modem Interface Port Control register
- #define SPCON (*(volatile unsigned long *)0x7F0081A0) //Special Port Control Register
- #define WIN0MAP (*(volatile unsigned long *)0x77100180) //Window'0 color control
- #define VIDOUT_RGB_I_F (3<<26)
- #define PNERMODE_RGB_PAR (3<<17)
- #define CLKSEL_F_HCLK (3<<2)
- #define CLKSEL_F_EXT (3<<2)
- #define DISPLAY_ON (3<<0)
- #define DISPALY_OFF (3<<0)
- #define IVCLK_FALLING (1<<7)
- #define IHSYNC (1<<6)
- #define IVSYNC (1<<5)
- #define IVDEN (1<<4)
- #define VSPW 9
- #define VBPD 1
- #define VFPD 1
- #define CLKVAL_HCLK 13
- #define CLKVAL_EXT 2
- #define HSPW 40
- #define HBPD 1
- #define HFPD 1
- #define LeftTopX 0
- #define LeftTopY 0
- #define RightBotX 480
- #define RightBotY 272
- #define LCD_XSIZE 480//水平分辨率
- #define LCD_YSIZE 272//垂直分辨率
- #define LINEVAL 271
- #define HOZVAL 479
- #define PAGEWIDTH ( (HOZVAL+1)*2 )
- #define OFFSIZE 0
- volatile unsigned int LCDBUFFER[LCD_YSIZE][LCD_XSIZE] = {0};
- typedef unsigned int U32;
- typedef unsigned short U16;
- typedef unsigned char U8;
- void lcd_port_init()
- {
- GPICON = 0xAAAAAAAA;
- GPJCON = 0xAAAAAA;
- }
- void lcd_control_init()
- {
- MIFPCON &= ~(1<<3); /* Normal mode */
- SPCON &= ~(0x3);
- SPCON |= 0x1; /* RGB I/F style */
-
- WPALCON |= (3<<1); /*16-bit data format*/
-
- /*Clock and Output Mode Configuration*/
-
- /*Clock Source --> HCLK*/
- #if 1
- VIDCON0 &= ~( DISPALY_OFF | VIDOUT_RGB_I_F | PNERMODE_RGB_PAR | CLKSEL_F_HCLK | (0XFF<<6) ); //RGB I/F,vclk = HCLK / (CLKVAL+1) = 133/14 = 9.5MHz
- VIDCON0 |= ( (1<<4) | (CLKVAL_HCLK<<6) ); //diplay on,CLKVAL = 13+1
- #endif
- /*Clock Source --> Ext Clock Input */
- #if 0
- VIDCON0 &= ~( VIDOUT_RGB_I_F | PNERMODE_RGB_PAR | (0XFF<<6) ); //RGB I/F,vclk== 27MHz Ext Clock input / (CLKVAL+1) = 27/3 = 9MHz */
- VIDCON0 |= (DISPLAY_ON | (1<<4) | (CLKVAL_EXT<<6) | CLKSEL_F_EXT ); //diplay on,CLKVAL = 3
- #endif
-
- /*Clock polarity and active edge configuration*/
- VIDCON1 &= ~( (IVCLK_FALLING) | (IVDEN) ); //falling edge,output enable
- VIDCON1 |= ( (IHSYNC) | (IVSYNC) ); //HSYNC High, VSYNC High, 1 = inverted
-
- /*Clock time configuration*/
- VIDTCON0 = (VBPD << 16) | (VFPD << 8) | (VSPW << 0); /*VBPD=1, VFPD=1, VFPD=9*/
- VIDTCON1 = (HBPD << 16) | (HFPD << 8) | (HSPW << 0); /*HBPD=1, HBPD=1, HSPW=40*/
- VIDTCON2 = (LINEVAL << 11) | (HOZVAL << 0); /*LINEVAL = 272-1, HOZVAL = 480-1*/
- /*Window 0 configuration*/
- WINCON0 &= ~(0xf<< 2);
- WINCON0 |= (0x5<<2) | (1<<0); //enable VIDEO control signal output,Bits Per Pixel = 16-BPP
-
- /*Window 0 position configuration*/
- VIDOSD0A =(LeftTopX << 11) | (LeftTopY << 0); /*top left orignal coordinate = (0,0)*/
- VIDOSD0B =(RightBotX << 11) | (RightBotY << 0); /*low right orignal coordinate = (480,272)*/
- VIDOSD0C = (LINEVAL + 1) * (HOZVAL + 1); /*Height * Width (Number of Word),Window Size = 272*480*/
-
- /* Window 0’s buffer configuration*/
- VIDW00ADD0B0 = ( (((U32)LCDBUFFER>>24)<<24) | ((U32)LCDBUFFER&0xffffff) );
- VIDW00ADD1B0 = ( (U32)LCDBUFFER + ( (PAGEWIDTH + OFFSIZE) * (LINEVAL+1) ) ) & (0xffffff); /*VBASEL = VBASEU + (PAGEWIDTH+OFFSIZE) x (LINEVAL+1)*/
- VIDW00ADD2 = (OFFSIZE<<13) | PAGEWIDTH ;
- /*screen offset size (the number of byte) = 0,
- creen page width (the number of byte) */
- }
- void lcd_init()
- {
- lcd_port_init();
- lcd_control_init();
- VIDCON0 |= (3<<0);
- }
- void point(unsigned int x,unsigned int y,unsigned int color)
- {
- unsigned int red, green, blue;
-
- red = (color>>19) & 0x1f;
- green = (color>>10) & 0x3f;
- blue = (color>>3) & 0x1f;
- LCDBUFFER[x][y] = (unsigned short)((red<<11)|(green<<5)|blue);
- }
- void Paint_Bmp(U16 x0,U16 y0,U16 wide,U16 high,const U8 *bmp)
- {
- U16 x,y;
- U16 c;
- U32 p = 0;
- for( y = y0 ; y < y0+high ; y++ )
- {
- for( x = x0 ; x < x0+wide ; x++ )
- {
- c = bmp[p] | (bmp[p+1]<<8);
-
- if ( ( x < 480) && ( y < 272) )
- LCDBUFFER[y][x] = c ;
-
- p = p + 2 ;
- }
- }
- }
- void clearSrc(unsigned int color)
- {
- //WIN0MAP = (1<<24) | (color&0xffffff); //fill screen with color
- }
- const unsigned char gImage_QQ[90200];
- void lcd_test()
- {
- int x;
-
- Paint_Bmp(0,0,220,205,gImage_QQ);
-
- }
- //http://www.114la.com/other/rgb.htm
复制代码
一周热门 更多>