SD + ILI9341 conflict

Status
Not open for further replies.

Adriano

Member
Hi,
I am using T3.2 with a SD card reader and a ILI9341 display. After executing the sketch I am unable to initialize a second time the SD (if powered off).
The code is simple:
Code:
#include <ILI9341_t3.h>
#include <SD.h>
#include <SPI.h>

ILI9341_t3 tft = ILI9341_t3(9, 22, 255, 11, 13, 12);

void setup() {  
  Serial.begin(115200);
  while(!Serial);
  
  tft.begin();
  tft.setRotation(1);
  tft.fillRectVGradient(0, 0, 320, 240, ILI9341_BLACK, ILI9341_NAVY);

  delay(200);
  Serial.println(SD.begin(10) ? "SD SUCCESS" : "SD FAILED");
}

void loop() {

}

I used always Sandisk SD and it works perfectly.
Now I got some Transcend 8GB (class4) SD and this Sketch can be executed only 1 time. If I power off the teensy and power up it again the SD card doesn't init anymore. I have to connect the card to my computer if I want use it again on the teensy.

Workaround:
- If I initialize the SD card before the TFT, it works like expected.
- Don't power off the teensy: if I upload the same sketch again it works.
- Don't use the Transcend 8GB memory.

But I would like initialize the TFT first and power off the module some times :p

Is this SD-bug with other SPI devices still present?
 
Do you have a pullup on the cs-line ? If not, add one - maybe it helps.
Or add a pinMode(10, pullup) as first line in setup() to your code - might be helpful, too.

Edit: Please post a link to the reader you use.
 
Last edited:
Using the TOUCH ILI9341 and an SD sample it worked for me - but others were having trouble until they tried my version. I'm not sure if that was an initialization order issue or something else they were seeing. It worked for me so I never saw the issue - but at least 2 others were failing until they tried my EVIL sketch - there may be something useful there from 15 months back if following Frank's advice doesn't work.

<EDIT>: I had the pull-up resistors on my display.
 
Last edited:
My guess is also along what Frank said. That is the CS pin was probably floating when the tft code was called and as such maybe the SD code tried to interpret the stuff going to the display and got locked up or such... So adding the pinMode as frank mentioned would work.
Or you might do it like: pinMode(10, OUTPUT); digitalWrite(10, HIGH);

Before you do the startup code for the TFT display.
 
@Frank: I have a lot of devices connected on the SPI, all from ebay.
- SD module (The module is this one: http://modtronix.com/mod-sdcard-l5.html)
- Display with unused but connected SD and touch (https://www.ebay.co.uk/p/LCD-Touch-Panel-240-X-320-2-8-SPI-TFT-Serial-Port-Module-With-PBC-Ili9341-Red/1170253741?_trksid=p2047675.m4097.l9055)
- RC522
Every CS (all 5) have a pullup and MOSI has a 100R.

After some troubles with my transcend card, I removed everything from teensy and have only this 2 modules (ILI + SD) but the SD become "corrupted" when I power off it. The only way to get it working again is to connect my micro SD to my computer. After, it works again once.
Everything was working fine with my Sandisk SD.

@defragster: I will try it. It works fine by me too if I use my Sandisk SD or if I initialize the SD before I init the display.
@ KurtE: I have both on my sketch: pullups and pinMode, but it doesn't help if I want show something on the TFT before reading the card.
 
Last edited:
Status
Not open for further replies.
Back
Top