The Control Center Serial Software provides an interface for Total Phase host adapters and allows users to control and interact with I2C and SPI devices.
Total Phase host adapters offer numerous ways to test and develop I2C and SPI systems, including support for master and slave configurations. In this article, we’ll discuss how users can enable slave mode for I2C and SPI in the Control Center Serial Software.
Before delving into the slave mode functionality within the Control Center Serial Software, we’ll provide some background on the I2C and SPI protocols to get an idea of how communication is handled over the bus, as both I2C and SPI utilize a master and slave paradigm.
I2C is a two-wire communication protocol that is often used to connect low-speed microcontrollers to peripheral devices, including sensors and EEPROMs. The master device is the initiator of the communication. Once the master issues a start condition, the slave devices will “listen” on the serial data line for their respective address. The master device then sends the address of the target device and a read/write flag. The slave device that has the matching address acknowledges it has received this flag and then communication can proceed. Both the master and slave can send or receive data. If the master issues a read command, the master is requesting information from the slave device and if it issues a write command, the master will send data to the slave so it performs a function. Once the communication is complete, the master will issue a stop command.
SPI is a four-wire communication protocol often used to connect high-speed microcontrollers to peripheral devices, including sensors and flash memory devices. SPI offers a simpler architecture compared to I2C in that there is a single master and does not have a minimum or maximum speed. Because it is full-duplex, meaning data can be sent and received simultaneously over the bus, it allows the data to be sent more quickly.
Each of the four wires corresponds to a specific logical signal:
One SPI master can be connected to multiple slave devices and the SLCK, MOSI and MISO signals can be shared by multiple slave devices. Each slave device has a unique Slave Select signal, so the master pulls low on a slave’s SS line to select a device for communication.
Slave mode in the Control Center Serial Software provides an interface for users who want to configure their Total Phase host adapter as a slave device. This means the host adapter will simulate a slave device and read/respond to messages from the external master device. Both master and slave devices can receive or transmit data depending on whether the communication is a read or write command. Configuring the host adapter as a slave is helpful in testing the validity of the system as a whole and ensures that the master device is operating as expected. For instance, having the slave send messages to a master, such as a microcontroller, will allow testers to monitor its behavior.
For developers utilizing Total Phase tools to test and develop I2C and SPI systems, the Control Center Serial Software provides an easy-to-use interface to do so. Particularly, it offers SPI and I2C Control Modules that can configure the host adapter to operate as a master or slave.
To set the host adapter as an I2C slave, users will find a Slave tab on the I2C Control Module. Here, users can input the required parameters needed to enable the slave mode including:
The slave address is the I2C address that the adapter will use an I2C slave device and it always uses a 7-bit slave address. The address is specified in the 7 least significant bits. The most significant bit is ignored.
The Max Tx Bytes and Max Rx Bytes indicate the maximum number of bytes the adapter device will send and receive respectively. The adapter will not exceed the maximum number of bytes that have been specified. Inputting a “0” into this field will set the number of bytes as unlimited.
The Message entry field allows users to input a slave response message once there is an I2C transaction. This field can be set in the adapter as a response to a write request and operates the same as the I2C master message field.
There are multiple ways to input data into the message field. Users can manually enter data into the field or upload a binary file into the software by using the “Load” button. Users can also save any entered data from this field into a binary file by clicking the “Save” button.
When clicked, the "Set Resp" button will set the response by the slave. It is advised to set the slave response before enabling the slave to ensure valid data to all requests.
To enable the adapter as an I2C slave, click on the "Enable" button. Once the slave is enabled, the status indicator will turn from "Disabled" in red to "Enabled" in green.
As requests arrive for the slave, the transaction log will be updated with the read and write actions that the slave performed.
To disable the adapter as an I2C slave device, simply click on the "Disable" button. Once the slave is disabled, the status indicator will change from "Enabled" in green to "Disabled" in red.
For more in-depth details on enabling the I2C slave, please visit the user manual.
The MISO (Master In, Slave Out) message is the message that the adapter will return as its response to an SPI transaction. Like the MOSI message, this message is entered in hexadecimal format.
There are multiple ways to input data into the message field. Users can manually enter data into the field or upload a binary file into the software by using the “Load” button. Users can also save any entered data from this field into a binary file by clicking the “Save” button.
To set the MISO message, click the “Set MISO” button. It is advised to set the MISO message before enabling the slave to ensure valid data to all requests.
An adapter will not respond as an SPI slave device until it has been enabled. To enable the adapter as an SPI slave, click on the "Enable" button. Once the slave is enabled, the status indicator will turn from “Disabled” in red to “Enabled” in green.
As requests arrive for the slave, the transaction log will be updated with the read and write actions that the slave performed.
When the MOSI message is received, a MISO message is sent to the master. The transaction log will log MOSI and MISO as two separate transactions that occur at the same time.
To disable the adapter as an SPI slave device, simply click on the "Disable" button. Once the slave is disabled, the status indicator will change from "Enabled" in green to "Disabled" in red.
For more in-depth details on enabling the SPI slave, please visit the user manual.
Both the Aardvark I2C/ SPI Host Adapter and Promira Serial Platform are capable of simulating a master and slave device for I2C and SPI protocols. The Cheetah SPI Host Adapter only supports SPI master mode.
The Aardvark I2C/SPI Host Adapter configured as an I2C slave device can operate up to 800 kHz and up to 4 MHz an as SPI slave. This adapter has a slave response buffer of up to 64 unique bytes.
The Promira Serial Platform can operate at much quicker speeds compared to the Aardvark adapter. As an I2C slave, the Promira platform can operate up to 3.4 MHz, and as an SPI slave can operate up to 20 MHz. The slave response is supported up to 256 bytes, several times larger than the Aardvark adapter.
Whatever the project requirements, both tools offer great performance for simulating I2C and SPI slave devices.
To learn more about how these tools can advance your own I2C and/or SPI applications, please email us at sales@totalphase.com or request a demo.