OK6410裸机4.3寸LCD显示问题求助

2019-07-16 07:55发布

如图所示,选取了一副220*205的图片,16-BPP输出,但是在屏幕上没有完全显示,查阅了许多博客,根据他们的配置做了许多修改依然没有解决问题,感觉对LCD的配置还没有理解到位,希望小伙伴们可以指点下,附件有代码,有兴趣的可以帮忙看看哪里配置还存在缺陷,感激不尽。 原图
取模截图
显示照片

代码 图片.rar (212.81 KB, 下载次数: 19)


  1. #define GPICON (*(volatile unsigned long *)0x7F008100)        //LCD Data Port VD[0:15]
  2. #define GPJCON (*(volatile unsigned long *)0x7F008120)        //LCD Data Port VD[16:23]

  3. #define VIDCON0 (*(volatile unsigned long *)0x77100000)        //Video control 0 register
  4. #define VIDCON1 (*(volatile unsigned long *)0x77100004)        //Video control 1 register
  5. #define VIDCON2 (*(volatile unsigned long *)0x77100008)        //Video control 2 register

  6. #define VIDTCON0 (*(volatile unsigned long *)0x77100010)    //Video time control 0 register
  7. #define VIDTCON1 (*(volatile unsigned long *)0x77100014)    //Video time control 1 register   
  8. #define VIDTCON2 (*(volatile unsigned long *)0x77100018)    //Video time control 2 register

  9. #define WINCON0 (*(volatile unsigned long *)0x77100020)        //Window control 0 register

  10. #define VIDOSD0A (*(volatile unsigned long *)0x77100040)    //Video Window 0's position control register
  11. #define VIDOSD0B (*(volatile unsigned long *)0x77100044)    //Video Window 0's position control register
  12. #define VIDOSD0C (*(volatile unsigned long *)0x77100048)    //Video Window 0's size control register

  13. #define VIDW00ADD0B0 (*(volatile unsigned long *)0x771000A0)        //Window 0's buffer start address register, buffer 0
  14. #define VIDW00ADD1B0 (*(volatile unsigned long *)0x771000D0)        //Window 0's buffer end address register, buffer 0
  15. #define VIDW00ADD2    (*(volatile unsigned long *)0x77100100)        //Window 0's buffer size register

  16. #define WPALCON    (*(volatile unsigned long *)0x771001A0)                //Window Palette control register

  17. #define MIFPCON    (*(volatile unsigned long *)0x7410800C)        //Modem Interface Port Control register
  18. #define SPCON      (*(volatile unsigned long *)0x7F0081A0)        //Special Port Control Register

  19. #define WIN0MAP        (*(volatile unsigned long *)0x77100180)        //Window'0 color control


  20. #define VIDOUT_RGB_I_F                 (3<<26)
  21. #define PNERMODE_RGB_PAR        (3<<17)
  22. #define CLKSEL_F_HCLK                (3<<2)
  23. #define CLKSEL_F_EXT                (3<<2)
  24. #define DISPLAY_ON                        (3<<0)
  25. #define DISPALY_OFF                        (3<<0)

  26. #define IVCLK_FALLING                (1<<7)
  27. #define IHSYNC                                (1<<6)
  28. #define IVSYNC                                (1<<5)
  29. #define IVDEN                                (1<<4)


  30. #define VSPW 9
  31. #define VBPD 1
  32. #define VFPD 1
  33. #define CLKVAL_HCLK 13
  34. #define CLKVAL_EXT 2
  35. #define HSPW 40
  36. #define HBPD 1
  37. #define HFPD 1

  38. #define LeftTopX 0
  39. #define LeftTopY 0
  40. #define RightBotX 480
  41. #define RightBotY 272

  42. #define LCD_XSIZE 480//水平分辨率
  43. #define LCD_YSIZE        272//垂直分辨率

  44. #define LINEVAL 271
  45. #define HOZVAL 479

  46. #define PAGEWIDTH        ( (HOZVAL+1)*2 )
  47. #define OFFSIZE        0

  48. volatile unsigned int LCDBUFFER[LCD_YSIZE][LCD_XSIZE] = {0};

  49. typedef unsigned int U32;
  50. typedef unsigned short U16;
  51. typedef unsigned char U8;

  52. void lcd_port_init()
  53. {
  54.     GPICON = 0xAAAAAAAA;
  55.     GPJCON = 0xAAAAAA;       
  56. }

  57. void lcd_control_init()
  58. {       
  59.     MIFPCON &= ~(1<<3);   /* Normal mode */
  60.     SPCON &= ~(0x3);
  61.     SPCON |= 0x1;       /* RGB I/F style */
  62.    
  63.     WPALCON |=  (3<<1); /*16-bit data format*/
  64.    
  65.         /*Clock and Output Mode Configuration*/
  66.    
  67.         /*Clock Source  -->  HCLK*/       
  68. #if 1
  69.     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
  70.                 VIDCON0 |= ( (1<<4) | (CLKVAL_HCLK<<6) );        //diplay on,CLKVAL = 13+1
  71. #endif  
  72.         /*Clock Source  -->  Ext Clock Input */
  73. #if 0
  74.     VIDCON0 &= ~( VIDOUT_RGB_I_F | PNERMODE_RGB_PAR | (0XFF<<6) );  //RGB I/F,vclk== 27MHz Ext Clock input / (CLKVAL+1) = 27/3 = 9MHz */
  75.     VIDCON0 |= (DISPLAY_ON | (1<<4) | (CLKVAL_EXT<<6) | CLKSEL_F_EXT );    //diplay on,CLKVAL = 3
  76. #endif
  77.      
  78.     /*Clock polarity and active edge configuration*/
  79.     VIDCON1 &= ~( (IVCLK_FALLING) | (IVDEN) );        //falling edge,output enable
  80.     VIDCON1 |= ( (IHSYNC) | (IVSYNC) );        //HSYNC High, VSYNC High, 1 = inverted
  81.        
  82.         /*Clock time configuration*/
  83.     VIDTCON0 = (VBPD << 16) | (VFPD << 8) | (VSPW << 0); /*VBPD=1, VFPD=1, VFPD=9*/
  84.     VIDTCON1 = (HBPD << 16) | (HFPD << 8) | (HSPW << 0);        /*HBPD=1, HBPD=1, HSPW=40*/
  85.     VIDTCON2 = (LINEVAL << 11) | (HOZVAL << 0);        /*LINEVAL = 272-1, HOZVAL = 480-1*/

  86.         /*Window 0 configuration*/
  87.     WINCON0 &= ~(0xf<< 2);
  88.     WINCON0 |= (0x5<<2) | (1<<0);        //enable VIDEO control signal output,Bits Per Pixel = 16-BPP      
  89.    
  90.         /*Window 0 position  configuration*/
  91.     VIDOSD0A =(LeftTopX << 11) | (LeftTopY << 0);        /*top left orignal coordinate = (0,0)*/
  92.     VIDOSD0B =(RightBotX << 11) | (RightBotY << 0);        /*low right orignal coordinate = (480,272)*/
  93.     VIDOSD0C = (LINEVAL + 1) * (HOZVAL + 1);        /*Height * Width (Number of Word),Window Size = 272*480*/
  94.    
  95.         /* Window 0’s buffer configuration*/
  96.     VIDW00ADD0B0 = ( (((U32)LCDBUFFER>>24)<<24) | ((U32)LCDBUFFER&0xffffff) );
  97.     VIDW00ADD1B0 =  ( (U32)LCDBUFFER + ( (PAGEWIDTH + OFFSIZE) * (LINEVAL+1) ) ) & (0xffffff);        /*VBASEL = VBASEU + (PAGEWIDTH+OFFSIZE) x (LINEVAL+1)*/
  98.     VIDW00ADD2 =  (OFFSIZE<<13) | PAGEWIDTH ;
  99.     /*screen offset size (the number of byte) = 0,
  100.     creen page width (the number of byte) */
  101. }


  102. void lcd_init()
  103. {       
  104.     lcd_port_init();
  105.     lcd_control_init();

  106.                 VIDCON0 |= (3<<0);       
  107. }

  108. void point(unsigned int x,unsigned int y,unsigned int color)
  109. {
  110.     unsigned int red, green, blue;
  111.    
  112.     red = (color>>19) & 0x1f;       
  113.     green = (color>>10) & 0x3f;       
  114.     blue = (color>>3) & 0x1f;       
  115.     LCDBUFFER[x][y] = (unsigned short)((red<<11)|(green<<5)|blue);       
  116. }

  117. void Paint_Bmp(U16 x0,U16 y0,U16 wide,U16 high,const U8 *bmp)
  118. {
  119.     U16 x,y;
  120.     U16 c;
  121.     U32 p = 0;

  122.     for( y = y0 ; y < y0+high ; y++ )
  123.     {
  124.             for( x = x0 ; x < x0+wide ; x++ )
  125.             {
  126.                 c = bmp[p] | (bmp[p+1]<<8);                                                                               
  127.             
  128.             if ( ( x < 480) && ( y < 272) )
  129.                 LCDBUFFER[y][x] = c ;
  130.                 
  131.             p = p + 2 ;       
  132.             }
  133.     }
  134. }

  135. void clearSrc(unsigned int color)
  136. {
  137.     //WIN0MAP = (1<<24) | (color&0xffffff);        //fill screen with color
  138. }

  139. const unsigned char gImage_QQ[90200];

  140. void lcd_test()
  141. {
  142.     int x;
  143.    
  144.     Paint_Bmp(0,0,220,205,gImage_QQ);
  145.    
  146. }

  147. //http://www.114la.com/other/rgb.htm

复制代码

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。