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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-15 9:33 AM
Why isn't the SDMMC code tolerant to interrupts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-15 10:23 AM
> 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-15 10:35 AM
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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-15 10:39 AM
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-15 10:44 AM
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.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-15 2:28 PM
Hi Tesla,
I have searched all of the FatFs directories (including Middleware) for an example using DMA but I cannot find a single one :(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-17 5:19 AM
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.
;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-06-17 6:53 AM
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.
