Will the real ILI9341 0xD9 command please stand up.

I am posting this as a call for help to find out what exactly the command 0xD9 does / performs in ILI9341 LCD.
It has been identified as "Woo sekret command " and " external command" in variety of LCD source codes.
It is always followed by data (?) apparently identifying "parameters". But that is just a guess.

The official and unofficial datasheets , to many to mention , sorry, searched so far made no mention about this D9 command.
Than I would advise against googling for it. Personal knowledge will probably work better.

Thanks
Jim

PS I hope administrator will not flag this a double post, I felt it needs its own thread.

I posted an example for you.

From memory:
bits 0-3 hold the number of parameters (as N-1) i.e. you can read 1-16 bytes.
bit 4 enables.

Did my example work for you?
I suggest that you just use it.

One day I might remember where 0xD9 is documented. I can assure you that there is an official App Note or datasheet somewhere.

David.

I think, not sure , the code you posted in not for Due hardware 4 wire SPI.
I have no way to conveniently check that , I would have to rewire the LCD .
Not a big deal, but since I had ( my latest code is broken) current setup working I see no point to try that.
At this point I had the class I am using working - getting correct data , but only 8 bits.
It was designed to retrieve 8 bits , so it is OK.
The hardware SPI should work for parameters.
However, none of the transfer functions in standard core SPI class are designed for that.
Thanks for helping, but I need to quit for tonight.
Jim

Just FYI - deleting the 0xD9 and 0x10 has NO effect on data retrieved from LCD.
Here is modified readcomman I use to test. Works same as readcommd8 to process / retrieve data from LCD.
The important part is - I am using real hardware SPI on Due, no generic I/O SPI as some of the libraries are using.

[code]   uint32_t readcommand16(uint8_t c, uint8_t parameter) {
#ifdef TRACE_TREE
      TraceTree_EX(1, 1, 0, (char*)__func__, __LINE__ , __FILE__, "uint8_t readcommand8(uint8_t c, paramater )  ");
#endif
      //while(1);
//      writecommand_cont(0xD9);  // woo sekret command?
//      writedata8_last(parameter);
      writecommand_cont(c);
#ifdef TRACE_TREE
      TraceTree_ellipses(1, 1, 0, (char*)__func__, __LINE__ , __FILE__, "  writecommand_cont(c);  ",
                         4, "c command ", c, "paramater ", parameter);
#endif
      //while(1);
      return readdata16_last();
    }

[/code]

What do you actually want to do?

I showed you how to read multi-byte register data.

I could show you how to read GRAM memory.

I don't think that Marek or Bodmer implement readGRAM() or readPixel()
My "SPI" libraries do. And they work on Uno, Zero, Due, ... MBED.

I have even done 3-wire bi-directional SDA with an ILI9481 which is a bit of a pain with Atmel hardware.
Most ILI9341 displays use 5-wire SPI. Straightforward 8-bit SPI with separate DC line.

So anything that is in the data sheet is proven in real-life.

I could make an effort to look up various points. I will only bother if you are prepared to read my replies.

David.

Thanks for your support.
What do you actually want to do? Learn.

I am sure your code works fine but it does not support my objective to learn.
I picked one SPI source code after I had my own code working with parallel interface.
Now I want to make SPI play. and so far that works for me.
Doing "cut and paste" from other sources at this time
is not my objective.
Please do not get upset that I just did not copy your code,
Not my style.

I appreciate your inputs.
Jim

julyjim:
Just FYI - deleting the 0xD9 and 0x10 has NO effect on data retrieved from LCD.

It does have an effect when used correctly.

The 0xD9 command sets an index into a list of parameters so you can read a single byte rather than a long list and thus extract the one you want.

For example, the Adafruit ILI9341 library sets the Negative Gamma Correction to:

 writecommand(ILI9341_GMCTRN1);    //Set Gamma 
  writedata(0x00); 
  writedata(0x0E); 
  writedata(0x14); 
  writedata(0x03); 
  writedata(0x11); 
  writedata(0x07); 
  writedata(0x31); 
  writedata(0xC1); 
  writedata(0x48); 
  writedata(0x08); 
  writedata(0x0F); 
  writedata(0x0C); 
  writedata(0x31); 
  writedata(0x36); 
  writedata(0x0F);

Then this line, which calls a function in the library that uses the 0xD9 command, reads an 8 bit value:

uint8_t x = tft.readcommand8(ILI9341_GMCTRN1, 14);

and returns 0x36 which is the 14th value in the list. Clearly this is only saves time if the parameter list exceeds a certain length as you have to issue the additional command, it also means you don't need to setup a buffer or discard unwanted values.

Thanks,
I really appreciate this.
So this business of command D9 data 0x10 is really not "woo sekret command " but bogus code everybody keeps repeating.
For example for ILI9341_RDSELFDIAG, self diagnostic command to work I have to build the list of parameters and than I can read the parameter which actually contains the real data.
Makes sense.

I am not sure if there is a way to actually prompt the ILI9341 controller to just send the multiubyte data and let the SPI to handle that The SPI speed and processor speed should allow for that without getting into handshake between the slave and master.

Time to rewrite the code.

Thanks
Jim .

david_prentice:
I don't think that Marek or Bodmer implement readGRAM() or readPixel()

I do readPixel.

@Jim,
No, you have not understood at all.

You either read Bodmer's reply or you go about your own sweet 'learning' method.

There is nothing secret about the 0xD9 command. It is just that it is not in the regular datasheet.

It is frustrating that it did not seem easy to read the ID in SPI mode. Well, if you use 0xD9, it is possible.

@Marek,
My apologies. I wrote from my tablet not the PC. So I had not checked.
I am sure that the OP will find readPixel() useful. Of course he may choose to disbelieve you.

David.