cancel
Showing results for 
Search instead for 
Did you mean: 

FATFs f_open ?

antonius
Senior
Posted on February 25, 2017 at 23:02

Everybody,

Why isn't my f_open working properly ?

I tried the example from UM1718 but stack on f_open.

Is SDIO initialized properly ?

here's the code :

/TEST SDIO begin

if(retSD == 0)

            {

                printf('inside if retSD \n');

                HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6, GPIO_PIN_RESET);

                HAL_Delay(1000);

                /*♯♯-2- Register the file system object to the FatFs module ♯♯♯*/

                    if(f_mount(&SDFatFs, (TCHAR const*)SD_Path, 0) != FR_OK)

                        {

                            /* FatFs Initialization Error : set the red LED on */

                            HAL_GPIO_WritePin(GPIOE, GPIO_PIN_5, GPIO_PIN_SET);

                            HAL_Delay(100);

                            HAL_GPIO_WritePin(GPIOE, GPIO_PIN_5, GPIO_PIN_RESET);

                            printf('FMOUNT FAIL! \n');

    

                            while(1);

                        }

                        else

                            {

                                printf('inside else on f_mount \n');

                                printf('f_mount OK! \n');

                                HAL_GPIO_WritePin(GPIOE, GPIO_PIN_5, GPIO_PIN_SET);

                                HAL_Delay(1000);

                                HAL_GPIO_WritePin(GPIOE, GPIO_PIN_5, GPIO_PIN_RESET);

                                // it's stopped here

                             res = f_open(&MyFile, 'hello.txt', FA_CREATE_ALWAYS | FA_WRITE);

                                

                                printf('after res command!');

I diagnosed from serial :

inside if retSD

inside else on f_mount

f_mount OK!

Anyone can help please ?

Thanks

#fatfs-sdio #sdio #stm32f103
3 REPLIES 3
antonius
Senior
Posted on February 25, 2017 at 23:03

The code is based from UM1718 page 194

Imen.D
ST Employee
Posted on March 01, 2017 at 12:10

Hi,

You may refer and get inspired from one of the provided FatFS applications with STM32CubeF1 firmware package. Compare your generated code with working example as this one:  STM32Cube_FW_F1_V1.4.0\Projects\STM3210C_EVAL\Applications\FatFs

May this

can helps you.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on March 01, 2017 at 22:29

I got it work already,

changing the SDIO init speed will fix it.