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/CC2640: Writing with SDSPI interface waits 34us for every byte?

Part Number: CC2640

Tool/software: TI-RTOS

Hello experts,

I've implemented a SD SPI interface a while back ago that based on TI SPI driver. I hook the ported driver with FATFS so I can write, sync and close the text file in a readable format.

Not until now that I have a chance to test the performance and notice that when I write a big chunk of data, there is a wait time of 34 us for every byte, is it intended somewhere in the SPI driver (or is it how the FATFS works?). I'll do more tests to figure out why this happens, but if anyone has experienced this before and share their thought, it would be greatly appreciated.

Thanks,

Henry

  • Hi Henry,

    From the TI side we don't have this example, but I will let others who have implemented SD support chime in with their experiences.

    Best wishes
  • Thanks JXS,

    To clarify, I ported most of the code from SDSPITiva driver. I did a couple tests to separate where the issue is and I think it's from the driver.

    Furthermore, I notice there is a wait_ready function in the driver, which "queries the SDCard to see if it is in a busy state or ready
    state". This function wait for a data packet in a timeout of 500ms. I think this might be where the problem is, but again I'm not very sure yet.

    Thanks,
    Henry

  • Hello JXS,

    Is there any specific person that I could contact to ask for help to understand the SDSPITiva driver? I ported the driver to work with my board without paying too much into driver details and now I notice some strange things,

    First off, the function rxSPI and txSPI only receive/transmit 1 byte every call, this is fine if we send a small amount of data, but imagine if we write a big chunk of data frequently, the time it takes when transferring 1 byte vs 2 bytes at a time (for example) would be quite big to be taken into account. Also I'd really like to know how the function xmit_datablock works, because it does not make sense to me (i.e.

            UChar   wc;        
            /* Transferring 512 byte blocks using a 8 bit counter */
            do {
                /* Xmit the SD_SECTOR_SIZE byte data block */
                txSPI(hwAttrs, *buf++);
                txSPI(hwAttrs, *buf++);
            } while (--wc);

    instead of sending 512 bytes for 512 times, would it be possible to modify to send 2 bytes (per function call) or 3 bytes,...?

    Thanks,

    Henry

  • Problem solved!

    I replaced the do while above with,

    SD_Spi_write(&(sdState->spi), buf, 512);

    and it sends a whole sector at a time.