打印
[ZLG-ARM]

LPC2478驱动4位单色STN 320x240问题

[复制链接]
2830|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
有意思|  楼主 | 2010-7-1 11:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
是用LPC2478的LCD控制器驱动4位单色STN 320x240屏,在uboot下初始化并显示,
void LcdInit(void)
{

        unsigned int i;
        static const unsigned char message1[] = "\r\nEntering InitLCD()";
        static const unsigned char message2[] = "\r\nEntering GenerateTestPattern()";
        static const unsigned char message3[] = "\r\nEntering EnableLCD()";
        static const unsigned char message4[] = "\r\nExiting LcdInit()\r\n";
        unsigned char *pMsg = (unsigned char *)message1 - (unsigned char *)TEXT_BASE;

       
        LCD_INIT_STRUCTURE mylcd;
#if 0
        mylcd.xsize = 320;
        mylcd.horiz_front_porch = 20;
        mylcd.horiz_back_porch = 38;
        mylcd.horiz_sync_pulse = 30;
        mylcd.ysize = 240;
        mylcd.vert_front_porch = 5;
        mylcd.vert_back_porch = 15;
        mylcd.vert_sync_pulse = 3;
        mylcd.color_mode = COLOR_MODE_24BPP;
        mylcd.hclk_divider = 14;
#else
        mylcd.xsize = 320;
        mylcd.horiz_front_porch = 20;
        mylcd.horiz_back_porch = 38;
        mylcd.horiz_sync_pulse = 30;
        mylcd.ysize = 240;
        mylcd.vert_front_porch = 5;
        mylcd.vert_back_porch = 15;
        mylcd.vert_sync_pulse = 3;
        mylcd.color_mode = COLOR_MODE_4BPP;
        mylcd.hclk_divider = 8;

        /* XXX - Ivan */
#endif

        for(i=0; i<(sizeof(message1)-1); i++)
        {
                while((U0LSR & (1<<5)) == 0);
                U0THR = *pMsg++;
        }

        lpc24xx_InitLCD(mylcd);

        pMsg = (unsigned char *)message2 - (unsigned char *)TEXT_BASE;
        for(i=0; i<(sizeof(message2)-1); i++)
        {
                while((U0LSR & (1<<5)) == 0);
                U0THR = *pMsg++;
        }

        //lpc24xx_show**bmp();
        lpc24xx_GenerateTestPattern();

        pMsg = (unsigned char *)message3 - (unsigned char *)TEXT_BASE;
        for(i=0; i<(sizeof(message3)-1); i++)
        {
                while((U0LSR & (1<<5)) == 0);
                U0THR = *pMsg++;
        }

       
        lpc24xx_EnableLCD();


        pMsg = (unsigned char *)message4 - (unsigned char *)TEXT_BASE;
        for(i=0; i<(sizeof(message4)-1); i++)
        {
                while((U0LSR & (1<<5)) == 0);
                U0THR = *pMsg++;
        }



}

