2022-07-04 12:48 PM
Hi, I have an issue with the SD card on a STM32 F446VET.
if(f_mount(&SDFatFS, (TCHAR const*)SDPath, 0) != FR_OK)
{
Error_Handler();
}
else
{
/*DWORD fre_clust,tot_sect,fre_sect;
FATFS *fs;
f_getfree("1:",&fre_clust,&fs );
//if (res) die(res);
/* Get total sectors and free sectors */
//tot_sect = (fs->n_fatent - 2) * fs->csize;
// fre_sect = fre_clust * fs->csize;
/* Print the free space (assuming 512 bytes/sector)
// printf("%10lu KiB total drive space.\n%10lu KiB available.\n", tot_sect / 2, fre_sect / 2);*/
res=f_mkfs((TCHAR const*)SDPath, FM_ANY, 0, rtext, sizeof(rtext));
if(res != FR_OK)
{
Error_Handler();
}
else
{
//Open file for writing (Create)
if(f_open(&SDFile, "STM32.TXT", FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
Error_Handler();
}
else
{
//Write to the text file
res = f_write(&SDFile, wtext, strlen((char *)wtext), (void *)&byteswritten);
if((byteswritten == 0) || (res != FR_OK))
{
Error_Handler();
}
else
{
f_close(&SDFile);
}
}
}
}
f_mount(&SDFatFS, (TCHAR const*)NULL, 0);
the error comes at the f_mkfs() that returns FR_NOT_READY Error. Tried the same code on an NUCLEO F446RE and on an STM32F746G-DICSO on both ones it works and it creates and writes the text file.
When connected the logic analyzer to the SD card the Clock is showing fine, the SDIO_CMD and SDIO_D0 no signal at all.
2022-07-04 03:03 PM
The series resistors should only be 27R or 33R, their role would be to suppress ringing/overshoot. You surely don't want it to act as a divider.
The pull-up on D0,D1,D2,D3,CMD should be of the order of 33K or 47K
Top-Level code is going to be entirely irrelevant to how SDIO works.
For a READY case, make sure you've got and handle a GPIO related to the card-present switch in the card socket assembly.
2022-07-04 04:00 PM
So R7 and R8 should be 47K? Also D1, D2 and D3 don't have any pull-up resistors could I use the Pull-Up option from GPIO settings? and how this settings affects the schematics?
In regard of the card present switch, on the Discovery it worked with that function ON and with OUT that function.
2022-07-06 09:21 AM
Quick update . I looks that the problem is that it tries to detect the card , but according to schematics the card detect is always connected to ground so it fails here . will try to remove that option so it will ignore the card detection.