I am trying to interface sd card with STM32F4 but things are not working,code was developed using cubemx
- Interface is sdio 1 bit mode(due to pin constraints)
- SD card 8 Gb formated with default allocation size
Steps taken to debug:
I single step through the code fmount is successful but when I step through fopen
there a error code at find_volume()
returning FR_NOT_READY
.
Hardware conections:
I have arduino micro SD breakout board with SPI pins so connection are
- DI → SDIO_CMD
- DO → SDIO_D0
- SCLK → SDIO_SCLK
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SDIO_SD_Init();
MX_FATFS_Init();
HAL_Delay(1000);
/* USER CODE BEGIN 2 */
if(f_mount(&mynewdiskFatFs,(const TCHAR*)SD_Path, 0) == FR_OK)
{
if(f_open(&MyFile, "abc.txt", FA_READ ) == FR_OK)
{
// GPIO_SetBits(GPIOD, GPIO_Pin_15);
if(f_read(&MyFile, wtext, sizeof(wtext), (void *)&wbytes) ==FR_OK);
{
f_close(&MyFile);
}
}
}
while (1)
{
}
}