📄 ili9320程序.c
字号:
/*************************************************
初始化程序
*************************************************/
void initial()
{
//************* Reset LCD Driver ****************//
_WR = 1;
RESETB = 1;
delay100ms();
RESETB = 0;
delay100ms();
RESETB = 1;
delay100ms();
// WCOM()函数说明:
// WCOM(Register, High_8bit_Parameter, Low_8bit_Parameter);
//************* Start Initial Sequence **********//
WCOM(0x00, 0x00, 0x01); // Start internal OSC.
WCOM(0x01, 0x01, 0x00); // set SS and SM bit
WCOM(0x02, 0x04, 0x00); // set 1 line inversion
WCOM(0x03, 0x10, 0x38); // set GRAM write direction and BGR=1.
//WCOM(0x03, 0x10, 0xB0); //vertical scan
WCOM(0x04, 0x00, 0x00); // Resize register
WCOM(0x08, 0x02, 0x02); // set the back porch and front porch
WCOM(0x09, 0x00, 0x00); // set non-display area refresh cycle ISC[3:0]
WCOM(0x0A, 0x00, 0x00); // FMARK function
WCOM(0x0C, 0x00, 0x00); // RGB interface setting
WCOM(0x0D, 0x00, 0x00); // Frame marker Position
WCOM(0x0F, 0x00, 0x00); // RGB interface polarity
//*************Power On sequence ****************// WCOM(0x51, 0x00, 0xEF);
WCOM(0x10, 0x00, 0x00); // SAP, BT[3:0], AP, DSTB, SLP, STB
WCOM(0x11, 0x00, 0x07); // DC1[2:0], DC0[2:0], VC[2:0]
WCOM(0x12, 0x00, 0x00); // VREG1OUT voltage
WCOM(0x13, 0x00, 0x00); // VDV[4:0] for VCOM amplitude
delay50ms(); // Dis-charge capacitor power voltage
WCOM(0x10, 0x17, 0xB0); // SAP, BT[3:0], AP, DSTB, SLP, STB
WCOM(0x11, 0x00, 0x01); // DC1[2:0], DC0[2:0], VC[2:0]
delay50ms(); // Delay 50ms
WCOM(0x12, 0x01, 0x3c); // VREG1OUT voltage
delay50ms(); // Delay 50ms
WCOM(0x13, 0x18, 0x00); // VDV[4:0] for VCOM amplitude
WCOM(0x29, 0x00, 0x0c); // VCM[4:0] for VCOMH
delay50ms(); // Delay 50ms
WCOM(0x20, 0x00, 0x00); // GRAM horizontal Address
WCOM(0x21, 0x00, 0x00); // GRAM Vertical Address
WCOM(0x2B, 0x00, 0x20); // Frame Rate and Color Control-----16M_EN, Dither, FR_SEL[1:0]
// ---------- Gamma Control ---------- //
WCOM(0x30, 0x00, 0x00);
WCOM(0x31, 0x03, 0x06);
WCOM(0x32, 0x02, 0x00);
WCOM(0x35, 0x01, 0x07);
WCOM(0x36, 0x04, 0x04);
WCOM(0x37, 0x06, 0x06);
WCOM(0x38, 0x01, 0x05);
WCOM(0x39, 0x07, 0x07);
WCOM(0x3C, 0x06, 0x00);
WCOM(0x3D, 0x08, 0x07);
// ---------- Window Address Area ---------- //
WCOM(0x50, 0x00, 0x00); // Horizontal GRAM Start Address-----HSA[7:0]
WCOM(0x51, 0x00, 0xEF); // Horizontal GRAM End Address-----HEA[7:0]
WCOM(0x52, 0x00, 0x00); // Vertical GRAM Start Address-----VSA[8:0]
WCOM(0x53, 0x01, 0x3F); // Vertical GRAM Start Address-----VEA[8:0]
// ---------- Gate Scan Control ---------- //
WCOM(0x60, 0x27, 0x00); // GS, NL[5:0], SCN[5:0]
//WCOM(0x60, 0xA7, 0x00); //vertical scan
WCOM(0x61, 0x00, 0x01); // NDL,VLE, REV
WCOM(0x6A, 0x00, 0x00); // VL[8:0]
// ---------- Partial Display Control ---------- //
WCOM(0x80, 0x00, 0x00); // Partial Image 1 Display Position-----PTDP0[8:0]
WCOM(0x81, 0x00, 0x00); // Partial Image 1 Start Address-----PTSA0[8:0]
WCOM(0x82, 0x00, 0x00); // Partial Image 1 End Address-----PTEA0[8:0]
WCOM(0x83, 0x00, 0x00); // Partial Image 2 Display Position-----PTDP1[8:0]
WCOM(0x84, 0x00, 0x00); // Partial Image 2 Start Address-----PTSA1[8:0]
WCOM(0x85, 0x00, 0x00); // Partial Image 2 Start Address-----PTEA1[8:0]
// ---------- Panel Interface Control ---------- //
WCOM(0x90, 0x00, 0x13); // Panel Interface Control 1-----DIVI[1:0], RTNI[4:0]
WCOM(0x92, 0x00, 0x00); // Panel Interface Control 2-----NOWI[2:0]
WCOM(0x93, 0x00, 0x03); // Panel Interface Control 3-----MCPI[2:0]
WCOM(0x95, 0x01, 0x10); // Panel Interface Control 4-----DIVE[1:0], RTNE[5:0]
WCOM(0x97, 0x00, 0x00); // Panel Interface Control 5-----NOWE[3:0]
WCOM(0x98, 0x00, 0x00); // Panel Interface Control 6-----MCPE[2:0]
WCOM(0x07, 0x00, 0x01); // Display Control 1
delay50ms();
WCOM(0x07, 0x00, 0x21); // Display Control 1
WCOM(0x07, 0x00, 0x23); // Display Control 1
delay50ms();
WCOM(0x07, 0x01, 0x73); // Display Control 1-----262K color and display ON
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -