I2C SPI USB CAN eSPI Cable Testing View All Quick Start Guides User Manuals Software Downloads Knowledge Base Videos Case Studies App Notes White Papers Sales Support About Us
Products Blog Sales Support Contact Search
Which Mechanism and Tool Do I Need to Write to an SPI EEPROM?
Rena Ayeras

Question from the Customer:

I am starting to use Promira Serial Platform with the Promira Software API I2C/SPI Active. The spi_eeprom command does not specify what data should be written - I need to send 0x1000 to register 0x50. There is a queue variable in the code that I believe needs to be filled. How do I access the queue?

Also, I want to constantly read from the same register (0xB0) multiple times (about 10,000 reads) and save the result to a file. I believe I would use _readmemory, but again, the queue variable and its use are not clear to me. Can you provide information so I can get started?

Response from Technical Support:

Thanks for your questions! We’ll show you the flow of the SPI queue mechanism, and other suggestions for getting started.

 Promira Serial Platform  I2C SPI Activity Board

The Promira API Queue Mechanism

The Promira platform provides the queue functionality so that multiple commands can be queued up and shifted to the device at once. The queuing mechanism is required to configure a write transaction.

API Queue Example – SPI Transfer

Here is an example of a queue:

  1. Call ps_queue_create to create a queue, and specify the queue type (such as PS_MODULE_ID_SPI_ACTIVE).
  2. Call ps_queue_clear to clear the queue.
  3. Call ps_queue_spi_oe to add a command to the queue to enable SPI outputs.
  4. Call ps_queue_spi_ss to add a command to the queue to assert SS line.
  5. Call ps_queue_spi_write or ps_queue_spi_write_word or ps_queue_spi_read to add an SPI command that's shifts data on the bus.
  6. Call ps_queue_spi_ss to add a command to the queue to deassert SS line.
  7. Call ps_queue_spi_oe to add a command to the queue to disable master output.
  8. Call ps_queue_submit to send the accumulated commands on the SPI bus.
  9. Call ps_collect_resp to collect the first/next response from the previously submitted queue.

    • If the return value is PS_SPI_CMD_READ, call ps_collect_spi_read to collect the response of with the SPI data.
    • Otherwise, no additional functions need to be called.
  10. Repeat step 9 until you receive from the function ps_collect_resp the return value PS_APP_NO_MORE_CMDS_TO_COLLECT.
  11. Call ps_queue_destroy to destroy the queue or go back to step 6 to submit the queue again.

At step 10, we expect ps_collect_resp to be called repeatedly until no more data is available to read from the queue buffer. By collecting and storing data in a local buffer, the queue buffer is consistently emptied and re-filled by incoming data, which is achieved only when SPI slave data is collected as soon as possible. This way data is not lost because the 2MB buffer is not filled up or overfilled.

Additional Information for Getting Started

Here are some recommendations for getting started with the Promira platform and accomplishing the most.

Reduce Latency Maximize Speed

If speed is an issue, the USB round-trip latency is reduced to 250us, when using the High-speed USB over Ethernet connectivity.  The Promira platform USB round-trip latency is further reduced when using the Ethernet connectivity. These features, plus using the API queuing mechanism, can help speed up your project.

Verify Test and Debug Tool

The I2C/SPI Activity Board is available for verifying new setups - known working I2C and SPI slave devices are provided for test and debug.

  • I2C Port Expander with configurable I2C address and a full complement of LEDs
  • EEPROM with configurable I2C address
  • SPI EEPROM with jumpered Slave Select

For more information about this Activity Board, please refer to the I2C/SPI Activity board User Manual.

For more information about API, please refer to the section API Documentation in the Promira Serial Platform I2C/SPI Active User Manual. You can also take a look at our Videos and Knowledge Base Articles for additional information and case studies about using our products.

Additional resources that you may find helpful include the following:

We hope this answers your questions. If you have other questions about our software, host adapters or other Total Phase products, feel free to email us at sales@totalphase.com. You can also request a demo that is specific for your application.

Request a Demo