uVision5 provides a debugger that allows us to suspend execution (by inserting a breakpoint), and examine/change values of variables used in our program.
Download and run the previous project,
debug_ADC
.Use the debug menu to insert a breakpoint on line 96 of our program (that is, at the statement
ADC_StartConversion ( );
.Select debug → Start/Stop Debug session to start a debug session.
Observe that execution stops at main. This is because the default project debug options are set to "Run to main".
Selecting Run (F5) will execute the statements up until the breakpoint.
Use Step (F11) to execute the statements in the program one after the other, and observe the values of variables. For example, when we reach line 39 (after stepping), the local variable
ADCvalue
is assigned to 10 (0x0000000A). This value is shown in the Call Stack + Locals window.