Skip to main content
Visitor II
May 1, 2025
Solved

Writing to SD card with Simulink Embedded Coder Support for STM32 Microcontrollers

  • May 1, 2025
  • 3 replies
  • 600 views

Has anyone successfully used this Simulink STM32 guide to write to an SD card? I am trying to run a simulink model on a Nucleo-F767ZI and write the output to an SD card. I have tried to follow the directions, but it is not working. The model can compile and run on the board, but when I check the SD card, it is still empty. I have tried different clock speeds, 1-bit and 4-bit modes, but nothing seems to work. I scoped the clock signal, and it seems to be at 400 kHz, which is indicative of it being in the initialization stage. Does anyone know what may be wrong? Thanks!

 

 

    This topic has been closed for replies.

    3 replies

    Super User
    May 1, 2025

    @escott01 wrote:

     I have tried to follow the directions, but it is not working. 


    It's a Mathworks document - nothing to do with ST - so you need to take that up with Mathworks

    https://uk.mathworks.com/support/contact_us.html?s_tid=hc_resources

    https://uk.mathworks.com/matlabcentral/?s_tid=hc_resources

     

    Graduate II
    May 1, 2025

    4-bit can be fussy with respect to commands / sequences, also sensitive to wiring and skewing of data arrival.

    Graduate II
    May 1, 2025

    Well MicroSD cards can work on a NUCLEO-F767ZI

    I've used them with FATFS, make sure cards are in FAT32, perhaps up to 32 GB to be safe / less complicated

    You might want to look at the WaveShare sockets with the 33K or 47K type pull-ups on the DATA, CMD and CARD-DETECT lines

    Check what GPIO you've used for the CD / CARD-DETECT, and it's polarity. Normally switch to GND when card inserted.

    Perhaps rather than point at this document you could describe exactly what you've wired up and what it looks like.

    MicroSD should be usable 4-bit at 24 MHz, but you'd want short leads of uniform lengths. Perhaps not DuPont wires.