Keil Logo

Debugging Programs

Several buttons on the toolbar can be used to debug programs using FlashMon51.

Button Description
Debug Button When a debugging session is started, µVision Debugger connects to the target board and downloads the application program. In the event of a communication failure, µVision displays a dialog with instructions and options.
Step Into Button
Breakpoints Button
Run Button
FlashMon51 supports most µVision debugger features like single-step commands, sett breakpoints, and run the application. Variables can be viewed using standard debugger features.
Serial Window Button FlashMon51 can share the serial interface, used for monitor communication, with the target program. Serial Window #1 shows the printf and putchar output from the target program.


  • Do not initialize the serial interface in the application. The monitor configures the UART. Subsequent configuration changes may cause the monitor to lose synchronization with the debugger. Use conditional compilation as shown in the example programs.
  • It is not possible to single-step through putchar or getkey I/O functions.
Stop Button If the option Serial Interrupt is enabled, program execution can be stopped using the Halt command from the menu Debug or toolbar, or by pressing the Esc key in the windowCommand.

The Monitor uses the serial interrupt to halt the user program. If the Monitor cannot stop the program (because the user application has disabled interrupts) a dialog opens that displays options and instructions.
Reset Button The µVision Reset command sets the program counter to 0. However, peripherals and SFRs are not reset. This command is not identical to a hardware reset of the MCU.

Working with Flash Monitor

Flash Monitor helps debugging target programs in real-time. It allows viewing program symbols, watch program variables, examine memory contents, and more!

There are only a few things to consider when using FlashMon51.

  1. Breakpoints are set by replacing instructions in the program with an ACALL instruction. This operation, while completely transparent, can have side effects that affect the operation of the target program.
  2. On hardware configurations where the Flash Monitor CODE is located at address 0, the developer has to relocate the startup code, program code segments, and interrupt vector table.
  3. Some devices (like Atmel parts) share the same xdata address regions for on-chip XRAM and on-chip EEPROM. In this case, it is not possible to set breakpoints or single step into routines that disable the xdata RAM area, which is used by Flash Monitor-51.
  4. Enable or disable the HALT command on the toolbar in µVision Debugger. When enabled with the check box Stop Program Execution with Serial Interrupt in the dialog Options — Debug — Keil Monitor-51 Driver Settings, Monitor-51 uses the 8051 serial interrupt vector to signal that the target program should stop running. Therefore, you may need to reserve the serial interrupt vector in the application. To do this, modify the application as follows:
    • The application may not write to the serial interface vector. The easiest way to reserve this vector is to locate an array of 3 bytes at a fixed address at the beginning of your C program. Just reserve the serial interrupt of the on-chip interface that the monitor configuration uses.
      • For the standard (or first) on-chip UART:
         char code reserve[3] _at_ 0x23;
      • For the second on-chip UART:
         char code reserve[3] _at_ 0x53;
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.