ISR Routines and dummy_handler

Hi ya all.
I’ve got a mkrwan1310 running a weather station which every now and then just stops and this week I almost figured it out. I was running it on a jlink debug tool when it suddenly jumped into dummy_handler but before I realised what it had done, I’d clicked again and reset everything. aarrgghh. However, it made me look at the ISR routines and their use of dummy_handler.

If I read the code correctly, for all the cortex handlers there is a link to dummy_handler that just sits there, and because it is in a ISr already, it would explain why my wdt hander fails to call.

My question is two fold.

Does anyone know of a resource anywhere that can help me understand the handlers better. I get the concept, I’m even using a few of them eg: rtc & wdt, but looking in cortex.c there are loads and some are obvious, some less so?

Secondly, I was thinking (dangerous I know) that I write a new dummy handler that rather than sits in the ISR forever, Sets a flag and drops out, allowing me to capture some info and for the wdt to kick in and reset everything. What info can I capture (in windows you can write the stack to file, is there anything similar? & how do I do it? I’d write the data to the serial flash to retrieve it later, its knowing what info I can find to write to it?

thanks for reading and look forward to your thoughts.

may be this will help : SAM D21 Exceptions and Interrupts

NVIC_IPR0..7 registers are used to provide 32 priority configuration registers for each of the 32 IRQs

Thanks a lot, I’ll had a read and its generated a few more questions around priority.

So from what I think I understand, within the cortex_handlers.c file are a list of all the interrupt handler routines, with only a few of them actually defined, the majority being a weak alias for dummy_handler. For some of the handlers I have already written routines, wdt_handler and rtc_hander, for those, I have also set a priority, although interestingly wdt is zero.

However, I think I might be seeing that although wdt is set to zero, that does not make it the highest priority, just the highest IRQ level, I think these still sit above it:-

  (void*) Reset_Handler,
  (void*) NMI_Handler,
  (void*) HardFault_Handler,
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) SVC_Handler,
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) PendSV_Handler,
  (void*) SysTick_Handler,

Is that understanding correct?

I also noted that only Reset_Handler and SysTick_Handler only have any code behind them ,the rest just redirect to Dummy_Handler that just halts the system. So if my WatchDog is IRQ lvl 0, which I assume is the highest, the only thing that can be calling Dummy_Handler is one of the ones listed above? The documentation indicates that higher priority interrupts are the only thing that can interrupt an interrupt and the assumption I am making here is that the background process that runs the watchdog is still running and it would trigger an interrupt if it could, is this correct?

Yes that seems right. The first three have the highest priority (-3, -2, -1) and you can play with the four programmable levels for all other exceptions, including interrupts and are at 0 by default.

If two exceptions happen at the same time and they have the same programmed priority level, the exception with the lower CMSIS IRQ number will be processed first.

the assumption I am making here is that the background process that runs the watchdog is still running and it would trigger an interrupt if it could, is this correct?

the watchdog is a counter and thus would be running indeed.

To be fair, I've used Adafruit SleepyDog library when I had to deal with the WDT to abstract all the complexity

Fantastic and I really appreciate your fast responses, it is really helping me understand what could be going on.

So if all the non configured interrupts are also zero, then it will be based on the IRQ number so if there is a interrupt in any of the ones above WDT, it will also trigger dummy handler?

EIC NMI – External Interrupt Controller - NMI
PM – Power Manager - 0
SYSCTRL – System Control - 1
WDT – Watchdog Timer - 2

So would it be prudent to set the priority of all the unused ones to be lower than the ones I am using? My failure mode suggests it is sticking in dummy handler although the failure incidence is currently 7 - 10 days, so it is not easy to test after each change.

I have also changed Dummy_Handler to flash the built in led in a specific pattern, so I know when it is there.

I tried the Adafruit SleepDog library, but I found that when I added RTC and interrupts on edge, it messed with the clocks and didn’t work correctly. I ended up configuring the chip manually for RTC and WDT and EIC as I needed interrupts on edge.

Thanks for all your help.

YES, that's my understanding to, if that interrupt is enabled of course.

I have also changed Dummy_Handler to flash the built in led in a specific pattern

this is of course slowing down (esp. if you use digitalWrite()) the ISR handling. if you have some race condition going on, it can make matters worse or better and you won't be able to tell

have you tried activating DEBUG in the library which will set a break point and you can inspect what's going on?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.