cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103Z: Speed up SD card access with a low SDIO clock (0.5 MHz)

msiddiquee
Associate

for my project I have to

  1. perform some controlling functionalities at high update rates (ideally the firmware should update at over 20 Hz)
  2. read data from the SD card through a very slow bandwidth with the sd card. the sdio clock is set to a low value due to other constraints

the small bandwidth is hogging up my cpu and impairing functionalities, so i want to explore alternatives. i am looking at

  1. trying to setup interrupts in the SDIO cache so that the microcontroller does not have to wait for the reading of the SD card
  2. setting up DMA.

I am looking for insights into this problem, such as which of these approaches are feasible, how to implement them, are there other ideas to do what i need done with such constraints, etc.

Any comments, opinions or ideas would be appreciated.

2 REPLIES 2

Sounds like you need to better partition the tasks so as not to block linear execution.

Put the critical, fast executing stuff in interrupts. Don't block. If you can't complete an operation, create a state machine so you can leave and come back later, and pick up from where you left. Use interrupts from the hardware, or a 1KHz task.

Queue IO tasks and buffer data. Manage the queue and access to the SD card in the foreground task.

20Hz is not fast

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
msiddiquee
Associate

Thanks for your reply. I am a complete beginner in the embedded world. Due to my limitations, I understand some of your ideas, but not all of them. For example, I do not understand why you ask me to create state machine (for a manual interruption of something?) or interrupt using a 1KHz task.

My current plan is as follows:

  1. Setup interrupt on SDIO cache being full (or half full); setup my micro-controller to detect that interrupt
  2. Program microcontroller to send read request to SDIO and than go back to what it was doing
  3. when SDIO gets the data, it will interrupt the microcontroller; it will store its state and do stuff with the data in the SDIO buffer. if i need more data from the SD, the interrupt handler will request more
  4. after handling the interrupt the microcontroller will back to doing what it was, until it gets interrupted/requires new data from the SD

Among other things, I do not exactly know how to implement the interrupt from the SD. for example:

  1. how do I make the SDIO send an interrupt. the ST reference manual RM0008 (found @ https://www.st.com/content/ccc/resource/technical/document/reference_manual/59/b9/ba/7f/11/af/43/d5/CD00171190.pdf/files/CD00171190.pdf/jcr:content/translations/en.CD00171190.pdf) mentions the following0690X000006DKHEQA4.png0690X000006DKLkQAO.png
  2.  But I am still uncertain as to how to set these registers to make the SDIO throw an interrupt when its recieve buffer is full (or half full)
  3.  I do not know how to configure the nested vector interrupt controller on the micro-controller to detect that interrupt
  4. I am not certain on how to connect that interrupt to a function in my code
  5. lastly, and perhaps most importantly, i need to figure how to restructure SdFat so that I can make it reads method command the SDIO to buffer data and than passes the processing thread back to the microcontroller (except for waiting for the data to come in)

Do you have any references for resources which will help me learn about setting up interrupts and using that to manage cache and SD card access.