void STM3210E_LCD_Init(void)
{
/* Configure the LCD Control pins --------------------------------------------*/
LCD_CtrlLinesConfig();
/* Configure the FSMC Parallel interface -------------------------------------*/
LCD_FSMCConfig();
Delay(5); /* delay 50 ms */
/* Check if the LCD is SPFD5408B Controller */
if(LCD_ReadReg(0x00) == 0x5408)
{
/* Start Initial Sequence ------------------------------------------------*/
LCD_WriteReg(R1, 0x0100); /* Set SS 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 18-bit System interface setting */
LCD_WriteReg(R13, 0x0000); /* Frame marker Position */
LCD_WriteReg(R15, 0x0000); /* RGB interface polarity, no impact */
/* 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(20); /* Dis-charge capacitor power voltage (200ms) */
LCD_WriteReg(R17, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */
Delay(5); /* Delay 50 ms */
LCD_WriteReg(R16, 0x12B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */
Delay(5); /* Delay 50 ms */
LCD_WriteReg(R18, 0x01BD); /* External reference voltage= Vci */
Delay(5);
LCD_WriteReg(R19, 0x1400); /* VDV[4:0] for VCOM amplitude */
LCD_WriteReg(R41, 0x000E); /* VCM[4:0] for VCOMH */
Delay(5); /* Delay 50 ms */
LCD_WriteReg(R32, 0x0000); /* GRAM horizontal Address */
LCD_WriteReg(R33, 0x013F); /* GRAM Vertical Address */
/* Adjust the Gamma Curve (SPFD5408B)-------------------------------------*/
LCD_WriteReg(R48, 0x0b0d);
LCD_WriteReg(R49, 0x1923);
LCD_WriteReg(R50, 0x1c26);
LCD_WriteReg(R51, 0x261c);
LCD_WriteReg(R52, 0x2419);
LCD_WriteReg(R53, 0x0d0b);
LCD_WriteReg(R54, 0x1006);
LCD_WriteReg(R55, 0x0610);
LCD_WriteReg(R56, 0x0706);
LCD_WriteReg(R57, 0x0304);
LCD_WriteReg(R58, 0x0e05);
LCD_WriteReg(R59, 0x0e01);
LCD_WriteReg(R60, 0x010e);
LCD_WriteReg(R61, 0x050e);
LCD_WriteReg(R62, 0x0403);
LCD_WriteReg(R63, 0x0607);
/* 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 */
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, 0x0112); /* 262K color and display ON */
return;
}
/* Start Initial Sequence ----------------------------------------------------*/
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(20); /* 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(5); /* Delay 50 ms */
LCD_WriteReg(R18, 0x0139); /* VREG1OUT voltage */
Delay(5); /* Delay 50 ms */
LCD_WriteReg(R19, 0x1d00); /* VDV[4:0] for VCOM amplitude */
LCD_WriteReg(R41, 0x0013); /* VCM[4:0] for VCOMH */
Delay(5); /* Delay 50 ms */
LCD_WriteReg(R32, 0x0000); /* GRAM horizontal Address */
LCD_WriteReg(R33, 0x0000); /* GRAM Vertical Address */
/* Adjust the Gamma Curve ----------------------------------------------------*/
LCD_WriteReg(R48, 0x0006);
LCD_WriteReg(R49, 0x0101);
LCD_WriteReg(R50, 0x0003);
LCD_WriteReg(R53, 0x0106);
LCD_WriteReg(R54, 0x0b02);
LCD_WriteReg(R55, 0x0302);
LCD_WriteReg(R56, 0x0707);
LCD_WriteReg(R57, 0x0007);
LCD_WriteReg(R60, 0x0600);
LCD_WriteReg(R61, 0x020b);
/* 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 */
}