AnsweredAssumed Answered

STM32F411RE ILI9225B 8bit parallel interfacing initialization problems

Question asked by kedopofe kedopofe on Dec 2, 2017
Latest reply on Dec 3, 2017 by kedopofe kedopofe

Hi everyone!

 

I want to connect 2" OpenSmart TFT LCD display (Image: Click here) with a touchscreen on STM32F411RE. Display characteristics are:

- Driver IC: ILI9225
- Touchscreen type: resistive touchscreen.
- Resolution: 176X220, 16-bit (262,000) color
- Logic level: 3.3V;

Display datasheet: Click here

Connections made:
DISPLAY          STM
GND                 GND
+3.3V               +3.3V
CS                     D0
RS                     D1
WR                    D2
RD                     D3
RST                   D4
LED                  GND
DB0                   A0
DB1                   A1
DB2                   A2
DB3                   A3
DB4                   A4
DB5                   A5
DB6                   A6
DB7                   A7

Part of my code and how it's work

void writeDataLines(uint8_t value)
{
     DB0_GPIO->ODR = value;
     mWR_LOW
     mWR_HIGH
}

uint32_t readDataLines()
{
     mRD_LOW
     mRD_HIGH
     return DB0_GPIO->IDR & 0x00FF;
}

uint16_t ILI9225_ReadRegister(uint8_t reg)
{
     uint8_t  reg_h=0,reg_l=0;
     uint16_t result=0;

     mRS_LOW
     mCS_LOW

     //Send register higher and lower byte
     writeDataLines(0x00);
     writeDataLines(reg);

     //Read register data
     readOnDataLines();
     mRS_HIGH

     reg_h = readDataLines();
     reg_l = readDataLines();

     mCS_HIGH

     writeOnDataLines();

     result =((uint16_t)reg_h << 8) | reg_l;
     return result;
}

void ILI9225_WriteRegister(uint8_t reg,uint16_t val)
{
     mCS_LOW
     mRS_LOW

     //Send register address

     writeDataLines(0x00);
     writeDataLines(reg);

     mRS_HIGH

     //Send register data
     writeDataLines(val >> 8);
     writeDataLines(val & 0xFF);

     mCS_HIGH
}

 

WriteOnDataLines() and ReadOnDataLines() just configures DB0-DB7 pins as input or output. I read successfully ID register (0x00h) with result 0x9225, so display have an ILI9225B controller, excellent. But initialization of display not working. Every time after initialization the screen is white. Here is code of initialization

 

