AnsweredAssumed Answered

SD card using SPI initialization stm32f303 issue

Question asked by ALKUOR.ABDELRAHEEM on Nov 30, 2016
Latest reply on Mar 5, 2018 by Daniel Koster
Hello, I am sending the correct command and I can see it on the scope.However, I don't get 0x01 response(I keep getting 0xff) from SDcard(SDHC)(SanDisk Ultra 40MB/s ...16GB) I am using the following code:

uint8_t c=0;
uint8_t cmd0[9]={0x40,0x00,0x00,0x00,0x00,0x95};
uint8_t dumb=0xff;
        FATFS_CS_HIGH;
     for (int i = 0; i < 10; i++) {
    HAL_SPI_Transmit(&hspi1, &dumb, 1, 10);
    while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
        }
 
    FATFS_CS_LOW;
 
HAL_SPI_Transmit(&hspi1, cmd0, 6, 10);
while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
 
 
for(int i = 0; i < 2; i++) {
HAL_SPI_Transmit(&hspi1, &dumb, 1, 10);
while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
}
 HAL_SPI_Receive(&hspi1, &c, 1, 10); I keep getting 0xff from slave
                                               
                                   

I am sending the correct command and I can see it on the scope.However, I don't get 0x01 response(I keep getting 0xff) from SDcard(SDHC)(SanDisk Ultra 40MB/s ...16GB) I am using the following code:

           

Outcomes