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

What is PRS?

I bumped into some compilation errors regarding PRS box4, when I tried to remove UART from an example.

I saw that PRS is "Peripheral Resource Sharing", but it looks like it's some kind of pseudo device.

Where can I find documentation about PRS and the boxes?

  • Hi,

    PRS is Peripheral Resource Sharing. This is a feature of the peripheral drivers which allows you to use peripherals that share the same resource (see Peripherals with shared ID). All peripherals with the same ID use the same hardware, and this is sometimes referred to as a "serial box". All peripherals with the same ID (and register offset) uses the same physical serial box. Normally this serial box can only be used for one purpose. However, PRS allows a serial box to be used as more than one peripheral, though never at the same time (as it is really just a single physical interface). 

    If you look at the code, you will see that the feature itself is quite simple. Each serial box has it's own interrupt number, and register offset. Normally, you will map this interrupt to a specific driver, and all is well. The trick with PRS is that it allows you to specify which driver is active at a specific time, and have a interrupt routine that is handled by the PRS implementation. Then it will forward the interrupt to the correct driver, which is the one which is currently active. That is essentially all it does.

  • Hi,

    I was trying to understand about PRS and bumped into this post. What I was expecting was that PRS would allow multiple peripherals with same Instance ID to be used at the same time. But seems like that is not the case. So why we need PRS at all? As we will be initializing only one peripheral at a time and using it and therefore the Interrupt handler for that peripheral will be mapped to its IRQ number in NVIC, likewise when we want to use some other peripheral with same Instance ID, we will first disable the previously enabled peripheral, configure the new one and enable it, so now its interrupt handler will be mapped to the same IRQ number in NVIC. So where does PRS comes into picture here?, what does it helps in, in this case? and what happens if just disable PRS? I am not getting what difference PRS creates.

  • I think the idea is in the handler address. The interrupt vector is usually put into flash, and is not that easy to change on-the-fly. Instead all the interrupts have common handler that figures out which "device" is being used, and calls its interrupt handler. There is only one interrupt for the box which, too, is shared by the "devices" of the box.

    I might be wrong, though...

  • You are right, the core feature of PRS is to support dynamically changing the interrupt handler between the drivers by having a common ISR which is can be configured runtime to call a different ISR (in essence you just update a function pointer). To see this you can for instance refer to nrfx_twis_init() from modules\nrfx\drivers\src\nrfx_twis.c. There you can see that if PRS is enabled, nrfx_prs_acquire() is called which updates the function pointer and flags it as in use. Similarily, nrfx_twis_uninit() calls nrfx_prs_release() to flag that it is not in use.

Related