I am trying to interface sd card with STM32F4 but things are not working,code was developed using cubemx
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
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)
{
}
}
f_open(&MyFile, "abc.txt", FA_READ )
See what are your config options in ffconf.h regarding file names.
Try using (FA_OPEN_EXISTING | FA_READ) flags.
Use f_open() repeatedly with 100ms interval, say 5 times, till it returns FR_OK.
嗨turboJ,我正在使用1位宽的SDIO模式连接SD卡,所以我猜没有用CS
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.