看了一下,LZ是用GPIO来模拟的。
贴出我的可以用的代码,供参考:
void LCD_Init(void)
{
// Configure the LCD Control pins --------------------------------------------
LCD_CtrlLinesConfig();
// Configure the Parallel interface ------------------------------------------
LCD_PrllConfig();
delay_ms(50); // Delay 50 ms
LCD_ID = LCD_ReadReg(0x00);
if(LCD_ID == 0x9325)
{
LCD_Type = NEW_LCD_9325;
// Start Initial Sequence
LCD_WriteReg(R0, 0x0001); // Start internal OSC.
LCD_WriteReg(R1, 0x0100); // set SS and SM bit
LCD_WriteReg(R2, 0x0700); // set 1 line inversion
LCD_WriteReg(R3, 0x1018); // set GRAM write direction and BGR=1.
LCD_WriteReg(R4, 0x0000); // Resize register
LCD_WriteReg(R8, 0x0202); // set the back porch and front porch
LCD_WriteReg(R9, 0x0000); // set non-display area refresh cycle ISC[3:0]
LCD_WriteReg(R10, 0x0000); // FMARK function
LCD_WriteReg(R12, 0x0000); // RGB interface setting
LCD_WriteReg(R13, 0x0000); // Frame marker Position
LCD_WriteReg(R15, 0x0000); // RGB interface polarity
// Power On sequence -------------------------------------------------------
LCD_WriteReg(R16, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
LCD_WriteReg(R17, 0x0000); // DC1[2:0], DC0[2:0], VC[2:0]
LCD_WriteReg(R18, 0x0000); // VREG1OUT voltage
LCD_WriteReg(R19, 0x0000); // VDV[4:0] for VCOM amplitude
delay_ms(200); // Dis-charge capacitor power voltage (200ms)
LCD_WriteReg(R16, 0x17B0); // SAP, BT[3:0], AP, DSTB, SLP, STB
LCD_WriteReg(R17, 0x0137); // DC1[2:0], DC0[2:0], VC[2:0]
delay_ms(50); // Delay 50 ms
LCD_WriteReg(R18, 0x0139); // VREG1OUT voltage
delay_ms(50); // Delay 50 ms
LCD_WriteReg(R19, 0x1d00); // VDV[4:0] for VCOM amplitude
LCD_WriteReg(R41, 0x0013); // VCM[4:0] for VCOMH
delay_ms(50); // Delay 50 ms
LCD_WriteReg(R32, 0x0000); // GRAM horizontal Address
LCD_WriteReg(R33, 0x0000); // GRAM Vertical Address
// Adjust the Gamma Curve (ILI9325)-----------------------------------------
LCD_WriteReg(R48, 0x0007);
LCD_WriteReg(R49, 0x0302);
LCD_WriteReg(R50, 0x0105);
LCD_WriteReg(R53, 0x0206);
LCD_WriteReg(R54, 0x0808);
LCD_WriteReg(R55, 0x0206);
LCD_WriteReg(R56, 0x0504);
LCD_WriteReg(R57, 0x0007);
LCD_WriteReg(R60, 0x0105);
LCD_WriteReg(R61, 0x0808);
// Set GRAM area -----------------------------------------------------------
LCD_WriteReg(R80, 0x0000); // Horizontal GRAM Start Address
LCD_WriteReg(R81, 0x00EF); // Horizontal GRAM End Address
LCD_WriteReg(R82, 0x0000); // Vertical GRAM Start Address
LCD_WriteReg(R83, 0x013F); // Vertical GRAM End Address
LCD_WriteReg(R96, 0xA700); // Gate Scan Line(GS=1, scan direction is G320~G1)
LCD_WriteReg(R97, 0x0001); // NDL,VLE, REV
LCD_WriteReg(R106, 0x0000); // set scrolling line
// Partial Display Control -------------------------------------------------
LCD_WriteReg(R128, 0x0000);
LCD_WriteReg(R129, 0x0000);
LCD_WriteReg(R130, 0x0000);
LCD_WriteReg(R131, 0x0000);
LCD_WriteReg(R132, 0x0000);
LCD_WriteReg(R133, 0x0000);
// Panel Control -----------------------------------------------------------
LCD_WriteReg(R144, 0x0010);
LCD_WriteReg(R146, 0x0000);
LCD_WriteReg(R147, 0x0003);
LCD_WriteReg(R149, 0x0110);
LCD_WriteReg(R151, 0x0000);
LCD_WriteReg(R152, 0x0000);
// set GRAM write direction and BGR=1
// I/D=00 (Horizontal : increment, Vertical : decrement)
// AM=1 (address is updated in vertical writing direction)
LCD_WriteReg(R3, 0x1018);
LCD_WriteReg(R7, 0x0133); // 262K color and display ON
return;
}
// Start Initial Sequence (ILI9320)-------------------------------------------
LCD_WriteReg(R229, 0x8000); // Set the internal vcore voltage
LCD_WriteReg(R0, 0x0001); // Start internal OSC.
LCD_WriteReg(R1, 0x0100); // set SS and SM bit
LCD_WriteReg(R2, 0x0700); // set 1 line inversion
LCD_WriteReg(R3, 0x1030); // set GRAM write direction and BGR=1.
LCD_WriteReg(R4, 0x0000); // Resize register
LCD_WriteReg(R8, 0x0202); // set the back porch and front porch
LCD_WriteReg(R9, 0x0000); // set non-display area refresh cycle ISC[3:0]
LCD_WriteReg(R10, 0x0000); // FMARK function
LCD_WriteReg(R12, 0x0000); // RGB interface setting
LCD_WriteReg(R13, 0x0000); // Frame marker Position
LCD_WriteReg(R15, 0x0000); // RGB interface polarity
// Power On sequence ---------------------------------------------------------
LCD_WriteReg(R16, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
LCD_WriteReg(R17, 0x0000); // DC1[2:0], DC0[2:0], VC[2:0]
LCD_WriteReg(R18, 0x0000); // VREG1OUT voltage
LCD_WriteReg(R19, 0x0000); // VDV[4:0] for VCOM amplitude
delay_ms(200); // Dis-charge capacitor power voltage (200ms)
LCD_WriteReg(R16, 0x17B0); // SAP, BT[3:0], AP, DSTB, SLP, STB
LCD_WriteReg(R17, 0x0137); // DC1[2:0], DC0[2:0], VC[2:0]
delay_ms(50); // Delay 50 ms
LCD_WriteReg(R18, 0x0139); // VREG1OUT voltage
delay_ms(50); // Delay 50 ms
LCD_WriteReg(R19, 0x1d00); // VDV[4:0] for VCOM amplitude
LCD_WriteReg(R41, 0x0013); // VCM[4:0] for VCOMH
delay_ms(50); // Delay 50 ms
LCD_WriteReg(R32, 0x0000); // GRAM horizontal Address
LCD_WriteReg(R33, 0x0000); // GRAM Vertical Address
// Adjust the Gamma Curve
LCD_WriteReg(R48, 0x0000);
LCD_WriteReg(R49, 0x0007);
LCD_WriteReg(R50, 0x0103);
LCD_WriteReg(R53, 0x0407);
LCD_WriteReg(R54, 0x090F);
LCD_WriteReg(R55, 0x0404);
LCD_WriteReg(R56, 0x0400);
LCD_WriteReg(R57, 0x0404);
LCD_WriteReg(R60, 0x0000);
LCD_WriteReg(R61, 0x0400);
// Set GRAM area -------------------------------------------------------------
LCD_WriteReg(R80, 0x0000); // Horizontal GRAM Start Address
LCD_WriteReg(R81, 0x00EF); // Horizontal GRAM End Address
LCD_WriteReg(R82, 0x0000); // Vertical GRAM Start Address
LCD_WriteReg(R83, 0x013F); // Vertical GRAM End Address
LCD_WriteReg(R96, 0x2700); // Gate Scan Line
LCD_WriteReg(R97, 0x0001); // NDL,VLE, REV
LCD_WriteReg(R106, 0x0000); // set scrolling line
// Partial Display Control ---------------------------------------------------
LCD_WriteReg(R128, 0x0000);
LCD_WriteReg(R129, 0x0000);
LCD_WriteReg(R130, 0x0000);
LCD_WriteReg(R131, 0x0000);
LCD_WriteReg(R132, 0x0000);
LCD_WriteReg(R133, 0x0000);
// Panel Control -------------------------------------------------------------
LCD_WriteReg(R144, 0x0010);
LCD_WriteReg(R146, 0x0000);
LCD_WriteReg(R147, 0x0003);
LCD_WriteReg(R149, 0x0110);
LCD_WriteReg(R151, 0x0000);
LCD_WriteReg(R152, 0x0000);
// set GRAM write direction and BGR=1
// I/D=01 (Horizontal : increment, Vertical : decrement)
// AM=1 (address is updated in vertical writing direction)
LCD_WriteReg(R3, 0x1018);
LCD_WriteReg(R7, 0x0173); // 262K color and display ON
} |