cancel
Showing results for 
Search instead for 
Did you mean: 

I am using a STM32H743 to access a SD card using the ST micro driver code. I m NOT using interrupts for the MMC however if an interrupt occurs during a file access the code sometimes crashes. By crashes I mean the read routine times out.

BBert
Associate III

Why isn't the SDMMC code tolerant to interrupts?

7 REPLIES 7
TDK
Guru

> Why isn't the SDMMC code tolerant to interrupts?

Because the hardware needs to be fed data (or have data read) with strict timing requirements to avoid overrun/underrun of the hardware buffer.

Disable interrupts during access or use DMA based accessing to avoid.

If you feel a post has answered your question, please click "Accept as Solution".

The FIFO adds some tolerance, but you can't go wandering off in the middle of the data transfer phase, the cards just don't have a mid-transfer abort protocol..

Figure you're interrupt routines are very tardy, or you're task switching to some completely alternate universe.

Use DMA, polled is very fragile, as I think I've expressed here multiple times.

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

Hi TDK,

Thanks for the quick reply. I have disabled interrupts during the read access which, as you said, solved the problem. However it raised a new problem. If the interrupts are disabled then the timeout, which uses the systick interrupt, no longer works :( I have not used DMA so far but I'm willing to try it. Do you have any examples showing how to use DMA with the SDMMC?

Thanks...

There should be example diskio drivers in the FatFs Middleware directories.

H7 going to want to be conscious of the memory being utilized, the alignment and cache coherency.

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

Hi Tesla,

I have searched all of the FatFs directories (including Middleware) for an example using DMA but I cannot find a single one :(

AScha.3
Chief II

Hi Bert,

i was searching also (about 4 minutes) and see: sd_diskio_dma.c

(in STM32CubeH7-master\Projects\STM32H747I-EVAL\Applications\FatFs\FatFs_Dual_Instance\CM7\Src ) .

Maybe this is what you want.

��

If you feel a post has answered your question, please click "Accept as Solution".
BBert
Associate III

Hi AScha.3,

Thanks for the reply :)

The example you mentioned is for a dual-core STM32H7 device but it may work for my needs. I'll give it a try as time permits.