So I use a uSD card on my board for my photon & electron devices with the SDFat library. I connect it with the standard SPI (not SPI1) pins. Everything works fine with my Electrons and Photons on the given board (and has for a long time) - they can use the SD card fine. The SD Card holder is soldered on the board with very short traces to the Particle device pins, and no other external components.
However, using an Argon via the Classic Adapter, the sd.begin() call fails, with error code: 0x20, 0x00 (with normal SPI), or 0x20, 0xFF (with SoftwareSpi). This is using the bench example from the SDFat library (using version 1.0.16).
Has anyone else successfully used an SD card with the Classic Adapter, especially with SDFat? Is there anything specific I should try or check for on the hardware level? I don’t have a ton of low-level experience with SPI or SD Cards, so while I could mess around, I’m sure someone may have some specific suggestions.
As you can see the Photon HW SPI pins are A3, A4, A5 and they are mapped to the Argon pins with exactly these name too, but on the Argon these are not the SPI pins. These are separate pins called SCK, MI, MO.
Ah that must be it, thanks. Not sure how I missed that while poring over those pinouts.
@rickkas7, I think the documentation above should be updated, specifically in Note 3 on the Pin Map, which implies that those are the only pins not connected to anything. Note 3 should also include:
MI
MO
SCK
I could put in a PR if that’s helpful, but not sure what the standard process is.
I’ll give it a go with Software SPI on the correct pins and that should probably work.
The author of SDFat has deprecated the functionality for Soft SPI (because it does not work very well). Thus it is no longer available.
I only had tried to use it to interface with legacy equipment. Since this is not what you are trying to do, my post is not intended for your use case.
Instead, simply use Pins 11-13 (Chip select on pin 14) for the standard SPI bus, or Pins 2-4 (chip select on pin 5) for SPI1 (the secondary spi bus). Connect the spi pins based on your sd adapter’s datasheet.
Using defaults for SPI (Pins 11-14):
SdFat sd;
const uint8_t chipSelect = SS; // SPI chipSelect pin - SS is default
// in setup()
sd.begin(chipSelect, SPI_FULL_SPEED);