9.6.2 MMD Details
In contrast to halt mode debugging, in monitor mode debugging the target CPU does not halt on a debug request but takes a debug interrupt instead and jumps to a specific debug interrupt handler which then handles the communication with a debug tool and also some low-level application maintenance that may be needed to be done while the application is halted. So technically, the CPU is still running and executing the code while the application itself is halted, allowing it to still handle some interrupts as well as some synchronous maintenance operation that can be done within the monitor code.
The monitor code consists of the following parts:
- A generic monitor that handles
communication with a debug tool. This part is delivered by Microchip and should not
be modified by the user. The specific file name is:
- MONITOR_ISR.s: Generic monitor assembler file. This file should not be modified by the user.
- A custom monitor part providing some
functions that can be filled in by the user. Microchip delivers a template for this
part. The specific file names are:
- MONITOR.c: Contains user-specific functions that are called on debug mode entry, exit and periodically while the CPU is in debug mode. Functions can be filled with user-specific code. None of the functions must block the generic monitor for more than 100ms.
- MONITOR.h: Header file to populate MONITOR_ functions.
The custom monitor part provides the following functions where the user can add functionality/maintenance which needs to be done in debug mode:
- MONITOR_OnExit(): Called once just before leaving the monitor and restarting the target application.
- MONITOR_OnEnter(): Called once just before entering the monitor. Target application is already stopped at this point.
- MONITOR_OnPoll(): Called periodically while the CPU is in debug mode.
The monitor modules need to be compiled, linked and downloaded with the application. For limitations to what can be done in the different functions of the custom monitor part, please see the next section.
