Here is a initialization code for ILI9325, which is a 320x240 LCD driver. The code was tested on STM32F10X.
LCD_W_REG(0x07, 0); // DTE=0, D[1:0]=00, GON=0
LCD_W_REG(0x10, 0); // BT[2:0]=0, SAP=0
LCD_W_REG(0x11, 0); // VC[2:0]=0
LCD_W_REG(0x12, 0); // PON=0, VRH[3:0]=0
LCD_W_REG(0x13, 0); // VDV[4:0]=0
LCD_W_REG(0x29, 0x0); // VCM[5:0]=0
// DELAY 50MS
GUI_Delay(50);
LCD_W_REG(0x10, 0x0090); // BT[2:0]=0, AP[2:0}=001, APE=1, SAP=0
LCD_W_REG(0x11, 0x0); // DC1[2:0]=000, DC0[2:0]=000
LCD_W_REG(0x12, 0x0011); // VCIRE=0, PON=1, VRH[3:0}=0001
// DELAY 80MS
GUI_Delay(80);
LCD_W_REG(0x07, 0x0133); // BASEE=1, DTE=1, GON=1, D[1:0]=11
LCD_W_REG(0x10, 0x1090); // SAP=1
LCD_W_REG(0x2B, 0x000e); // frame rate 112hz
LCD_W_REG(0x0060, 0xA700); // Gate Scan Line
LCD_W_REG(0x0061, 0x0001); // REV=1
Showing posts with label LCD. Show all posts
Showing posts with label LCD. Show all posts
Saturday, 20 May 2017
Wednesday, 17 May 2017
ILI9341 initialization code for 16-bit interface
ILI9341 is a common LCD driver for 320x240 LCD displays. The graphic controller is pretty flexible, it can have serial or parallel interface, and the parallel interface can be 8, 9, or 16 bits wide. You can find handful of initialization codes for ILI9341 on the internet, some of them can be long and complicated. Here I provide a very simple one, it's for the 16-bit interface, and only has less than 10 lines of code.
It was tested on STM32F103 with external bus (SFMC)
#define LCD_ILI9341_CMD(index) ((*(volatile u16 *) ((u32)0x6C000000)) = ((u16)index))
#define LCD_ILI9341_Parameter(val) ((*(volatile u16 *) ((u32)0x6D000000)) = ((u16)(val)))
volatile u32 i;
GPIOG->BRR = LCD_RESET; //reset lcd
for (i=0; i< (0xAFFf<<2); i++); // delay
GPIOG->BSRR = LCD_RESET;
for (i=0; i< (0xAFFf<<2); i++);
/* Pixel Format Set (3Ah) */
LCD_ILI9341_CMD(0x3a);
LCD_ILI9341_Parameter(0x55); // set to 16bit per pixel
/* Sleep Out (11h) */
LCD_ILI9341_CMD(0x11);
for (i=0; i< (0xAFFf<<2); i++);
/* Display ON (29h) */
LCD_ILI9341_CMD(0x29);
It was tested on STM32F103 with external bus (SFMC)
#define LCD_ILI9341_CMD(index) ((*(volatile u16 *) ((u32)0x6C000000)) = ((u16)index))
#define LCD_ILI9341_Parameter(val) ((*(volatile u16 *) ((u32)0x6D000000)) = ((u16)(val)))
for (i=0; i< (0xAFFf<<2); i++); // delay
GPIOG->BSRR = LCD_RESET;
for (i=0; i< (0xAFFf<<2); i++);
/* Pixel Format Set (3Ah) */
LCD_ILI9341_CMD(0x3a);
LCD_ILI9341_Parameter(0x55); // set to 16bit per pixel
/* Sleep Out (11h) */
LCD_ILI9341_CMD(0x11);
for (i=0; i< (0xAFFf<<2); i++);
/* Display ON (29h) */
LCD_ILI9341_CMD(0x29);
Subscribe to:
Posts (Atom)