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 can I identify IRQ handlers that occur during a normal CPU execution?

I have a time-sensitive block of code run purely by the CPU, not within any interrupt handler or peripheral. Part of the execution is getting interrupted, and so what I would like is to simply identify which IRQ or IRQs are occurring, preferably in real time. To be clear, I am not looking for advice regarding superior techniques for time-sensitive operations, I would just like to identify which IRQ or IRQs are occurring in a particular block of code. Is there a way to do this in general, or is it a process of narrowing down the potential suspects. Detailed answers much appreciated. I am using Segger Embedded Studio in my development. Thank you!

  • Hi,

    you can try this source to count interrupt occurrences, I used it with 52832 but it should work also on 52840.

    Define an array in you main.c:

    uint32_t irqstat_array[64];

    At start of main(), add call to irqstat_init(). Each entry in irqstat_array will contain a number of invocations of corresponding IRQ.

    irqstat.S

  • Is irqstat_init a function that's provided in some source? Where can I find it?

  • Hello,

    You can set some breakpoints in your interrupts to see which one that triggered. There is no way from the main context (where I suspect you are running your time-sensitive block of code from) to know what interrupt that occured. 

    Do you use BLE?

    If the interrupt is a softdevice interrput, things are a bit more tricky. You can use some CRITICAL_REGION_ENTER() and CRITICAL_REGION_EXIT() to block these from happening. However, please be aware that this will block the softdevice completely. If the softdevice misses a time critical event, it may assert and reset your application. 

    If you are using the softdevice and need to perform very time sensitive blocks of code, where you don't get interrupted by the softdevice, you either need to shut down all softdevice activity (disconnect and stop scanning/advertising), or you can use the Timeslot API, where you can request timeslots in between the softdevice events where you know that you will not be interrupted by the softdevice within this timeslot. 

    To be clear, I am not looking for advice regarding superior techniques for time-sensitive operations

     Loud and clear. However, I don't know what sort of time sensitive blocks of code you are running. Could they be automated by timers and the PPI?

    Best regards,

    Edvin

  • Hi . This operation happens close to the beginning of main context (and yes, within the main context), and it's possible to do this before turning on the softdevice. I read in another thread that running __disable_irq() has no guarantee of stopping the softdevice, that it may take back control at any time. Why is that the case? Should I expect similar constraints with CRITICAL_REGION_ENTER? I'm fine with breaking softdevice functionality temporarily, but want to ensure it will not take back any control.

  • apologies, I missed the attachment, will look now

Related