How Can SPI Devices Use Dummy Bytes for Reading Data of Nonstandard Word Lengths over an SPI Bus?

Question from the Customer:

I plan to use the Cheetah SPI Host Adapter to generate traffic on a 4-wire Mode 0 SPI bus at 8 MHz. The communication pattern is specialized. The protocol being used is not a full duplex. The master sends 3 bytes on the MOSI and then reads 3 returned bytes on the MISO. It looks like the Cheetah only returns the bytes seen on MISO when there is a write on MOSI, essentially assuming only a Write/Read operation.

My application does not Write/Read. Instead, it does a Write then a Read. I’m looking for a way to make this work.  What do you advise? Also, to monitor the traffic, I’m looking at the Beagle I2C/SPI Protocol Analyzer – any comments about that?

Response from Technical Support:

Thanks for your questions! The Cheetah adapter instantly reads from MISO when the MOSI is shifted out to the bus. It does not directly support reading MISO data after a specific delay after MOSI data. MOSI write and MISO read cannot take place independently.

Once a MOSI is set, MISO is read concurrently byte-by-byte. This is valid for all our platforms that can generate SPI traffic - the Aardvark I2C/SPI Host Adapter and the Promira Serial Platform, as well as the Cheetah SPI Host Adapter.

Cheetah SPI Host Adapter

Figure 1: Cheetah SPI Host Adapter

For your setup, you can send dummy bytes on MOSI to read the MISO bits from the next clock cycles. Note: this method may be affected by the operational limits of your slave device.

To send 3 bytes on MOSI and then read 3 bytes in MISO, send 6 bytes on MOSI (3 actual data bytes + 3 dummy bytes to read the MISO data). Similarly, to read 4 bytes on MISO, send a total of 8 bytes on MOSI, the last 4 being the dummy bytes.

Example: if MISO read has to be 01 02 03 after MOSI sends 0A 0B 0C, it will be reflected as follows (format: MOSI/MISO).

0A/00 0B/00 0C/00 00/01 00/02 00/03

Note: the extra dummy bytes must be equivalent to the number of bytes that are actually read by the slave.

The Promira Serial Platform may provide some advantages for your setup. Comparing the features of these two devices:

  • On the Cheetah adapter, while shifting the Write MOSI commands, MISO is automatically collected and Read.
  • On the Promira platform, the MISO data is always collected in a buffer, and can be read by issuing a Read command. Since MOSI is sent byte-by-byte, MISO generated with each MOSI will be reflected.In the buffer of the example above, MISO would be saved as 00 00 00 01 02 03 for the 6 bytes written on MOSI. Unlike the Cheetah adapter, the Promira platform can work with various word lengths (other than 8-bit words) and a wider range of bit rates.

About the Beagle I2C/SPI Protocol Analyzer:

  • The Beagle I2C/SPI analyzer will non-intrusively monitor data sent between the master (Cheetah adapter or Promira platform) and your slave.
  • It will display all traffic on both MOSI and MISO in real-time with the ability to search and filter through transactions.

Additional resources that you may find helpful include the following:

If you have other questions about our host adapters or other Total Phase products, feel free to email us at sales@totalphase.com, or if you already own one of our devices and have a technical question, please submit a request for technical support.

Leave a Reply