TheQuestor
Member
Never having worked with smd components before, how do you substitute resistors?
For what? With these things I just add them either inline or on the PCB that I attach the teensy to
Never having worked with smd components before, how do you substitute resistors?
Never having worked with smd components before, how do you substitute resistors?
Yes, ask the nocdemcu forum. We're using Teensy in this forum.
Are you sure you are using two separate Chip Selects ? One for the SD card and a second one for the TFT Display. Both CS pins need separate pullups.
That's not a problem with the display, it is a software-problem. Perhaps a problem with the SPI-Driver or whatever is used to access SPI. Do you have pullups on all chipselects ?
#include <SD.h>
#include <Adafruit_GFX.h>
#include <Arduino.h>
#include <Adafruit_ILI9341.h>
#define TFT_DC D1
#define TFT_CS D2
#define SD_CS D8
//here i use hardware SPI
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup() {
Serial.begin(9600);
Serial.println();
tft.begin();
tft.fillScreen(ILI9341_RED);
delay(500);
if (!SD.begin(SD_CS)){
Serial.println("fail");
}
}
void loop() {
//just to see if screen works
tft.fillScreen(ILI9341_BLUE);
}
/*
SD & TFT card test
*/
// include the SD library:
#include <SD.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Arduino.h>
#include <Adafruit_ILI9341.h>
// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;
// change this to match your microprocessor IO pins !!!!!
// The numbers below reflect the Arduino and Teensy Standard numbering system
#define SD_CS 4
#define TFT_CS 20
#define TFT_DC 21
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void setup()
{
delay (2000); // Give Windoze USB Serial time to reconnect after upload
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.println("ILI9341 TFT using OnBoard SD Test");
tft.begin();
tft.fillScreen(ILI9341_RED);
delay(2000); // give me a chance to look at tft screen !!
tft.fillScreen(ILI9341_BLUE);
Serial.println("\n\nInitializing SD card...");
tft.println("\nInitializing SD card...");
// we'll use the initialization code from the utility libraries
// since we're just testing if the card is working!
//if (!SD.begin(SD_CS)) { // This seems to init the card but NO card info is read later !!
if (!card.init(SPI_FULL_SPEED, SD_CS)) { // this alternate init WORKS OK
Serial.println("initialization failed. Things to check:");
tft.println("SD initialization failed.");
Serial.println("* is a card inserted?");
Serial.println("* is your wiring correct?");
Serial.println("* did you change the chipSelect pin to match your shield or module?");
return;
} else {
Serial.println("Wiring is correct and a card is present.");
tft.println("Wiring correct and card present.");
}
// print the type of card
Serial.print("\nCard type: ");
tft.print("\nCard type: ");
switch (card.type()) {
case SD_CARD_TYPE_SD1:
Serial.println("SD1");
tft.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.println("SD2");
tft.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.println("SDHC");
tft.println("SDHC");
break;
default:
Serial.println("Unknown");
tft.println("Unknown");
}
// Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
if (!volume.init(card)) {
Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
tft.println("Could not find FAT16/FAT32 partition.");
return;
}
// print the type and size of the first FAT-type volume
uint32_t volumesize;
Serial.print("\nVolume type is FAT");
Serial.println(volume.fatType(), DEC);
Serial.println();
tft.print("\nVolume type is FAT");
tft.println(volume.fatType(), DEC);
tft.println();
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
if (volumesize < 8388608ul) {
Serial.print("Volume size (bytes): ");
Serial.println(volumesize * 512); // SD card blocks are always 512 bytes
tft.print("Volume size (bytes): ");
tft.println(volumesize * 512); // SD card blocks are always 512 bytes
}
Serial.print("Volume size (Kbytes): ");
tft.print("Volume size (Kbytes): ");
volumesize /= 2;
Serial.println(volumesize);
Serial.print("Volume size (Mbytes): ");
tft.println(volumesize);
tft.print("Volume size (Mbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
tft.println(volumesize);
Serial.println("\nFiles found on the card (name, date and size in bytes): ");
tft.println("\nSee Serial Terminal for\n Listing of Files found on SD Card.");
root.openRoot(volume);
// list all files in the card with date and size to Serial
root.ls(LS_R | LS_DATE | LS_SIZE);
}
void loop(void) {
//just loop forever... we said everything in setup !!
}
SD_CS: any free digital pin
SD_MOSI: 11
SD_MISO 12
SD_SCK: 13
F_CS: this is the chip select for the not populated flash memory chip
I've modified my ili9341 display a little bit.
The display is now 3.3V only - max voltage for VCC is 3.3V!
- The resistors R1, R2 and R3 are replaced with 0R resistors,
- ~10k pull-up resistors for SD_CS, TFT_CS and TFT_D/C
- the solder jumper J1 is closed.
View attachment 4273
I take it that since I have a Teensy 4.1 with a built in SD (Thanx so much Paul for helping me get the SD up and running) I should have no concerns about SD cards and the display working, as long as I connect the display to the pins shown in the device description and use the suggested libraries. Is this right??