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

nRF5340 - P0.10 not working as SPIM MISO on non-secure build

I'm trying to use the nRF5340-PDK SPIM at 16MHz, which requires me to use SPIM4 and dedicated SPIM4 pins 

P0.08 - SCK for SPIM4

P0.09 - MOSI for SPIM4

P0.10 - MISO for SPIM4

See my other ticket: https://devzone.nordicsemi.com/f/nordic-q-a/62533/using-16mhz-spim-on-nrf5340-pdk

I started off using a non-secure build and found that I was receiving nothing on the SPIM even if MOSI and MISO were shorted together.

In investigating further, I've found that this isn't an issue if I use a secure build.

I also found that it is an issue, even if I'm not using SPIM4.

I've tried to reduce it to the simplest implementation that still demonstrates the problem.

The rallare spi example code using SPIM1 and MOSI = P0.4, MISO = P0.5, SCK = P0.6 (non-secure build)

spi-rallare-ns-working.zip

This is essentially the same as the rallare_spi.zip file available in this ticket: https://devzone.nordicsemi.com/f/nordic-q-a/58966/is-there-any-sample-for-spi-based-on-nrf5340

If I short P0.4 (MOSI) to P0.5 (MISO) I receive the transmitted data (as shown on the console)

SPM: NS image at 0x8000
SPM: NS MSP at 0x200111e8
SPM: NS reset vector at 0x8c75
SPM: prepare to jump to Non-Secure image.
*** Booting Zephyr OS build v2.1.99-ncs1 ***
SPIM Example
TX sent: 0
RX recv: 0
TX sent: 1
RX recv: 1
TX sent: 2
RX recv: 2
TX sent: 3
RX recv: 3
TX sent: 4
RX recv: 4
TX sent: 5
RX recv: 5

Now I change MISO to P0.10 and short P0.4 (MOSI) to P0.10 (MISO) (still non-secure build)

spi-rallare-ns-not-working.zip

SPM: NS image at 0x8000
SPM: NS MSP at 0x200111e8
SPM: NS reset vector at 0x8c75
SPM: prepare to jump to Non-Secure image.
*** Booting Zephyr OS build v2.1.99-ncs1 ***
SPIM Example
TX sent: 0
RX recv: 0
TX sent: 1
RX recv: 0
TX sent: 2
RX recv: 0
TX sent: 3
RX recv: 0
TX sent: 4
RX recv: 0
TX sent: 5
RX recv: 0

Finally I change to a secure build.  MISO is still P0.10 and P0.4 (MOSI) is still shorted to P0.10 (MISO) (secure build)

spi-rallare-secure-working.zip

*** Booting Zephyr OS build v2.1.99-ncs1 ***
SPIM Example
TX sent: 0
RX recv: 0
TX sent: 1
RX recv: 1
TX sent: 2
RX recv: 2
TX sent: 3
RX recv: 3
TX sent: 4
RX recv: 4
TX sent: 5
RX recv: 5

I don't know if it's related, but I found this ticket that indicated some kind of problem with using P0.10

https://devzone.nordicsemi.com/f/nordic-q-a/59254/can-not-control-p1-with-nrf5340_dk_nrf5340_cpuappns-configuration/241984#241984

It identifies the source of the problem, but does not explain how to work around it.

Is this the same problem I'm seeing?

Do you have a workaround?

Related