打印

就调试LCP2478的LCD遇到的问题请教大家。

[复制链接]
2934|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
chetazo|  楼主 | 2009-4-20 10:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
大家好,我在调试NXP的LPC2478的LCD驱动器时遇到如下问题:
我的LCD是典型的4位单扫描的黑白STN屏。在调试的过程中发现调色板不知道如何初始化,如果我不初始化调色板的话,就完全没有显示,如果初始化第0,1个调色板为0XFFFF0000,则可以显示,但显示会乱,显示出来的不是我写入的。另外还有一个问题就是我在显存中写第一行,但是显示的是第一二行都有显示。这就导致写1/4屏就会有1/2屏显示,写1/2屏就全屏都有显示。调试了2天都没有成功,也没有可参考的代码。下面是我的初始化代码,请用过的大侠指点一二。


#define    GUI_LCM_XMAX   (320)                                            /*  LCD x size                  */
#define    GUI_LCM_YMAX   (240)                                            /*  LCD y size                  */

#define LcdPwr          1                                               
#define LcdTFT          0                                               
#define LcdBpp          0                                               
#define LcdEn           1

#define HBP             5                                              /*  Horizontal back porch       */
#define HFP             5                                              /*  Horizontal front porch      */
#define HSW             3                                              /*  Horizontal pulse width      */

#define VBP             2                                               /*  Vertical back porch         */
#define VFP             2                                               /*  Vertical front porch        */
#define VSW             1                                               /*  Vertical pulse width        */

#define PPL             (GUI_LCM_XMAX / 16) - 1                         /*  Pixels-per-line             */

#define LPP             (GUI_LCM_YMAX - 1)                              /*  Lines-per-panel             */

#define CPL             (GUI_LCM_XMAX / 4) - 1                          /*  clock per line              */



    PCONP     |= (1 << 20);                                             /*  enable LCD controller power */   
    LCD_CTRL  |= (1 << 11);                                             /*  Power enable                */


   /* P2.2:LCDDCLK  P2.3:LCDFP  P2.4:LCDFP   P2.5:LCDLP  
      P2.6:UD[0]    P2.7:UD[1]  P2.8:UD[2]   P2.9:UD[3] */
    PINSEL4   &= ~((0x3 << 2*2) | (0x3 << 2*3) | (0x3 << 2*5) | 
                   (0x3 << 2*6) | (0x3 << 2*7) | (0x3 << 2*8) | 
                   (0x3 << 2*9));
                   
    PINSEL4   |=  ((0x3 << 2*2) | (0x3 << 2*3) | (0x3 << 2*5) | 
                   (0x3 << 2*6) | (0x3 << 2*7) | (0x3 << 2*8) | 
                   (0x3 << 2*9));                           
                                                                                                          
    /* DISP OFF is control by LCDM in GPIO mode */
    FIO2DIR   |= 1 << 4;    
    FIO2SET   |= 1 << 4;                                                /* set DISP_OFF high to open    */           

    PINSEL10  &= 0xFFFFFFF7;                                            /*  disable the ETM interface 
                                                                            pins                        */
    PINSEL11   = (int)(0xfffffffll << 4)                                /*  Reserved,should write 1     */
               | (0 << 1)                                               /*  4-bit mono STN single       */ 
               | (1 << 0);                                              /*  lcd port is enable          */     

    _DelayNs(15);

    LCD_UPBASE = ((unsigned int)(&frameBuffer));                        /*  set buffer's base address   */
    
    LCD_CTRL   = 0;                                                     /*  power disable               */
    _DelayNs(20);
               
    LCD_CFG    = 0x07;                                                  /*  pixel clock 9MHZ            */ 
    LCD_TIMH   = (HBP << 24) |                                          /*  set horizontal timing       */
                 (HFP << 16) |                                            
                 (HSW << 8)  |
                 (PPL << 2);
    
    LCD_TIMV   = (VBP << 24) |                                          /*  set vertical timing         */
                 (VFP << 16) |
                 (VSW << 10) |
                 (LPP << 0);
               
    LCD_POL    = (0 << 26)   |                                          /*  bypass pixel color driver   */
                 (CPL << 16) |                                          /*  clock per line              */
                 (0 << 14)   |                                          /*  LCDENAB output pin is active
                                                                            HIGH in TFT mode,no care in 
                                                                            STN mode                    */
                 (0 << 13)   |                                          /*  Data is driven on the LCD on 
                                                                            the rising edge of LCDDCLK */
                 (0 << 12)   |                                          /*  HSYNC is active low         */                                           
                 (0 << 11)   |                                          /*  VSYNC is active low         */
                 (0 << 5)    |                                          /*  select HCLK:clock source for
                                                                            the LCD block is HCLK       */
                 (0x01);                                                /*  Lower five bits of panel 
                                                                            clock divisor.              */                                                         
    
    LCD_CTRL   = (LcdTFT << 5) |                                        /*  select TFT LCD type         */
                 (1 << 6)      |                                        /*  monochrome LCD uses a 4-bit 
                                                                            interface                   */
                 (1 << 4)      |                                        /*  STN LCD is monochrome       */
                 (LcdBpp << 1) |                                        /*  select 1bpp                 */
                 (LcdEn);                                               /*  LCD enable                  */
    
    LCD_INTMSK = 0;                                                     /*  disable LCD interrupt       */
    
    _DelayNs(20);
    
    ptr = (volatile unsigned long *)(LCD_BASE_ADDR + 0x200);
    
    
    ptr[0] = 0xffff0000;  

   
    LCD_CTRL  |= (1 << 11);                                             /*  Power enable                */



上面的代码中,如果不加入ptr[0] = 0xffff0000; 就完全没有显示。

相关帖子

沙发
chetazo|  楼主 | 2009-4-20 14:10 | 只看该作者

哈哈,自己发现一个低级的BUG


LCD_CTRL   = (LcdTFT << 5) |                                        /*  select TFT LCD type         */
                 (1 << 6)      |                                        /*  monochrome LCD uses a 4-bit 
                                                                            interface                   */
                 (1 << 4)      |                                        /*  STN LCD is monochrome       */
                 (LcdBpp << 1) |                                        /*  select 1bpp                 */
                 (LcdEn);                                               /*  LCD enable                  */

中,(1 << 6) 应该是 (0 << 6) 

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

15

主题

25

帖子

1

粉丝