VS1053 SD Initialization Issue

My setup is a AdaFruit Feather RP2040 with an attached AdaFruit Music Maker FeatherWing w/ Amp.

I am using Arduino IDE 2.2.1 with pico-debug. I have also tried without pico-debug. I am able to run and debug basic sketches and play a sinetest using the Music Maker. So at some level the VS1053 board is recognized.

My problem is that it will not read from the SD card (I know...common issue based on the Googles). I have tried three different SD cards all using SDFormatter. At this point, my sample code is simply trying to call SD.begin() and it fails.

When I trace the code into SharedSpiCard::cardCommand, the spiReceive() call in SdSpiCard.cpp (line 272) always returns a 0.

My code below:

#define PREFER_SDFAT_LIBRARY 1  //I have tried defining an undefining this
#include <fs.h>
#include <Adafruit_VS1053.h>

#define	SPI_SCK_PIN		 	18		/* hardware SPI SCK pin		*/
#define SPI_MOSI_PIN		19		/* hardware SPI MOSI pin	*/
#define SPI_MISO_PIN		20 		/* hardware SPI MISO pin	*/

#define VS1053_CS       8     // VS1053 chip select pin (output)
#define VS1053_DCS     10     // VS1053 Data/command select pin (output)
#define CARDCS          7     // Card chip select pin
#define VS1053_DREQ     9     // VS1053 Data request, ideally an Interrupt pin
#define VS1053_RESET -1

Adafruit_VS1053_FilePlayer musicPlayer = 
  // create breakout-example object!
//  Adafruit_VS1053_FilePlayer(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);
  // create shield-example object!
 // Adafruit_VS1053_FilePlayer(VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);
Adafruit_VS1053_FilePlayer(SPI_MOSI_PIN, SPI_MISO_PIN, SPI_SCK_PIN, VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);

void setup() {
  // put your setup code here, to run once:
  //pinMode(CARDCS, OUTPUT);
  //pinMode(SPI_MOSI_PIN, OUTPUT);
  //pinMode(SPI_MISO_PIN, INPUT);
  //digitalWrite(CARDCS, HIGH);  
  
  // initialise the music player
  if (!musicPlayer.begin()) {
    while (1);  // don't do anything more
  }

  if (!SD.begin(CARDCS)) {   //this always fails
    while (1);  // don't do anything more
  }

  musicPlayer.setVolume(20,20);
}

void loop() {
  // put your main code here, to run repeatedly:
  musicPlayer.sineTest(0x44, 1500);  
  musicPlayer.playFullFile("/Disney.mp3");
}

Any help is appreciated...even with no help I appreciate the body of knowledge in these forums.

Thanks

FYI: Some additional information. This is where the error is being returned (SdSpiCard.cpp):

 // command to go idle in SPI mode
  for (uint8_t i = 1;; i++) {
    if (cardCommand(CMD0, 0) == R1_IDLE_STATE) {
      break;
    }
    if (i == SD_CMD0_RETRY) {
      error(SD_CARD_ERROR_CMD0);
      goto fail;
    }
  }

It appears the card reader is not going idle??

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.