刚开始学习LPC4357单片机,使用的是7寸液晶,程序如下 帮忙看看什么问题吧 液晶型号是AT070TNA2_V[1]
LPC_CGU->BASE_LCD_CLK = 1<<11 +0X10<<24; /* IDIVE is clock source 26.32MHz */
/* Enable GPIO register interface clock */
LPC_CCU1->CLK_M4_GPIO_CFG = 1<<1 | 1<<0;
while (!(LPC_CCU1->CLK_M4_GPIO_STAT & CCU_CLK_STAT_RUN));
/* Enable LCD clock */
LPC_CCU1->CLK_M4_LCD_CFG = 1<<1 | 1<<0;
while (!(LPC_CCU1->CLK_M4_LCD_STAT & CCU_CLK_STAT_RUN));
/* Configure LCD controller pins -------------------------------------------*/
LPC_SCU->SFSP4_1 = LCD_PIN_SET | 2; /* P4_1: LCD_VD0 */
LPC_SCU->SFSP4_4 = LCD_PIN_SET | 2; /* P4_4: LCD_VD1 */
LPC_SCU->SFSP4_3 = LCD_PIN_SET | 2; /* P4_3: LCD_VD2 */
LPC_SCU->SFSP4_2 = LCD_PIN_SET | 2; /* P4_2: LCD_VD3 */
LPC_SCU->SFSP8_7 = LCD_PIN_SET | 3; /* P8_7: LCD_VD4 */
LPC_SCU->SFSP8_6 = LCD_PIN_SET | 3; /* P8_6: LCD_VD5 */
LPC_SCU->SFSP8_5 = LCD_PIN_SET | 3; /* P8_5: LCD_VD6 */
LPC_SCU->SFSP8_4 = LCD_PIN_SET | 3; /* P8_4: LCD_VD7 */
LPC_SCU->SFSP7_5 = LCD_PIN_SET | 3; /* P7_5: LCD_VD8 */
LPC_SCU->SFSP4_8 = LCD_PIN_SET | 2; /* P4_8: LCD_VD9 */
LPC_SCU->SFSP4_10 = LCD_PIN_SET | 2; /* P4_10: LCD_VD10 */
LPC_SCU->SFSP4_9 = LCD_PIN_SET | 2; /* P4_9: LCD_VD11 */
LPC_SCU->SFSP8_3 = LCD_PIN_SET | 3; /* P8_3: LCD_VD12 */
LPC_SCU->SFSPB_6 = LCD_PIN_SET | 2; /* PB_6: LCD_VD13 */
LPC_SCU->SFSPB_5 = LCD_PIN_SET | 2; /* PB_5: LCD_VD14 */
LPC_SCU->SFSPB_4 = LCD_PIN_SET | 2; /* PB_4: LCD_VD15 */
LPC_SCU->SFSP7_4 = LCD_PIN_SET | 3; /* P7_4: LCD_VD16 */
LPC_SCU->SFSP7_3 = LCD_PIN_SET | 3; /* P7_3: LCD_VD17 */
LPC_SCU->SFSP7_2 = LCD_PIN_SET | 3; /* P7_2: LCD_VD18 */
LPC_SCU->SFSP7_1 = LCD_PIN_SET | 3; /* P7_1: LCD_VD19 */
LPC_SCU->SFSPB_3 = LCD_PIN_SET | 2; /* PB_3: LCD_VD20 */
LPC_SCU->SFSPB_2 = LCD_PIN_SET | 2; /* PB_2: LCD_VD21 */
LPC_SCU->SFSPB_1 = LCD_PIN_SET | 2; /* PB_1: LCD_VD22 */
LPC_SCU->SFSPB_0 = LCD_PIN_SET | 2; /* PB_0: LCD_VD23 */
LPC_SCU->SFSP4_5 = LCD_PIN_SET | 2; /* P4_5: LCD_VSYNC */
LPC_SCU->SFSP4_6 = LCD_PIN_SET | 2; /* P4_6: LCD_EN */
LPC_SCU->SFSP4_7 = LCD_PIN_SET | 0; /* P4_7: LCD_DOTCLK */
LPC_SCU->SFSP7_0 = LCD_NPR_SET | 0; /* P7_0: LCD_BL_EN */
LPC_SCU->SFSP7_6 = LCD_PIN_SET | 3; /* P7_6: LCD_HSYNC */
/* Configure LCD controller ------------------------------------------------*/
LPC_RGU->RESET_CTRL0 = (1U << 16);
while ((LPC_RGU->RESET_ACTIVE_STATUS0 & (1U << 16)) == 0);
LPC_LCD->CTRL &= ~(1 << 0); /* Disable LCD */
LPC_LCD->INTMSK = 0; /* Disable all interrupts */
LPC_LCD->UPBASE = FRAME_BUFFER_ADDR;
/*ÏñËØΪ 1024*600 */
LPC_LCD->TIMH = (60 << 24) | /* Horizontal back porch */
(209 << 16) | /* Horizontal front porch */
(0 << 8) | /* Horizontal sync pulse width */
(63 << 2) ; /* Pixels-per-line 272=16*(16+1) 800=16*(49+1) ÿÐÐÏñËØ1024=(PLL+1)*16*/
LPC_LCD->TIMV = (12 << 24) | /* Vertical back porch */
(21 << 16) | /* Vertical front porch */
(0 << 10) | /* Vertical sync pulse width */
(599 << 0) ; /* Lines per panel */
LPC_LCD->POL = (1 << 26) | /* Bypass pixel clock divider */
(1023 << 16) | /* Clodcks per line: num of LCDCLKs */
(0 << 14) | /*ºó¼Ó µÍµçƽÓÐЧ*/
(0 << 13) | /* Invert panel clock */
(1 << 12) | /* Invert HSYNC */
(0 << 11) ; /* Invert VSYNC */
LPC_LCD->LE = (1 << 16) | /* LCDLE Enabled: 1, Disabled: 0 */
(9 << 0) ; /* Line-end delay: LCDCLK clocks - 1 */
LPC_LCD->CTRL = (1 << 11) | /* LCD Power Enable */
(1 << 5) | /* 0 = STN display, 1: TFT display */
(6 << 1) | /* Bits per pixel: 16bpp */
(1 << 8); /* Red and blue swapped */
for (i = 0; i < 256; i++) {
LPC_LCD->PAL[i] = 0; /* Clear palette */
}
LPC_LCD->CTRL |= (1 << 0); /* LCD enable */ |