1. Debug Options in STM32CubeIDE

1. Stepping

Step Over

  • What it is: Executes the current line of code and stops at the first line of code after the function call, if there is any.
  • When to use: When you want to skip a function call without entering it.

Step Into

  • What it is: Executes the next line of code, and if it's a function, the debugger enters the function.
  • When to use: When you want to debug a function in detail.

Step Return

  • What it is: Continues running your code until the currently executing function returns.
  • When to use: When you want to exit the current function after debugging it.

2. Disassembly

  • 4 Columns: These columns display the Address, Machine Code, Assembly Mnemonic, and Arguments/Operands, respectively.

Example: 0x08001234 4863 LDR r0, [r1, #4] - 0x08001234: Memory address - 4863: Machine code - LDR: Mnemonic - r0, [r1, #4]: Operands


3. Breakpoints

  • Limited Number: STM32 only supports a limited number of hardware breakpoints (usually 6 or 10).

  • Breakpoint Window: You can open this window to see all active breakpoints. It's useful for managing and clearing them as needed.


4. Expression and Variable Window

  • Do Math: You can directly perform calculations in the expression window. Useful for quick evaluations or conversions.

  • Hover to View: Hovering over a variable in the code while debugging allows you to see its current value.


5. Call Stack

  • What it is: The Call Stack window shows you the chain of function calls that led to the current point in code.

  • Why it's Useful: It helps you to trace the execution flow, figure out how you arrived at a certain point, and identify any recursive functions or loops.


6. Fault Analyzer

  • What it is: The Fault Analyzer window provides insights into the faults that have triggered, like HardFaults or BusFaults.

  • Why it's Useful: This tool helps you diagnose issues at the hardware level, such as memory access violations.


7. Data Watchpoints

  • What it is: Data watchpoints allow you to break the execution when a specific variable changes.

  • Why it's Useful: Excellent for tracking variable changes and understanding how and where a variable's value is being modified.


8. Special Function Registers (SFR) Window

  • What it is: This window shows the state of the MCU's Special Function Registers.

  • Why it's Useful: Any changes here will directly affect the hardware, letting you see or manually adjust the hardware settings in real-time.