Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Problems with the SD Drive or some conflicting Buttons

Phil Schatzmann edited this page Sep 26, 2023 · 32 revisions

AI Thinker AudioKit

The Audio Boards have different DIP Switches. On some boards the word ON is printed on the upper left corder of the switch. We will use the word ON, in our documentation if the switch is in the upper position showing away from you.

SD / SDFAT Library

The working of the SD drive depends on the dip switches. Please check the documentation of your board. Usually the setting OFF, ON, ON, OFF, OFF is recommended.

Please note that an active SD drive might also deactivate some of the buttons because the same GPIOs are used.

You can also switch off the automatic SD initialization:

  • At compile time: (e.g. in the AudioKitSettings.h) by defining AUDIOKIT_SETUP_SD to 0 if you do not intent to use the SD card.
  • At runtime: by setting the sd_active to false in the AudioKitConfig that is passed to the begin method. Example:
  auto cfg = kit.defaultConfig();
  cfg.bits_per_sample = 16;
  cfg.channels = 1;
  cfg.sample_rate = 8000;
  cfg.sd_active = false;
  kit.begin(cfg);

In some exceptional cases you might want to use the SD of the AudioKit w/o setting up any AudioKitStream. In this case you have to initialize the SD SPI pins yourself:

// These pins are defined in the HAL
// #define PIN_AUDIO_KIT_SD_CARD_CS 13  
// #define PIN_AUDIO_KIT_SD_CARD_MISO 2
// #define PIN_AUDIO_KIT_SD_CARD_MOSI 15
// #define PIN_AUDIO_KIT_SD_CARD_CLK  14

void setup() {
    SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
    ...

SDMMC Library

The ESP32 provides an example to test the SDMMC which is using the following pins:

  SD Card | ESP32
     D2       12
     D3       13
     CMD      15
     VSS      GND
     VDD      3.3V
     CLK      14
     VSS      GND
     D0       2  (add 1K pull up after flashing)
     D1       4

1 Bit Mode

The DIP Switches must be in the N/A, OFF, ON, OFF, OFF position. This has the advantage that you can still use the KEY2 if you set the first Dip Switch to ON! The critical setting here is to activate CMD.

4 Bit Mode

The DIP Switches must be in the OFF, ON, ON, OFF, OFF position. The critical setting here is to activate CMD and DATA3.

ESP32-S3

For the ESP32-S3 you need to define the pins:

   //1 bit mode
   setPins(ESP_SD_PIN_CLK, ESP_SD_PIN_CMD, ESP_SD_PIN_D0);
   //4 bit mode
   setPins(ESP_SD_PIN_CLK, ESP_SD_PIN_CMD, ESP_SD_PIN_D0, ESP_SD_PIN_D1, ESP_SD_PIN_D2, ESP_SD_PIN_D3);

Please note that ESP32 does not allow to change the pins and therefore will always fail.

Formatting

If you have any issues with the formatting I suggest to use the official SD Formatter