This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrf52840 SPI clock line contention causing SPI driver to hang

Hello,

I encountered an interesting issue with SPI0 on the nrf52840 that I cannot explain. In short, my SPI bus would stop working shortly after communicating with my slave device. After an extensive investigation and trying different pins to use for SPI, I discovered that the slave device was holding the SPI clock line low. This was causing the Nordic SPI driver to hang in nrfx_spim.c at the line highlighted in green below. I could disconnect the SPI clock line from the slave device and the driver would resume operation without issues. Why does contention on the SPI clock line cause the driver to hang? Should there be some sort of safety timeout here?  I was able to reproduce this issue using the Nordic SPI peripheral example project. As a side note, I have since discovered why the slave device was holding the clock line low but not why the driver gets stuck.

SoftDevice: S140

SDK: 15.0.0

Note: I am using the Rigado BMD-340 Eval Kit which is software and pin compatible with the nrf52840 DK.

Thanks,

Derek

Parents
  • Just a note to add to this: I've also had this same issue when using an external SPI display. When the display was connected incorrectly and its own MCU wasn't booting correctly, it would load the SPI lines in strange ways causing transfers to fail / the driver to stop in the same place.

    droberson: Do you have a logic analyser result you can add to this post? I was finding very long rise times when SPI was being held down by the peripheral.

Reply
  • Just a note to add to this: I've also had this same issue when using an external SPI display. When the display was connected incorrectly and its own MCU wasn't booting correctly, it would load the SPI lines in strange ways causing transfers to fail / the driver to stop in the same place.

    droberson: Do you have a logic analyser result you can add to this post? I was finding very long rise times when SPI was being held down by the peripheral.

Children
Related