2024-07-20 11:51 AM
I referred a youtube video https://www.youtube.com/watch?v=I9KDN1o6924
So i followed the steps
/* USER CODE BEGIN 2 */
if(f_mount(&SDFatFS, (TCHAR const*)SDPath, 0) != FR_OK)
{
Error_Handler();
}
else
{
if(f_mkfs((TCHAR const*)SDPath, FM_ANY, 0, rtext, sizeof(rtext)) != 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);
/* USER CODE END 2 */
In this code its unable to execute from f_mkfs
But its not showing any error during execution and i am also not understanding what is the error
FYI: I determined it was not executing from that part by using transmit function
2024-07-20 12:10 PM - edited 2024-07-20 12:11 PM
Did you verify, that you can READ without error or at all ?
Its very bad idea, to format (mkfs) on a device, you dont know , working or making nonsense on the sd-card.
So first try to read (an existing file) on card, then go on.
(Format is never needed, except you destroyed existing file system on card. )
2024-07-20 12:21 PM
I did not check for READ. i will see it
I know about mkfs, i want to format sdcard then write on it
2024-07-20 12:24 PM
All new sd-cards are formatted , so you just might do it worse. :)
2024-07-26 09:48 PM
@AScha.3 I tried it is giving me FR_NOT_READY and i have verified there no error while mounting (f_mount) and also sdcard is working normally when i connect it to laptop.
I think there something wrong with initialization , i am unable to figure what's the problem.
2024-07-27 12:00 AM
You have to mount NOW , to see, its working - or not. (-> hardware problem )
f_mount(&SDfs, (TCHAR const*)SDPath, 1); // SD card mount, 1 = now!
2024-08-05 05:46 AM
Hey everything worked out, actually i had to first turn on the board then insert uSD and reset board. If i turn on the board with uSD inserted it will not work.
2024-08-05 07:19 AM
So you are close...
Should work also on power up, so maybe..
Tip: insert a hal_delay , just 50 ms or so, before init card or any access. Many cards need some ms time before ready.