This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DebugMon Handler Exception - Keil Debugger

I am currently having an issue with the debugging mode in Keil. I have a sample code which runs on a Cortex-M33 device, utilizes a JLink to debug, and was originally written to run on an Eclipse environment. I am migrating this application into the Keil IDE, but am experiencing issues running it in Keils debugging mode. In short, this application is used to showcase how the board can utilize different sources to wake the board up from a sleep state, which can be verified by hooking its GPIO peripherals up to an oscilloscope. It performs as expected on Eclipse without any problems, yet experiences issues when tested on the Keil environment – specifically, I have issues with the Keil debugger.

The behavior observed during testing is summarized below:

  • When run on Keil, the debugger halts in the DebugMon exception handler, which stalls the application and makes it behave improperly
  • The exception gets triggered when using the SWD port on any JLink (I tried using both the built-in and external JLink), yet it works completely fine with JTAG
  • When the exception handler is triggered and I perform a hard reset on the board to disconnect it from the debugger, the application works as expected
  • This issue is configuration dependent:
    • This issue only occurs consistently for a few wakeup sources at longer intervals (ie. The issue is observed when the wakeup period is ~1 s or greater)
    • When I reduce the wakeup period, it works as expected (ie. The exception handler does not get triggered when the wakeup period is very short, something like ~100 – 250 ms)
    • The exception handler gets triggered consistently when using debugger max clock rates above 50 kHz, but is much less frequent for rates under 50 kHz (please note that I need it to work for 1 MHz, so reducing the clock rate cannot be a solution)
  • This issue is intermittent as the observations stated above occur 90% of the time, but on rare occasions the DebugMon exception handler does not get triggered, which makes this problem troublesome to solve

Here are some of the methods I’ve tried to pinpoint the issue:

  • Thoroughly tested sample code on Eclipse as well as flashed it directly onto the device using JLink Commander – the application performs as expected using either method, regardless of JLink configuration (SWD or JTAG, onboard or external)
  • Used different boards to test – this includes trying another board of the same model but with a differing configuration (we can reproduce the issue exactly on that board too)
  • Got another engineer to port the sample code from Eclipse to Keil themselves and test on their end – they can reproduce the issue
  • Tried altering the clock rates on the debugger – as mentioned above, we need this to work for 1 MHz
  • Used both the onboard JLink as well as different external JLinks, using both SWD and JTAG ports

This process revealed that there is some configuration in Keil which is producing this exception – the device and the sample code do not seem to be the issue.

Does anyone know why the DebugMon exception handler gets triggered in the first place? Is there a way to disable it from being triggered?