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.

CC2640R2F: Does the SPI of CC2640R2F already use dma by default?

Part Number: CC2640R2F
Other Parts Discussed in Thread: ADS1291

Hi Team,

Recently, I used SPI to read ADS1291 data, and I felt that the frequency of data reading was not very stable. Would it be better to use dma?

Then I looked at the spi program and felt that the spi had been configured with DMA, so I want to make sure if this is true or not?

const SPICC26XXDMA_HWAttrsV1 spiCC26XXDMAHWAttrs[BOARD_SPICOUNT] = {
{
.baseAddr = SSI0_BASE,
.intNum = INT_SSI0_COMB,
.intPriority = ~0,
.swiPriority = 0,
.powerMngrId = PowerCC26XX_PERIPH_SSI0,
.defaultTxBufValue = 0,
.rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX,
.txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX,
.mosiPin = BOARD_SPI0_MOSI,
.misoPin = BOARD_SPI0_MISO,
.clkPin = BOARD_SPI0_SCK,
.csnPin =BOARD_SPI0_CSN
}
};

//spi_config includes configuration for dma?

const SPI_Config SPI_config[BOARD_SPICOUNT] = {
{
.fxnTablePtr = &SPICC26XXDMA_fxnTable,
.object = &spiCC26XXDMAObjects[BOARD_SPI0],
.hwAttrs = &spiCC26XXDMAHWAttrs[BOARD_SPI0]
}
};

/* SPI function table for SPICC26XXDMA implementation */
const SPI_FxnTable SPICC26XXDMA_fxnTable = {
SPICC26XXDMA_close,
SPICC26XXDMA_control,
SPICC26XXDMA_init,
SPICC26XXDMA_open,
SPICC26XXDMA_transfer,
SPICC26XXDMA_transferCancel
};

SPI_Handle SPI_open(uint_least8_t index, SPI_Params *params)
{
SPI_Handle handle = NULL;

if (isInitialized && (index < SPI_count)) {
/* If params are NULL use defaults */
if (params == NULL) {
params = (SPI_Params *) &SPI_defaultParams;
}

/* Get handle for this driver instance */
handle = (SPI_Handle)&(SPI_config[index]); 
handle = handle->fxnTablePtr->openFxn(handle, params);
}

return (handle);
}

SPIHandle = SPI_open(BOARD_SPI0, &SPIparams);

Should I use SPICC26XXDMA_transfer instead of SPI_transfer(); when transmitting?

Kind regards,

Katherine

  • In the end, SPI_transfer() still called SPICC26XXDMA_transfer.

    void SPI_transferCancel(SPI_Handle handle)
    {
    handle->fxnTablePtr->transferCancelFxn(handle);
    }
    
    const SPI_FxnTable SPICC26XXDMA_fxnTable = {
    SPICC26XXDMA_close,
    SPICC26XXDMA_control,
    SPICC26XXDMA_init,
    SPICC26XXDMA_open,
    SPICC26XXDMA_transfer,
    SPICC26XXDMA_transferCancel
    };
    
    typedef struct {
    /*! Function to close the specified peripheral */
    SPI_CloseFxn closeFxn;
    
    /*! Function to implementation specific control function */
    SPI_ControlFxn controlFxn;
    
    /*! Function to initialize the given data object */
    SPI_InitFxn initFxn;
    
    /*! Function to open the specified peripheral */
    SPI_OpenFxn openFxn;
    
    /*! Function to initiate a SPI data transfer */
    SPI_TransferFxn transferFxn;
    
    /*! Function to cancel SPI data transfer */
    SPI_TransferCancelFxn transferCancelFxn;
    } SPI_FxnTable;
    
    const SPI_Config SPI_config[EEG_BOARD_SPICOUNT] = {
    {
    .fxnTablePtr = &SPICC26XXDMA_fxnTable,
    .object = &spiCC26XXDMAObjects[EEG_BOARD_SPI0],
    .hwAttrs = &spiCC26XXDMAHWAttrs[EEG_BOARD_SPI0]
    }
    }; 
    
    

  • Hi Katherine,

    As you have discovered, the SPI TI Driver does use the DMA peripheral.  You should use SPI_transfer which will map to the correct implementation of SPICC26XXDMA_transfer.  Please refer to the spimaster or spiffsexternal example and specify the instabilities you are observing, preferably with terminal output logs and logic analyzer screenshots.

    Regards,
    Ryan