/* Reset power control */
     ILI9225_WriteRegister(ILI9225_POWER_CTRL1, 0x0000); // Set SAP,DSTB,STB
     ILI9225_WriteRegister(ILI9225_POWER_CTRL2, 0x0000); // Set APON,PON,AON,VCI1EN,VC
     ILI9225_WriteRegister(ILI9225_POWER_CTRL3, 0x0000); // Set BT,DC1,DC2,DC3
     ILI9225_WriteRegister(ILI9225_POWER_CTRL4, 0x0000); // Set GVDD
     ILI9225_WriteRegister(ILI9225_POWER_CTRL5, 0x0000); // Set VCOMH/VCOML voltage

     MDelay_ms(40);

     /* Power-on sequence */
     ILI9225_WriteRegister(ILI9225_POWER_CTRL2, 0x0018); // Set APON,PON,AON,VCI1EN,VC
     ILI9225_WriteRegister(ILI9225_POWER_CTRL3, 0x6121); // Set BT,DC1,DC2,DC3
     ILI9225_WriteRegister(ILI9225_POWER_CTRL4, 0x006F); // Set GVDD   /*007F 0088 */
     ILI9225_WriteRegister(ILI9225_POWER_CTRL5, 0x495F); // Set VCOMH/VCOML voltage
     ILI9225_WriteRegister(ILI9225_POWER_CTRL1, 0x0800); // Set SAP,DSTB,STB

     MDelay_ms(10);

     ILI9225_WriteRegister(ILI9225_POWER_CTRL2, 0x103B); // Set APON,PON,AON,VCI1EN,VC

     MDelay_ms(50);

     /* Configure display */
     ILI9225_WriteRegister(ILI9225_DRIVER_OUTPUT_CTRL, 0x011C);    // Set the display line number and display direction
     ILI9225_WriteRegister(ILI9225_LCD_AC_DRIVING_CTRL, 0x0100);   // Set 1 line inversion
     ILI9225_WriteRegister(ILI9225_ENTRY_MODE, 0x1030);                  // Set GRAM write direction and BGR=1.
     ILI9225_WriteRegister(ILI9225_DISP_CTRL1, 0x0000);                  // Display off
     ILI9225_WriteRegister(ILI9225_BLANK_PERIOD_CTRL1, 0x0808);    // Set the back porch and front porch
     ILI9225_WriteRegister(ILI9225_FRAME_CYCLE_CTRL, 0x1100);      // Set the clocks number per line
     ILI9225_WriteRegister(ILI9225_INTERFACE_CTRL, 0x0000);        // CPU interface
     ILI9225_WriteRegister(ILI9225_OSC_CTRL, 0x0D01);              // Set Osc  /*0e01*/
     MDelay_ms(10);
     ILI9225_WriteRegister(ILI9225_VCI_RECYCLING, 0x0020);             // Set VCI recycling
     ILI9225_WriteRegister(ILI9225_RAM_ADDR_SET1, 0x0000);         // Set RAM Address
     ILI9225_WriteRegister(ILI9225_RAM_ADDR_SET2, 0x0000);         // Set RAM Address

     /* Set GRAM area */
     ILI9225_WriteRegister(ILI9225_GATE_SCAN_CTRL, 0x0000);            // Set full display scan
     ILI9225_WriteRegister(ILI9225_VERTICAL_SCROLL_CTRL1, 0x0000); // Turn off vertical scroll
     ILI9225_WriteRegister(ILI9225_VERTICAL_SCROLL_CTRL2, 0x0000);
     ILI9225_WriteRegister(ILI9225_VERTICAL_SCROLL_CTRL3, 0x0000);
     ILI9225_WriteRegister(ILI9225_PARTIAL_DRIVING_POS1, 0x00DB);
     ILI9225_WriteRegister(ILI9225_PARTIAL_DRIVING_POS2, 0x0000);
     //Set full screen window
     ILI9225_WriteRegister(ILI9225_HORIZONTAL_WINDOW_ADDR1, 0x00AF); //Window horizontal end   address
     ILI9225_WriteRegister(ILI9225_HORIZONTAL_WINDOW_ADDR2, 0x0000); //Window horizontal start address
     ILI9225_WriteRegister(ILI9225_VERTICAL_WINDOW_ADDR1, 0x00DB);   //Window vertical   end   address
     ILI9225_WriteRegister(ILI9225_VERTICAL_WINDOW_ADDR2, 0x0000);   //Window vertical   start address

     /* Set GAMMA curve */

     // Gamma for positive polarity
     ILI9225_WriteRegister(ILI9225_GAMMA_CTRL1, 0x0000);
     ILI9225_WriteRegister(ILI9225_GAMMA_CTRL2, 0x0808);
     ILI9225_WriteRegister(ILI9225_GAMMA_CTRL3, 0x080A);
     // Gradient for positive polarity
     ILI9225_WriteRegister(ILI9225_GAMMA_CTRL4, 0x000A);
     // Gama for negative polarity
     ILI9225_WriteRegister(ILI9225_GAMMA_CTRL5, 0x0A08);
     ILI9225_WriteRegister(ILI9225_GAMMA_CTRL6, 0x0808);
     ILI9225_WriteRegister(ILI9225_GAMMA_CTRL7, 0x0000);
     // Gradient for negative polarity
     ILI9225_WriteRegister(ILI9225_GAMMA_CTRL8, 0x0A00);
     // Amplitude adj. for pos. polarity
     ILI9225_WriteRegister(ILI9225_GAMMA_CTRL9, 0x0710);
     //Amplitude adj. for neg. polarity
     ILI9225_WriteRegister(ILI9225_GAMMA_CTRL10, 0x0710);

     /* Turn on display */
     //Prepare panel by setting black color on normally black panel or white on norm. white panel
     ILI9225_WriteRegister(ILI9225_DISP_CTRL1, 0x0012);

     MDelay_ms(50);

     //Turn on display
     ILI9225_WriteRegister(ILI9225_DISP_CTRL1, 0x1017);

 

Could someone help me, what could go wrong? I checked with logic analyzer signals while writing data into register but everything was like in datasheet. Sometimes display color changes to dark gray but after restarting its white again.

Outcomes