Author Topic: 2.4" touchscreen display w/ ILI9341 driver and ATSAME70Q21 project  (Read 2255 times)

0 Members and 1 Guest are viewing this topic.

Offline kenp_rkiTopic starter

  • Newbie
  • Posts: 4
  • Country: us
I’m attempting to add an 2.4” TFT LCD touchscreen with the ILI9341 controller (SPI mode) to an existing project. We are using the Atmel SAME70Q21 uC. I have the SAME70 Xplained demo board and display wired in but none of the examples have worked, either there written for another controller or communication type.

Does anyone have an example project that was written for the SAME70 Xplained demo board and an LCD display with the ILI9341 controller?

Thanks for your help
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2601
  • Country: us
Re: 2.4" touchscreen display w/ ILI9341 driver and ATSAME70Q21 project
« Reply #1 on: May 30, 2018, 12:14:46 am »
None of which examples have worked? Have you verified that your SPI is working? Does your SPI config match what the controller is configured for? ILI934x controllers have several different serial modes.  Do you have the correct configuration data for the panel?

Examples being written for different interfaces shouldn't be a problem--you just need to be able to see how commands and data are transmitted.  Once you figure out your interface layer you can create a function like LCD_write(uint8_t cmd, uint8_t * data, uint8_t length), then you build all of your drawing functions on top of that.  If the interface ever changes you simply rewrite that one function. 
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: 2.4" touchscreen display w/ ILI9341 driver and ATSAME70Q21 project
« Reply #2 on: May 30, 2018, 06:54:07 am »
Thanks for your help
Help us help you!

From your post the only things we know are:
- You have a SAME70 Xplained board
- You have a 2.4" TFT, supposedly based on ILI9341
- You have tried some software

We don't know:

HW:
- How you've wired the display.
- Its exact model (or a link to the relevant ebay/aliexpress/sparkfun/adafruit).
- Whether the display is really SPI (many different options, as ajb says).
- We'll leave the touch screen controller aside for the moment.

SW:
- If you managed to at least compile, link, flash and run the the examples you mention.
- Where they failed and how.
- If you've tried modifying them to suit your configuration, and what where the results.

ILI9341 is a very common controller, plenty of initialization code on the net that can be adapted to your board and configuration.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline kenp_rkiTopic starter

  • Newbie
  • Posts: 4
  • Country: us
Re: 2.4" touchscreen display w/ ILI9341 driver and ATSAME70Q21 project
« Reply #3 on: May 30, 2018, 07:47:01 pm »
Thanks for your replies.

Here is more info.
The display is found here: https://www.adafruit.com/product/2478
I connected the display to the SAME70 XPlained as follows:
EXT1         Display
15             CS
16             MOSI
17             MISO
18             CLK
19             GND
20             VCC
I have been looking for an example in the AS7 selections that are available when the demo board is recognoised.
Yes, the examples compiled, linked and flashed.
My main problem is getting the AS7 project started with both the SPI and ILI9341 examples into one project. That's why I was looking for an example that had both implemented in one project.

Thanks

 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: 2.4" touchscreen display w/ ILI9341 driver and ATSAME70Q21 project
« Reply #4 on: May 30, 2018, 10:34:04 pm »
Ok,
that's some more info.

Please note that I don't have a SAME70-XPLD board, but I've successfully driven the ILI9341 on the STM32F429 DISCO with SPI.

Here are some initial considerations; sorry if I might seem patronizing, but I don't know your proficiency with C, code in general, HW etc. :-//
  • The pins you have connected match the SPI on the EXT1 connector, good! :-+
  • You are only using the basic SPI pins:
    This means that you need to use the so called "3-wire serial" mode of the ILI9341.
  • For the above to happen, IM0 (15) and IM2 (17) pins on JP1 connector of the display need a pull-up, rather than the default pull-down, as the IM[3:0] interface select bits must be 0101. This can done by closing the solder bridges SJ1 and SJ3, is the display HW correctly set up?
  • Using this serial mode, each write must consist of 9 bits, the first (D/CX) indicates whether the remaining 8 bits are a command or data (see the pictures in chapter 7.1.9 of the datasheet).
    Is your SPI set up correctly (8 or 16 bits won't work, I don't know if a 9 bit mode is actually supported by that MCU)?
    Is the SW taking this into account?
  • Reads are "complicated" as a dummy clock cycle need to be inserted between the command and data in some case. I did not bother :=\ too lazy.
  • I actually would prefer to use the 4-wire serial, using a GPIO to drive the D/C pin, due to the simpler and more efficient handling in SW when moving a large number of data.
  • For your last point, you need to modify (say) the 9341 example so that writes to the display go through SPI rather than whatever was used.
    With the assumption that the example is decently written -yes, a big one- you'll be able to find a function that writes a command or data byte to the display: as ajb suggests, that's the one to be rewritten using SPI. Of course, SPI initialization must also be copied in!
  • Last, but not least: show us your code!
    But before, reduce the example to the minimum (e.g.: peripheral and 9341 initialization).

