C28x SPI Master Transfer

Write data to and read data from SPI slave device

  • Library:
  • Embedded Coder Support Package for Texas Instruments C2000 Processors / C2802x

    Embedded Coder Support Package for Texas Instruments C2000 Processors / C2803x

    Embedded Coder Support Package for Texas Instruments C2000 Processors / C2805x

    Embedded Coder Support Package for Texas Instruments C2000 Processors / C2806x

    Embedded Coder Support Package for Texas Instruments C2000 Processors / C280x

    Embedded Coder Support Package for Texas Instruments C2000 Processors / C281x

    Embedded Coder Support Package for Texas Instruments C2000 Processors / C2833x

    Embedded Coder Support Package for Texas Instruments C2000 Processors / C2834x

    Embedded Coder Support Package for Texas Instruments C2000 Processors / F2807x

    Embedded Coder Support Package for Texas Instruments C2000 Processors / F2837xD

    Embedded Coder Support Package for Texas Instruments C2000 Processors / F2837xS

    Embedded Coder Support Package for Texas Instruments C2000 Processors / F28004x

    Embedded Coder Support Package for Texas Instruments C2000 F28M3x Concerto Processors / F28M35x / C28x

    Embedded Coder Support Package for Texas Instruments C2000 F28M3x Concerto Processors / F28M36x / C28x

Description

The C28x SPI Master Transfer block writes data to and reads data from a slave device over the Serial Peripheral Interface (SPI). The block runs in master mode. The block outputs an array of the same size and data type as the input values. You can use this block with the Byte Pack and Byte Unpack blocks for heterogeneous data type transfers.

Configure the SPI modules for the specific hardware board by navigating to Hardware Implementation > Target hardware resources. Verify that these settings meet the requirements of your application.

Using this block, you can access an SPI device to measure quantities such as temperature and pressure.

Ports

Input

expand all

The data written by the block to the registers of a slave device over the SPI interface.

Data Types: uint16

Output

expand all

The data read by the block from the registers of a slave device over the SPI interface.

Data Types: uint16

Parameters

expand all

Main

The SPI peripheral module to which the SPI slave device is connected. Each processor has a different number of modules.

The clock polarity (CPOL) for SPI communication mode.

The clock phase (CPHA) for SPI communication mode.

Enables the Register address parameter.

The slave register address from which the block reads data.

Dependencies

This parameter appears only when you select Enable register address.

Advanced

Length in bits of each transmitted or received character, specified as an integer in [1 16]. For example, if you select 8, the maximum value that can be transmitted using SPI is 28 – 1. If you send data values greater than this value, the buffer overflows.

The SPI master uses these methods to select SPI slave devices.

  • Provided by the SPI peripheral — The SPI master uses the STE pin assignment parameter in Hardware Implementation > Target Hardware Resources > SPI to select the slave device. Slave select and deselect are handled by the SPI peripheral.

  • Explicit GPIO calls — The SPI master uses the general purpose input/output pins explicitly to select/deselect SPI slave devices. The SPI Master Transfer block selects the slave before data is transmitted and deselects the slave after data is received using GPIO pins.

The logic levels supported by the slave select pin to select the SPI slave device.

  • Active low — The device is enabled on logic low. The SPI slave device is enabled when its slave select pin is set to low.

  • Active high — The device is enabled on logic high. The SPI slave device is enabled when its slave select pin is set to high.

Dependencies

This parameter appears only when Slave select calling method is set to Explicit GPIO calls.

The general purpose input/output pin that serves as slave select for SPI.

Dependencies

This parameter appears only when Slave select calling method is set to Explicit GPIO calls.

Introduced in R2017b