Welcome, Guest

Author Topic: Use of SD_MMC and SPI at the same time fails.  (Read 42 times)

quikue

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Use of SD_MMC and SPI at the same time fails.
« on: February 13, 2019, 05:29:46 PM »
I’m trying to use in the Olimex ESP32-EVB board the SD card and the SPI at the same time, and for me is impossible.

I know that the SD card uses SPI but without CS line, and also without instantiating the SD_MMC class, that I don’t understand that, but I use because I saw in the SD_MMC examples, and works fine.

The problem is when I read a sensor value in SPI, with a CS in the GPIO17, that runs fine but the next SD_MMC action, append,  fails!

Can you help me!

Thanks.

LubOlimex

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1851
  • Karma: +47/-2
Re: Use of SD_MMC and SPI at the same time fails.
« Reply #1 on: February 14, 2019, 10:39:22 AM »
The card is not working in SPI mode, it is working in one-bit SD card mode, read about it here: https://en.wikipedia.org/wiki/Secure_Digital

I believe that after you have done with the SPI you need to re-initialize the three pins for the card's one-bit SD mode operation, else they would remain SPI and the card would fail. I am not sure about the best way it should be done but in the Arduino IDE package for ESP32 check the libraries/sd/src/SD.cpp begin() function - you can change the pins with parameters.
Technical support and documentation manager at Olimex

quikue

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Use of SD_MMC and SPI at the same time fails.
« Reply #2 on: February 15, 2019, 08:41:21 PM »
Thank you!

You have perfectly indicated the problem to me, when the SPI protocol is used on the MAX31856 chip, the MISO pin goes to LOW, and the SD card no longer works.

I have tried all day to find a solution in the files of the SD library, but the state of the three pins is hidden by several layers of interlaced libraries.

I've also googled, I tried to reset and put the MISO on HIGH, but it does not work.

If any know any idea to continue trying it will be very grateful.

And sincerely, thank you very much for your wise advice