SPIM Recevie data is allways 1bit shift

Hi Nordic team,

I'm currently facing a bit of a snag while trying to establish communication between the nRF52840 (NCS 2.5.0) and the MS5540C sensor using a 3-wire SPI protocol (note that the device doesn't require a ‘Chip select’ signal).

Here's the setup: I'm using SPI MODE 0 (CPOL=0, CPHA = 0) to transmit commands to the sensor and SPIM MODE 1 to retrieve data from it.

However, I've hit a roadblock. It seems like the data I'm receiving in the buffer is consistently shifted by 1 bit. Take a look at the attached image - upon system boot, there's always a single clock pulse from low to high. Upon my analysis, it seems to be recognized as an SPIM pulse, leading to data misalignment.

The data I'm getting back is 0xC73C instead of the expected 0x8E79.

So, here's my question: Is there a way to keep the clock signal at the low level by default after powering on the system? Or perhaps, is there a method to reset the receiver MISO counter or buffer?

Any insights or suggestions would be highly appreciated.

Thanks a bunch.
3603.SPIM shift clock mode 0.sal


Parents
  • Hi,

    Can you provide a sample application that can be used to reproduce this behavior?

    It is unclear to me if the pin levels is caused by the SPIM peripheral or by some GPIO config in the application.

    Is there a way to keep the clock signal at the low level by default after powering on the system?

    From a HW perspective, the GPIOs are set as inputs, with input buffer disconnected and no pull by default. This should not drive the signals high, but since they are floating, the level might be interpreted as high or low by the sensor. 

    Or perhaps, is there a method to reset the receiver MISO counter or buffer?

    There is no way to do that apart from stopping the transfer and starting a new one. You could also read one additional byte and do the shifting in your application (it this does not mess up the state of the sensor).

    Best regards,
    Jørgen

Reply
  • Hi,

    Can you provide a sample application that can be used to reproduce this behavior?

    It is unclear to me if the pin levels is caused by the SPIM peripheral or by some GPIO config in the application.

    Is there a way to keep the clock signal at the low level by default after powering on the system?

    From a HW perspective, the GPIOs are set as inputs, with input buffer disconnected and no pull by default. This should not drive the signals high, but since they are floating, the level might be interpreted as high or low by the sensor. 

    Or perhaps, is there a method to reset the receiver MISO counter or buffer?

    There is no way to do that apart from stopping the transfer and starting a new one. You could also read one additional byte and do the shifting in your application (it this does not mess up the state of the sensor).

    Best regards,
    Jørgen

Children
Related