hwconfig: Fix pad config for SD SPI, move clockrate to hwconfig #42
Reference in New Issue
Block a user
Delete Branch "fix-sd-spi-hwconfig"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The code snippet in hwconfig to adjust the drive strength was incorrect:
It was adjusting the wrong pins. This was probably not updated during
some pin shuffling in the breadboard phase.
Fix this by adjusting the correct pins. Experimentation shows that both
setting the slew rate to fast or setting the drive strength to 8 mA
(default: slow and 4 mA) is sufficient to make SD SPI work at 25 MHz on
the Rev1 PCB. For now, the combination 8 mA and slow is chosen (slow
slew rate should result in less high frequency EMI).
Also make the SD clock rate adjustable in hwconfig, and set it to 25 MHz
for Rev1 and 15 MHz for the breadboard setup.
@@ -9,6 +9,7 @@ SD_DI = Pin.board.GP3SD_DO = Pin.board.GP4SD_SCK = Pin.board.GP2SD_CS = Pin.board.GP5SD_CLOCKRATE = 25000000Still causes issues with my 'SanDisk Ultra 32 GB' card. Reducing this back to 15000000 works, but 20000000 already yields a 'RuntimeError: sd_init() failed'
I think I have found the underlying issue and solved it in rp2_sd: Disable input synchronizer for MISO pin. Please re-test.
For further reference, screenshots of the SD SPI clock signal with different drive strength. (Taken with a passive 500 MHz / 10 MOhm / 11 pF probe).
2 mA drive strength
4 mA drive strength
8 mA drive strength
12 mA drive strength
Validated on my setup, works with SanDisk Ultra 32 GB card.