2019-05-13 06:59 AM
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
SD_CMD_WRITE_MULT_BLOCK
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
SD_CMD_STOP_TRANSMISSION
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
SD_CMD_WRITE_SINGLE_BLOCK
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.
2019-05-14 02:16 AM
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