• I am trying to get my head around connecting up a microSD card using SPI and wouldn't mind a bit of guidance, especially since I am new to Espruino.

    Some background:

    I am using the following hardware

    1. STM32F4 Discovery board
    2. MikroElektronika STM32F4 Discovery shield
    3. MikroElektronika microSD click board

    which pretty much looks like this:

    I have the microSD click board (bottom left in the image above) in the mikroBUS port 1 on the Discovery shield which translates to the following pinout:

    mikroBUS port 1:
    SD card pin -----------> STM32F4 Pin
    2 (CS) -------------------> B12 (CS)
    3 (DI) -------------------> B15 (SPI2 MOSI)
    5 (SCK) -----------------> B13 (SPI2 SCK)
    7 (DO) ------------------> B14 (SPI2 MISO)

    Goal:

    Is obviously to read from and write to the SD card.

    I found the following conversation on the Espruino forum where @Gordon alludes how to go about using SPI to get this working but I am still a bit lost.

    I see that the filesystem module is only supported on boards with a SD card slot

    @Gordon says in his comment above to, "just stick with normal SPI"

    Getting the SPI setup seems very straight forward:

    SPI2.setup({mosi:B15, miso:B14, sck:B13, baud:?});
    

    SPI setup comments:

    • About the baud rate. Should it be half the clock speed, which is 168 MHz (max)?
    • Where does the chip select pin (CS, B12) come into play?

    Once the SPI is taken care of how does one deal with reading and writing files with normal SPI?

    Any help greatly appreciated!

About