docs(sdcardio): clarify SD-first init rule for boards with floating C…#10947
docs(sdcardio): clarify SD-first init rule for boards with floating C…#10947dhalbert merged 3 commits intoadafruit:mainfrom
Conversation
…S pins The existing "Important" note says the SD card must always be initialized before any other SPI peripheral. This is correct in most cases, but is misleading for boards like the Feather RP2040 RFM where the co-located peripheral (RFM95) has a floating CS pin with no hardware pull-up. On those boards the floating CS corrupts the SPI bus during SD init, so that peripheral's CS must be driven HIGH first. Added an exception paragraph to the important block to document this case.
|
thx dan - indentation aligned with blank line after |
dhalbert
left a comment
There was a problem hiding this comment.
I looked at the docs-html artifact, and it looks good. Thanks!
I never understood this note, can you give some reasoning why "this is correct"? Driving the CS of the SD card high, initialize a different device first and then the SD-card should also work. The floating CS is a general problem of shared busses, irrespective of an SD-card present or not. |
|
@bablokbGood point. The "SD first" rule was never really about SD cards being special — it was implicitly relying on hardware pull-ups on all other CS pins doing the work of keeping the bus clean at boot. The floating CS on the Feather RP2040 RFM just exposed what the real invariant actually is: before any SPI transaction, every CS line on the bus must be in a known HIGH state, whether that's guaranteed by a pull-up resistor or driven HIGH in software. The init order is secondary to that. |
|
It's fine to rewrite this again to clarify. |
|
I actually fell over this a few years ago when my e-ink was wildly flashing while initializing the SD-card. One thing that would really simplify things if |
|
@bablokb common_hal_digitalio_digitalinout_switch_to_output(&self->cs, true, DRIVE_MODE_PUSH_PULL);So the CS pins are pulled high in the constructor. For But for |
|
Before adjusting the comments the original forum issue isn't entirely resolved. I'll work with the user and what I believe is the same hardware setup today before changing the comments to something like:
|
I think my comment above is only true for 9.x. If I read the code correctly, it is possible now to pass a pin or dio to the Fourwire constructor. Splitting Fourwire-construction and display construction is a valid workaround (I wasn't aware of that). But it makes the encapsulation of display creation within an utility class/method impossible. |
Documentation change only.
The
.. important::note inSDCard.__init__says to always initialize the SD card before other SPI peripherals. This is correct in most cases, but on boards with a floating CS pin (e.g. Feather RP2040 RFM, where RFM_CS has no pull-up), the other peripheral's CS must be driven HIGH first to avoid corrupting the bus during SD init.Adds an exception note to the existing important block for this case.
forum thread credit ThoMue for pointing this out...