Subsection7.1.5Part 3b: Watching a Register Change
Your debug session from Subsection 7.1.4 is halted at the first line of main(), and while it is halted, the debugger can show you every peripheral register on the chip, live. In the pane on the right, select the SFRs tab (Special Function Registers). It lists the processor’s internals under Cortex_M0PLUS and every peripheral you have used, under STM32C031: ADC, GPIOA, RCC, USART2, and the rest, each expandable down to individual registers and bit fields (Figure 7.1.7). These are the same registers, with the same names, as in the reference manual, RM0490. What the SFRs view adds is the value each one holds on your own chip at this moment.
Figure7.1.7.The SFRs tab: the processor’s internals under Cortex_M0PLUS, and every peripheral from the reference manual under STM32C031. The x16/x10/x2 buttons switch the value display’s radix between base-16 (hexadecimal), base-10 (decimal) and base-2 (binary).
Figure7.1.8.RCC_IOPENR before and after single-stepping the first line of main(). Left: at launch the register reads 0x0, and GPIOA’s clock is off. Right: after one Step Over it reads 0x1, and the GPIOAEN field holds 1. The yellow highlight means “this value changed since the debugger last looked.” Right after launch the debugger is reading every register for the first time, so many rows glow yellow. Ignore that first flush. After a step the highlight becomes useful: only RCC_IOPENR is yellow, the one register the step changed.
You wrote RCC->IOPENR |= GPIOAEN; in week one and trusted that it did something. You have now watched it happen on your own board: one line of code changing one bit in one register. Every register write in every program this term can be checked the same way.
Select the SFRs tab in the right-hand pane, then expand RCC.
One Step Over: RCC_IOPENR 0x0 → 0x1, GPIOAEN 0 → 1. At launch the debugger reads everything for the first time, so many rows glow yellow; ignore that first flush. After the step, IOPENR is the only yellow row: the one register that changed. This is the line you wrote in week one, now watched as it executes.