Go Down

Topic: Help connecting Open-Smart ILI9327 SE 3.2" TFT to SPI (Read 465 times) previous topic - next topic

Bitcrusher

May 12, 2017, 04:27 am Last Edit: May 12, 2017, 04:33 am by Bitcrusher
Hi guys :)

First of all, I'd just like to say that this is my very first experience using Arduino and have never worked with software <-> hardware I/O before, and have only done software code till now.

I'm JUST starting out with Arduino and have bought a screen off aliexpress, the link https://www.aliexpress.com/item/3-2-TFT-LCD-Touch-Screen-Expansion-Shield-W-Touch-Pen-For-Arduino/32795070895.html, but beware that the item show on the product page and the one I received, we're different - a picture of the one I received are attached to this post though.

Currently the TFT shield is mounted on a Uno clone and I've tried different versions of the UTFT library that supports the ILI9327 chipset, but I've had no luck so far getting anything to show on the screen.

I have seen mentioned on the net something about 8bit and 16bit TFTs, but I have not yet figured out what it does - some of the UTFT library version I tried, did have a ILI9327_8 driver in them, so dunno if a 16 bit version of ILI9327 even exists.

As I understand it, it's possible to connect the TFT using different methods, I2C, SPI, or "custom" pins - I'm hoping to use the SPI port and the code I'm trying to is as follows:
Code: [Select]

// UTFT_ViewFont (C)2014 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a demo of the included fonts.
//
// This demo was made for modules with a screen resolution
// of 320x240 pixels.
//
// This program requires the UTFT library.
//

#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];

// Set the pins to the correct ones for your development shield
// ------------------------------------------------------------
// My chipKit Uno32/uC32 shield                : <display model>,38,39,40,41
// My chipKit Max32 shield                     : <display model>,82,83,84,85
// AquaLEDSource All in One Super Screw Shield : <display model>,82,83,84,85
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(ILI9327,38,39,40,41);

void setup()
{
  myGLCD.InitLCD();

  myGLCD.clrScr();
}

void loop()
{
  myGLCD.setColor(0, 255, 0);
  myGLCD.setBackColor(0, 0, 0);

  myGLCD.setFont(BigFont);
  myGLCD.print(" !\"#$%&'()*+,-./", CENTER, 0);
  myGLCD.print("0123456789:;<=>?", CENTER, 16);
  myGLCD.print("@ABCDEFGHIJKLMNO", CENTER, 32);
  myGLCD.print("PQRSTUVWXYZ[\\]^_", CENTER, 48);
  myGLCD.print("`abcdefghijklmno", CENTER, 64);
  myGLCD.print("pqrstuvwxyz{|}~ ", CENTER, 80);

  myGLCD.setFont(SmallFont);
  myGLCD.print(" !\"#$%&'()*+,-./0123456789:;<=>?", CENTER, 120);
  myGLCD.print("@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_", CENTER, 132);
  myGLCD.print("`abcdefghijklmnopqrstuvwxyz{|}~ ", CENTER, 144);

  myGLCD.setFont(SevenSegNumFont);
  myGLCD.print("0123456789", CENTER, 190);

  while(1) {};
}


Hope someone here can point out any obvious mistakes I've done, like SPI pin IDs or similar :)

david_prentice

Surely they supplied you with some working software.   And a schematic.

As far as I know,  there is no version of UTFT that supports the data bus on your pcb.    And no version that supports ILI9327 with 8-bit parallel interface.

MCUFRIEND_kbv supports several 240x400 controllers including ILI9326, ILI9327, SPFD5420, R61509.   Open-Smart have used some unusual controllers in the past.

I think that I have published SPECIALs for MCUFRIEND_kbv to work with this unusual data bus.
The first step is to determine what controller is actually mounted on the screen by editing the pin numbers in LCD_ID_readreg.ino

Note that the SPI bus is likely to go haywire every time that you do a read operation on the TFT.  The SD library should cope.

David.

Bitcrusher

#2
May 12, 2017, 11:38 pm Last Edit: May 12, 2017, 11:50 pm by Bitcrusher
I ran the LCD_ID_readreg from your code repo, but am unsure about the results:

