-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STM32: SPI.readinto ignores write_value, causes SD cards not to detect #3176
Comments
Good session, nRF52840 (particle xenon): Bad session, STM32F405 feather Notice how outside the "40 00 00 00 95" packet sent to initialize the SD card into SPI mode, the MOSI pin stays high on nRF but doesn't on STM. I believe this is because the
I suspect the underlying cause is the same here and in adafruit/Adafruit_CircuitPython_SD#36 and will be fixed by the same fix -- whatever that is. |
I've taken the liberty of punting this to @hierophect but can take it back if that's preferred. |
I can check it out, I'll add it to my list. |
Changing the readinto code like this works, but may not be acceptable (it puts a potentially large variable size array on the stack):
|
@jepler I'm fixing this today. Do you think you could provide me with a test sketch I can use to verify the fix? Something with a clear differentiation between the desired/undesired behavior. I can use my logic analyzer to view the same waveforms you did if you give me that same sketch. If it's just the same one jerryn provided let me know. |
I'd like to understand the significance of |
Looks like this is a limitation of the ST HAL in regards to handling the MOSI line when using an SD card. I'll look around for other workarounds since this one seems kind of slow. Micropython, STM32Duino, and even the ST FatFS library must all deal with this issue somehow. |
While SPI just needs the value 0xff (all bits same), the nRF24 library needs specific values:
|
@jepler @hierophect to be clear, the nRF24L01 hardware actually ignores MOSI after the first byte. I wrote that code when I was just starting out with CircuitPython in an effort to better familiarize myself with SPI transactions. Using EDIT: Oops, I didn't mean to steal credit from Damien George, Peter Hinch, or Rhys Thomas. Turns out the use of |
@jepler @tannewt Report from looking at this this morning. Delay obviously changes a lot based on the size of the incoming data. Measuring the duration of the memset with the DWT at 168MHz, these are the timings I got:
This is of course not variable with the speed of the SPI line, so it'll be a more significant delay compared to the actual transaction the faster the SPI is going. Is this a big enough deal for us to put in the API modification that Jeff suggested to allow write_value to be set as an "invalid" token, so that the memset can be skipped? |
Actual DWT Values:
|
related to
adafruit/Adafruit_CircuitPython_SD#36
I know the "on-board" SDcard is not support on the feather STM32F405.
I tried attaching an Adalloger Featherwing using sdcardio and it is not able to detect the card
The also happens with the Adafruit_CircuitPython_SD library
see
adafruit/Adafruit_CircuitPython_SD#36
code -- sdcardio_lib.py
The text was updated successfully, but these errors were encountered: