Teensy 4.0: audio shield and ILI9341 possible?

Status
Not open for further replies.

whofferbert

New member
Hello!

I've been using the Teensy 4.0 and the audio shield successfully for a while now, and I started looking at adding an ILI9341 display to the project.

On this page, it details alternate pins that can be used on the Teensy 3.2 if the audio shield is in use as well.
Looking over the pinout for Teensy 4.0, and I was able to find alternate pin locations for MOSI (26/35), MISO (34), and SCK (27), but I ran into trouble with the CS and DC pins.
Once the audio shield is attached to the Teensy 4.0, it seems there is only one CS pin left: 36.

Is there a good work around for this? I understand it's possible to emulate SPI in software, but that it "is much, much slower and prevents your sketch from doing useful work meanwhile."
I'm curious if attempting to use another pin for CS or DC connection, and some software for this task may have a poor effect on the real-time audio processing.

(Later edit) Looking a bit further at the Adafruit_ILI9341 library source, it seems that it's okay to pass -1 to the CS, if CS is tied to Ground.
According to the datasheet for the ILI9341, CS low is to enable the chip select.
Since the rest of the MOSI/MISO/SCK is happening on different pins than what the audio shield uses, would that be a reasonable way to use the display along side the audio shield on the Teensy 4.0?

Any suggestions or guidance would be greatly appreciated! Thank you for your time.
 
Last edited:
Note, you have to understand the Teensy 4.0 is different in terms of pin layout than the Teensy 3.2. That's why there is the revision D of the audio shield that only works with the Teensy 4.0 (and with earlier shields, you have to do some re-wiring).

On the Teensy 4.0, it uses the standard SPI pins (11-13) as SPI pins. In the Teensy 3.2, you have to use 2 of the alternate pins because the I2S pins use pins 11 and 13. On the Teensy 4.0, the I2S pins use pins 23, 21, 20, 7, and 8).

On the Teensy 3.2, there are special pins that are optimized for CS/DC usage and the ILI9341_t3 library uses them. On the Teensy 4.0, there is only one special pin (10), and that is the SD card reader on the audio shield. I don't know the details (KurtE, mjs513, and defragster are the experts), but there is some speed up if the CS pin is 10, but it isn't much. So you should be able to use any pin for CS and DC that isn't otherwise used.

Note, the Teensy 4.0 has two other SPI ports, but to use them, you need to solder wires underneath the Teensy. Using ST7789 lcds, I have run two different displays using two different SPI buses (for the uncanny eyes program).

If you wanted to use the flash memory and/or micro sd card on the audio shield, you might need to think about using the second SPI controller for the display. It depends on what kind of optimizations are done. For un-optimized displays, the CS pin allows you to have multiple devices on the same SPI bus, but I'm not sure how well it works with the display using DMA to optimize things.
 
Yes, I understand that the Teensy 4.0 is different than the 3.2 in pinout, and many other regards. Thank you. It's kind of hard to miss that the audio shield was also redesigned for the 4.0, since that's written all over the product page.
I had linked in the page for the 3.2 because that was the only page I found on PJRC where there were explicit instructions on using different SPI pins for the ILI9341, when using an audio shield.
That leads me to believe that with the Teensy 4.0 and the Audio Shield Rev D, I would still need to find alternate pins for the SPI communication; and the concern that picking some other arbitrary pin and handling that in software might be a slow/poor approach.

I currently have the pins 24-33 on the underside of the 4.0 broken out for this project, but none of the 34-39 pins that seem like they would be better suited being broken out with a ribbon cable.

I suppose I'll take a shot at tying CS to ground and pass -1 as the CS pin, and see what happens, to avoid having to manage CS in software.
 
Seems this question went by in past weeks - may have added details there … The Audio Board page shows the PINS used Rev D .vs. Rev C - and the ili9341 connect notes can use the version as if Rev D Audio board not connected when T4 in use.

Not an expert - but noted there AFAIK was that Teensy 4 does not have the 'optimized' ability to tie the CS pin to the SPI process in the same way so any pin works as well for CS on T4.

For T_4 with Rev D Audio :: the primary SPI bus as noted uses standard normal SPI pins [ 11, 12, 13 ] even with Rev D board attached

>> So an ILI9341 should attach to those same SPI bus lines without trouble, just need to find a usable pin for CS to the display.
>> Or SPI1 or SPI2 could be hooked up if desired - but with proper CS pins more than one device works - except for careful sharing if ili9341 DMA were enabled
 
I was able to get it sorted out and working, after updating the Adafruit_ILI9341 library to it's most recent github version. Not sure if using Arduino 1.8.7 is the issue there, but no big deal.

CS can be tied to ground (and -1 passed as the CS pin), then you don't have to control that pin on the Teensy 4, so pin 36 can be broken out and used as a second chip select for the ILI9341.
When I did that and shared the same MOSI/MISO/SCK pins with the audio shield, i seemed to get a bit of extra noise (static?) in the audio that was not there before.
The noise issues is not great, but I didn't spend a lot of time troubleshooting it, since there were enough SPI connections left on the bottom pads.
I broke out the Teensy 4.0 pins 34-39, and used the other SPI port there to handle it.


ILI9341 | Teensy/other pin
--------|-----------------
1 Vcc __| Vin (+5v)
2 Gnd __| Ground
3 CS ___| Ground
4 Reset | +3v3
5 DC ___| 36
6 MOSI _| 35
7 SCK __| 37
8 LED __| Vin (+5v)
9 MISO _| 34


Seems to let me use my Audio Shield Rev D on the Teensy 4.0, and the ILI9341 together at the same time, without much trouble. On to programming things now!
 
Status
Not open for further replies.
Back
Top