cancel
Showing results for 
Search instead for 
Did you mean: 

Why can't I get the SPI clock to idle low

TomC1
Associate III

I'm working on a STM32H755ZIQ.  I am setting up a SPI master, with CPol= 0, CPha = 1, accordingly I need the clock to be low when inactive.  Additionally I want the clock to be low when idling, even when the SPI is not active. To achieve this, I have modified the GPIO settings to use a pulldown resistor on the clock pin.

I set this up using the CubeMX utility, but I don't necessarily trust it, so I have checked the generated code, and I find, in main.c, within the function MX_SPI1_Init(void), the polarity is set low:

TomC1_0-1742391694539.png

and also, in stm32h7xx_hal_msp.c, within the function HAL_SPI_MspInit(SPI_HandleTypeDef* hspi), the GPIO is set to use the pulldown resistor:

TomC1_1-1742391813142.png

And yet, the clock is idling high. You can see in the logic trace below, that the clock is NOT normally pulled down, but only goes low when the SPI is activated.  

TomC1_2-1742391925483.png

I assert the CS pin before carrying out an SPI write operation. The clock is still high when the slave detects the CS change, and the slave fails to correctly read the data.

 

Can anyone tell me what more I need to do to ensure that the clock like is idling low?

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

When the peripheral is disabled, the pin will float unless you set it to keep the IO state here:

TDK_0-1742393214253.png

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
Uwe Bonnes
Principal III

Did you try to set the pull functionality of the GPIO pin  to the right direction and pull active?

TDK
Guru

When the peripheral is disabled, the pin will float unless you set it to keep the IO state here:

TDK_0-1742393214253.png

 

If you feel a post has answered your question, please click "Accept as Solution".