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/PROCESSOR-SDK-OMAPL138: SPI EDMA issue

Part Number: PROCESSOR-SDK-OMAPL138
Other Parts Discussed in Thread: OMAP-L138, OMAPL138

Tool/software: TI-RTOS

Hi All,

I am trying to communicate my device with spi with Edma by configuring SPI as below but facing transaction issue. So, I started spi edma in loopback mode.

My configurations are as follows...

SPI_INSTANCE = 1

SPI_socGetInitCfg(SPI_INSTANCE, &spi_cfg);

hEdma[0] = edma3init(0, &edmaResult);
if (edmaResult != EDMA3_DRV_SOK)
{
goto err;
}


spi_cfg.edmaHandle = hEdma[0];
spi_cfg.dmaMode = true;
SPI_socSetInitCfg(SPI_INSTANCE, &spi_cfg);


SPI_Params_init(&spiParams);
spiParams.frameFormat = SPI_POL0_PHA1;

SPI_init();

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

SPI_control(hwHandle,SPI_V0_CMD_LOOPBACK,(void *) &loop);


if (!hwHandle)
{
while(1);
}


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

txBuffer = (uint8_t *)Osal_local2Global(txBuf);
RxBuffer = (uint8_t *)Osal_local2Global(rxBuf);

while(1)
{

memcpy(txBuffer, "hello\n", 6);

len = 6;

CacheP_wb((void *)RxBuffer, 128);

transaction.txBuf = (uint32_t *)txBuffer;
transaction.rxBuf = (uint8_t *) RxBuffer;
transaction.count = len;
transaction.arg = (void *)&terminateXfer;

retVal = SPI_transfer(hwHandle, &transaction);

if (retVal == false)
{
testPassed = false;
while(1);
}
CacheP_Inv((void *)RxBuffer, 128);
memset(rxBuf, 0, 4);

udelay(1000);
}

SPI_close(hwHandle);

I took mcbsp as a reference to configure spi in edma mode but couldn't make it work. 

I am receiving dma interrupt Once with rx data as 0xB5B5B5B5B5B5 after that control getting exit from the task after keeping it in while(1) also.

Can anyone help me, where I am going wrong?

Thanks,

Bhargavi Ale.

  • Hi Bhargavi,

    I am currently out office this week so I will not be able to reproduce this on my board until next week. In the meantime, please refer to section 30.2.13 "DMA Events Support" and section 30.2.19 "Initialization" of the TRM to see if there are any steps you might've missed.

    OMAP-L138 Technical Reference Manual

  • Hi Sahin Okur,

    I have cross checked steps in TRM, it seems to be fine. Can you please, tell where I am going wrong?

    Thanks & Regards,
    Bhargavi Ale.
  • Hi Bhargavi,

    I'm sorry for the delay, are you still running into this issue?

    If so, can you please zip up your project and attach it here so we can try reproducing on our end?
  • Hi Sahin Okur,

    I'm sorry for late reply, Still I'm facing issue with SPI/EDMA.

    Please find the attachment and let me know if I do wrong.

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/spiLoopbaclWithDma.7z

    Thanks & Regards,

    Bhargavi Ale.

  • Hi All,

    Please, can anyone reply me back where I'm going wrong?

    Thanks & Regards,

    Bhargavi Ale.

  • Hello,

    I'm sorry for the delayed response. SPI DMA for OMAP-L138 is not officially supported in the SDK, but the same SPI driver (V0) is used on the K2G platform which has SPI DMA support.

    To enable DMA in the SPI driver for OMAP-L138, you will need to do the following:

    • Add "omapl138" to "drvspi_dma_SOCLIST" in spi_component.mk
    • Add "omapl138" to SOCLIST in \ti\drv\spi\build\makefile.mk 
    • Add "omapl138" to SOCLIST in \ti\drv\spi\build\makefile_dma.mk 
    • Rebuild the spi driver
      • cd pdk_omapl138_x_x_x\packages
      • pdksetupenv.bat
      • gmake spi
    • Add “Spi.Settings.useDma  = "true" to project .cfg
    • Define symbol "SPI_DMA_ENABLE" in CCS project.

    There may be some additional steps required since this hasn't been tested since it's not officially supported. But please give this a try and let us know if you run into any issues. We will do our best to provide any additional guidance.   

  • Hi Sahin Okur,

    Sorry for late reply. I was on leave didn't get chance to try the same. 

    I have done changes below changes

    drvspi_dma_SOCLIST     = tda2xx tda2px tda2ex tda3xx dra72x dra75x dra78x am574x am572x am571x k2h k2k k2l k2e k2g c6678 c6657 am437x am335x am65xx omapl138 --> in spi_component.mk file

    ifeq ($(SOC),$(filter $(SOC), k2h k2k k2l k2e k2g c6678 c6657 omapl138))
    SRCDIR += soc/dma/v0

    ifeq ($(SOC),$(filter $(SOC), tda2xx tda2px dra72x dra75x tda2ex am571x am572x am574x tda3xx dra78x am437x am335x k2h k2k k2l k2e k2g c6678 c6657 omapl138))
    INCLUDE_EXTERNAL_INTERFACES = pdk edma
    else
    INCLUDE_EXTERNAL_INTERFACES = pdk
    endif

    ifeq ($(SOC),$(filter $(SOC), tda2xx tda2px dra72x dra75x tda2ex am571x am572x am574x tda3xx dra78x k2h k2k k2l k2e k2g c6678 c6657 am437x am335x am65xx omapl138))
    PACKAGE_SRCS_COMMON += soc/$(SOC) soc/SPI_soc.h
    ifeq ($(SOC),$(filter $(SOC), k2h k2k k2l k2e k2g c6678 c6657 omapl138))
    PACKAGE_SRCS_COMMON += soc/dma/v0  --> in makefile_dma.mk

    and there is no SOC list to add "omapl138" in makefile.mk

    Followed same steps to build spi in pdk and enabled spi dma option in my project but I couldn't see any luck on this.

    Is still I'm missing any steps??

    Please, let me know any changes require.

    Capture of Debug after addition of spi dma in pdk.

    Thanks & Regards,

    Bhargavi Ale.

  • Hi Sahin Okur,

    I forgot to inform that, edma transaction is working only once without any above chances in pdk and after one transaction control got stuck at semStatus = SPI_osalPendLock(object->transferComplete, object->waitTimeout);. I was attached same project in my previous post.

    Please, let me know any idea on the same issue.

    Thanks & Regards,

    Bhargavi Ale.