This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/TMS320C6748: SYS/BIOS FATFS failed

Genius 13655 points

Part Number: TMS320C6748

Tool/software: TI-RTOS

Hello Champs,

Customer used C6748 to implement a data acquisition system. The acquisition data are stored to SD card in FATFS format. The acquisition data code can run correctly without adding FATFS function. When adding FATFS storage function, it entered into the IDLE task after a while, the main task is running in another task's while() function. 

He used fatfs in Processor SDK4.0, below is the FATFS storage code. 

            char filename[40]={0};
            char dirname[20]="0:";

            //GateKey = GateSwi_enter(Gateswi);
            RTCTime_Read();
            RTCCalendar_Read();

            strcat(dirname,calendarstr);
            fresultRead = f_opendir(&Dir,dirname);
            if(fresultRead != FR_OK)
            {
                fresultRead = f_mkdir(dirname);
                if(fresultRead != FR_OK)
                {
                    UART_puts("Document creat failure\r\n",-2);
                }
            }
            strcat(dirname,"/");
            //TemValue();
            //strcat(timestr,Tread);
            strcat(timestr,".txt");
            strcpy(filename,dirname);
            strcat(filename,timestr);

            UART_puts(filename,-2);
            UART_puts("\r\n",-2);
            fresultRead=f_open(&file,filename,FA_WRITE|FA_CREATE_ALWAYS);
            if(fresultRead != FR_OK)
            {
                UART_printf("Fail to open file!!!!\n");

            }

            unsigned int i,j;
            char data_str[40]={0};
            for(i=0;i<i_step;i++)
            {
                for(j=0;j<AverageTimes;j++)
                {
                    System_sprintf(data_str,"%d %f %f",VolFsr[i][j],RDTime[i][j],FitResidue[i][j]);
                    f_puts(data_str,&file);
                    f_puts("\r\n",&file);
                }
            }

            f_close(&file);
            f_closedir(&Dir);

Thanks.
Rgds

Shine

  • Hello Shine,

    Can you verify that they call FATFS_init and FATFS_open prior to the other FATFS API calls (f_open, f_puts, etc)? I don't see them in the code snippet provided.

    Have they already referred to our FATFS example?
    software-dl.ti.com/.../Device_Drivers.html
  • Hello Sahin
    Thank you very much for your reply, This issue is what I posted in E2E Chinese community.
    I have tried to call FATFS_init and FATFS_open prior to the other FATFS API calls every time, but only the first time calling is correct to save data to SD card, and then all of calling is fault. all of FATFS API can't running correctly, data can't save in SD card.
    I have read TI FATFS example in your html, and I find the architecture of FATFS_init and FATFS_open have some difference with the "FATFS.h".
    Here is the new program.
    void MMCSDStoreFunc(void)
    {
    char filename[40]={0};
    char dirname[20]="0:";

    RTCTime_Read();
    RTCCalendar_Read();

    strcat(dirname,calendarstr);

    /*fresultRead = f_opendir(&Dir,dirname);
    if(fresultRead != FR_OK)
    {
    fresultRead = f_mkdir(dirname);
    if(fresultRead != FR_OK)
    {
    UART_puts("Document creat failure\r\n",-2);
    }
    }*/
    strcat(dirname,"/");
    //TemValue();
    //strcat(timestr,Tread);
    strcat(timestr,".txt");
    strcpy(filename,dirname);
    strcat(filename,timestr);

    UART_puts(filename,-2);
    UART_puts("\r\n",-2);

    FATFS_Params_init(&FATFSParams);
    FATFS_init();

    //
    FATFS_open(0U, NULL, &fatfsHandle);
    fresultRead=f_open(&file,filename,FA_WRITE|FA_CREATE_ALWAYS);
    if(fresultRead != FR_OK)
    {
    UART_printf("Fail to open file!!!!\n");

    }
    else
    {
    unsigned int i,j;
    char data_str[40]={0};
    for(i=0;i<i_step;i++)
    {
    for(j=0;j<AverageTimes;j++)
    {
    System_sprintf(data_str,"%d %f %f",VolFsr[i][j],RDTime[i][j],FitResidue[i][j]);
    f_puts(data_str,&file);
    f_puts("\r\n",&file);
    }
    }

    f_close(&file);

    }


    //f_closedir(&Dir);


    FATFS_close(fatfsHandle);
    // UART_printf("\nFATFS Init Success !!!!\n");


    }

    EDMA3 is configurate in the beginning of main(). the below is the configuration program.

    void mmcsd_fatfs_init(void)
    {
    EDMA3_DRV_Result edmaResult = 0;
    EDMA3_RM_Handle gEdmaHandle = NULL;
    MMCSD_v0_HwAttrs hwAttrsConfig;

    gEdmaHandle = (EDMA3_RM_Handle)edma3init(MMCSD_EDMACC_NUM, &edmaResult);

    if(MMCSD_socGetInitCfg(0,&hwAttrsConfig)!=0) {
    UART_printf ("\nUnable to obtain MMCSD config.Exiting. TEST FAILED.\r\n");
    return;
    }

    hwAttrsConfig.edmaHandle = gEdmaHandle;
    if(MMCSD_socSetInitCfg(0,&hwAttrsConfig)!=0) {
    UART_printf ("\nUnable to set config.Exiting. TEST FAILED.\r\n");
    return;
    }


    }