Skip to main content

IAR Embedded Workbench for RISC-V 3.40

Executing macros using Quick Watch

In this section:

The Quick Watch window lets you dynamically choose when to execute a macro function.

  1. Consider this simple macro function that checks the status of a timer enable bit:

    TimerStatus()
    {
      if ((TimerStatreg & 0x01) != 0)/* Checks the status of reg */
        return "Timer enabled"; /* C-SPY macro string used */
      else
        return "Timer disabled"; /* C-SPY macro string used */
    }
  2. Save the macro function using the filename extension mac.

  3. To load the macro file, choose View>Macros>Macro Registration. The Macro Registration window is displayed. Click Add and locate the file using the file browser. The macro file appears in the list of macros in the Macro Registration window.

  4. Select the macro you want to register and your macro will appear in the Debugger Macros window.

  5. Choose View>Quick Watch to open the Quick Watch window, type the macro call TimerStatus() in the text field and press Return,

    Alternatively, in the macro file editor window, select the macro function name TimerStatus(). Right-click, and choose Quick Watch from the context menu that appears.

    QW_macro_Mym80_04.png

    The macro will automatically be displayed in the Quick Watch window. For more information, see Quick Watch window.