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.

TMS320C6745: SPI Low level driver with DMA works only one time

Using:

- Code compser 8

- pdk_omapl137_1_10

If DMA is enabled on SPI, only the first transaction works; a second transaction will hang.

Code (with SPI_DMA_ENABLE predefined symbol and Spi.Settings.useDma  = "true"; in the cfg:

Init:


SPI_Params spiParams; /* SPI params structure */
SPI_v0_HWAttrs spi_cfg;
uint32_t xferEnable= 1;

SPI_socGetInitCfg(SPI_INSTANCE, &spi_cfg);

spi_cfg.enableIntr = false;

#ifdef SPI_DMA_ENABLE
/* Set the DMA related init config */
spi_cfg.edmaHandle = SPIApp_edmaInit();
spi_cfg.dmaMode = TRUE;
spi_cfg.enableIntr = false;
#endif


SPI_socSetInitCfg(SPI_INSTANCE, &spi_cfg);

SPI_Params_init(&spiParams);

/* Init SPI driver */
SPI_init();

hwHandle = (SPI_Handle)SPI_open(SPI_INSTANCE, &spiParams);

xferEnable = 1;
SPI_control(hwHandle, SPI_V0_CMD_XFER_ACTIVATE, (void *)&xferEnable);

Single Transaction:

unsigned char SpiTransaction(unsigned int len,void* txBuf,void* rxBuf)
{
SPI_Transaction transaction; // SPI transaction structure
uint32_t terminateXfer = 0; // SPI argument for callback mode
unsigned char retval;

#ifdef SPI_DMA_ENABLE
CacheP_wbInv((void *)txBuf, (int32_t)sizeof(txBuf));
CacheP_wbInv((void *)rxBuf, (int32_t)sizeof(rxBuf));
#endif
transaction.txBuf = txBuf;
transaction.rxBuf = rxBuf;
transaction.count = len;
transaction.arg = (void *)&terminateXfer;

retval = SPI_transfer(hwHandle, &transaction);
return retval;
}

In SPI_MODE_CALLBACK is the same; only the first transaction calls the callback.

  • Hello,

    Could you please try updating the code to enable/disable SPI before/after SPI transfer using the control function? Please see the below code.

    /* Enable transfer */
    xferEnable = 1;
    SPI_control(hwHandle, SPI_V0_CMD_XFER_ACTIVATE, (void *)&xferEnable);
    
    retVal = SPI_transfer(hwHandle, &transaction);
    
    if (retVal == false)
    {
    testPassed = false;
    goto err;
    }
    
    /* Disable transfer */
    xferEnable = 0;
    SPI_control(hwHandle, SPI_V0_CMD_XFER_ACTIVATE, (void *)&xferEnable);

    Regards,
    Sahin

  • Hello,

    with this modification the spi works.

    Thanks.

    But now there is a new problem; with DMA enabled on SPI, McAsp (integrated from MCASP_Audio_evmOMAPL137_c674xExampleProject) doesn't work anymore.

    Probably there is some conflict at interrupt or EDMA3 level.

    For now I will don't use DMA on SPI; i will  create a new thread with different topic in future.