Teensy 4.1 SD Card + Display issues

Gary

Active member
Hi

I have done some changes of the example code of the flexcan_t4 library. First I have installed the 3.5 display. This works very good. After the installing of the onboard SD card I have some problems with the display.

I think there is a problem with the CS pin. Basically the SD card work without the display.

The display has the CS pin 10. Is it possible that the SD Card (const int chipSelect = BUILTIN_SDCARD;) also use the CS pin 10?

Both (display and SD card) needs to be updated while receiving messages.

How can I fix the problem.

I use a circuit board from skpang and I think I have no option to change the CS pin from the display.



#include <FlexCAN_T4.h>
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_64> can3;

#include <isotp.h>
isotp<RX_BANKS_16, 512> tp;

#include <Adafruit_GFX.h>
#include "ILI9488_t3.h"
#include "ili9488_t3_font_Arial.h"

#include <Adafruit_FT6206.h>

#include <SD.h>
#include <SPI.h>

// The FT6206 uses hardware I2C (SCL/SDA)
Adafruit_FT6206 ts = Adafruit_FT6206();

#define TFT_CS 10
#define TFT_DC 9
ILI9488_t3 display = ILI9488_t3(&SPI, TFT_CS, TFT_DC);

const int chipSelect = BUILTIN_SDCARD;

int LCD_RESET = 15;
int LCD_BL = 14;


Thanks a lot

Gary
 
Are you using Teensy 3.5? You have not shown how you are trying to use the SD card, so it's hard to say what is wrong.

For all Teensy with built-in SD card (T3.5, T3.6, T4.1), the value of BUILTIN_SDCARD is 254, and the SD card is not on the standard SPI bus, so there should not be a conflict with the display.
 
Post title notes T_4.1 and then display as 3.5 (assume inches?)

But, as p#2 notes the BUILTIN_SDCARD on T_3.5, 3.6 and 4.1 are all connected on an SDIO bus wholly independent and not sharing any pins with any available SPI pin, and that BUILTIN_SDCARD device does not use any other pin for CS or other, it is wired directly as needed to the processor chip.

Perhaps some information is shown in the verbose console output on building? A warning or error message or not using the correct libraries from the Teensy CORES installation?

NOTE: Inserting code in CODE markings with the toolbar "#" symbol is preferred.
 
Thanks for your help. It help much because now I lnow where I have to search.

Greetings
Gary
 
Good morning

I have searched for a fault but I can't find one. In my sight this code looks good.

The display isnt working and I cant see him counting. The SD card is working.

This is only a code to test the writing to the SD card. This code dosnt make sense. ;-) But I Need the SD card for a project.

Thanks for taking a look....

Gary



Code:
#include <FlexCAN_T4.h>
    FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_64> can3;


    #include <Adafruit_GFX.h>
    #include "ILI9488_t3.h"
    #include "ili9488_t3_font_Arial.h"

    #include <Adafruit_FT6206.h>

    #include <SD.h>
    #include <SPI.h>

   
    Adafruit_FT6206 ts = Adafruit_FT6206();

    #define TFT_CS 10
    #define TFT_DC  9
    ILI9488_t3 display = ILI9488_t3(&SPI, TFT_CS, TFT_DC);

    const int chipSelect = BUILTIN_SDCARD; 

    int LCD_RESET = 15;
    int LCD_BL = 14;

    int nummer = 1;

  
  
  void setup(){
  
  delay(400);
  
 
  
  pinMode(LCD_BL,OUTPUT);
  pinMode(LCD_RESET,OUTPUT);     
    
  digitalWrite(LCD_BL, HIGH); 
  digitalWrite(LCD_RESET, HIGH); 
   
  delay(50); 
  digitalWrite(LCD_RESET, LOW); 
  delay(20);
  digitalWrite(LCD_RESET, HIGH); 

  
  

   if (!ts.begin(40)) { 
    Serial.println("Unable to start touchscreen.");
  } 
  else { 
    Serial.println("Touchscreen started."); 
  }

  
  Serial.print("Initializing SD card...");
  
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");

  
  
  can3.begin();
  can3.setBaudRate(500000);       // 250kbps data rate
  can3.enableFIFO();
  can3.enableFIFOInterrupt();
  can3.mailboxStatus();

  

   File dataFile = SD.open("CAN.txt", FILE_WRITE);

   if (dataFile) {
        dataFile.println("Start"); 
        dataFile.close();
  }
  
  
    
   display.begin();

   can3.onReceive(FIFO, CAN); 

  display.fillScreen(ILI9488_BLUE);

  }

  void loop(){
     
  display.fillScreen(ILI9488_BLUE);
  display.setFont(Arial_18);
  display.setTextSize(1);
  display.setCursor(140, 160);
  display.print (nummer);
  nummer ++;
  delay (1000);
  }

  void CAN(const CAN_message_t &msg){

  File dataFile = SD.open("CAN.txt", FILE_WRITE);

  if (dataFile) {
          dataFile.println(msg.id); 
          
          for ( uint8_t i = 0; i < msg.len; i++ ) {
          dataFile.print(msg.buf[i], HEX); dataFile.print(" ");
          } 
          dataFile.close();
  }}
 
Try a simple example from the 'ILI9488_t3' library perhaps? Make any needed adjustments for setup for the T_4.1.

Excluding all the other devices and libraries until the display works, confirming each wire if needed (continuity check display pin to Teensy pin - and adjacent pins for a short). If that does not work, it may be the display.
 
hi defragster

My display works fine. Then I have implemented the SD card. After this the display doesnt work.

Thanks for your help
 
So from a working display library example - adding only usage of the BUILTIN_SDCARD (none of the other devices) - the display stops working?

If sketch to that effect (starting with working Display example and combined SD example using DirList or CardInfo) were created and seen to fail and posted anyone with a ILI9488_t3 display could observe the behavior and offer assistance.
 
Back
Top