大家好,我在调试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; 就完全没有显示。 |