Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 31 of 31

Thread: SdFat SDIO for Teensy 4.0

  1. #26
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,460
    Quote Originally Posted by defragster View Post
    FAILS write at 150 MHz.
    do you mean CPU clock at 150MHz?

  2. #27
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,390
    Quote Originally Posted by WMXZ View Post
    do you mean CPU clock at 150MHz?
    Yes. Set in the IDE - edited to show F_CPU_ACTUAL in setup {also print __FILE__ so I know what the sketch will do when I type 'Any' char}:
    Code:
    Use a freshly formatted SD for best performance.
    Sketch is :T:\TEMP\arduino_modified_sketch_197682\bench.ino
    	 F_CPU=151200000
    Type any character to start
    FreeStack: 441608
    Type is FAT32
    Card size: 31.91 GB (GB = 1E9 bytes)
    
    Manufacturer ID: 0X3
    OEM ID: SD
    Product: SU32G
    Version: 8.0
    Serial number: 0XAC3E2E1C
    Manufacturing date: 9/2012
    
    error: open failed
    SdError: 0X23,0X1
    Should have presented that as the SdError may be useful - though should repro. Wondering if a CLOCK isn't set right?

    Also fails at 24 MHz - a bit earlier on begin():
    Code:
    Sketch is :T:\TEMP\arduino_modified_sketch_69952\bench.ino
    	 F_CPU=24000000
    Type any character to start
    FreeStack: 441608
    begin() failed
    Do not reformat the SD.
    SdError: 0X17,0X1

  3. #28
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,460
    Quote Originally Posted by defragster View Post
    Yes. Set in the IDE - edited to show F_CPU_ACTUAL in setup {also print __FILE__ so I know what the sketch will do when I type 'Any' char}:
    I ask as I run T4 +AudioCard-uSD (spi) + sdfat-beta at 24 MHz CPU clock without problems (I think)
    so issue may be with SDIO clock generation

  4. #29
    Greiman, with the SdFat-beta library: Is it possible to generate in the serial monitor a list of the files contained in a folder inside any microSD card installed in the Teensy 4?.

    Will you have an example?

    Thank you for making the SdFat library compatible with teensy 4. We have been able to use your library for handling .avi, .jpg, .jpeg files stored on a microSD card connected in SDIO; by a profound modification in the gameduino library 23x.

  5. #30
    Senior Member
    Join Date
    Dec 2013
    Posts
    253
    Will you have an example?
    Here is what I have you can probably modify it to suit your needs.

    Code:
    #include <SdFat.h> // SdFat V "2.0.0"
    
    SdFat SD;
    File m_pSource;
    
    const int DIR_max = 250; // [# of Directory - max]
    const int max_DIR_name_lenght = 255;
    char CURDIRname[max_DIR_name_lenght] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Elements with missing values will be initialized to 0;
    uint32_t DIRcount = 1; // COUNT of all DIRs on SD CARD
    char DIR_list_array[DIR_max][max_DIR_name_lenght]; // [# of DIRs max][max DIR name lenght];
    
    //============================================================================
    //------------                    setup()                        -------------
    //============================================================================
    void setup() {
      // put your setup code here, to run once:
    
      Serial.begin(9600);
      while (!Serial && millis() < 15000) {}  // wait for Serial Monitor with 15sec. timeout.
    
    #if defined(SdFat_h)
      Serial.print( "SdFat version "), Serial.println( SD_FAT_VERSION ), Serial.println("");
    #elif defined(__SD_H__)
      Serial.println( "SD - a slightly more friendly wrapper for sdfatlib"), Serial.println("");
    #endif
    
      if (!SD.begin(SdioConfig(FIFO_SDIO))) { // SdFat.h Ver 2.0.0 Beta only...
        Serial.println("m.SD initialization failed!");
      } else {
        Serial.println("m.SD initialization OK");
      }
    
      LISTDIRs();
    
      m_pSource = SD.open("/"); // ROOT
      PrintFiles(m_pSource);
      m_pSource.close();
    }
    //----------------------------------------------------------------------------
    
    //============================================================================
    //------------                    loop()                        -------------
    //============================================================================
    void loop() {
      // put your main code here, to run repeatedly:
    }
    //----------------------------------------------------------------------------
    
    //============================================================================
    //------------ LIST ALL DIRs ON SD CARD & SAVE IN DIR_list_array -------------
    //============================================================================
    void LISTDIRs() {
      Serial.println("\t**List Directories**");
      m_pSource = SD.open("/"); // ROOT
      char dirname[max_DIR_name_lenght]; // SDFAT // max_DIR_name_lenght
      if (m_pSource.isDirectory()) {
        strcpy(DIR_list_array[DIRcount], "/"); // array
    
        Serial.print("ROOT# ");
        Serial.print(DIRcount);
        Serial.print("\t");
        Serial.println(DIR_list_array[DIRcount]); // SDFAT LIB
        DIRcount++;
      }
      while (true) {
        File DIR = m_pSource.openNextFile();
    
        if (! DIR) {
          // no more files
          Serial.println("\t **no more Directories** ");
          //dir.close();
          break;
        }
        DIR.getName(dirname, sizeof(dirname));
        if (DIR.isDirectory()) {
          //DIRcount++;
          strcpy(DIR_list_array[DIRcount], dirname); // array
          strcat(DIR_list_array[DIRcount], "/");
          Serial.print("DIR# ");
          Serial.print(DIRcount);
          Serial.print("\t");
          Serial.println(DIR_list_array[DIRcount]); // SDFAT LIB
          DIRcount++;
        }
        DIR.close();
      }
      DIRcount --;
      Serial.print("\t **Directory count ");
      Serial.print(DIRcount), Serial.println(" **"), Serial.println();
      m_pSource.close();
    }
    //----------------------------------------------------------------------------
    
    //============================================================================
    // Print Files in Cur. Directory
    //============================================================================
    void PrintFiles(File dir) {
      Serial.println("\t**List Files in Cur. Directory**");
      char filename[max_DIR_name_lenght]; // SDFAT
      while (true) {
    
        File entry = dir.openNextFile();
        if (! entry) {
          // no more files
          Serial.println("\t **no more files**"), Serial.println();
          break;
        }
        entry.getName(filename, sizeof(filename));
    
        if (entry.isDirectory()) {
          //Serial.println(" / ");
          //printDirectory(entry, numTabs + 1);
        } else {
          Serial.print(filename); // SDFAT LIB
          // files have sizes, directories do not
          Serial.print("       \t");
          Serial.println(entry.size(), DEC);
        }
        entry.close();
      }
    }
    //----------------------------------------------------------------------------

  6. #31
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,390
    re: post #27 above { fail at 24 and 150 MHz } - it may be a clock setting issue : pjrc.com/threads/58567-Teensyduino-1-49-Beta-1
    Resolved perhaps in TD 1.49 by release.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •