SoftSPI on ESP32
Posted: Fri Sep 02, 2022 8:26 am
Hi
I try to run a sdcard on my M5Stack Core2 (esp32).
I have to use the SoftSPI, due to the given cardreader connection on the M5Stack Core2.
Pins are checked with the documentation of the core2. https://docs.m5stack.com/en/core/core2
Card is formatted with FAT32 and I tried different micro-SD cards with the same result.
The most I got was a very long waiting time and the following error on the REPL.
Here is my code.... Does anybody see the problem with it or has an advise on how to fix the problem?
Thanks in advance
I try to run a sdcard on my M5Stack Core2 (esp32).
I have to use the SoftSPI, due to the given cardreader connection on the M5Stack Core2.
Pins are checked with the documentation of the core2. https://docs.m5stack.com/en/core/core2
Card is formatted with FAT32 and I tried different micro-SD cards with the same result.
The most I got was a very long waiting time and the following error on the REPL.
Code: Select all
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "<stdin>", line 11, in <module>
File "sdcard.py", line 54, in __init__
File "sdcard.py", line 87, in init_card
File "sdcard.py", line 135, in init_card_v2
OSError: timeout waiting for v2 card
Thanks in advance
Code: Select all
import machine
import sys
import time
from machine import SoftSPI,Pin
import sdcard
import uos
spi =SoftSPI(baudrate=100000,polarity=1,phase=0,sck=Pin(18),mosi=Pin(23),miso=Pin(38))
cs = Pin(4, Pin.OUT, Pin.PULL_UP)
sd = sdcard.SDCard(spi,cs)
time.sleep_ms(10)
uos.mount(sd,"/sd")
time.sleep_ms(10)
file = open("/sd/data.txt", 'w')
file.write("Test Test Test")
file.close()