I2C SPI USB CAN eSPI Cable Testing View All Videos Quick Start Guides Software Downloads App Notes White Papers User Manuals Knowledge Base Sales Support About Us
Products Blog Sales Support Contact Search
Control Center Serial Software Series: Using I2C and SPI Mode
Brendan Murphy

The Control Center Serial Software is a GUI offered by Total Phase that can be used with the Promira Serial Platform, the extremely popular Aardvark I2C/SPI Host Adapter, and the Cheetah SPI Host Adapter to interface with I2C protocol and SPI protocol applications. The software provides easy access to all the I2C and SPI features available in our collection of host adapters and platform tools.

The Control Center Serial Software provides I2C and SPI control panels that allow users to interface with their devices. Both the I2C and SPI control panels offer Master and Slave mode configurations, making it easy to perform write and read functions, depending on the application. In this article, we will discuss how to get started using I2C and SPI mode and explain the different features and functions of the I2C and SPI control panels in the software.

I2C and SPI Overview

To get started, we will briefly go over the basics of both the I2C and SPI protocols.

I2C Overview

Philips developed the Inter-Integrated Circuit (I2C) protocol in the 1980s. I2C is a low-bandwidth, short-distance protocol for onboard communications.

The I2C communication protocol uses only two bidirectional open collector or open-drain lines, Serial Data Line (SDA) and Serial Clock Line (SCL), pulled up with resistors. Traditionally, typical voltages used have been 5V or 3.3V; however, recently 2.5V, 1.8V, and 1.2V have become more common.

I2C implements a master/slave paradigm. The master initiates the communication and the slave responds accordingly.

SPI Overview

In 1980, electronics manufacturer Motorola designed a communication protocol known as Serial Peripheral Interface (SPI) intended for its microcontroller-operated embedded systems that would allow full-duplex synchronous serial communication between master and slave devices on the bus. Today, the SPI protocol has become a leading standard for short-distance communication in embedded systems.

Sometimes called a four-wire serial bus, a basic SPI bus consists of an SPI master device and an SPI slave device connected by four wires. Two of the wires, the Master Out, Slave In (MOSI) and Master In, Slave Out (MISO) lines, act as signal lines that can be used to transmit data, either from the master to the slave or in the opposite direction.  Another line is used for the clock, the Serial Clock (SCLK) wire, and the fourth, the Slave Select (SS) line, is used to designate the target slave device for communication.

I2C + SPI Mode

When selecting to use the I2C and SPI mode within the Control Center Serial Software, you are presented with two side-by-side panels. One panel is for I2C control and the other is for SPI control, as seen in the image below.

Control Center I2C+SPI Mode within the Control Center Serial Software Control Center I2C+SPI Mode within the Control Center Serial Software

 

I2C Control Master Tab

I2C Control Master within the Control Center Serial Software I2C Control Master within the Control Center Serial Software

In the I2C Control panel, users can select between master or slave mode. As seen in the image above, we are highlighting  the “Master” mode.

In the I2C Master tab, there are three actions users can initiate: write, read, or register read the connected device.

Master Write

I2C Control Master Write within the Control Center Serial Software I2C Control Master Write within the Control Center Serial Software

Before initiating a master write, users must first specify their device’s bitrate, slave address, and other I2C feature settings.

Bitrate

The bitrate is the speed at which the master and slave will communicate. For I2C, the maximum master bitrate is 1 MHz and the minimum is 1 kHz. The Control Center Serial Software supports all bitrates between the maximum and minimum values specified above.

Slave Address

The slave address is the address of the target I2C slave device. This address can be entered in either decimal or hexadecimal notation.

Features

Features within the Control Center Serial Software Features within the Control Center Serial Software

The next step is specifying additional features. Some of these features include setting a 10-bit slave address, setting combined format, and enabling a “No Stop” command. If the no stop command is enabled, the bus will be held and the subsequent master read or write events will issue the repeated start on the bus until the “Free Bus” button is clicked. Once this button is clicked, it will issue the stop command and free the bus.

Message

Master Write Message within the Control Center Serial Software Master Write Message within the Control Center Serial Software

In the Master Write Message field, users can enter data to be sent over the bus. Enter the message to be sent in hexadecimal format and click the “Master Write” button to write the message.

Users can also upload a binary message file directly by clicking the “Load” button just below the message box. Conversely, the message can also be saved to a binary file by clicking on the “Save” button.

Master Read

Master Read within the Control Center Serial Software Master Read within the Control Center Serial Software

To perform a master read, users must first specify the number of data bytes they would like to read from the specified slave address. This value is the maximum number of bytes the master will accept in a single transaction. Once the number of data bytes is specified, clicking on the “Master Read” button will show the read data from the slave address in the Transaction Log below.

Master Register Read

Master Register Read within the Control Center Serial Software Master Register Read within the Control Center Serial Software

Generally, in order to read a register on an I2C device, users need to perform an I2C write with the registered address followed by a repeated start and an I2C read. The Master Register Read feature provides a way to do this in one operation. Simply enter in the register address, address width, and number of data bytes to be read and click the “Master Register Read” button to initiate the read.

