Debugging in uVision
Overview
In this tutorial, we will learn how to use uVision for debugging firmware programming.
Preparation
Open your previous tutorial project or can create a new project.
You can also copy the given example "TU_uVision_Debugging.c" source code here
You will learn how to use debugging mode to check how the registers change
Software vs Hardware Debug
There are two methods to debug your program: software debug and hardware debug.
Software Debug: you do not need to connect the MCU to PC to debug a software program.
Hardware Debug: MCU board must be connected to the computer.
For this tutorial, we will use Hardware Debugging.
Debug Control
Compile, Debug, and Run
STM32 allows up to six breakpoints during hardware debugging. When a program stops at a breakpoint, the corresponding instruction has not been executed yet.
You can choose either debugging assembly code or C-code line by choosing the disassembly or source window in focus.
Control buttons of debugging
Run (F5): Continues the execution from the current position until you click Stop or the program is paused by a breakpoint.
Step In (F11): Execute one step and enter the function if the current step calls a function.
Step Out (Ctrl + F11): Execute until the current function returns.
Step Over (F10): Execute one step and run the function all at once if the current step calls a function.
Pheripheral Registers
Choose the menu: Peripherals ⟶ System Viewer
View and update the control and data registers of all available peripherals
Check Registers for GPIO Port A (PA5 for LED).
Check the value of Output Data Register (ODR) ODR5 and LED status
Check and uncheck ODR5 with mouse click and see how LED turns on/off
Check Registers for GPIO Port C (PC_13 for Button B1).
Check the value of Input Data Register (IDR) IDR13
Keep pressing ‘F10’ while B1 button is pressing and unpressing. Check the value of IDR13.
Now, check other peripheral registers such as RCC.
Processor Registers
Core Registers
Program counter (PC) r15 holds the memory address (location in memory) of the next instruction to be fetched from the instruction memory.
Stack point (SP) r13 holds a memory address that points to the top of the stack. SP is a shadow of either MSP or PSP.
xPSR (Special-purpose program status registers) is a combination of the following three processor status registers:
Application PSR
Interrupt PSR
Execution PSR
xPSR | Description |
---|---|
N | Negative or less than flag (1 = result negative) |
Z | Zero flag (1 = result 0) |
C | Carry or borrow flag (1 = Carry true or borrow false) |
V | Overflow flag (1 = overflow) |
Q | Q Sticky saturation flag |
T | Thumb state bit |
IT | If-Then bits |
ISR | ISR Number (6 bits) |
Last updated