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.

CC2640r2 or CC2640: SPI example code in sensor controller studio

Hello Everyone,

I searched too many forums related to SPI sample for sensor controller.

So, is there any example code available for SPI in sensor controller studio?

If not then any documentation which guide how to implement SPI in sensor controller studio?

Any help will be appreciated.

Thanks

  • Hello Mahesh,
    There are a few code snippets in the Sensor Controller Studio Help Viewer. Press F1 in SCS and go to the SPI section.
  • Thanks Eirik for quick reply.

    I read the SPI section in sensor controller studio.

    And I have add following lines in "execution code" in SCS:

    spiBegin(SPI_POL0_PHA0, AUXIO_SPI_CSN_ACCEL);

    spiTx8bit(SPI_POL0_PHA0, 0x42);

    spiEnd(SPI_POL0_PHA0, AUXIO_SPI_CSN_ACCEL);

    Also mapped the SPI io pins. After code generation, I didn't see spi code in "main_tirtos.c" or any other SC files. Which files contain the spi related files?

    Or I can not use SC API in "main_tirtos.c" file. Could you please let me know how to read or write data using spi in SC.

    How can I use SPI function directly to read the data.

    Any help will be appreciated.

  • Hello,

    The SPI serial interface is implemented (bit-banged) in the sensor controller. That means you need to implement the SPI communication part in the Sensor Controller and then share data with the main application processor ( in main_titros.c ). Please refer to the Sensor controller ADC examples for how to share data between the sensor controller and the main application processor.

    You do not have to use the Sensor Controller, you can use the TI-RTOS SPI driver instead. Then you can refer to the TI-RTOS SPI examples. Please refer to resource explorer . Select SDK->Examples->Development Tools->Launchpad->TI Drivers->SPIxxx 

  • Hi Eirik,

    I know how to share data between sensor controller and main processor. My question is, How to implement the SPI communication part in the Sensor Controller? It will be good If you can give the example/template code for SPI sensor controller.

    I have spent so many time to implement SPI for sensor controller but still no success.

    Thanks
  • Hello,
    Usually, SPI on the sensor controller is used to interface to an external sensor. There might be some examples for future releases of SCS, but the code will be similar to the snippets in the help viewer.