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

interrupt priority levels on nRF51

Hi,

This is just a quick check of my understanding of the interrupt priority levels on nRF51. I read up on the documentation I can find.

I'm assuming that I will receive BLE events at interrupt level 2, even though I can't find where that is directly stated?

Is there any reason I cannot also have peripheral interrupts (UART) also run at level 2?

Here the goal. If I can have the UART run at the same interrupt level as BLE events, then no processing will be able interrupt any other processing. This will make my app run very much like a cooperative scheduling app, even though it is all event driven. So I won't have to worry about preemption and reentrancy issues.

Nothing in my app takes very long to execute, so I really don't need to use the scheduler. But I would probably run a timer task at a lower interrupt level (not sharing any resources with tasks running at level 2).

Hope this all makes sense.

Parents Reply Children
  • The softdevice will set_pending the interrupt softdevice_handler.c::SOFTDEVICE_EVT_IRQHandler whenever a event needs to be processed by the application, and this interrupt will run in level 3. 

    Yes, if you set the UART to run at "low" level on the nRF51-device, it will run at level 3, taken here from app_util_platform.h:

    #if __CORTEX_M == (0x00U)
    #define _PRIO_SD_HIGH       0
    #define _PRIO_APP_HIGH      1
    #define _PRIO_APP_MID       1
    #define _PRIO_SD_LOW        2
    #define _PRIO_APP_LOW       3
    #define _PRIO_APP_LOWEST    3
    #define _PRIO_THREAD        4

     

    Note that I recommend that you use _LOWEST (_LOW and _LOWEST == 3 for nRF51-series) define, in case you port your application over to one of the nRF52-series devices. The Cortex M4 has 8 levels, so you have a bit more available for the application to use there. 

     

    Cheers,

    Håkon

Related