cancel
Showing results for 
Search instead for 
Did you mean: 

Problems opening a File on a SD-Card with CubeMX 5

SWend
Associate II

Hi all,

I´m trying to use a micro SD-Card with my Nucleo L433RC and have some Problems. The Code is generated by CubeMX 5. I added the following lines to it:

 FRESULT res;

 uint32_t byteswritten;

 uint8_t wtext[] = "Test1";

 if(retSD==0)

 {

 if(f_mount(&SDFatFS,(TCHAR const*)SDPath, 0)!= FR_OK)

 {

 Error_Handler();

 }

 else

  {

   if(f_open(&SDFile, "sd_test.txt",FA_CREATE_ALWAYS | FA_WRITE)!= FR_OK)

   {

   Error_Handler();

   }

   else

   {

   res = f_write(&SDFile, wtext, sizeof(wtext)-1,(void*)&byteswritten);

   if((byteswritten == 0)||(res!= FR_OK))

   {

   Error_Handler();

   }

   else

   {

   f_close(&SDFile);

   }

   }

  }

 }

The Code can´t open the File. Debugging shows that the command:

res = find_volume(&path, &fs, mode); 

Returns FR_NOT_READY

I´ve tested several SD-Cards but without succes. Pull-ups are the internal from the STM32.  

The Clock is at 8 MHZ. Clock divide factor for SD is 4.

Do you have any Suggestions for me?That would be awesome :) I do not know how to continue.

Best regards

Stephan

1 REPLY 1
Steve Melnikoff
Associate III

Can you use the debugger to find the function which first issues an error, and report back here?