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.

Compiler/IWR6843: Send data from IWR6843 to PC/Raspberry Pi via SPI or I2C

Part Number: IWR6843
Other Parts Discussed in Thread: DCA1000EVM, , MMWAVEICBOOST

Tool/software: TI C/C++ Compiler

I want to send data from IWR6843 to PC/Raspberry Pi  via SPI or I2C instead of UART. I don't have DCA1000EVM, so I need a solution without it. Please tell me 

1) Which part of IWR6843 dss & mss source code can do this function? How to write code for SPI/I2C? Any reference?

2) Is there any device required to do the data transmission?

3) Currently I only have python sample code for GUI via UART, is there any source code for GUI via SPI/I2C?

Below is the code for SPI in SDK. Please explain why:

a. Chip select of slave 1 & 2 are 0xFFU (None)? Why does 0xFFU mean None?

b. MIBSPI_RAM_MAX_ELEM = 64U. But SPI hardware has an internal RAM buffer that stores transmit/receive data element in 8bits or 16bits. Why does RAM Length in bytes that used by the slave 0 can reach 64 bytes?

#include <stdint.h>
#include <stdlib.h>
#include <ti/drivers/spi/SPI.h>
#include <ti/drivers/dma/dma.h>
#include <ti/common/sys_common.h>

/* Externs */
extern const SPI_Config SPI_config[];

/* Used to check status and initialization */
static int32_t SPI_count = MINUS_ONE;

/* Default Master params */
const SPI_MasterModeParams SPI_defaultMasterParams =
{
    /* Master Params */
    5000000U,            /* bitRate */
    1,                   /* numSlaves */
    0,                   /* t2cDelay */
    0,                   /* c2tDelay */
    0,                   /* wDelay */
    {
        /* Slave - 0 */
        {
            (uint8_t)0U,                    /* CS0 */
            (uint8_t)MIBSPI_RAM_MAX_ELEM,   /* ramBufLen in number of dataSize */
            {
                DMA_CHANNEL_NONE,           /* TX DMA channel */
                DMA_CHANNEL_NONE            /* RX DMA channel */
            }
        },
        /* Slave - 1 - not valid */
        {
            (uint8_t)0xFFU,               /* CS_NONE */
            (uint8_t)0U,                    /* ramBufLen in number of dataSize */
            {
                DMA_CHANNEL_NONE,           /* TX DMA channel */
                DMA_CHANNEL_NONE            /* RX DMA channel */
            }
        },
        /* Slave - 2 - not valid */
        {
            (uint8_t)0xFFU,               /* CS_NONE */
            (uint8_t)0U,                    /* ramBufLen in number of dataSize */
            {
                DMA_CHANNEL_NONE,           /* TX DMA channel */
                DMA_CHANNEL_NONE            /* RX DMA channel */
            }
        }
    }
};

/* Default Slave params */
const SPI_SlaveModeParams SPI_defaultSlaveParams =
{
    /* Slave Params */
    {
        DMA_CHANNEL_NONE,   /* TX DMA channel */
        DMA_CHANNEL_NONE    /* RX DMA channel */
    },
    0U                      /* CS0 */
};

/* Default SPI parameters structure */
const SPI_Params SPI_defaultParams =
{
    .mode               = SPI_SLAVE,
    .pinMode            = SPI_PINMODE_4PIN_CS,
    .dataSize           = 16U,
    .frameFormat        = SPI_POL0_PHA0,
    .shiftFormat        = SPI_MSB_FIRST,
    .dmaEnable          = (uint8_t)1U,
    .dmaHandle          = (DMA_Handle)NULL,
    .eccEnable          = (uint8_t)1U,
    .csHold             = (uint8_t)0U,
    .txDummyValue       = (uint16_t)0xFFFFU,
    .transferMode       = SPI_MODE_BLOCKING,
    .transferTimeout    = SPI_WAIT_FOREVER,
    .transferCallbackFxn  = NULL,
    .custom             = (uintptr_t) NULL
};

/*
 *  ======== SPI_close ========
 */
void SPI_close(SPI_Handle handle)
{
    handle->fxnTablePtr->closeFxn(handle);
}

/*
 *  ======== SPI_control ========
 */
int32_t SPI_control(SPI_Handle handle, uint32_t cmd, void *arg)
{
    return (handle->fxnTablePtr->controlFxn(handle, cmd, arg));
}

/*
 *  ======== SPI_getStats ========
 */
int32_t SPI_getStats(SPI_Handle handle, SPI_Stats *ptrStats)
{
    return (handle->fxnTablePtr->getStatsFxn(handle, ptrStats));
}

/*
 *  ======== SPI_init ========
 */
void SPI_init(void)
{
    if (SPI_count == MINUS_ONE) {
        /* Call each driver's init function */
        for (SPI_count = 0; SPI_config[SPI_count].fxnTablePtr != NULL; SPI_count++) {
            SPI_config[SPI_count].fxnTablePtr->initFxn((SPI_Handle)&(SPI_config[SPI_count]));
        }
    }
}

/*
 *  ======== SPI_open ========
 */
