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.

AWR1843BOOST: SPI_open call returning error

Part Number: AWR1843BOOST

AWR1843BOOST


static void MRR_MSS_initTask (UArg arg0, UArg arg1)
{
       SPI_Handle      handle;
       SPI_Params      params;
       SPI_Transaction spiTransaction;
       /* SPIA_MOSI */
       Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PIND13_PADAD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
       Pinmux_Set_FuncSel(SOC_XWR18XX_PIND13_PADAD, SOC_XWR18XX_PIND13_PADAD_SPIA_MOSI);

      /* SPIA_CLK */
      Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PINE13_PADAF, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
      Pinmux_Set_FuncSel(SOC_XWR18XX_PINE13_PADAF, SOC_XWR18XX_PINE13_PADAF_SPIA_CLK);

     /* SPIA_CS Latch */
     Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PINE15_PADAG, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
     Pinmux_Set_FuncSel(SOC_XWR18XX_PINE15_PADAG, SOC_XWR18XX_PINE15_PADAG_GPIO_30);

     GPIO_setConfig (SOC_XWR18XX_GPIO_30, GPIO_CFG_OUTPUT);

       /* Initialize the SPI */
       SPI_init();


       /* Initialize the SPI Parameters*/
       SPI_Params_init(&params);

       params.mode  = SPI_MASTER;
       params.u.masterParams.bitRate = 3000000U;
       params.pinMode  = SPI_PINMODE_3PIN;
       params.u.masterParams.numSlaves = 1;
       params.u.masterParams.slaveProf[0].chipSelect = 0;



       handle = SPI_open(0, &params);
       if(!handle)
       {

           while(1)
           {
               GPIO_toggle(SOC_XWR18XX_GPIO_30);
               Task_sleep(500);

           }
       }
}
  • HI,

    Have you looked at the SPI driver unit test provided?

    C:\ti\mmwave_sdk_03_05_00_04\packages\ti\drivers\spi\test\xwr18xx

    It shows how to use the SPI driver.

    Give me some time to check if there are any additional examples.

    Thank you

    Cesar

  • Yes, I'm taking reference of the same from C:\ti\mmwave_sdk_03_05_00_04\packages\ti\drivers\spi\test\xwr18xx, but my handler itself is returning error, I'm not able to proceed further if handle itself NULL

  • Also i'm not even getting clock pulse in SPI_CLK pin (J6 PIN 13)

  • Are you able to run the SPI driver example.

    These examples are validated by the SW test team and should work.

    I think the first step would be for you to be able to run this example before you try to integrated this code in your demo,

    Let me check with the team about other demos that use SPI.

    Thank you

    Cesar

  • I'm testing the same code, open call itself returning error , also I tested I2C example from same directory, its working perfectly
    Only for SPI, there is no clock pulse from SPI_CLK (J6 Connector pin number13).

    1. Both SPIA and SPIB pinmux configuration i did (instance 0 and 1)

    2. S2 line switched towards SPI

    None of them are working, at least i expect clock pulse coming from SPI_CLK after doing pinmux configuration but its always in low state 

  • Hi,

    If I understand correctly you are running the SPI unit test and the open call returns an error?

    C:\ti\mmwave_sdk_03_05_00_04\packages\ti\drivers\spi\test\xwr18xx\xwr18xx_spi_mss.xer4f

    Thank you
    Cesar

  • Yes your understanding is correct

  • Hi,

    The unit test have been validated through automated testing. There is always a possibility that there are issues with testing but the possibility is very low.

    Could you please let me know what are the steps you are taking to run this code?

    thank you
    Cesar

  • Hello Siddharth,

    I would request you to debug step by step via CCS when you load default SPI test application.

    And while you step into the SPI_Open function, CCS may ask for reference path to map the source file, so there you need to 'C:\ti\mmwave_sdk_03_05_00_04\packages\ti\drivers\spi\test\common' folder path if it is looking for test_common.c file or 'C:\ti\mmwave_sdk_03_05_00_04\packages\ti\drivers\spi\src' if looking for spi.c/mibspi_dma.c file.

    So after you map the driver source files in the CCS you can now debug further step into the driver code and check at which point or condition it is returning NULL or error. This way you can find the missing setting for SPI_open.

    Regards,

    Jitendra

  • Hello Jitendra, Thank you for your reply, I tried debugging SPI test application, it is working fine.
    but if I use exact same code in a new project my handle is returning error, I did not make single change exactly took same configuration, should I do any additional configuration apart from whatever code I attached below


    /* MCPI logger include files */
    #include <ti/utils/testlogger/logger.h>
    
    /* SPI test include files */
    #include <ti/drivers/spi/test/common/test_common.h>
    
    #include <ti/drivers/gpio/gpio.h>
    
    /**************************************************************************
     *************************** Local Definitions *********************************
     **************************************************************************/
    
    /**************************************************************************
     *************************** Global Definitions ********************************
     **************************************************************************/
    /* System DMA handle, created in init Task */
    DMA_Handle          gDmaHandle = NULL;
    
    /* Test case global variables */
    bool gXWR1xxxLoopbackTest = true;
    bool gXWR1xxxSlaveReady = false;
    
    /* Test with MSP43x */
    bool gXWR1xxxMasterWithMSPTest = false;
    bool gXWR1xxxSlaveWithMSPTest = false;
    
    /* Test with PC through FTDI */
    bool gXWR1xxxSlaveWithFTDITest = true;
    
    /* Test with XWR1xxx */
    bool gXWR1xxxMasterWithXWR1xxx = false;
    bool gXWR1xxxSlaveWithXWR1xxx  = false;
    
    /**
     * @brief
     *  Initialize the MCPI Log Message Buffer
     */
    MCPI_LOGBUF_INIT(9216);
    
    void Test_spiAPI_oneInstance(uint8_t inst)
    {
        SPI_Params     params;
        SPI_Handle     handle;
    
        /* Setup the default SPI Parameters */
        SPI_Params_init(&params);
    
        /* Enable DMA and set DMA channels */
        params.dmaEnable = (uint8_t)1U;
        params.dmaHandle = gDmaHandle;
        params.u.slaveParams.dmaCfg.txDmaChanNum =1U;
        params.u.slaveParams.dmaCfg.rxDmaChanNum =0U;
    
        params.mode = SPI_MASTER;
        params.u.masterParams.bitRate = 0;
    
        /* Open the SPI Instance for MibSpiA */
        handle = SPI_open(0, &params);
        if (handle == NULL)
        {
            while(1)
            {
                GPIO_write(SOC_XWR18XX_GPIO_2, 1);
            }
    
    
    
    
        }
    
    
    }
    static void Test_initTask(UArg arg0, UArg arg1)
    {
        bool            masterMode = true;
        DMA_Params      dmaParams;
        int32_t         retVal = 0;
        SOC_Handle      socHandle;
        int32_t         errCode;
    
        /* Get SOC driver Handle */
        socHandle = (SOC_Handle) arg0;
    
        /**************************************************************************
         * Test: MCPI_Initialize
         **************************************************************************/
        /* Initialize MCPI logger framework */
        //  MCPI_Initialize ();
    
        /* Init SYSDMA params */
        DMA_Params_init(&dmaParams);
    
        /* Open DMA driver instance 0 for SPI test */
        gDmaHandle = DMA_open(0, &dmaParams, &retVal);
    
        if(gDmaHandle == NULL)
        {
            printf("Open DMA driver failed with error=%d\n", retVal);
            return;
        }
    
        /* Initialize the SPI */
        SPI_init();
    
        /**************************************************************************
         * Test: One instace API test - SPIA
         **************************************************************************/
        Test_spiAPI_oneInstance(0);
    
        while(1)
        {
           
    
        }
    
    
    }
    
    
    
    
    int main (void)
    {
        Task_Params      taskParams;
        SOC_Handle       socHandle;
        int32_t               errCode;
        SOC_Cfg          socCfg;
    
        /* Initialize the ESM: Dont clear errors as TI RTOS does it */
        ESM_init(0U);
    
        /* Initialize the SOC confiugration: */
        memset ((void *)&socCfg, 0, sizeof(SOC_Cfg));
    
        /* Populate the SOC configuration: */
        socCfg.clockCfg = SOC_SysClock_INIT;
    
        /* Initialize the SOC Module: This is done as soon as the application is started
         * to ensure that the MPU is correctly configured. */
        socHandle = SOC_init (&socCfg, &errCode);
        if(socHandle == NULL)
        {
            /* Debug Message: */
            System_printf ("Debug: Soc_init failed with Error [%d]\n", errCode);
    
        }
    
        /* Wait for BSS powerup */
        if (SOC_waitBSSPowerUp(socHandle, &errCode) < 0)
        {
            /* Debug Message: */
            System_printf ("Debug: SOC_waitBSSPowerUp failed with Error [%d]\n", errCode);
    
        }
    
        /*=======================================
         * Setup the PINMUX to bring out the MibSpiA
         *=======================================*/
        /* NOTE: Please change the following pin configuration according
                to EVM used for the test */
    
        /* SPIA_MOSI */
        Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PIND13_PADAD, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR18XX_PIND13_PADAD, SOC_XWR18XX_PIND13_PADAD_SPIA_MOSI);
    
        /* SPIA_MISO */
        Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PINE14_PADAE, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR18XX_PINE14_PADAE, SOC_XWR18XX_PINE14_PADAE_SPIA_MISO);
    
        /* SPIA_CLK */
        Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PINE13_PADAF, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR18XX_PINE13_PADAF, SOC_XWR18XX_PINE13_PADAF_SPIA_CLK);
    
        /* SPIA_CS */
        Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PINE15_PADAG, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR18XX_PINE15_PADAG, SOC_XWR18XX_PINE15_PADAG_SPIA_CSN);
    
        /* SPI_HOST_INTR - not used, reference code */
        Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PINP13_PADAA, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR18XX_PINP13_PADAA, SOC_XWR18XX_PINP13_PADAA_SPI_HOST_INTR);
    
    
    
        GPIO_init();
    
        Pinmux_Set_OverrideCtrl(SOC_XWR18XX_PINK13_PADAZ, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
        Pinmux_Set_FuncSel(SOC_XWR18XX_PINK13_PADAZ, SOC_XWR18XX_PINK13_PADAZ_GPIO_2);
    
    
        GPIO_setConfig (SOC_XWR18XX_GPIO_2, GPIO_CFG_OUTPUT);
    
        /* SPIB signals are connected to PMIC and XDS110 , unless the connection is removed on XWR16
           EVM, SPI signals can not be enabled as output. */
    
    
        /* Debug Message: */
        System_printf ("******************************************\n");
        System_printf ("Debug: MibSPI Driver Test Application Start \n");
        System_printf ("******************************************\n");
    
        /* Initialize the Task Parameters. */
        Task_Params_init(&taskParams);
        taskParams.stackSize = 6*1024;
        taskParams.arg0 = (UArg)socHandle;
        Task_create(Test_initTask, &taskParams, NULL);
    
        /* Start BIOS */
        BIOS_start();
    
    
    
    }
    
    
    

  • Hi,
    Here is an example that uses SPI
     
    Please download the SW from the link at the bottom of the page
     
    Thank you
    Cesar
     
     
  • Update: I tried integrating automotive code base with SPI test code, then it is working, as a standalone it was not working, I will close this thread as solved, Once again thank you for your support

  • Great to hear that!

    thank you

    Cesar