FAT and SDIO on the STM32F4: Early Experiments

I've been trying to marry the FatFS filesystem driver with a modified version of ST's SDIO sample code in order to read/write a FAT filesystem on an SD card for logging on my AVC robot.

It's been a frustrating few days. I've had intermittent results and I'm not sure why. I think there's some uncertainty with the DMA completion interrupts in my current lash-up. Moving from ST's library to Lukasz Iwaszkiewicz's software helped. I don't know the differences between the two codebases. Clocking the SD card at 25MHz (I think that's the clock speed in use) at the end of 12" jumper wires surely isn't helping anything. I also think that stopping the debugger and relaunching my code without powering off the SD card may leave its internal state machine confused. All of this is just conjecture, though, based largely on my wholescale ignorance of how the SD interface and the code I'm using actually work.

Currently, I'm able to read a file from the SD card but I'm having problems writing a file. (I started my attempt at writing this morning and only had 45 minutes to work on it before I had to leave for work.)

First experiments with the STM32F4DISCOVERY and an SD card.
First experiments with the STM32F4DISCOVERY and an SD card.

I'm designing a circuit board for my robot's brain that will solve the long wire problem when it's built, but I'm still a ways out from sending that off to be fabbed.

The Saleae logic analyzer that's barely visible in the picture has been worth its purchase price many times over. Many thanks to Supermodel Wife who bought it as a Christmas present for me despite knowing absolutely nothing about what it was!

3 thoughts on “FAT and SDIO on the STM32F4: Early Experiments”

  1. If you stop the debugger and relaunch your code, the SD card should already have gone through the initialization process. I was once stuck because I was trying to initialize an already initialized SD card. Be aware of this failure mode.

    1. Thanks, Michael. I suspected this might be the case, but at the same time, was thinking that the SD_Init() functions should take the SD card from whatever state it’s in and re-initialize it. But given my almost complete ignorance of the SD card protocol, those were both guesses. I’m thinking of supplying power to the SD card through a MOSFET switch controlled by a GPIO pin in my final design to ensure I don’t run into issues like this.

Leave a Reply

Your email address will not be published.


*