Read display identification information (04h)

Hi there,

My Display is a Chinese 2.8" display ILI9341 SPI with touch and SD. See picture

It does show nothing on the screen. I am using the adafruit library as this one was the only one which supports SPI with MOSI and MISO.

I tried to read out the driver chip info with the command 04h (0x04).

The Adafruit Library reads with the tft.readcommand8 only one byte. The command 04h would give 4 bytes out in regard to the Ilitek manual.

How can I get all 4 bytes?
Which library are you using with this TFT?

Regards
Sven

I don't know which library you are using.

void diag_reg(const __FlashStringHelper *name, uint8_t reg, uint8_t n)
{
    uint8_t x = reg;
    Serial.print(name);
    Serial.print(" (0x");
    Serial.print(x < 0x10 ? "0" : "");
    Serial.print(x, HEX);
    Serial.print("):");
    for (int i = 0; i < n; i++) {
        uint8_t x = tft.readcommand8(reg, i);
        Serial.print(x < 0x10 ? " 0" : " ");
        Serial.print(x, HEX);
    }
    Serial.println("");
}

void diag_show(void)
{
    diag_reg(F("ILI9488_RDDID"), 0x04, 5);
    diag_reg(F("ILI9488_RDIMGFMT"), 0x0A, 1);
    diag_reg(F("ILI9488_RDMADCTL"), 0x0B, 1);
    diag_reg(F("ILI9488_RDPIXFMT"), 0x0C, 1);
    diag_reg(F("ILI9488_RDSELFDIAG"), 0x0F, 1);
    diag_reg(F("ILI9488_DFUNCTR"), 0xb6, 5);
    diag_reg(F("ILI9488_PWCTR1"), 0xC0, 3);
    diag_reg(F("ILI9488_VMCTR1"), 0xC5, 3);
    diag_reg(F("ILI9488_VMCTR2"), 0xC7, 2);
    diag_reg(F("NVM Status   "), 0xD2, 3);
    diag_reg(F("ID4          "), 0xD3, 4);
    diag_reg(F("ILI9488_RDID1"), 0xDA, 2);
    diag_reg(F("ILI9488_RDID2"), 0xDB, 2);
    diag_reg(F("ILI9488_RDID3"), 0xDC, 2);
    diag_reg(F("GAMMAP       "), 0xE0, 16);
    diag_reg(F("GAMMAN       "), 0xE1, 16);
    diag_reg(F("INTERFACE    "), 0xf6, 4);
}

Don't worry about the ILI9488 names. It was originally written for ILI9341.

I think that the Adafruit_ILI9341 library has the readcommand8(register, index) method.

David.

Hi David,

Thanks for the code. Your code worked but still others than backlight nothing on the screen.
Can you tell me if the codes show something?

ILI9488_RDDID (0x04): 00 00 00 00 00
ILI9488_RDIMGFMT (0x0A): 08
ILI9488_RDMADCTL (0x0B): 48
ILI9488_RDPIXFMT (0x0C): 05
ILI9488_RDSELFDIAG (0x0F): 00
ILI9488_DFUNCTR (0xB6): 00 0A 82 27 04
ILI9488_PWCTR1 (0xC0): 00 21 00
ILI9488_VMCTR1 (0xC5): 3C 31 3C
ILI9488_VMCTR2 (0xC7): 86 86
NVM Status (0xD2): 03 00 00
ID4 (0xD3): 41 00 93 41
ILI9488_RDID1 (0xDA): 00 00
ILI9488_RDID2 (0xDB): 00 00
ILI9488_RDID3 (0xDC): 00 00
GAMMAP (0xE0): 00 0F 16 14 0A 0D 06 43 75 33 06 0E 00 0C 09 08
GAMMAN (0xE1): 00 08 2B 2D 04 10 04 3E 24 4E 04 0F 0E 35 38 0F
INTERFACE (0xF6): 00 01 00 00

ID4           (0xD3): 41 00 93 41

That is your ID. Note that the first byte read is always a dummy e.g.

ID4           (0xD3): xx 00 93 41

You don't say which library you are using. Or describe any of your hardware wiring.
But the registers are being read correctly. Look at the GAMMA entries. You can see whether you have ILI9341 or ILI9341V chip by looking at the power-up values.

Regarding the screen display. I have no idea what library you are using. Or if your initialisation is appropriate.

Note that there a several ILI9341 SPI libraries. And examples that run on Zero, Due, Teensy3.x, STM32, ESP8266, ESP32, ...
If you want to use 5V GPIO, you must convert the logic levels to 3.3V.

David.

Hi David,

Sorry, I am using a Nano V2 clone with the adafruit library:

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"

Any other library I should use? My display needs MISO and MOSI. I read that some libraries use only one of the data pins. My Display wants both.

The ILI9488_RDID1-3 values are all 00h. Is that OK? And is it OK that the ILI9488_RDSELFDIAG (0x0F) is 00?

Any hints?

Regards
Sven

From memory, the diagnostic registers i.e. 0x04 - 0x0F are readable directly. You don't need to read the index via 0xD9.

Note that the first read is valid with these special registers.

The ILI9488_RDID1-3 values are all 00h. Is that OK? And is it OK that the ILI9488_RDSELFDIAG (0x0F) is 00?

Looks ok. ID1-3 reflect whatever is stored in reg(0x04). And these registers are directly readable. (you must check with the datasheet)

I am always horrified by people that have 5V Nanos.
They buy the cheapie hardware and then can't afford resistors or level shifter chips.

And it is a lot more fiddly with external logic hardware than regular 3.3V Arduinos.

Please post a schematic of your wiring. Or a photo of the real-life wires.

David.

Hi David,

