Teensy 3.2 - Sd card reader partition error

Status
Not open for further replies.

Nosfé

New member
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:
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
 
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.
 
Have you tried any of the SD or SDFat examples? Try the SD|listfiles example - you may have to set chipSelect to 10.

Pete
 
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 :)
 
Status
Not open for further replies.
Back
Top