Support Question of the Week: Queue Batch and Clear Slave Select Commands on SPI Bus with Cheetah SPI Host Adapter
Q: I'm using the Cheetah SPI Host Adapter to send slave select commands across the SPI bus. I referred to your API examples, but I seem to be missing something. The commands I entered:
ch_spi_queue_ss ( cheetah,0x07);
ch_spi_queue_ss (cheetah,0x00);
ch_spi_queue_ss (cheetah,0x07);
ch_spi_queue_ss (cheetah,0x00);
After executing the commands, I don't see any changes on the port. Please advise.
Thanks for your question! ch_spi_queue_ss does control SS (slave select) signals, but to execute the command queue it needs to be "batched". Commands are accumulated in a queue until a call is made to batch shift all of the queued commands. Also, to make sure only the commands you need are executed, the command queue should cleared before running the desired commands.
Figure 1: Cheetah SPI Host Adapter - Queuing Commands on SPI Bus
Following is an example of an SPI transaction:
- Call ch_spi_queue_clear to clear the command queue.
- Call ch_spi_queue_oe to add a command to the queue to enable the Cheetah device’s outputs on the SPI bus.
- Call ch_spi_queue_ss to add a command to the queue to enable the slave select signal.
- Call ch_spi_queue_byte and ch_spi_queue_array to queue data send across the SPI bus.
- Call ch_spi_queue_ss to queue a command to disable the slave select signal.
- If you prefer to disable the outputs of the Cheetah SPI Host Adapter, you can instead call ch_spi_queue_oe for the command queue.
- Call ch_spi_batch_shift to send the queued commands across the SPI bus.
Notes:
- The command queue is not cleared after it has been executed. This allows the same queue to be repeatedly executed times without re-queuing the commands. To clear a queue, ch_spi_queue_clear must be called.
- Only after you perform ch_spi_batch_shift command, the accumulated commands (including SS enable command and SS disable command) are sent across the SPI bus. You can then see the SPI signals (SS, MISO, MOSI, SCLK) toggle according to the accumulated commands.
For more information about using API functions, please refer to section 5 of the Cheetah SPI Host Adapter User Manual.
For more information about Cheetah and other Total Phase products, please see the following:
Cheetah SPI Host Adapter
Cheetah SPI Host Adapter User Manual
Software downloads for Cheetah
Total Phase Products
Product Selector Guide
We hope this answers your question. If you have other questions about our Host Adapters or other Total Phase products, feel free to email us at sales@totalphase.com or support@totalphase.com.