nRF54L15DK, cannot port HAL SPI code that was working in nRF53

I had previously gotten working code to communicate with my SPI device on the nRF5340DK w/ NCS v2.5.0 that uses the HAL SPI library inside TF-M. I used NCS v2.5.0 (nrf\samples\tfm\tfm_secure_peripheral) as the baseline.

I now need to port that code to nRF54L15DK w/ NCS v2.9.0, but am having issues where I see the SPI transactions (w/ logic analyzer) but the data being read in is wrong (and/or it's an issue with the writes I'm using when I configure my SPI device).

I tried looking through the NCS examples, but could find no examples of HAL SPI, or "HAL-SPI + TFM-secure-partition" that use the nRF54. With that, I have several questions:

  1. Can you provide code for a simple working "HAL-SPI + TFM-secure-partition" example that works on nRF54L15DK and NCS v2.9.0?
  2. Can you provide code for a simple working "HAL-SPI only" example that works on nRF54L15DK and NCS v2.9.0?
    1. We would like to see if the issue is related to TF-M or not.
  3. Are you aware of any other issues in the DK or NCS v2.9.0 that can cause issues with SPI?
    1. This could be related to overlays, KConfig, or anything.

For context, my setup is using a Windows 10 machine, VS Code (with nRF Connect extensions).

Parents Reply Children
  • If time permits, I can take a look. But that is using nrfx, and I'm looking for code using HAL directly. I don't expect nrfx to work especially since I need TFM (see Einar's Nov 1 post here). I'm also requesting code that works with nRF54L15, since examples like those were only tested with boards up thru nRF53.

  • esmart-engineering said:
    I don't expect nrfx to work especially since I need TFM

    Ah, right. Let us have a look at HAL then.

    I see that there are SPIM code inside the secure partition sample. Do you mean to say that this code does not work out of the box?

    Alternativley: How is your code different from what the sample does?

    but the data being read in is wrong

    Wrong how exactly?

  • Code pretty much worked out-of-the-box. This is confirmed in our nRF53 code, which did read/write correctly. It was only changed in the following ways:

    • all pins (CS, SCLK, MISO, MOSI) are used
    • interrupt mask ENDRX is enabled instead of ENDTX
    • NRF_SPIM4 was used instead of NRF_SPIM3 (changes to .yaml and .conf files were made accordingly)
    • nrf_spim_enable() and nrf_spim_disable() are called in functions to conserve power

    nRF54 code is minimally changed from nRF53 code (but again, seems to read and/or write incorrectly). Only major changes were:

    • NRF_SPIM22 was being used
    • Pins I passed into spim_init() were all in Port 1
      • I did try playing around with Port 2 pins (including cutting SB11-22 on the nRF54L15 DK) but it did not change the results.
    • nrf_spim_frequency_set() replaced w/ nrf_spim_prescaler_set(), since the former doesn't seem possible in nRF54 anymore
      • Frequency is 2MHz, so now I call it with nrf_spim_prescaler_set(NRF_SPIM22, NRF_SPIM_PRESCALER_CALCULATE(NRF_SPIM22, 2000000));

    Data read is wrong because when reading the SPI device's registers, it should return values I had written when initializing the peripheral (via SPI writes). But the values don't match what I wrote. Yet, logic analyzer also shows these same wrong values.

Related