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.

AWR1642: SPI communication with AWR1642

Part Number: AWR1642

Hi Team,

The customer communicates using the SPIB of the AWR1642. Is there any way to make the program receive the transmitted data without scanning? Customer sets the callback function but can't always enter it.

The specific code is as follows:

void driver_spi_init(void)

{
SPI_Params spiParams;
DMA_Params dmaParams;
int32_t retVal;
int32_t errCode;

Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PIND13_PADAD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);/* SPIA_MOSI */
Pinmux_Set_FuncSel(SOC_XWR16XX_PIND13_PADAD, SOC_XWR16XX_PIND13_PADAD_SPIA_MOSI);

Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINE14_PADAE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);/* SPIA_MISO */
Pinmux_Set_FuncSel(SOC_XWR16XX_PINE14_PADAE, SOC_XWR16XX_PINE14_PADAE_SPIA_MISO);

Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINE13_PADAF, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);/* SPIA_CLK */
Pinmux_Set_FuncSel(SOC_XWR16XX_PINE13_PADAF, SOC_XWR16XX_PINE13_PADAF_SPIA_CLK);

Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINC13_PADAG, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);/* SPIA_CS */
Pinmux_Set_FuncSel(SOC_XWR16XX_PINC13_PADAG, SOC_XWR16XX_PINC13_PADAG_SPIA_CSN);

Pinmux_Set_OverrideCtrl(SOC_XWR16XX_PINP13_PADAA, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);/* SPI_HOST_INTR - not used, reference code */
Pinmux_Set_FuncSel(SOC_XWR16XX_PINP13_PADAA, SOC_XWR16XX_PINP13_PADAA_SPI_HOST_INTR);

/* Enable output control for SPIB */
if(SOC_SPIOutputCtrl(gMmwMssMCB.socHandle, 1U, 1U, &errCode) < 0)
{
/* Debug Message: */
System_printf ("Debug: SOC_SPIOutputCtrl failed with Error [%d]\n", errCode);
}

System_printf ("Debug: MibSPI Driver Test Application begin \n");

/* Init SYSDMA params */
DMA_Params_init(&dmaParams);

/* Open DMA driver instance 0 for SPI test */
gMmwMssMCB.gDmaHandle = DMA_open(0, &dmaParams, &retVal);

if( gMmwMssMCB.gDmaHandle == NULL)
{
System_printf("Open DMA driver failed with error=%d\n", retVal);
}

SPI_init();

/* Setup the default spi Parameters */
SPI_Params_init(&spiParams);

spiParams.mode = SPI_MASTER;
spiParams.u.masterParams.bitRate = 40000000;
spiParams.u.masterParams.numSlaves = 1;
spiParams.u.masterParams.slaveProf[0].chipSelect = 0;
spiParams.u.masterParams.slaveProf[0].ramBufLen = MIBSPI_RAM_MAX_ELEM;
spiParams.u.masterParams.slaveProf[0].dmaCfg.txDmaChanNum =1U;
spiParams.u.masterParams.slaveProf[0].dmaCfg.rxDmaChanNum =0U;

/* Enable DMA and set DMA channels */
spiParams.dmaEnable = 1;
spiParams.dataSize = 16;
spiParams.dmaHandle = gMmwMssMCB.gDmaHandle;

// spiParams.frameFormat = SPI_POL0_PHA0;
// spiParams.shiftFormat = SPI_MSB_FIRST;

spiParams.frameFormat = SPI_POL1_PHA0;
spiParams.shiftFormat = SPI_LSB_FIRST;
spiParams.pinMode = SPI_PINMODE_4PIN_CS;
spiParams.eccEnable = 1;

gMmwMssMCB.gSpiHandle = SPI_open(0, &spiParams);
if (gMmwMssMCB.gSpiHandle == NULL)
{
System_printf("Error: Unable to open the SPI Instance\n");
return;
}
System_printf("SPI open successful..\n");

}

The above is the way to receive using the scan method. May I know what is the configuration of the SPI callback function?

Thanks.

  • Hi Annie,

    Could you explain a bit about scanning mode here?

    If the customer is looking for interrupt handler for SPI transfer, then look for mibspi_dma.c: MIBSPI_ISR();

    Regards,

    Jitendra

  • Hi Jitendra,

    Customer uses another MCU to continuously send data to the AWR1642 SPI using DMA. The AWR1642 is configured as above.
    Data can only be received when SPI_Transfer() is called in a task, but this way there is a gap in receiving large amounts of data.

    Then the question is:
    1. If using DMA interrupt mode to receive, the customer adds these in the above code
    spiParams.transferMode = SPI_MODE_CALLBACK;
    spiParams.transferCallbackFxn = Spi_CallBack;
    In the customer's understanding, after receiving the data, the SPI DMA interrupt will call Spi_CallBack(). But actually there is no. He doesn't know how he should receive the data.

    2. If he uses SPI interrupt mode to receive, the above code does not initialize DMA. Even if he added the following code, it didn't work.
    spiParams.transferMode = SPI_MODE_CALLBACK;
    spiParams.transferCallbackFxn = Spi_CallBack;
    When he calls SPI_Transfer(), the program doesn't even run properly.

    Thanks.

  • Hi Annie,

    If you visit ti/drivers/spi/spi.h then SDK mentions that callback is not supported.

    /*!
     *  @brief      The definition of a callback function used by the SPI driver
     *              Callback mode is not support.
     *
     *  @param      SPI_Handle          SPI_Handle
     *  @param      SPI_Transaction*    SPI_Transaction*
     */
    typedef void        (*SPI_CallbackFxn) (SPI_Handle handle,
                                            SPI_Transaction * transaction);
    

    Currently, even if DMA is enabled for SPI driver, driver internally waits for DMA transfer to complete and after that only returns to the application.

    Mibspi_dma.c: MIBSPI_transfer() ->  SemaphoreP_pend(ptrMibSpiDriver->transferCompleteSem,...)

    Mibspi_dma.c: MIBSPI_sysDmaIntHandler

    Regards,

    Jitendra

  • Hi Jitendra,

    Thanks for your answer. 

    The SDK version is: mmwave_sdk_01_01_00_02.
    Customer saw in the SDK that the callback was called.

  • Hi Annie,

    Callback will get called whenever 'MIBSPI_sysDmaIntHandler' get called. I tried SDK 3.2 SPI test application and in that it is able to hit this interrupt handler.

    So I would request you to check the SPI test application to verify if DMA interrupt handler is getting called. 

    Regards,

    Jitendra

  • H Jitendra,

    Customers need a download link for your SDK 3.2. Could you send it to me? Customer says he is using SDK 1.1 now, so maybe this SDK 1.1 is not supported, thank you.

  • They can find all the mmWave SDK version at this link

    http://www.ti.com/tool/MMWAVE-SDK

    And here is SDK 3.2 

    http://software-dl.ti.com/ra-processors/esd/MMWAVE-SDK/latest/index_FDS.html

    Regards,

    Jitendra