[ZLG-ARM] LPC2478驱动4位单色STN 320x240问题

[复制链接]
 楼主| 有意思 发表于 2010-7-1 11:32 | 显示全部楼层 |阅读模式
是用LPC2478的LCD控制器驱动4位单色STN 320x240屏,在uboot下初始化并显示,
  1. void LcdInit(void)
  2. {

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

  9.        
  10.         LCD_INIT_STRUCTURE mylcd;
  11. #if 0
  12.         mylcd.xsize = 320;
  13.         mylcd.horiz_front_porch = 20;
  14.         mylcd.horiz_back_porch = 38;
  15.         mylcd.horiz_sync_pulse = 30;
  16.         mylcd.ysize = 240;
  17.         mylcd.vert_front_porch = 5;
  18.         mylcd.vert_back_porch = 15;
  19.         mylcd.vert_sync_pulse = 3;
  20.         mylcd.color_mode = COLOR_MODE_24BPP;
  21.         mylcd.hclk_divider = 14;
  22. #else
  23.         mylcd.xsize = 320;
  24.         mylcd.horiz_front_porch = 20;
  25.         mylcd.horiz_back_porch = 38;
  26.         mylcd.horiz_sync_pulse = 30;
  27.         mylcd.ysize = 240;
  28.         mylcd.vert_front_porch = 5;
  29.         mylcd.vert_back_porch = 15;
  30.         mylcd.vert_sync_pulse = 3;
  31.         mylcd.color_mode = COLOR_MODE_4BPP;
  32.         mylcd.hclk_divider = 8;

  33.         /* XXX - Ivan */
  34. #endif

  35.         for(i=0; i<(sizeof(message1)-1); i++)
  36.         {
  37.                 while((U0LSR & (1<<5)) == 0);
  38.                 U0THR = *pMsg++;
  39.         }

  40.         lpc24xx_InitLCD(mylcd);

  41.         pMsg = (unsigned char *)message2 - (unsigned char *)TEXT_BASE;
  42.         for(i=0; i<(sizeof(message2)-1); i++)
  43.         {
  44.                 while((U0LSR & (1<<5)) == 0);
  45.                 U0THR = *pMsg++;
  46.         }

  47.         //lpc24xx_show**bmp();
  48.         lpc24xx_GenerateTestPattern();

  49.         pMsg = (unsigned char *)message3 - (unsigned char *)TEXT_BASE;
  50.         for(i=0; i<(sizeof(message3)-1); i++)
  51.         {
  52.                 while((U0LSR & (1<<5)) == 0);
  53.                 U0THR = *pMsg++;
  54.         }

  55.        
  56.         lpc24xx_EnableLCD();


  57.         pMsg = (unsigned char *)message4 - (unsigned char *)TEXT_BASE;
  58.         for(i=0; i<(sizeof(message4)-1); i++)
  59.         {
  60.                 while((U0LSR & (1<<5)) == 0);
  61.                 U0THR = *pMsg++;
  62.         }



  63. }

  64. void lpc24xx_InitLCD(LCD_INIT_STRUCTURE lcd)
  65. {

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

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


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

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

  77.         LCD_CTRL = (1 << LCD_CTRL_LCDEN);



  78.       delay_Ns(20);   



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


  81.         //LCD_CTRL = 0;


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

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

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

  91.         LCD_POL = (        (((uint32_t)0        ) << LCD_POL_PCD_HI        ) | \
  92.                         (((uint32_t)0        ) << LCD_POL_BCD        ) | \
  93.                         (((uint32_t)lcd.xsize-1        ) << LCD_POL_CPL        ) | \
  94.                         (((uint32_t)0        ) << LCD_POL_IOE        ) | \
  95.                         (((uint32_t)0        ) << LCD_POL_IPC        ) | \
  96.                         (((uint32_t)1        ) << LCD_POL_IHS        ) | \
  97.                         (((uint32_t)0        ) << LCD_POL_IVS        ) | \
  98.                         (((uint32_t)6        ) << LCD_POL_ACB        ) | \
  99.                         (((uint32_t)0        ) << LCD_POL_CLKSEL        ) | \
  100.                         (((uint32_t)4        ) << LCD_POL_PCD_LO        ) );


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


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

  110.     delay_Ns(20);

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

  112.     delay_Ns(20);   
  113. }
  114. void lpc24xx_GenerateTestPattern(uint8_t pattern)
  115. {
  116.         uint32_t cntr;
  117.         uint32_t * ptr;


  118. //        if ( (framebuffer == 0) || (framebuffer_size == 0))
  119. //                return;

  120.        
  121. #ifdef LCD_USE_MALLOC
  122.         ptr = framebuffer;
  123. #else
  124.         ptr = (void *)LCD_FRAMEBUFFER_START;
  125. #endif

  126.     {
  127.             int x, y;
  128.             unsigned char *posy;
  129.             unsigned char *posy1;
  130.             int LCDx_bpp_res;
  131.                 LCDx_bpp_res = ((320) * (16))/8;
  132.                
  133.             for(y=0 ; y <( 240); y++)
  134.             {
  135.                 posy = (unsigned char *)(LCD_FRAMEBUFFER_START+ y*LCDx_bpp_res);
  136.                     for(x=0;x < LCDx_bpp_res ; x++)
  137.                 {
  138.                         posy1=(unsigned char *)((unsigned int)(posy+x)^1);
  139.                         *(posy1)= boot_screenMap[y*LCDx_bpp_res+x];// 这一个图片数组38400,水平扫描,16位灰色 320x240
  140.                     }                       
  141.             }
  142.     }






  143. 在uboot的命令行中,使用md a0f0000查看SDRAM的内容,已经是boot_screenMap数组的内容了但是屏幕上无显示
  144. }
 楼主| 有意思 发表于 2010-7-1 11:35 | 显示全部楼层
已经把LCD控制器的LCD_UPBASE初始化为0xA0F0000,在SDRAM中,如何操作才能使STN液晶显示,
xuhao0210 发表于 2011-1-10 17:01 | 显示全部楼层
同问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

79

主题

331

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部