kiwih / cubeide-sd-card

CubeIDE/CubeMX compatible MMC/SD memory card FatFs driver
Other
97 stars 56 forks source link

Low throughtput using the driver #19

Closed TheTarados closed 11 months ago

TheTarados commented 12 months ago

Hello everyone,

I had to take over a project that used this driver and find the source of the low throughput obtained (only around 20kB/s when way more should have been possible).

Looking at the driver, I changed the lines for(UINT i=0; i<btx; i++) { xchg_spi(*(buff+i)); } in function xmit_spi_multi in file user_diskio_spi.c to HAL_SPI_Transmit(&SD_SPI_HANDLE, buff, btx, 100);.

This greatly improved throughput (I am now around 800kB/s). I think there would be no difference if my SPI clock was way slower than my CPU clock, which is not my case but I don't see any advantage at the current way it is implemented.

Is there any reason why this is not done by default? I can do a pull request if this change would be accepted.

Have a good day!

kiwih commented 12 months ago

Ah I expect this was an oversight on my part when this code was made (I had refactored some older code to suit the HAL). I'd love if you submitted a PR to fix this.