Audio/TFT/Touchscreen/ILI9341 Pin Choices

sleitman

Member
I posted a specific help question yesterday.

But it brought up a broader range of questions that I have had using the audio shield and a touchscreen.

To be clear - I have had success with a specific set of pin connections and the Teensy 4.0. I have read the PJRC ILI9341 documentation and the audio documentation many times. I am still confused and have some clarification questions. I am using these tools for all sorts of projects and as someone who is largely self-taught on these matters, sometimes there are holes in my knowledge that I want to fix but don't know what I am missing. I think that in this case, it has to do with the requirements for SPI communication on different chips. I have read SPI tutorials and use SPI frequently for microcontroller projects but am still confused about the pin choices when dealing with the touch, screen and audio communications and Teensy.


1) On the touchscreen page, 2 options are given for pin connections: "Teensy 3.x
and 4.x Standard" and "Teensy 3.x Audio Board". What is the pin connection list for a Teensy 4.x and an Audio board? Is it the same as the Teensy 3.x
and 4.x Standard"?

2) The table on the PJRC ILI9341 page, says that on a Teensy 4.x, the D/C and Screen CS pins could be connected to Teensy pins 9, 10, 15, 20, or 21, but only all of those pins are used by the audio shield except for pin 9. So, what other pins should be used? On a previous PCB with a 4.0, I used pin 3

3) What types of pins do the ILI9341 DC and CS pins need to be connected to? Are the types different for the touch and the screen CS pins? Touch CS pin on the PJRC ILI9341 page says that it can be connected to anything but the screen CS pin gives specific pin options (9, 10, 15, 20, or 21).

If there was any way that an updated column could be added on the ILI9341 page for best practices pin choice when using a 4.0 or 4.1 and an audio shield, I would be incredibly grateful. If I lived on the same continent as Paul, I would be happy to trade an updated table column for yard work, beer, surfing lessons, or any other menial task. Failing that, I promise to answer at least 80 even-more-beginner questions from my students before they reach this forum.

Sasha

This is the pin configuration that I was using on my last PCB with a Teensy 4.0, audio adapter and the ILI9341 from PJRC. It worked fine but now I am having trouble on my new PCB that uses a 4.1.

Pins.png
 
I posted a specific help question yesterday.

But it brought up a broader range of questions that I have had using the audio shield and a touchscreen.
Lets see if I can shed a little light on the subject. Note, while I know the libraries and the optimizations, I haven't delved into reading the machine specific optimizations or reading the various data sheets.

Unfortunately, the documentation in some places has not been updated when the Teensy 4.0/4.1 came out, and changed a lot of the pin assignments (except for the basic Serial1, first I2C bus, first SPI bus, the first 10 analog input pins, LED).

There are 4 basic configurations:

  • Teensy LC (note, you cannot use a lot of the audio functions with the Teensy LC, and it has limited memory);
  • Teensy 3.1, 3.2, 3.5, and 3.6 without the audio shield (revisions A-C of the audio shield);
  • Teensy 3.1, 3.2, 3.5, and 3.6 with the revision A-C of the audio shield; (and)
  • Teensy 4.0 and 4.1. For the Teensy 4.0 and 4.1, it does not matter if you use the revision D audio shield.

If you use the audio shield on the Teensy 3.x, it needs to re-map 2 of the 3 primary SPI pins, because these pins are also used by the I2S bus, used by the audio shield. If you do not use the audio shield, the primary SPI pins are the same as used by the Teensy LC and the Teensy 4.x: Note, the Teensy 4.x cannot re-map the primary SPI pins.

  • Teensy 3.x with audio shield: MOSI is remapped to pin 7, MISO is pin 12, and SCLK is remapped to pin 14; (and)
  • Teensy 4.x, LC, or 3.x without audio shield: MOSI is pin 11, MISO is pin 12, and SCLK is pin 13.

Then we get into the fast pins for the ILI9341 displays (also ST7735, SSD1351, and maybe other displays). The Teensy 3.x processors have several special, fast pins that can speed up the display if you select both the CS and D/C pins for the display from these fast pins. Note, several of these pins cannot be used at the same time when doing the optimization.

