I2C Read with GTT43

GTT TFT Support

Moderator: Mods

Post Reply
iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

I2C Read with GTT43

Post by iotexpert.com » Fri Apr 27, 2018 9:30 am

I have a GTT43... and I am able to read and write successfully with UART

I am able to successfully WRITE with I2C

However, when I try to read with I2C I get crazy data back.

For instance if I am trying to read the protocol version... I have tried
I2C Start, address + write 254 0 stop
i2c start address read read read read read read stop

I have tried
i2c start, address + write 254 0 restart address+read read read read read read read stop

I have tried i2c start, address+ write 254 0 stop
i2c start address, read stop

With all of the different combinations of reads that I have tried... the 254 0 I always get (in hex)
FC+ FA+ 00+ 03+ 01+ 0D+

I am supposed to get
FC 00 00 02 02 08

Do I need to configure something special in the LCD to get the read responses to work correctly? I notice that there is a command 254 5 (set communication channel)... but that doesnt seem to be it.

.... so I suppose that I must not understand how to do the I2C read responses from a write... any help would be appreciated.

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 128
Joined: Thu Sep 24, 2015 9:38 am

Re: I2C Read with GTT43

Post by Daniel Divino » Fri Apr 27, 2018 9:48 am

Hi iotexpert,

Welcome to the forums!

Have you designed your screens in the GTT Designer?

Cheers,
Daniel Divino
Daniel Divino
Technical Support
Matrix Orbital

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com » Fri Apr 27, 2018 9:53 am

Yes... but I guess that I dont understand why having or not having screens in there would impact the I2C interaction.

In other words... it seems to me that I would be able to do a "protocol version" read regardless of anything?

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com » Fri Apr 27, 2018 9:54 am

Is there an I2C protocol timing diagram in some document? If so I haven't been able to find it... but I would love to see it.

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 128
Joined: Thu Sep 24, 2015 9:38 am

Re: I2C Read with GTT43

Post by Daniel Divino » Fri Apr 27, 2018 11:03 am

Hi iotexpert,

Thanks for the added details about your project.

Designing your project in the GTT Designer won't prevent the use of any GTT Commands.

The GTT Designer Suite simply converts your screens into scripts and images, and uploads those files to the GTT. Upon boot, the GTT will start executing the autoexec script as if it were receiving commands from a host. Any return messages generated during this time will be sent to the Communication Channel, in this case I2C. All of the return messages generated during this time will be held within the GTT's return buffer until read via I2C. This is why you are seeing FC FA 00 03 01 0D messages rather than the expected FC 00 00 02 02 08.

There are two methods around this issue:
-You can continuously read the GTT's I2C buffer to ensure that all of the return messages generated upon startup do not interfere with future read operations
-You can set the default Communication Channel to None in your GTT Designer project and add a post load script to set the Communication Channel to I2C once the first screen has been loaded and drawn. This will ensure that you don't get the long list of return messages when the autoexec is being executed, but you will still be able to read data from the GTT once the screen is drawn.

Either of those methods should keep your I2C buffer clear, allowing you to immediately read the proper data from your display.

Cheers,
Daniel Divino
Daniel Divino
Technical Support
Matrix Orbital

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com » Fri Apr 27, 2018 2:48 pm

OK. I understand... I think.

I think you are saying that I can setup things with GTT designer and set the communication to none... then after the system boots, I can send an I2C command to set the channel to I2C

Or I can read the data until the buffer is clear.

Is there a command to clear the I2C buffer?

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com » Fri Apr 27, 2018 2:56 pm

I tried reading bytes to try to clear out the buffer...

Looks like after I read about 25 bytes the buffer is clear...

And then my commands work correctly (this is good).

1) is there a way to know how many bytes are in the buffer?

2) are there always complete responses in the buffer (meaning I could parse them all until the buffer is empty)?

Thanks,
Alan

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 128
Joined: Thu Sep 24, 2015 9:38 am

Re: I2C Read with GTT43

Post by Daniel Divino » Mon Apr 30, 2018 9:48 am

Hi Alan,

I'm glad to hear you're able to properly read all of your commands via I2C now.

At the moment, there is no way to know how many bytes are in the GTT's return buffer, nor is there a single command to clear the buffer.

The buffer will only house complete responses, so you can run a parser loop that will read all of the messages until the buffer is empty.

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com » Mon Apr 30, 2018 1:38 pm

Thank you that is helpful. Having complete messages is good.

One more question... what happens if the display needs to over-run the buffer? Does it throw out earlier stuff? Or not write into it?

Daniel Divino
Matrix Orbital
Matrix Orbital
Posts: 128
Joined: Thu Sep 24, 2015 9:38 am

Re: I2C Read with GTT43

Post by Daniel Divino » Tue May 01, 2018 9:01 am

Hi Alan,

Once the return buffer is full, the GTT will not be able to continue operating until it's data is read. It will wait until there is more space in the return buffer before executing any more commands. This is to prevent data loss, and ensures that all events registered by the GTT are reported to the host.

Cheers,
Daniel
Daniel Divino
Technical Support
Matrix Orbital

iotexpert.com
LCD!
Posts: 16
Joined: Fri Apr 27, 2018 9:15 am

Re: I2C Read with GTT43

Post by iotexpert.com » Tue May 01, 2018 11:21 am

Awesome. Thank you that helps a lot.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests