
I have a question about the Cheetah SPI Host Adapter reading responses from a peripheral device. I am using the example code flash.c that is provided with Cheetah Software API. I am trying to read a message from a peripheral SPI slave device, the Aardvark I2C/SPI Host Adapter, but not all the SPI data is read.
When I set the Aardvark adapter message to “AB CD” the function only prints out “AB” as read. I have not changed the example code. I just wanted to know if there is a way to read the entire message from the Aardvark adapter.
Here is a screenshot of the output of the flash.c where it only shows “ab” as read, then followed by many 0s.

Both the Cheetah adapter and the Aardvark adapter are configured at 1 MHz and SPI mode 0. When setting no message to the Aardvark adapter (all 0s), and sending 11 11 11 through the Cheetah adapter, there is one group of 00 being read from the aardvark (00 11 11). Is the Cheetah adapter only supposed to read the first byte of the MISO message?
Here are screenshots of the traffic going through the Control Center Serial Software. The Aardvark adapter is writing all three 00 groups, but the Cheetah adapter is only reading the first 00.
Cheetah Adapter Transaction:

My questions - why is the master device, the Cheetah adapter, ignoring everything except the first byte of MISO data? Do I need to make any changes?
Response from Technical Support:Thank you for your questions! SPI is always bi-directional. For every CLK cycle, a bit will be shifted out on MOSI and the Cheetah adapter will read 1 bit in from MISO. Often there are times you must ignore MISO data, and similarly there are times the slave ignores MOSI data. In general, the definition for this response is usually provided in your SPI slave's datasheet. If you are just communicating with an Aardvark adapter, then what data the Aardvark shifts out will depend on how it is configured. The Aardvark adapter will also wrap if you exceed the size of its slave response buffer.
However, in your case, a delay will provide the results you are looking for: the master device will read all the SPI data from the slave device.
To resolve your issue, add a delay of at least 5us to 10us. There are two ways to do so:
Add the delay in the where Cheetah adapter is configured in Control Center Serial Software. This is an easy way to test how much delay is needed before applying API.
In API, here is a snippet of the code where the delay is added between handle 1 and handle 0.
Ch_spi_queue_clear(handle)
Ch_spi_queue_oe(handle, 1)
Ch_spi_queue_ss(handle, 0x01)
........... Delay (1)
Ch_spi_queue_ss(handle,0)
Ch_spi_queue_oe(handle,0)
length = ch_spi_batch_length(handle);
Ch_spi_batch_shift(handle, length, read_buffer)p
We hope this answers your questions. Additional resources that you may find helpful include the following:
If you want more information, feel free to contact us with your questions, or request a demo that applies to your application.