The Teensy 4.0 processor only has 1 fast pin for the main SPI bus (pin 10), so even if it is supported in the driver, it can't use the fast pin optimization.

The Teensy 4.1 processor has 3 fast pins for the main SPI bus (pins 10, 36, and 37). However, I'm not sure the Teensy 4.x drivers use these fast pins, so it doesn't matter what CS and D/C pins you use for the display. I haven't used the ILI9341 display that much. The ST7735 driver did not do the fast pin optimization on the Teensy 4.x processors.

IIRC, the Teensy LC does not have any fast pins.

The Teensy 3.x fast pins are:

  • Pin 10 or pin 2;
  • Pin 9 or pin 6;
  • Pin 15/A1;
  • Pin 23/A9 or pin 20/A6; (and)
  • Pin 22/A8 or pin 21/A7.

To simplify the documentation, I don't think the alternate fast pins (pin 2, 6, 20, and 21) are mentioned.

To be clear - I have had success with a specific set of pin connections and the Teensy 4.0. I have read the PJRC ILI9341 documentation and the audio documentation many times. I am still confused and have some clarification questions. I am using these tools for all sorts of projects and as someone who is largely self-taught on these matters, sometimes there are holes in my knowledge that I want to fix but don't know what I am missing. I think that in this case, it has to do with the requirements for SPI communication on different chips. I have read SPI tutorials and use SPI frequently for microcontroller projects but am still confused about the pin choices when dealing with the touch, screen and audio communications and Teensy.


1) On the touchscreen page, 2 options are given for pin connections: "Teensy 3.x
and 4.x Standard" and "Teensy 3.x Audio Board". What is the pin connection list for a Teensy 4.x and an Audio board? Is it the same as the Teensy 3.x
and 4.x Standard"?

2) The table on the PJRC ILI9341 page, says that on a Teensy 4.x, the D/C and Screen CS pins could be connected to Teensy pins 9, 10, 15, 20, or 21, but only all of those pins are used by the audio shield except for pin 9. So, what other pins should be used? On a previous PCB with a 4.0, I used pin 3

3) What types of pins do the ILI9341 DC and CS pins need to be connected to? Are the types different for the touch and the screen CS pins? Touch CS pin on the PJRC ILI9341 page says that it can be connected to anything but the screen CS pin gives specific pin options (9, 10, 15, 20, or 21).

I don't believe the touch screen driver uses the fast pin optimization method. Unlike the display, it is a fairly slow device, so it probably doesn't need fast pin optimization.

One other issue comes up from time to time. Some touchscreen drivers don't seem to be able to share the SPI bus (using different CS and D/C pins than the display). I think the display offered by PJRC can share the SPI bus, but if you buy other vendors display they might not work.

I've seen at 3 methods are trying to deal with this:

  • Add additional hardware to allow the touch screen to share the SPI bus. At the least, you may need pull-up resistors on the CS pins for display and touch screen that allows the SPI hardware to see the transition in the CS pins being used much quicker;
  • Write a slower software SPI bus for handling the touch screen that does not use the faster hardware SPI bus; (or)
  • Move the touch screen to a second SPI bus. The Teensy LC, 3.5, 3.6, 4.0, and 4.1 have secondary SPI buses. The Teensy 3.1 and 3.2 does not have a second SPI bus. Note, to use the second SPI bus on the Teensy 4.0 requires soldering wires to the solder pads under the Teensy. The pins used for the Teensy 4.0/4.1 second SPI bus differ from the pins used in the Teensy LC/3.5/3.6 second SPI bus.

If there was any way that an updated column could be added on the ILI9341 page for best practices pin choice when using a 4.0 or 4.1 and an audio shield, I would be incredibly grateful. If I lived on the same continent as Paul, I would be happy to trade an updated table column for yard work, beer, surfing lessons, or any other menial task. Failing that, I promise to answer at least 80 even-more-beginner questions from my students before they reach this forum.
It would be nice...

One other thing. Some devices can't be driven that fast. I found in playing around with the uncanny eyes setup (2 displays that each draw eyes as fast as possible), I often had to de-tune the SPI bus speed so that the faster Teensies could not send data to the display faster than it could handle. You may have to spend a little time tuning the speed of the display, if you notice it glitching.
 
Back
Top