HTH
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline kenp_rkiTopic starter

  • Newbie
  • Posts: 4
  • Country: us
Re: 2.4" touchscreen display w/ ILI9341 driver and ATSAME70Q21 project
« Reply #5 on: May 30, 2018, 11:58:19 pm »
Thanks newbrain, I've got most of this covered. I will add a GPIO for D/C and take a closer look tomorrow and reply. I had all 4 of the IM[3:0] jumpered. If I add D/C, do I need to modify any of the IM[3:0] jumpers?
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2601
  • Country: us
Re: 2.4" touchscreen display w/ ILI9341 driver and ATSAME70Q21 project
« Reply #6 on: May 31, 2018, 05:30:45 am »
Thanks newbrain, I've got most of this covered. I will add a GPIO for D/C and take a closer look tomorrow and reply. I had all 4 of the IM[3:0] jumpered. If I add D/C, do I need to modify any of the IM[3:0] jumpers?
Page 10 of the ILI9341 datasheet shows the proper pin strapping for IM[3:0] to get the various interface modes.  You want the 4-wire 8-bit mode, probably with separate SDI and SDO, so that's IM3, IM2, and IM1 need to be high and IM0 needs to be low.  The schematic for the LCD module shows those pins have pull down resistors on the board, so you'll need to pull IM3-1 high and leave IM0 floating.

Looking at your link, there's a link to example code with panel initialization starting at line #337 here: https://github.com/adafruit/Adafruit_ILI9341/blob/master/Adafruit_ILI9341.cpp.  So if you implement your own writeCommand(), spiWrite(), startWrite() and endWrite() functions, you should be able to copy and paste lines 337 through 449 and have it just work.  startWrite and endWrite just need to lower and raise CS respectively, so those are easy.  writeCommand will be the same as spiWrite, except for setting or clearing DCX while sending the command.  The hardest part is spiWrite, since that requires setting up the SPI hardware correctly. 

Do you have the ability to test that the SPI itself ('scope, logic analyzer, bus pirate, etc)?

As an aside, if you have the option, the parallel interface is much faster than SPI on the ILI934x chips because it's 8 or 16 bits at a time versus 1.  This can make a substantial difference if you have to redraw large areas of the screen a lot.  Looks like your MCU has an external memory bus, which works really nicely with parallel LCD interfaces. 
 

Offline kenp_rkiTopic starter

  • Newbie
  • Posts: 4
  • Country: us
Re: 2.4" touchscreen display w/ ILI9341 driver and ATSAME70Q21 project
« Reply #7 on: June 20, 2018, 04:16:18 pm »
Thanks for all your help, we finally got it working!
 

Offline waveman

  • Newbie
  • Posts: 3
  • Country: ca
Re: 2.4" touchscreen display w/ ILI9341 driver and ATSAME70Q21 project
« Reply #8 on: July 24, 2020, 05:39:24 pm »
Hello @kenp_rki, 
I am also working on the ATSAME70 for a similar TFT display, but I do have a ILI9341 also. Is it necessary to use The ILI9341 .
I prepared the Atmel Studio environment to compile cpp files.

I made a port of the SPI.h and tested it with digital potentiometer and logic analyzer. Did you use bitbang SPI or hardware E70 SPI, or did you use parallel?

Did you have to copy all kinds of Arduino core .cpp and.h files?

Did you have to include Adafruit_GFX files, or did you make it work without Adafruit_GFX?

The code Adafruit_ILI9341 code today is different compared to the May 4 2018 version where Adafruit_ILI9341 had 907lines and today’s version has 330 lines. I guess you downloaded around May 4, is that correct?

Could you give general advice, or share some code?
Thanks,
Frank
 :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf