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

Request more detailed SDK 15.2.0 peripheral interrupt priority change explanation

The SDK 15.2.0 release notes state:

Changed the default interrupt priority level for the peripherals from 7 to 6. This is done to be aligned with the priority of the SWI coming from the SoftDevice.

A while ago I upgraded my project to build with SDK 15.2.0, and didn't notice that change, so my sdk_config.h still has all of the peripheral interrupt priorities set to 7. I haven't observed this to cause any problems, but could you please explain in more detail what problem setting the priorities to 6 solves?

The reason I ask is that I want to use two different peripheral interrupt priorities, with most of my peripherals interrupting at priority 7, but with a few particularly latency-sensitive peripheral interrupts at priority 6. (Latency from SoftDevice interrupts is short enough that I'm not concerned about that.) However, if you're recommending that the peripheral interrupts should be at priority 6, then the next higher level available to me is priority 3, and if I use that I could potentially delay SoftDevice interrupts that are on priorities 4 and 5, which I'd prefer not to do.

If it makes any difference, my firmware is based on ble_app_hrs_freertos, so the SWIs from the SoftDevice are handled by SD_EVT_IRQHandler() in nrf_sdh_freertos.c, which just does a task notify to the softdevice task.

Thanks!

Eric

Parents
  • Hi Eric, 

    I would assume you were porting your application from earlier SDK to SDK v15.2 and then brought the configuration of peripheral interrupt priority to 7 from your previous application ? 

    In SDK v15.1 and earlier we have been setting the Softdevice SWI (the interrupt to send softdevice event to application) from 6 to 7 to match with the peripheral lowest interrupt priority level 7. So they have the same level. You can find the workaround in nrf_sdh.c in SDK v15.1 and earlier. However, in the workaround we missed S140 as at the time we though its SWI's default level was already 7. But it actually was 6. 

    So on SDK v15.2 we decided to remove that workaround and now everything is configured to level 6 including the application peripherals default interrupt. 

    In your case, you set your application interrupt priority level to 7, meaning your application interrupt can be pre-empted by the softdevice events.

    If your application has no problem being preempted I don't see a problem here. 

    You are right about the  FreeRTOS configuration, I would need to check with our FreeRTOS expert to see if there is any impact here. 

Reply
  • Hi Eric, 

    I would assume you were porting your application from earlier SDK to SDK v15.2 and then brought the configuration of peripheral interrupt priority to 7 from your previous application ? 

    In SDK v15.1 and earlier we have been setting the Softdevice SWI (the interrupt to send softdevice event to application) from 6 to 7 to match with the peripheral lowest interrupt priority level 7. So they have the same level. You can find the workaround in nrf_sdh.c in SDK v15.1 and earlier. However, in the workaround we missed S140 as at the time we though its SWI's default level was already 7. But it actually was 6. 

    So on SDK v15.2 we decided to remove that workaround and now everything is configured to level 6 including the application peripherals default interrupt. 

    In your case, you set your application interrupt priority level to 7, meaning your application interrupt can be pre-empted by the softdevice events.

    If your application has no problem being preempted I don't see a problem here. 

    You are right about the  FreeRTOS configuration, I would need to check with our FreeRTOS expert to see if there is any impact here. 

Children
  • Hi Hung,

    You are correct, we started with an earlier SDK. Thank you for the explanation. For my purposes it probably doesn't matter whether the SWI from the SoftDevice is above, below, or the same priority as the peripheral interrupts, because I've been careful to have all of the interrupt and event handlers do very little before returning; most of them just give a semaphore or post to a queue.

    I've now changed the peripheral interrupts from 7 to 6 in our project to match SDK 15.2.0, and it seems to work fine.

    Just to be clear about what I said regarding FreeRTOS, the defines I quoted are used to set the interrupt priority of RTC1, used for the FreeRTOS tick and scheduling.

    Thanks!

    Eric

Related