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:
The current code sequence:
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:
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.
Here are the reasons why opening and closing the GPIO lines will have not have the results you are looking for:
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).
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.