kiwih / cubeide-sd-card

CubeIDE/CubeMX compatible MMC/SD memory card FatFs driver
Other
100 stars 58 forks source link

Extraneous call to xchg_spi() within despiselect() after CS raised HIGH #7

Closed geosmall closed 2 years ago

geosmall commented 2 years ago

I've been moving this eample over from bloated STM32 HAL SPI to LL. I was getting SPI sync issues, I now believe there may be an extraneous call to xchg_spi() within despiselect() function that HAL SPI may have been hiding. See:

https://github.com/kiwih/cubeide-sd-card/blob/b73c66bee687bffc1ec1e938c5f3533a81308229/cubeide-sd-card/FATFS/Target/user_diskio_spi.c#L177

/*-----------------------------------------------------------------------*/
/* Despiselect card and release SPI                                         */
/*-----------------------------------------------------------------------*/

static
void despiselect (void)
{
    CS_HIGH();      /* Set CS# high */
    xchg_spi(0xFF); /* Dummy clock (force DO hi-z for multiple slave SPI) */  <<< THIS LINE CAUSED ISSUES

}
kiwih commented 2 years ago

Hi there, Thanks for your input. I have not previously used the LL drivers. That said, I'm not sure why it would cause a desync. After all, the SPI is deselected before this dummy transaction occurs. Have you tried other SD cards? Some SD cards do not properly support SPI etc. Good luck on resolving your issue.