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.

CC3200: Question about SPI multi word transmission performance

Part Number: CC3200


I'm seeing a larger than expected delay in between words on a multi word SPI transmission.  I'm transferring thirty two 16-bit transmissions per SPITransfer.  For each 16-bit transfer, the SPIEN is active low for 824nS, then goes high between words for 900nS.  This is the code for testing:

    // Test non TI-RTOS SPI performance
    unsigned short transmitBuffer[256];
    unsigned short receiveBuffer[256];
    PinMuxConfig();
    MAP_PRCMPeripheralClkEnable(PRCM_GSPI,PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralReset(PRCM_GSPI);
    MAP_SPIReset(GSPI_BASE);
    MAP_SPIConfigSetExpClk(GSPI_BASE,MAP_PRCMPeripheralClockGet(PRCM_GSPI),
                     20000000,SPI_MODE_MASTER,SPI_SUB_MODE_0,
                     (SPI_HW_CTRL_CS |
                     SPI_4PIN_MODE |
                     SPI_TURBO_ON |
                     SPI_CS_ACTIVELOW |
                     SPI_WL_16));
    MAP_SPIEnable(GSPI_BASE);
    while(1){
    MAP_SPITransfer(GSPI_BASE,(unsigned char *)transmitBuffer,(unsigned char *)receiveBuffer,64,SPI_CS_ENABLE|SPI_CS_DISABLE);
    }

For this attached SPI device, SPIEN must go high between each transfer.  Currently it takes less time to send the 16-bits than it does to get the SPIEN back low for the next transfer.  Is there anything I can do to reduce the between word delay?  Does using the uDMA help?  

Thanks,

Alex

  • Hi Alex,

    From my testing at the max clock rate of 20MHz, I observed that the SPI CS signal was deasserted for 0.2 - 0.22 microseconds per word. This was using the same settings as you, except with turbo mode off.

    This was however using a uDMA ping-pong buffering scheme, where the SPI peripheral has its FIFOs continuously serviced without any processor intervention beyond reloading a DMA transfer once every 1024 words.

    Using the uDMA to handle the data transfer to the SPI peripheral will likely greatly reduce the CS inactive time in your case. At such high transfer rates, making a SPI_Transfer function call for each word consumes a significant amount of processor time. With DMA, you would only have to spend that processor time once at the beginning of your transfer.

    If you take a look at the udma example in the SDK, there are functions such as InitUART0Transfer() that you can look at for a reference on how to setup the DMA controller. While that example demonstrates how to use DMA with the UART peripheral, you can use that as a guide on how to setup the DMA with SPI as the steps should be mostly the same.

    Regards,
    Michael

  • Michael,

    Thanks for the information and your timing results are what I was trying to achieve so I'll use the DMA controller and post my results as soon as they are confirmed.

    Thanks,
    Alex
  • As you mentioned, switching to the dma transfer (with fifo) reduced time between transmissions. My results were 50ns (one 20MHz cycle) between words.  Unfortunately, this is now too fast for the peripheral chip select specification (~150ns).  Is there a way to adjust the length of chip select (SPIEN) ?

    Thanks,

    Alex

  • Hi Alex,

    Try turning Turbo Mode off. That should get you to the 0.2us measurement that I got.

    Regards,
    Michael
  • I had just tried this and it increased the time to 200ns, which is acceptable. If there is a way to set CS time (by clock cycle), please let me know.

    Thanks again for your help,
    Alex