AnsweredAssumed Answered

Cube F4 v4.3 and SDIO SD_TX_UNDERRUN error

Question asked by JasonP on Jul 16, 2014
Latest reply on Mar 25, 2015 by elaske
Hi All,
Using the standard Cube (F4 v1.30) HAL_SD drivers, I randomly get the SD_TX_UNDERRUN" error when writing using HAL_SD_WriteBlocks().
It happens totally at random.
I have tried:
- using older libraries - same result
- Modified SRAM (data source) speed - same "underrun"
- Modified PLLQ (slower) - same  "underrun" 
- Modified "HAL_SD_WriteBlocks() where it performs the FIFO writes to just write "SDIO->FIFO = 0", this actually made it more reliable (especially for 1 block write), but not 100% consistent, and this obviously is unusable anyway.
This points to the fact that the function cannot source data fast enough for the FIFO sink - hence the underrun (I know this is obvious - but why??????)

What DOES work is modifying the "Init.ClockDiv" value to (say) '2' from '0' to slow the SD peripheral down from 25MHz (This obviously also slows the transfer rate)

Why can't the STM keep up with the SD write FIFO?
Is this normal?
Has anyone else found this issue?
It happens with all cards I have tried (SD,SDHC,SDXC)

DMA doesn't have this issue (although that's another can of worms using the unmodified HAL drivers)