Debugging ST programs

For Structured Text (ST) programs, generate debug information for individual program organization units (POUs) to enable step-by-step execution while simulating an application. For ST programs in a resource with generated debug information, the controller switches to step-by-step execution when the application encounters a breakpoint. Set breakpoints to lines of code to instantiate step-by-step execution.
TIP: Breakpoints, cycle-to-cycle, and step-by-step execution are only available while simulating an application.
In the language editor, breakpoints appear as red circles to the left of the line of code and the line is highlighted in red.
stx_db1
While debugging, the application stops when it encounters a breakpoint. At this time, the application is in the DEBUGGING state. Perform one of these operations:
  • Step into the line of code, execute the current line of code then steps into the subsequent line of code. When the current line of code includes a call to a function, stepping continues in the called function then returns to the line of code in the POU.
  • Step over the line of code, execute the current line of code then steps to the next line of code
  • Execute in real-time mode
  • Execute one cycle
    TIP: Set breakpoints for Target-independent code (TIC); C source code POUs do not support breakpoints.
When the application stops on a breakpoint, a yellow arrow appears over the breakpoint and the line of code is highlighted pink.
stx_db2
The arrow points downward when stepping passes beyond the last line of code of a POU.
Task
Procedure
Generate debug information for an ST POU
  1. In the
    Application View
    , select the ST POU for which to generate debug information.
  2. In the
    Properties
    for the POU, set
    Generate Debug Info
    to True.
Set a breakpoint
  • Right-click in the margin to the left of the line of code on which to add a breakpoint, then select
    Add/Remove Breakpoint
    .
Remove a breakpoint
  • Right-click in the area to the left of the line of code having a breakpoint to remove, then select
    Add/Remove Breakpoint
    .
Step into the line of code
  • From the
    Target Execution
    toolbar, select (or press
    F11
    ).
Step over the line of code
  • From the
    Target Execution
    toolbar, select (or press
    F10
    ).
Execute in real-time mode
  • From the
    Simulation
    menu, select
    Continue
    .
    The POU executes in real-time mode.
Execute in cycle-to-cycle mode
  • From the
    Simulation
    menu, select
    Pause
    .
    The POU executes in cycle-to-cycle mode.
Execute one cycle
  • From the
    Target Execution
    toolbar, select .
TIP: Set or remove breakpoints in the RUNNING state or cycle-to-cycle execution while simulating.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal