Keil Logo

Technical Support

On-Line Manuals

µVision User's Guide

About µVision User Interface Creating Applications Debugging Start Debugging Start Energy Measurement without Debug Application Program Execution Debug Windows and Dialogs Breakpoints Window Call Stack and Locals Window Code Coverage Command Window Component Viewer Disassembly Window Editor Window Event Recorder Setup Event Recorder Event Recorder Window Events Filtering Event Statistics Window Post-mortem Analysis Event Viewer Execution Profiler Instruction Trace Window System Analyzer Usage tips Save System Analyzer Contents Statistics Restrictions Logic Analyzer Setup Setup in Detail Restrictions Cortex-M Trace Configuration Memory Map Memory Window Performance Analyzer Registers Window Serial Window Debug (printf) Viewer Symbols Window System Viewer Adding System Viewer Windows System and Thread Viewer Thread States Toolbox Trace Data Window Trace Navigation Trace Exceptions Event Counters ULINKplus Window Watch Window Core Peripherals Cortex-M0 and Cortex-M0+ CM0/M0+: Nested Vector Interrupt Controller CM0/M0+: System Control and Configuration CM0/M0+: System Tick Timer Fault Reports (Cortex-M0+ only) Cortex-M3, Cortex-M4, and Cortex-M7 CM3/M4/M7: Nested Vector Interrupt Controller CM3/M4/M7: System Control and Configuration CM3/M4/M7: System Tick Timer CM3/M4/M7: Fault Reports CM3/M4/M7: Memory Protection Unit Cortex-M23/M33/M35P and Cortex-M55 Armv8-M: Nested Vector Interrupt Controller Armv8-M: System Control and Configuration Armv8-M: System Tick Timer Armv8-M: Fault Reports Armv8-M: Memory Protection Unit Armv8-M: Security Attribution Unit M-Profile Vector Extension (MVE) Debug Scripting Expressions Constants System Variables Peripheral Variables I/O Ports Serial Ports Program Variables (Symbols) Fully Qualified Symbols Non-Qualified Symbols Literal Symbols Using Symbols Line Numbers Bit Addresses Type Specifications Memory Attribution Specifiers Operators Differences between µVision and C Expression Examples Code and Data Trace (Cortex-M) Trace Features Configuring Trace Tracepoint Expressions Tracepoint Intrinsics Tracepoint Limitations Tracepoint Marks Tips and Tricks Review Peripherals and CPU Configuration Simulate I/O Ports Simulate Interrupts and Clock Inputs Simulate external I/O Devices Assign Serial I/O to a PC COM Port Check Illegal Memory Access Command Input from File Preset I/O Ports or Memory Contents Write Debug Output to a File Keyboard Shortcuts TPIU Initialization after RESET (Cortex-M) Prevent Opening Files Show Japanese Messages Debug Commands Debug Functions Simulation Flash Programming Dialogs Utilities Command Line Example Programs Appendix

Debug Scripting

µVision provides a powerful scripting language that allows you to create complex debug scripts. The scripting language is identical to the C programming language with a few exceptions.

Debugger script files are plain text files (usually referred to as INI scripts) that can contain:

Typically, debug script files are used to configure the debugger or to setup or initialize something prior to running the program. When using debug adapters, such as the ULINKplus, you can also setup the power measurement or the I/Os. A debug script template for ULINKplus is located on your installation drive at [installation_path]\ARM\ULINK\Template\. The default [installation_path] is C:\Keil_v5.

To make an INI file simple to change and reconfigure, add Configuration Wizard syntax to the file.

Define Toolbox buttons to execute associated debug commands or debug functions.


/* Set Watchpoints                           */

ws myvar
ws myvar2

/* Create a Signal Function                  */

signal void bob(void) {
  while (1) {
    twatch (5000);               // Delay for 5,000 clocks
    P1 = ~P1;                    // Toggle P1 Pins

/* Executes upon software RESET;             */
/*  (Use the function name as is)            */
FUNC void OnResetExec (void)  {  //
   EnableTPIU();                 // call the initialization function

/* Change the program start address          */


/* Configure Toolbox buttons                 */
define button "Send Bob's signal", "bob"

/* Run the Program (stop at main)            */

g, main

Running debug scripts

There are two ways to execute a debug script:

  1. Executed on entering the debug session when configured as Initialization File in the Options for Target - Debug window.
  2. Executed manually from the Command window using the INCLUDE command.

Which one you choose depends on when you want to run the debug script. When µVision enters the debug mode, the following happens:

  1. The debugger loads the file set in the field Project - Options for Target - Output Name of Executable when Load Application at Startup is enabled.
  2. Restores Debug Session Settings for enabled dialogs.
  3. Executes the commands in the Initialization File.
  4. Executes the instructions until reaching main() when Run to main() is enabled or the command g, main is found in the Initialization File.


  • If you do not want to interfere with debug enter, you can run the script using the INCLUDE command from the Command window.
  • If you are using an Initialization file, disable Run to main() in the Options for Target - Debug window.

User functions in debug scripts

The command FUNC defines ANSI-style C-like functions for being used during a debugging session. These functions are removed when calling a LOAD command without INCREMENTAL from the command line after including the debug script. To work around this, do one of the following:

  • Use "LOAD ... INCREMENTAL" to preserve the functions.
  • Call "INCLUDE debug_script.ini" to redefine the functions after a LOAD without INCREMENTAL.
  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.