In regard to the Arduino specs the Nano is always 5V. The display is in regard to the seller 5V capable.
As labeled on my display module, the connections are

SCK - Arduino Pin 13
SDO(MISO) - Arduino Pin 12
SDI(MOSI) - Arduino Pin 11
CS - Arduino Pin 10
D/C - Arduino Pin 9
RESET (Display) - Arduino Pin 8
LED - Pin 6 (with PWM driven)
VCC - 5V
GND - GND

See pictures.

And installed a separate power supply in case the Nano cannot supply enough.
See pictures and code.

graphicstest2.ino (11.6 KB)

In regard to the Arduino specs the Nano is always 5V. The display is in regard to the seller 5V capable.

As you know, the Moon is made of green cheese.

These Red ILI9341 displays are very popular. There are lots of libraries. There is a lot of advice about wiring for 3.3V

And installed a separate power supply in case the Nano cannot supply enough.

The controller takes about 20mA. The backlight needs about 50mA. It is your responsibility to restrict the LED current. This will cost you a whole resistor.

Your construction is an excellent way to do things. It also makes it easy to add series resistors or voltage dividers.

Resistors are not expensive. But you can buy level-shifter i.c. from Ebay with several "channels".
Life is so much simpler with 3.3V STM32 or SAM controllers.

David.

Hi David,

Added a resistor to LED and run several tests. The display does not show anything still. Just the back light. Can the 5V operation cause the problem?

Or could the Adafruit library not be compatible with this TFT?

The ILI9341 chip is responding to the Arduino (see code and result from the serial monitor attached), just the TFT shows no content.

Any advice or other ideas where to look?

Regrads
Sven

graphicstest2.ino (11.9 KB)

Your display is 3.3V

You can quote as many Ebay vendors as you like. I can probably find an equivalent number of "green cheese" advocates.

Yes, your construction method is an excellent way to make a mechanically reliable project.
And it is very easy to mount series resistors or voltage dividers.

If you had placed the Nano on one side of your protoboard, you could have mounted a purpose level shifter i.c.

You might have damaged the ILI9341 with 5V logic. But it may have survived.
Please let us know how you get on (after you have added resistors or i.c.).

David.

Thanks David, will do.

Sven

Hi,

Made a new board to 3,15V with resistors. 2,7k and 4.7k (to GND). No result at all. The Arduino gives all registers back as 00h. Tried both VCC to 3,3V and 5V. No result on the screen too.

When I put it back to the 5v board, it gives out the old results, as shown above. The ILI responses but nothing on the screen.

Any one a clou?

Regards
Sven

Go on. You could have posted your schematic. A pencil drawing is fine.

Or you could have taken an accurate photo of your protoboard. e.g. showing the resistors and different coloured DuPont cables.

A photo of a "switched off" DMM is a bit pointless.
I would assume that someone with soldering skills probably knows how to use Ohm's and Kirchoff's Laws.

What is less obvious is Adafruit's trick of example constructors which omit the LCD_RST argument.
Your Red Display does not have a pullup on RST. Adafruit's Displays do have a pullup on RST.

I have suggested Bodmer's libraries for many TFTs.
But one of the most useful pages from Bodmer is this instructable

There are several Tutorials on wiring your SPI Display. Note that many Tutorials on the Internet are complete crap. e.g. no capacitors, no level shifters, ...
If you are following a Tutorial, please post a link to it. Readers might advise whether it is good or bad.

David.

Thanks, will do tomorrow. Getting late today.

Regards
Sven

Hi David,

Will the INPUT_PULLUP command do or do I need an external resistor? For a pullup resistor do I need a 1Meg Ohm or a different value?

Regards
Sven

@Sven,

Post your schematic or a good photo.

2k7 and 4k7 should be fine as a voltage divider.
Bodmer uses 1k2 and 1k8.

I would be happy with any voltage divider with a similar division ratio. With total load anywhere between 3k0 and 30k0. e.g. 12k, 18k or 10k, 20k

1M0 is not a realistic value.

The advantage of schematic or (good) photo is that a reader can see everything in one go.
And offer practical advice for a solution.

David.

David,

Got it to run with the Bodmer Lib.

Maybe because it's using just MOSI and not MISO. Adafruit Lib uses both.

Don't know if its the Display or the chip.

Thanks for all advice. Will post pictures of my device shortly with description.

Which Lib do you use for the SD Card and touch??

Thanks and regards
Sven

#2 showed that your SPI interface was working.

I am pleased that you have got the TFT working now. You should find that Marek's ILI9341_due library will work, ILI9341_PDQ, ILI9341_t3, ... as well as Adafruit_ILI9341 library.

Please note that Adafruit examples deliberately omit the RST argument in the constructor.
This is probably to make your Red board fail. Add the RST argument and the board will work.

Personally, I put TFT, Touch and SD all on the same 3.3V hardware SPI bus.

David.

Hi David,

Added pictures of the system and a schematic.

Found another library the works with one of my displays. Not with the other one.

Both claim to be ILI9341. Strange.

Ordered level shifter to be more safe and flexible. Ran out of resistors.

The adafruit library still does not work with any of my displays.

I added the output for the reset (Pin 8) to the adafruit example:
pinMode(8, OUTPUT); // Reset pin
analogWrite(5, 130); // LED Pin

tft.begin();
digitalWrite(8, HIGH); // insures that the reset pin is high
delay(500);
tft.readcommand8(ILI9341_SWRESET); // adds a software reset to the display
delay(550); // give the ILI9341 time to reset

Unfortunately does the UTFT from Henning Karlsen not work. He has a SPI touch library. Does not work on my display with touch either.

Do you know a touch lib with SPI? Which one do you use?

Regards
Sven