SPI mode 3 clock polarity incorrect, nrfConnect SDK 2.5.0

Hello,

I am working on talking to a SPI slave device using SPI mode 3, so CPOL = 1 and CPHA = 1.

It is currently a very minimalistic project for testing purposes.

I am using the zephyr API for doing a single SPI transceive.

The problem is that the clock polarity is incorrect when doing a transaction. After the SPI CS is pulled low by the SPI API, the clock polarity is still low. While it should be high in SPI mode 3. This causes a rising edge, where it is visible that the SPI API has some vague understanding of what SPI mode it should be, as it is then high for a short idle period.

The result is that the SPI slave is confused now, since a rising edge on the SCLK when CS is low means that it samples a bit.

During the transceive, the SPI CLK goes to a low idle state (seems to not comply to its configured SPI mode).

I am struggling to find a way to make the SCLK be high from the moment CS is low (or before, I don't need this GPIO for anything else, it can be always high when idle).

Relevent code:

proj conf

dtsi

dts

application code

I hope I provided enough info. Your help would be much appreciated.

Kind regards.

Parents
  • Hello,

    I think I found the root cause of this issue.

    This line was executed during initialization. I was under the impression that setting the default pin state (again) was not changing anything, but it seems to be the cause of the SCLK in the wrong polarity.

    Kind regards.

  • Alright, so now it displays the correct clock polarity?

    regards

    Jared

Reply Children