I am using a Feather M4 Express in conjunction with an Adalogger Featherwing to store collected data on a microSD card (swissbit 512 MB). The circuit I am using this in collects data from 8 sensors over SPI (and uses a line decoder - which takes 4 inputs to select one of 16 outputs - to generate the chip select signal) and 2 sensors over I2C. The SPI and I2C measurements are solid. The issue I am having is that when I run the code to initialize the SD card, I get the error message "OSError: Couldn't determine SD card version". What's weirder is that when I disconnect the MISO and SCK lines (the sensors have no MOSI pin), the SD card works perfectly. I am perplexed by this since I then connected the Feather/Featherwing assembly to an SPI circuit with just one sensor and that worked fine. To troubleshoot, I measured the voltage at each chip select pin and found that one of the sensors was at 1.2 V instead of 3.3 V during initialization of the SD card, but when I hardwired this chip select pin and ran the code again, I got the same error message (and yes, I did recheck all remaining chip select pins after this rerun). I have tried placing the initialization of the SD card before and after setting all chip select pins low, but to no avail. Any ideas of what I should try next?
Here is a snippet of my code for the 10 sensor setup. The error occurs at "sdcard = sdcardio.SDCard(spi, SD_CS)" - the third to last line.
Code: Select all
import board
import busio
import digitalio
import time
import adafruit_tmp117
import adafruit_mprls
import sdcardio
import microcontroller
import storage
# Use Pin A1 on Feather for Data 1 pin on Line Decoder
cs1 = digitalio.DigitalInOut(board.A1)
cs1.direction = digitalio.Direction.OUTPUT
cs1.value = False
# Use Pin A2 on Feather for Data 2 pin on Line Decoder
cs2 = digitalio.DigitalInOut(board.A2)
cs2.direction = digitalio.Direction.OUTPUT
cs2.value = False
# Use Pin A3 on Feather for Data 3 pin on Line Decoder
cs3 = digitalio.DigitalInOut(board.A3)
cs3.direction = digitalio.Direction.OUTPUT
cs3.value = False
# Use Pin A4 on Feather for Data 4 pin on Line Decoder
cs4 = digitalio.DigitalInOut(board.A4)
cs4.direction = digitalio.Direction.OUTPUT
cs4.value = False
# Use Pin A5 on Feather to toggle the Inhibit pin on Line Decoder
# Set Inhibit to True when not making measurements
# Set Inhibit to False after setting binary input for desired sensor
INH = digitalio.DigitalInOut(board.A5)
INH.direction = digitalio.Direction.OUTPUT
INH.value = True
# Use Pin A0 on Feather to control Strobe on Line Decoder
# Set Strobe low to latch Line Decoder Output
# Set Strobe high to unlatch outputs
STR = digitalio.DigitalInOut(board.A0)
STR.direction = digitalio.Direction.OUTPUT
STR.value = True
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
# Configure SD Card
SD_CS = board.D10
sdcard = sdcardio.SDCard(spi, SD_CS)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")