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.

CCS/SIMPLELINK-CC3220-SDK: v1.50.00.06: SPI_transfer() in blocking slave mode (rx only) always returns no valid data if DMA is used internally

Part Number: SIMPLELINK-CC3220-SDK

Tool/software: Code Composer Studio

If I setup my spi interface as slave to receive a block of data (SPI_Transfer from SDK), it returns no valid data if the DMA is used internally (dataSize > minDmaTransferSize).

Once I change the transfer size below minDmaTransferSize (100) by either transfer less data or by increasing the dataSize and lowering the count, spiPollingTransfer() is used internally (see SPICC32XXDMA.c) and the correct data gets received.

So it seems to me, there's an issue in the sdk/driverlib spi/dma code.

here's part of my code:

#define TRANSFER_SIZE        256

static Event_Struct ev_struct;
#define ev_handle       Event_handle(&ev_struct)
#define EV_SPI_SLAVE    Event_Id_00

static SPI_Handle spi_handle;
static SPI_Params spi_params;
static SPI_Transaction spi_trans;

static uint8_t rx_buf[TRANSFER_SIZE];

void thread(UArg arg0, UArg arg1)
{
    Event_construct(&ev_struct, NULL);
    SPI_init();

    SPI_Params_init(&spi_params);
    spi_params.dataSize = 8;
    spi_params.mode = SPI_SLAVE;
    spi_params.transferMode = SPI_MODE_BLOCKING;

    while (1) {
        // wait on event
        Event_pend(ev_handle, Event_Id_NONE, EV_SPI_SLAVE, BIOS_WAIT_FOREVER);

        spi_handle = SPI_open(Board_SPI0, &spi_params);

        spi_trans.rxBuf = rx_buf;
        spi_trans.txBuf = NULL;
        spi_trans.count = TRANSFER_SIZE;

        if (SPI_transfer(spi_handle, &spi_trans)) {
            UART_PRINT("got date over spi\r\n");
        } else {
            UART_PRINT("error on spi transfer\r\n");
        }

        // check content of rx_buf here

        SPI_close(spi_handle);
    }
}

  • I just checked, the call to SPI_transfer overwrites the buffer 0, the dma is most likely doing something but probably gets the date from the wrong place...
  • Hi Gartin,

    Do you have a section like the following in your CC3220SF_LAUNCHXL.c?

    /*
     *  =============================== DMA ===============================
     */
    #include <ti/drivers/dma/UDMACC32XX.h>
    
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN(dmaControlTable, 1024)
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment=1024
    #elif defined(__GNUC__)
    __attribute__ ((aligned (1024)))
    #endif
    static tDMAControlTable dmaControlTable[64];
    
    /*
     *  ======== dmaErrorFxn ========
     *  This is the handler for the uDMA error interrupt.
     */
    static void dmaErrorFxn(uintptr_t arg)
    {
        int status = MAP_uDMAErrorStatusGet();
        MAP_uDMAErrorStatusClear();
    
        /* Suppress unused variable warning */
        (void)status;
    
        while (1);
    }
    
    UDMACC32XX_Object udmaCC3220SObject;
    
    const UDMACC32XX_HWAttrs udmaCC3220SHWAttrs = {
        .controlBaseAddr = (void *)dmaControlTable,
        .dmaErrorFxn = (UDMACC32XX_ErrorFxn)dmaErrorFxn,
        .intNum = INT_UDMAERR,
        .intPriority = (~0)
    };
    
    const UDMACC32XX_Config UDMACC32XX_config = {
        .object = &udmaCC3220SObject,
        .hwAttrs = &udmaCC3220SHWAttrs
    };

    If so, is UDMACC32XX_init (in UDMACC32XX.c) completing successfully? You may have to use a breakpoint here.

    Best regards,

    Sarah

  • Hi Sarah

    Thanks for looking at my issue.

    I just checked, UDMACC32XX_init completes successfully (dmaInitialized = true;) and above mention code is in my CC3220SF_LAUNCHXL.c.
    Can you confirm that SPI slave using DMA is working for you?
  • Hi Gartin,

    Apologies for the delay. Can you test if you are seeing a similar behavior when using the SPI driver from SDK 1.40? We are currently investigating if there is an issue with SPI + DMA in SDK 1.50.

    Best regards,
    Sarah
  • Hi Sarah

    I checked with v1.40.01 and it it works. So it's a regression...

    Please let me know once you have a patch I can test.

    Thanks
    Martin

  • Hi Martin,

    The fix will be included in our next quarterly release of SDK 1.60 (in December).

    Best regards,

    Sarah

  • Hi Sarah,

    I am also facing the same issue, when bytes are less then 100 then communication works fine but for greater then 100 (DMA mode) it is not.

    please let me know the progress on it.

    Regards

  • Hi Rajendra,

    This fix was included in the 1.60.00.04 release of the CC3220 SDK. This is available at www.ti.com/.../simplelink-cc3220-sdk

    If you're having additional issues, please start a new thread.

    Best regards,
    Sarah