Register Address

The “Register Address” can be entered in either decimal or hexadecimal notation. If using hexadecimal notation, preface the number with "0x". Note that this is different from the I2C slave address.

Address Width

The “Address Width” specifies the size in bytes of the register address. If the provided register address exceeds this width, the least significant bytes of the register address are used.

Number of Data Bytes

This value is the number of bytes the adapter will attempt to read from the I2C slave. The adapter may receive fewer bytes than are specified in this field, but not more. In the case that a slave does not have the requested number of bytes available, the remainder of the bytes will simply default to 0xff due to the pullup resistors on the bus.

I2C Control Slave Tab

I2C Control Slave within the Control Center Serial Software I2C Control Slave within the Control Center Serial Software

Since we now know how to use the I2C Master tab of the I2C Control panel, we will discuss how to use the Slave tab.

To start using the I2C slave mode, users must first set the device bitrate and enter the slave address.

Slave Mode Enabled within the Control Center Serial Software Slave Mode Enabled within the Control Center Serial Software

Max TX Bytes & Max Rx Bytes

Max TX Bytes & Max Rx Bytes within the Control Center Serial Software Max TX Bytes & Max Rx Bytes within the Control Center Serial Software

The Max Tx Bytes and Max Rx Bytes indicate the maximum number of bytes the adapter device will send and receive. The adapter will not exceed the maximum number of bytes that have been specified.

An exception to this rule is "0" which indicates that the number of bytes is unlimited.

Slave Response Message

Set Response Message within the Control Center Serial Software Set Response Message within the Control Center Serial Software

Next, a slave response message can be set in the message field as a response to a write request. The maximum message size for the Aardvark I2C/SPI Host Adapter is 64 bytes and for the Promira Serial Platform, it is 255 bytes.

To set the response, click on the "Set Resp" button. It is recommended to set the slave response before enabling the slave. If a response is not set before the slave is enabled, a slave response may be requested before the slave device has one to return. To enable the slave, users can click “Enable”, which will turn green, indicating its status.

Now that we’ve covered how to use the I2C Control panel in the Control Center Serial Software, we will discuss how to use the SPI Control panel.

SPI Control Master Tab

The SPI Control panel acts very similarly to the I2C Control panel but there are some key differences. First, we will discuss the SPI Master tab then move on to the SPI Slave tab.

SPI Control Master within the Control Center Serial Software SPI Control Master within the Control Center Serial Software

Bitrate

Just like the I2C Master and Slave control panels, we must first set our bitrate. The Control Center Serial Software supports SPI master speeds from 31 KHz to 40 MHz and SPI slave speeds from 31 KHz to 20 MHz depending on the device. Users can select a bitrate anywhere between the minimum and maximum values established above.

Data Frame Exchange Parameters

Data Frame Exchange Parameters within the Control Center Serial Software Data Frame Exchange Parameters within the Control Center Serial Software

Once the bitrate is established, we then are given the ability to set data frame information. Both the master and the slave devices need to agree about the data frame for communication to occur. The data frame is described by three parameters: clock polarity, clock phase, and bit order.

SS Polarity and MOSI Message

SS Polarity and MOSI Message within the Control Center Serial Software SS Polarity and MOSI Message within the Control Center Serial Software

Next, users will establish the SS polarity and Master Out, Slave In (MOSI) message. The SS polarity will dictate whether the SS pin will pull high or low to activate the SPI slave device. Once the polarity is specified, users can enter the MOSI message.

The MOSI message can be entered in the message box via hexadecimal format. Users can also upload a binary file by clicking on the “Load” button below. Once the message is in place, hit the “Send” button to send the message. The sent message will then be displayed in the Transaction Log below.

SPI Control Slave Tab

SPI Contol Slave Tab within the Control Center Serial Software SPI Control Slave Tab within the Control Center Serial Software

The SPI Slave tab is almost identical to the Master tab with only a few slight differences. Users will follow the steps above to set the bitrate and set the data frame exchange parameters.

Once completed, simply enter the Master In, Slave Out (MISO) message. This message is what the adapter will return as a response to an SPI transaction. Like the MOSI message, this message is entered in hexadecimal format. The maximum message size for the Aardvark adapter is 64 bytes and the one for the Promira Serial Platform is 255 Bytes.

Users can also upload a binary file by clicking on the “Load” button. Once the message is in place, click the “Set MISO” button to set the response message.

An adapter will not respond as an SPI slave device until it has been enabled. It is advisable that the MISO message be set in the slave device before it is enabled to ensure valid data to all requests. To enable the slave, users can click “Enable”, which will turn green, indicating its status.

Conclusion

As you can see, the Control Center Serial Software is a complex, yet simple tool that allows users to interface with their I2C and SPI applications with confidence and ease.

If you have any questions additional questions about the I2C and SPI Control panels, please email us at sales@totalphase.com.