# ADS1261_CC2652 **Repository Path**: s3iot/ADS1261_CC2652 ## Basic Information - **Project Name**: ADS1261_CC2652 - **Description**: CC2652驱动ADS1261, Δ∑ADC - **Primary Language**: C - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-10-13 - **Last Updated**: 2021-09-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README README

README

SysConfig Notice

All examples will soon be supported by SysConfig, a tool that will help you graphically configure your software components. A preview is available today in the examples/syscfg_preview directory. Starting in 3Q 2019, with SDK version 3.30, only SysConfig-enabled versions of examples will be provided. For more information, click here.


spimaster


Example Summary

Demonstrates how to use SPI driver in master mode to communicate with another SimpleLink device. To run this example successfully, another SimpleLink device running the spislave example is required.

Peripherals Exercised

Resources & Jumper Settings

If you’re using an IDE (such as CCS or IAR), please refer to Board.html in your project directory for resources used and board-specific jumper settings. Otherwise, you can find Board.html in the directory <SDK_INSTALL_DIR>/source/ti/boards/<BOARD>.

Before running the example the following pins must be connected between master & slave devices.

Master Pins Slave Pins
Board_SPI_MASTER CLK Board_SPI_SLAVE CLK
Board_SPI_MASTER MOSI Board_SPI_SLAVE MOSI
Board_SPI_MASTER MISO Board_SPI_SLAVE MISO
Board_SPI_MASTER CS Board_SPI_SLAVE CS
Board_SPI_MASTER_READY Board_SPI_MASTER_READY
Board_SPI_SLAVE_READY Board_SPI_SLAVE_READY

The SPI can be used in 4-pin or 3-pin modes (chip select is optional). When running this example SPI peripherals on both SimpleLink devices must align on chip select use. Users must verify before running the example.

Although not in the table above, a ground jumper must also be connected between both boards.

Example Usage

The connection will have the following settings:

    Baud-rate:     115200
    Data bits:          8
    Stop bits:          1
    Parity:          None
    Flow Control:    None

Messages should appear as follows:

    Starting the SPI master example
    This example requires external wires to be connected to the header pins. Please see the Board.html for details.

    Master SPI initialized

    Master received: Hello from slave, msg#: 0
    Master received: Hello from slave, msg#: 1
    Master received: Hello from slave, msg#: 2
    Master received: Hello from slave, msg#: 3
    Master received: Hello from slave, msg#: 4
    Master received: Hello from slave, msg#: 5
    Master received: Hello from slave, msg#: 6
    Master received: Hello from slave, msg#: 7
    Master received: Hello from slave, msg#: 8
    Master received: Hello from slave, msg#: 9

    Done

Note: The SPI peripheral on CC13x0, CC26x0, and CC26x0R2 devices have a bug which may result in TX data being lost when operating in SPI slave mode (SSI Advisory 04 & 05 in device errata). This bug causes the first SPI frame sent from the slave to be 0 instead of the actual data. When the master prints the received message to the display, the 0 will be interpreted as a NULL termination character & the message will not be printed. When this occurs, halt the master SPI device & check the contents of the receive buffer; the slave message should have been received with the first frame as 0.

Application Design Details

This application uses a single thread:

masterThread - creates the master SPI message, opens Board_SPI_MASTER and waits for the slave to be ready for a SPI transfer. When the slave is ready it starts the transfer. Once complete, the master prepares the next transaction & waits for the slave once more. A total of MAX_LOOP SPI transactions are performed in this manner.

The masterThread performs the following actions:

  1. Before performing transfers, we must make sure both, spimaster & spislave applications are synchronized with each other. The master will set Board_SPI_MASTER_READY to 1 to notify the slave it is ready to synchronize. The master will then wait for the slave to pull Board_SPI_SLAVE_READY high in acknowledgment.

  2. Opens Board_SPI_MASTER & sets Board_SPI_MASTER_READY to 0. Setting Board_SPI_MASTER_READY will notify the slave Board_SPI_MASTER has been opened.

  3. Waits for the slave to be ready for the SPI transfer. The slave will pull Board_SPI_SLAVE_READY low when ready for a transfer.

  4. Creates a SPI transaction structure and sets txBuffer to Hello from master, msg# n, where n is the iteration number.

  5. Toggles Board_GPIO_LED1.

  6. Transfers the message. If the transfer is successful, the message received from the slave SPI is printed. Otherwise, an error message is printed.

  7. Sleeps for 3 seconds.

  8. Repeats from step 3 for MAX_LOOP iterations.

  9. Closes the SPI driver object and terminates execution.

TI-RTOS:

FreeRTOS: