Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two SdCards example not working #22

Open
sufius opened this issue Dec 15, 2023 · 0 comments
Open

Two SdCards example not working #22

sufius opened this issue Dec 15, 2023 · 0 comments

Comments

@sufius
Copy link

sufius commented Dec 15, 2023

Operating System

Windows 10

IDE version

PlatformIO 6.4.0

Board

esp32 DevKitC v4

BSP version

0

SPIFlash Library version

0

Sketch

#include <SdFat.h>

#define PIN_CS_SDCARD 13
#define SPI_SPEED_SDCARD SD_SCK_MHZ(4)

#define PIN_CS_CHIP 5
#define SPI_SPEED_CHIP SD_SCK_MHZ(20)

#define SD_CONFIG_SDCARD SdSpiConfig(PIN_CS_SDCARD, SHARED_SPI, SPI_SPEED_SDCARD)
#define SD_CONFIG_CHIP SdSpiConfig(PIN_CS_CHIP, SHARED_SPI, SPI_SPEED_CHIP)

SdFat32 SD_SDCARD;
SdFat32 SD_CHIP;


void setup()
{
  Serial.begin(115200);

  // Wait for USB Serial
  while (!Serial)
  {
    yield();
  }

  // disable sd2 while initializing sd1
  pinMode(PIN_CS_SDCARD, OUTPUT);
  digitalWrite(PIN_CS_SDCARD, HIGH);


//                     _                      
//    ___ __ _ _ __ __| |     ___  _ __   ___ 
//   / __/ _` | '__/ _` |    / _ \| '_ \ / _ \
//  | (_| (_| | | | (_| |   | (_) | | | |  __/
//   \___\__,_|_|  \__,_|    \___/|_| |_|\___|

  if (!SD_CHIP.begin(SD_CONFIG_CHIP))
  {
    Serial.println("CHIP initialization failed!");
    return;
  }
  else
  {
    Serial.println("CHIP initialization successful!");
  }


//                     _     _                 
//    ___ __ _ _ __ __| |   | |___      _____  
//   / __/ _` | '__/ _` |   | __\ \ /\ / / _ \ 
//  | (_| (_| | | | (_| |   | |_ \ V  V / (_) |
//   \___\__,_|_|  \__,_|    \__| \_/\_/ \___/ 
                                            
  if (!SD_SDCARD.begin(SD_CONFIG_SDCARD))
  {
    Serial.println("SDCARD initialization failed!");
    return;
  }
  else
  {
    Serial.println("SDCARD initialization successful!");
  }


  Serial.println("SDCARD directory:");
  Serial.println(PIN_CS_SDCARD);
  SD_SDCARD.ls(LS_R | LS_DATE | LS_SIZE);

  Serial.println("CHIP directory:");
  Serial.println(PIN_CS_CHIP);
  SD_CHIP.ls(LS_R | LS_DATE | LS_SIZE);
}

void loop()
{
  
}

What happened ?

I'm trying to follow the official example (v1, v2 not found) of running two cards. but i can run always just one alone, never together. the second card initialization is always failing, why?

I'm using esp32 DevKitC v4 on PlatformIO with Adafruits SdFat version 2 (version of Greiman not working too with me). Please Help.

How to reproduce ?

I'm using the default SPI pins 18,19,23.
CS for card 1: 5
CS for card 2: 13

Debug Log

No response

Screenshots

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant