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.

Fat SD write speed

Hello

My project needs to sample data from a sensor at 1000Hz and write it to the SD card.
I'm using MSP-EXP432P401R I collect data in blocks of 512 bytes but despite this the writing speed to the card is too slow.

Any help how can I increase the writing speed?
What is the SPI speed of the fatSD(FatFSDraw) I cannot find where is this configured.

Thank you for your help

Regards

  • Hi user4504050,
    The default SDSPI bit rate is 2,500,000 for MSP432 (I found this in ti/drivers/SDSPI.c). How are you collecting the data? Is it interrupt driven? The SDSPI driver is polling, so only Hwis, Swis, and Tasks of higher priority can interrupt the Task making the FatFS calls. We probably need more information about your system to figure out why this is too slow.
    Best regards,
    Janet
  • Hi Janet,

    Thank you for your reply.

    My project will collect data from sensors over i2c(accel,gyro).
    Currently I switched off this sensors and I'm making extensive testing on sd writing performance with dummy data.

    My first test was:

    while(enableSD) {
       f_write(...);
       f_sync();
    }

    Time for a cycle = 8,4ms

    Second test:

    while(enableSD) {
       f_write(...);
       if (timerSec % 60 == 0) {
         f_sync();
       }
    }
    

    This is like 100x faster, but once a minute it hangs for sync.
    I think that MSP432 is capable of writing to SD card much faster, but I don't know hot to achieve this. 

    Can I change the bit rate in the SDSPI.c?

    P.S. TI RTOS is new for me I switched from FreeRTOS(lpcxpresso) this is my first project with TI so far I'm really impressed but I have a lot of things still to learn.

  • You could try increasing the SDSPI bit rate and see if that makes any difference. You can do this with as follows:

    SDSPI_Params sdspiParams;

    SDSPI_Params_init(&sdspiParams);
    sdspiParam.bitRate = 'put your value here';
    sdspiHandle = SDSPI_open(Board_SDSPI0, DRIVE_NUM, &sdspiParams);

    (I took this code from the FatSDRaw example, and just added the line to set the bitRate of the params.)
    Best regards,
    Janet
  • I've increased the bit rate, but the results are the same.

    It looks like that the settings are not taking effect.

    Tried with:
    // sdspiParams.bitRate = 250000;
    // sdspiParams.bitRate = 1200000;
    // sdspiParams.bitRate = 4800000;

    Is there something else I can try?

    Thank you for you help!

    Regards,
    Best regards
  • Hi, I've been looking into this a bit and found that the code in the SDSPI_open() is setting the SPI bit rate to 400000 if the disk is not initialized. That could explain why changing the bitRate parameter has no affect. I'm trying to see if there's a way to work around this, but I'm having trouble with my SDCard right now.
    Best regards,
    Janet
  • As an experiment, you could try modifying and rebuilding the SPI driver to see if this is really the problem.  Specifically, in the initHw() function in SPIMSP432.c:

    static void initHw(SDSPIMSP432_Object *object,
        SDSPIMSP432_HWAttrs const *hwAttrs, uint32_t inputClkFreq)
    {
        uint32_t               bitRate;
        eUSCI_SPI_MasterConfig masterCfg;

        /*
         * If disk is not initialized configure the SPI bus to 400 kHz as
         * required per SD specs. Otherwise configure SPI with operating bit rate.
         */
        bitRate = (object->diskState == STA_NOINIT) ? 400000 : object->bitRate;

    You could just set the bitRate to object->bitRate, regardless of the state:

    bitRate = object->bitRate;

    Best regards,

        Janet

  • Thank you Janet,

    Something strange is happening here. After changing the bit rate ind the SPIMSP432.c I rebuild the project but this file is not rebuild. Actually it is not even included in the build path.

    This is the example file that I use..(it's ti rtos..)


    But this is what is actually build. :/

    making /Users/miha/Documents/CCS/workspace_01_test/fatsdraw_MSP_EXP432P401R_GNU_MSP432P401R/src/sysbios/sysbios.am4fg ...
    gmake[1]: Entering directory `/Users/miha/Documents/CCS/workspace_01_test/fatsdraw_MSP_EXP432P401R_GNU_MSP432P401R/src/sysbios'
    asmm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/m3/Hwi_asm_gnu.sv7M ...
    asmm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/m3/Hwi_asm_switch_gnu.sv7M ...
    asmm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/m3/IntrinsicsSupport_asm_gnu.sv7M ...
    asmm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/m3/TaskSupport_asm_gnu.sv7M ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/BIOS.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/knl/Clock.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/knl/Idle.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/knl/Intrinsics.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/knl/Queue.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/knl/Semaphore.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/knl/Swi.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/knl/Swi_andn.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/knl/Task.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/hal/Hwi.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/hal/Hwi_stack.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/hal/Hwi_startup.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/hal/Seconds.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/hal/SecondsClock.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/hal/Timer.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/msp432/init/Boot.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/rts/gnu/ReentSupport.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/rts/gnu/SemiHostSupport.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/m3/Hwi.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/m3/TaskSupport.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/m3/Timer.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/m3/TimestampProvider.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/msp432/Timer.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/family/arm/msp432/ClockFreqs.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/gates/GateHwi.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/gates/GateMutex.c ...
    clm4fg /Applications/ti/tirtos_msp43x_2_14_03_28/products/bios_6_42_03_35/packages/ti/sysbios/heaps/HeapMem.c ...






    As I know sd has to be initialized a lower speed, maybe that's why the 400kHz.


  • Janet, I found out that the file is compiled and that the bit rate is changing.

    The main problem is the f_sync function that is really slow.

    Hopefully I will find a way to speed this up.

    Thank you once again.
  • Hello,
    Could someone upload this example of MSP430 here in a zip file, please?
    Where must we call the function which reads/writes in the SD card? When I cal it either in the main function or in the taskFxn(), the BLE stops to advertise! Any idea of which is the problem?

    Thank you,
  • Hi,
    We generally discourage posting a new question to an old closed thread because the person who answered before may no longer be available, and also it will allow whomever is currently assigned to monitor the forum to respond to you more quickly. For these reasons, I suggest you start a new thread with your question and reference this thread.

    Thanks
  • Hello,

    Ok, thank you.

    Kind regards,