Showing results for 
Search instead for 
Did you mean: 

stm32l496 SDMMC Correct Sequence for writing multiple blocks

Lead II

I am in the process of porting some code from stm32F405 to stm32L496 in the hope of reducing current consumption.

One of the things my code does is write to an SD card, and because it writes a lot of data, I use


And then repeat {

set DTIMEr to a sensible value and DLEN to 512

DMA a blocks of 512 bytes

} until I have written all I want, at which point I issue


I typically do one of these multiple-block-writes every two seconds.

I was surprised to see that the supply current to my board would occasionally dip by about 5 mA for two seconds. This seems to happen when I do a


in the gap between my multi-block writes.

Any idea how to find out what I am doing wrong leading to the excessive current consumption?

I note that stm32l4xx_hal_sd.c sets DLEN to be total number of bytes to transfer, and does it all in one hit.

Lead II

I have since discovered I can get the current down by polling the SD card immediately after SD_CMD_STOP_TRANSMISSION.

In other words, I repeatedly send SD_CMD_SEND_STATUS until SDIO->RESP1 & 0x100 is non-zero.

I don't know why this works

  • Danish