Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use PRS

Hi there!

I'm currently in a position where I'm using SPI0, SPI1 and SPI2 (for ST7735, WS2812 and SD-Card for FatFS) while I need to also be able to use I2C for the Adafruit NFC reader. I knew there was something named Peripheral Resource Sharing (PRS) that's used for sharing the common resources for peripherals that're sharing the same hardware and base address. Furthermore, I'm also aware of the fact that the peripherals that are sharing resources aren't able to be active at the same time.

That's where my question comes in; is this handled from within the SDK or does the user have to take care of this. The issue I'm currently facing is the following. When SPI0 for the WS2812's has been initialized and I try to initialize TWI0 for the NFC Reader, I get the output underneath.

<info> PRS: Function: nrfx_prs_acquire, error code: NRF_SUCCESS.
<info> PRS: Function: nrfx_prs_acquire, error code: NRF_SUCCESS.
<info> adafruit_pn532: Creating I2C
<warning> PRS: Function: nrfx_prs_acquire, error code: NRF_ERROR_BUSY.

This makes me think the SPI0 and TWI0 peripheral aren't allowed to be initialized at the same time. But then the question arises what the goal of the PRS is. Wasn't that the problem PRS was supposed to solve?

If the above really is true, and the peripherals in the PRS box aren't allowed to be active all at once, I don't think it's very useful for me. That rises another question; why doesn't the SPI bus support the CS (Chip Select) pin. Isn't that a core functionality of SPI? The way I see the bus now is that it can't be shared with 2 or more slaves. That's right, right?

Kind regards,

Jochem

  • This makes me think the SPI0 and TWI0 peripheral aren't allowed to be initialized at the same time. But then the question arises what the goal of the PRS is. Wasn't that the problem PRS was supposed to solve?

     It is just a fancy mutual exclusion element and does not aid you to use the same SerioBox for two different things at the same time. You initialize a SerioBox as one perpheral instance and the registers have different meaning for the other peripheral inside the same SerioBox and we cannot assume that the transactions are mapped like inside a virutal box. A bit clearer explanation can be found here

  • Hi Susheel,

    Okay, I thought so. Thanks for confirming and clearing it further up!

    I ended up bit banging the WS2812 by the way. Now SPI0 is available as TWI bus. Wink

    Kind regards,

    Jochem

Related