With the Promira Serial Platform, How Do I Set the SPI Clock to 0 Volts after Closing the SPI Device?

Question from the Customer:

I am using the Promira Serial Platform to drive an SPI bus. For this application, I am using the Promira Software API I2C/SPI Active wrapped in my custom code. My issue: I need the clock (SCLK) to reach 0V in its off state, but so far, that is not yet achieved.

What I see:

  1. I have a scope channel probe in-line with SCLK line from the Promira platform to the target hardware.
  2. After the code segment provided, the scope channel shows about 2V.
  3. In this application, I need 0V for the off state. However, the line voltage on the bus is back-powering the device, and does not allow it to reach the OFF state.

The current code sequence:

  1. Connect the Promira platform via USB
  2. Measure bus interface signals at connector = 0.0V
  3. Initialize Promira platform to drive SPI at voltage drive levels of 1.8V
  4. Communications work properly and no issues present
  5. Close driver
  6. Check pin states and I see that the SCLK remains at 1.8V

Closing the device, as shown in application notes:

public static void closeTool(bool echo)
{
SpiMasterOE(g_channel, g_queue, 0, echo); // Disable master output
Promact_isApi.ps_queue_destroy(g_queue); // Destroy the queue
DevClose(g_pm, g_conn, g_channel); // Close the device and exit
}

Details of my setting up the clock phase:

Promact_isApi.ps_spi_configure(g_channel,
PromiraSpiMode.PS_SPI_MODE_3,
PromiraSpiBitorder.PS_SPI_BITORDER_MSB,
0);

I am considering a different approach, such as closing GPIO to drive the SCLK pin to 0V:

  1. Close Promira SPI
  2. Reopen as GPIO
  3. Set all as output with value 0x00
  4. Close GPIO

Could that work? What are your recommendations to drive the SCLK pin to 0V?

Response from Technical Support:

Thanks for your question! Based on the information you provided, we see that SPI Mode 3 is being used: PromiraSpiMode.PS_SPI_MODE_3. In this mode, the default state of the clock is high, which is why you are seeing 1.8V on the SCLK line. We have a solution for you that doesn’t require opening and closing GPIO lines.

GPIO in SPI Mode

Here are the reasons why opening and closing the GPIO lines will have not have the results you are looking for:

  • The SPI pins on the Promira platform are not shared with GPIO pins.
  • There are no pull-up resistors on the SPI clock and data lines.

API Script to Drive SCLK to 0V

Here is a solution to drive the SCLK to 0V by adding one line of code to the original device close, which changes the SPI Mode to 0. This way, SCLK will be 0V when the device is closed.

public static void closeTool(bool echo)
{
ps_spi_configure(channel, PS_SPI_MODE_0, PS_SPI_BITORDER_MSB, 0)
SpiMasterOE(g_channel, g_queue, 0, echo); // Disable master output
Promact_isApi.ps_queue_destroy(g_queue); // Destroy the queue
DevClose(g_pm, g_conn, g_channel); // Close the device and exit
}

The figure below shows the four SPI clock modes (SPI_MODE_0/1/2/3), which are defined by two clock parameters: clock polarity (CPOL) and clock phase (CPHA).

The Clock Polarities and Clock Phases affect the SPI Modes SPI Clock Modes
  • “sample” indicates on which edge of the SPI clock the data is latched.
  • For both MODE 0 and MODE 3, data is latched on the rising edge.

However, with the difference in polarity, changing the mode from MODE 3 to MODE 0 ensures SCLK will be 0V when the device is disabled. For more information, please refer to the section SPI Modes in the Promira Serial Platform I2C/SPI Active User Manual.

We hope this answers your question. Additional resources that you may find helpful include the following:

If you have any questions or want more information about Total Phase tools, you can email us a message or request a demo that is specific for your application.

Request a Demo