SPI_Handle SPI_open(uint32_t index, SPI_Params *params)
{
    SPI_Handle handle;

    if ((int32_t)index >= SPI_count) {
        return ((SPI_Handle)NULL);
    }

    /* 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]);

    return (handle->fxnTablePtr->openFxn(handle, params));
}

/*
 *  ======== SPI_Params_init ========
 */
void SPI_Params_init(SPI_Params *params)
{
    *params = SPI_defaultParams;

    if(params->mode == SPI_MASTER)
    {
        /* Set Master Params */
        params->u.masterParams = SPI_defaultMasterParams;
    }
    else
    {
        /* Set Slave Params */
        params->u.slaveParams = SPI_defaultSlaveParams;
    }
}

/*
 *  ======== SPI_serviceISR ========
 */
void SPI_serviceISR(SPI_Handle handle)
{
    handle->fxnTablePtr->serviceISRFxn(handle);
}

/*
 *  ======== SPI_transfer ========
 */
bool SPI_transfer(SPI_Handle handle, SPI_Transaction *transaction)
{
    return (handle->fxnTablePtr->transferFxn(handle, transaction));
}

/*
 *  ======== SPI_transferCancel ========
 */
void SPI_transferCancel(SPI_Handle handle)
{
    handle->fxnTablePtr->transferCancelFxn(handle);
}

SPI hardware has an internal RAM buffer that stores transmit/receive data element in 8bits or 16bits.

  • Hi,

    Please find my response below:

    1) Which part of IWR6843 dss & mss source code can do this function? How to write code for SPI/I2C? Any reference?

      The SPI/I2C are accessible from MSS. Please refer to the test code @ C:\ti\mmwave_sdk_03_03_00_03\packages\ti\drivers\i2c\test\xwr68xx and 

    C:\ti\mmwave_sdk_03_03_00_03\packages\ti\drivers\spi\test\xwr68xx

    2) Is there any device required to do the data transmission?

    Not sure if i got the question. Could you please explain.

    3) Currently I only have python sample code for GUI via UART, is there any source code for GUI via SPI/I2C?

    No we do not have any GUI test code for SPI/I2C. But you should be able to modify the existing GUI for SPI/I2C. Please refer to spidev and smbus python packages.

     

    a. Chip select of slave 1 & 2 are 0xFFU (None)? Why does 0xFFU mean None?

    Slave 1 and 2 are invalid configuration. So if you try to open you will get an error.

    b. MIBSPI_RAM_MAX_ELEM = 64U. But SPI hardware has an internal RAM buffer that stores transmit/receive data element in 8bits or 16bits. Why does RAM Length in bytes that used by the slave 0 can reach 64 bytes?

    It can reach to 128 bytes if you use 16 bit data elements: 64 *16/8= 128 bytes 

    It is 64 bytes if you use 8 bit data elements: 64 *8/8= 64 bytes 

    Thanks

    Yogesh

     

     

     

  • Thanks Yogesh Siraswar

    1. I want to ask if we need any device to connect IWR6843 to Rapsberry Pi or PC? Or we can connect directly via SPI port? If so, is SPI pins on 60-pin connector (J10 connector)? Please tell me SPI pin location.

    2. Where are spidev and smbus python packages? Please send me the download link or directory path. I couldn't find those files in SDK folder.

    3. When should we transfer data from IWR6843 to PC via SPI/I2C/CAN or LVDS instead of UART? What's the advantage and usage case of each protocol in TI mmWave?

  • Hi Hector,

    1. I want to ask if we need any device to connect IWR6843 to Rapsberry Pi or PC? Or we can connect directly via SPI port? If so, is SPI pins on 60-pin connector (J10 connector)? Please tell me SPI pin location.

    Please refer to mmwaveicboost user guide @http://www.ti.com/lit/ug/swru546b/swru546b.pdf to get the SPI pin information. 

    2. Where are spidev and smbus python packages? Please send me the download link or directory path. I couldn't find those files in SDK folder.

    These are not part of SDK. They are available in public domain. You can refer to below link for more info:

    https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial/all

    3. When should we transfer data from IWR6843 to PC via SPI/I2C/CAN or LVDS instead of UART? What's the advantage and usage case of each protocol in TI mmWave?

    Its part of your system design depending on your requirements the data bandwidth, transfer rates etc. you can choose that works.

     

    Thanks

    Yogesh

  • Hi Yogesh,

    1. Is it necessary to write some register codes or hardware modification related to pinMux in order to use SPI, I2C? I checked the document swru546b, but there's no information about it. As I know, if we do wrong on pinMux, the board will be broken. Please provide me with documents and share real application experience on it,

    I read IWR6843 datasheet and see some infor such as PINCNTL ADDRESS

    I2C_SCL is 0xFFFFEA74

    I2C_SDA is 0xFFFFEA78

    SPIA_CLK is 0xFFFFEA14, SPIA_CS_N, SPIB_CLK... Are SPIA & SPIB 2 SPI ports? Are these 2 SPI ports initially enabled ready for use or we have to do something to enable it?

    Based on PINCNTL ADDRESS, please show me how to write code for PinMux SPI/I2C setup.

    2. By the way, can u introduce me any adapter device (SPI/I2C to USB converter) to connect IWR6843 to PC via SPI/I2C pins?

  • Hi Hector,

    Could you please create new thread for this issue. One of our H/W expert will be able to help you.

    Thanks

    Yogesh