void lpc24xx_InitLCD(LCD_INIT_STRUCTURE lcd)
{

        /* this needs to run from the ROM so skip that section for now */
#ifdef LCD_USE_MALLOC
        framebuffer = malloc(framebuffer_size);
#else
        framebuffer = (void *)LCD_FRAMEBUFFER_START; //显示buf地址,0xa0f00000
#endif

    PINSEL4         = PINSEL4 & (~(0xfffff << 0)) | 0xfffff; //只使用lcd0~lcd3


       PINSEL11 = PINSEL11 & (~0xf << 0) \
                           | (1 << 0);

        PCONP |= 1<<20;                /* Turn On LCD PCLK */
        delay_Ns(200);

        LCD_CTRL = (1 << LCD_CTRL_LCDEN);



      delay_Ns(20);   



        LCD_UPBASE = ((uint32_t)framebuffer&0xfffffff8); /* make sure the framebuffer is DWORD aligned - fixme */
        //LCD_LPBASE = ((uint32_t)framebuffer&0xfffffff8);


        //LCD_CTRL = 0;


        LCD_CFG = (uint32_t)lcd.hclk_divider << LCD_CFG_CLKDIV;

        LCD_TIMH = ((((uint32_t)lcd.horiz_back_porch-1) << LCD_TIMH_HBP ) | \
                           (((uint32_t)lcd.horiz_front_porch-1) << LCD_TIMH_HFP) | \
                        (((uint32_t)lcd.horiz_sync_pulse-1) << LCD_TIMH_HSW ) | \
                        (((lcd.xsize / 16) - 1) << LCD_TIMH_PPL ) );

        LCD_TIMV = (        (((uint32_t)lcd.vert_back_porch) << LCD_TIMV_VBP ) | \
                        (((uint32_t)lcd.vert_front_porch) << LCD_TIMV_VFP) | \
                        (((uint32_t)lcd.vert_sync_pulse) << LCD_TIMV_VSW ) | \
                        (( lcd.ysize-1) << LCD_TIMV_LPP ) );

        LCD_POL = (        (((uint32_t)0        ) << LCD_POL_PCD_HI        ) | \
                        (((uint32_t)0        ) << LCD_POL_BCD        ) | \
                        (((uint32_t)lcd.xsize-1        ) << LCD_POL_CPL        ) | \
                        (((uint32_t)0        ) << LCD_POL_IOE        ) | \
                        (((uint32_t)0        ) << LCD_POL_IPC        ) | \
                        (((uint32_t)1        ) << LCD_POL_IHS        ) | \
                        (((uint32_t)0        ) << LCD_POL_IVS        ) | \
                        (((uint32_t)6        ) << LCD_POL_ACB        ) | \
                        (((uint32_t)0        ) << LCD_POL_CLKSEL        ) | \
                        (((uint32_t)4        ) << LCD_POL_PCD_LO        ) );


        LCD_LE = (10 << 0) | (1 << 16);
        LCD_INTMSK = 0; /*  disable LCD interrupt       */
        //LCD_UPBASE = ((uint32_t)framebuffer&0xfffffff8); /* make sure the framebuffer is DWORD aligned - fixme */
        //LCD_LPBASE = ((uint32_t)framebuffer&0xfffffff8);


    LCD_CTRL = ( /*(((uint32_t) 1        ) << LCD_CTRL_BGR        ) | \*/
                         /*   (((uint32_t) 1        ) << LCD_CTRL_LCDTFT        ) | \*/
                         (((uint32_t) 0        ) << LCD_CTRL_LCDMONO8) | \
                         (((uint32_t) 1        ) << LCD_CTRL_LCDBW) | \
                            (((uint32_t)lcd.color_mode ) << LCD_CTRL_LCDBPP ) );

    delay_Ns(20);

    LCD_CTRL |= (((uint32_t) 1        ) << LCD_CTRL_LCDPWR);

    delay_Ns(20);   
}
void lpc24xx_GenerateTestPattern(uint8_t pattern)
{
        uint32_t cntr;
        uint32_t * ptr;


//        if ( (framebuffer == 0) || (framebuffer_size == 0))
//                return;

       
#ifdef LCD_USE_MALLOC
        ptr = framebuffer;
#else
        ptr = (void *)LCD_FRAMEBUFFER_START;
#endif

    {
            int x, y;
            unsigned char *posy;
            unsigned char *posy1;
            int LCDx_bpp_res;
                LCDx_bpp_res = ((320) * (16))/8;
               
            for(y=0 ; y <( 240); y++)
            {
                posy = (unsigned char *)(LCD_FRAMEBUFFER_START+ y*LCDx_bpp_res);
                    for(x=0;x < LCDx_bpp_res ; x++)
                {
                        posy1=(unsigned char *)((unsigned int)(posy+x)^1);
                        *(posy1)= boot_screenMap[y*LCDx_bpp_res+x];// 这一个图片数组38400,水平扫描,16位灰色 320x240
                    }                       
            }
    }






在uboot的命令行中,使用md a0f0000查看SDRAM的内容,已经是boot_screenMap数组的内容了但是屏幕上无显示
}

相关帖子

沙发
有意思|  楼主 | 2010-7-1 11:35 | 只看该作者
已经把LCD控制器的LCD_UPBASE初始化为0xA0F0000,在SDRAM中,如何操作才能使STN液晶显示,

使用特权

评论回复
板凳
xuhao0210| | 2011-1-10 17:01 | 只看该作者
同问

使用特权

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

本版积分规则

79

主题

331

帖子

0

粉丝