Here it is with the TFT shield attached:
Code: [Select]
Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 04 04 04 04 Manufacturer ID
reg(0x0009) 08 08 08 08 08 Status Register
reg(0x000A) 08 08 Get Power Mode
reg(0x000C) 0C 0C Get Pixel Format
reg(0x0061) 20 20 RDID1 HX8347-G
reg(0x0062) 20 20 RDID2 HX8347-G
reg(0x0063) 20 20 RDID3 HX8347-G
reg(0x0064) 24 24 RDID1 HX8347-A
reg(0x0065) 24 24 RDID2 HX8347-A
reg(0x0066) 24 24 RDID3 HX8347-A
reg(0x0067) 24 24 RDID Himax HX8347-A
reg(0x0070) 20 20 Panel Himax HX8347-A
reg(0x00A1) 20 20 F3 20 20 RD_DDB SSD1963
reg(0x00B0) 20 20 RGB Interface Signal Control
reg(0x00B4) 24 24 Inversion Control
reg(0x00B6) 24 24 24 24 24 Display Control
reg(0x00B7) 24 26 Entry Mode Set
reg(0x00BF) 2E 2E 2C 2C 2C 2C ILI9481, HX8357-B
reg(0x00C0) 00 00 00 00 00 00 00 00 00 Panel Control
reg(0x00C8) 08 08 08 08 08 08 08 08 08 08 08 08 08 GAMMA
reg(0x00CC) 0C 0C Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00D4) 04 04 04 04 Novatek ID
reg(0x00DA) 08 08 RDID1
reg(0x00DB) 08 08 RDID2
reg(0x00DC) 0C 0C RDID3
reg(0x00E0) 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 GAMMA-P
reg(0x00E1) 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 GAMMA-N
reg(0x00EF) 2C 2C 2C 2C 2C 2C ILI9327
reg(0x00F2) 20 20 20 20 20 20 20 20 20 20 20 20 Adjust Control 2
reg(0x00F6) 24 24 24 24 Interface Control


And here it is without the TFT shield:
Code: [Select]
Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 04 04 04 04 Manufacturer ID
reg(0x0009) 09 09 09 09 09 Status Register
reg(0x000A) 0A 0A Get Power Mode
reg(0x000C) 0C 0C Get Pixel Format
reg(0x0061) 61 61 RDID1 HX8347-G
reg(0x0062) 62 62 RDID2 HX8347-G
reg(0x0063) 63 63 RDID3 HX8347-G
reg(0x0064) 64 64 RDID1 HX8347-A
reg(0x0065) 65 65 RDID2 HX8347-A
reg(0x0066) 66 66 RDID3 HX8347-A
reg(0x0067) 67 67 RDID Himax HX8347-A
reg(0x0070) 70 70 Panel Himax HX8347-A
reg(0x00A1) A1 A1 A1 A1 A1 RD_DDB SSD1963
reg(0x00B0) B0 B0 RGB Interface Signal Control
reg(0x00B4) B4 B4 Inversion Control
reg(0x00B6) B6 B6 B6 B6 B6 Display Control
reg(0x00B7) B7 B7 Entry Mode Set
reg(0x00BF) BF BF BF BF BF BF ILI9481, HX8357-B
reg(0x00C0) C0 C0 C0 C0 C0 C0 C0 C0 C0 Panel Control
reg(0x00C8) C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 GAMMA
reg(0x00CC) CC CC Panel Control
reg(0x00D0) D0 D0 D0 Power Control
reg(0x00D2) D2 D2 D2 D2 D2 NVM Read
reg(0x00D3) D3 D3 D3 D3 ILI9341, ILI9488
reg(0x00D4) D4 D4 D4 D4 Novatek ID
reg(0x00DA) DA DA RDID1
reg(0x00DB) DB DB RDID2
reg(0x00DC) DC DC RDID3
reg(0x00E0) E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 GAMMA-P
reg(0x00E1) E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 GAMMA-N
reg(0x00EF) EF EF EF EF EF EF ILI9327
reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 Adjust Control 2
reg(0x00F6) F6 F6 F6 F6 Interface Control


