Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Teensy 3.2 - Sd card reader partition error

  1. #1
    Junior Member
    Join Date
    Jul 2020
    Posts
    3

    Teensy 3.2 - Sd card reader partition error

    Hello,

    I'm actually trying to automate a little my brewing process with a Teensy 3.2.

    I was using an arduino nano but it wasnt powerfull enough to use an oled screen and a micro SD card reader.

    So now oled screen is working fine with teensy, but SD reader is not, I can see my card, wiring is correct but i have a partition error when I try to open volume.

    I've tried with or without breadbord.

    Here is my code:
    Code:
    #include <SPI.h>
    #include <Wire.h>
    #include <SD.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>
    
    
    #define SCREEN_WIDTH 128 // OLED display width, in pixels
    #define SCREEN_HEIGHT 64 // OLED display height, in pixels
    
    // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
    #define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
    Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
    
    
    // set up variables using the SD utility library functions:
    Sd2Card card;
    SdVolume volume;
    SdFile root;
    
    const int chipSelect = 10;  
    
    void setup() {
      Serial.begin(9600);
      
    
      // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
      if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c)) { // Address 0x3D for 128x64
      Serial.println(F("SSD1306 allocation failed"));
        for(;;); // Don't proceed, loop forever
      }
    
      display.setTextSize(1);
      display.setTextColor(WHITE);  
      display.clearDisplay();
      display.println("Initializing SD card.");
    
      // we'll use the initialization code from the utility libraries
      // since we're just testing if the card is working!
      if (!card.init(SPI_HALF_SPEED, chipSelect)) {
        display.println("initialization failed.");
        return;
      } else {
       display.println("Wiring is correct!"); 
       display.println("SD card detected!"); 
      }
      display.display();
      delay(5000);
      display.setCursor(0,0);
      display.clearDisplay();
       // print the type of card
      display.print("\nCard type: ");
      switch(card.type()) {
        case SD_CARD_TYPE_SD1:
          display.println("SD1");
          break;
        case SD_CARD_TYPE_SD2:
          display.println("SD2");
          break;
        case SD_CARD_TYPE_SDHC:
          display.println("SDHC");
          break;
        default:
          display.println("Unknown");
      }
        if (!volume.init(card)) {
        display.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
        display.display();
        return;
      }
      display.display();
      
    }
    
    void loop() {  
    
    }
    Thanks for your help.
    Last edited by Nosfé; 07-09-2020 at 01:55 AM.

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,454
    I tried your code on a T3.2 with an audio board. I had to remove your code which uses the display and use setMOSI and setSCK for the audio board, but your code has no problem finding the uSD card and identifying it as "Card type: SDHC". There's no error about partitions.

    Pete

  3. #3
    Junior Member
    Join Date
    Jul 2020
    Posts
    3
    Hi,
    I can see card type, it's just after :

    Code:
        if (!volume.init(card)) {
        display.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
        display.display();
        return;
    I get an error there. I've tried 3 different cards to be sure.

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,454
    Have you tried any of the SD or SDFat examples? Try the SD|listfiles example - you may have to set chipSelect to 10.

    Pete

  5. #5
    Junior Member
    Join Date
    Jul 2020
    Posts
    3
    I've figured out how to fix it!

    Changing
    Code:
    if (!card.init(SPI_HALF_SPEED, chipSelect))
    by
    Code:
    if (!card.init(SPI_QUARTER_SPEED, chipSelect))
    Found more informations there

    Thank you anyway

Posting Permissions

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