Is it weird that it mentions ILI9327 in both with and without the TFT shield?

david_prentice

Quote
The first step is to determine what controller is actually mounted on the screen by editing the pin numbers in LCD_ID_readreg.ino
You have made no effort to edit the pin numbers.

Anyway,  I had a look.   The official v2.9.5 Release already supports OpenSmart.   You must edit:

mcufriend_shield.h:
Code: [Select]
#define USE_SPECIAL

mcufriend_special.h:
Code: [Select]
#define USE_OPENSMART_SHIELD_PINOUT

There are instructions in mcufriend_how_to.txt

When you run any example,  they generally report the ID to the Serial Terminal.   If it is an ILI9326, SPFD5420, ST7793, ... you must #define the appropriate #define in MCUFRIEND_kbv.cpp


Please let me know how you get on.

David.

Bitcrusher

You have made no effort to edit the pin numbers.
Hi again David

You're right, I'd made no practical effort on mapping out the pins, as I had no real experience with microprocessors/hardware to draw on.
Since then though, I've gotten some a more rudimentary grasp of it and I'm pretty confident I've mapped out every pin, except for the LCD_RST, which I think can only be on the SPI pins (see attached pic), but I have no idea how to address it - I've tried PC6 and similar, but they don't exist.

I tried using the mapped out pins, with the LCD_ID_reader from http://misc.ws/2015/01/24/lcd-touch-screen-information/ and it can make the screen white, even though it should make it red - but at least it does "something", so that's progress ;)

The script mentioned can't read the ID and gives me 0x0000 and this is what yours outputs:
Code: [Select]
Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 54 00 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 00 08 Get Power Mode
reg(0x000C) 00 06 Get Pixel Format
reg(0x0061) 06 06 RDID1 HX8347-G
reg(0x0062) 06 06 RDID2 HX8347-G
reg(0x0063) 06 06 RDID3 HX8347-G
reg(0x0064) 06 06 RDID1 HX8347-A
reg(0x0065) 06 06 RDID2 HX8347-A
reg(0x0066) 06 06 RDID3 HX8347-A
reg(0x0067) 06 06 RDID Himax HX8347-A
reg(0x0070) 06 06 Panel Himax HX8347-A
reg(0x00A1) 00 00 FF 00 00 RD_DDB SSD1963
reg(0x00B0) 00 00 RGB Interface Signal Control
reg(0x00B4) 00 00 Inversion Control
reg(0x00B6) 00 00 00 00 00 Display Control
reg(0x00B7) 00 00 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 00 35 00 00 01 02 02 02 Panel Control
reg(0x00C8) 02 44 44 44 44 08 10 44 44 44 44 08 10 GAMMA
reg(0x00CC) 10 10 Panel Control
reg(0x00D0) 10 07 04 Power Control
reg(0x00D2) 04 01 44 44 44 NVM Read
reg(0x00D3) 44 01 44 44 ILI9341, ILI9488
reg(0x00D4) 44 01 44 44 Novatek ID
reg(0x00DA) 00 54 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-N
reg(0x00EF) 00 02 04 93 27 FF ILI9327
reg(0x00F2) FF FF FF FF FF FF FF FF FF FF FF FF Adjust Control 2
reg(0x00F6) FF FF FF FF Interface Control


As I read the code, it's because of that damn RESET pin I can't figure out how to address.

Hope this is better that what I "provided" last time :)

david_prentice

Mapping the pins was quite simple.  You just look at the printed legends on the pcb.   e.g. DB5 (LCD_D5) goes to 13,  LCD_D1 goes to 9, ...

Your photo does not seem to show a LCD_RST.  I guess that the pcb connects it to the AVR_RESET pin.

Anyway, #4 shows that you got LCD_ID_readreg working.   You have a genuine ILI9327.

If you followed the instructions in #3 (or in mcufriend_how_to.txt) ,  the MCUFRIEND_kbv library would just work.

David.


Go Up