Debug support (DBG)
Example of configuration
To output a simple value to the TPIU:
●
Configure the TPIU and assign TRACE I/Os by configuring the DBGMCU_CR (refer to
Section 26.16.2: TRACE pin assignment
configuration
●
Write 0xC5ACCE55 to the ITM Lock Access Register to unlock the write access to the
ITM registers
●
Write 0x00010005 to the ITM Trace Control Register to enable the ITM with Sync
enabled and an ATB ID different from 0x00
●
Write 0x1 to the ITM Trace Enable Register to enable the Stimulus Port 0
●
Write 0x1 to the ITM Trace Privilege Register to unmask stimulus ports 7:0
●
Write the value to output in the Stimulus Port Register 0: this can be done by software
(using a printf function)
26.15
MCU debug component (MCUDBG)
The MCU debug component helps the debugger provide support for:
●
Low-power modes
●
Clock control for timers, watchdog and bxCAN during a breakpoint
●
Control of the trace pins assignment
26.15.1
Debug support for low-power modes
To enter low-power mode, the instruction WFI or WFE must be executed.
The MCU implements several low-power modes which can either deactivate the CPU clock
or reduce the power of the CPU.
The core does not allow FCLK or HCLK to be turned off during a debug session. As these
are required for the debugger connection, during a debug, they must remain active. The
MCU integrates special means to allow the user to debug software in low-power modes.
For this, the debugger host must first set some debug configuration registers to change the
low-power mode behavior:
●
In Sleep mode, DBG_SLEEP bit of DBGMCU_CR register must be previously set by
the debugger. This will feed HCLK with the same clock that is provided to FCLK
(system clock previously configured by the software).
●
In STOP mode, the bit DBG_STOP must be previously set by the debugger. This will
enable the internal RC oscillator clock to feed FCLK and HCLK in STOP mode.
26.15.2
Debug support for timers, watchdog, bxCAN and I
During a breakpoint, it is necessary to choose how the counter of timers and watchdog
should behave:
●
they can continue to count inside a breakpoint. This is usually required when a PWM is
controlling a motor, for example.
●
they can stop to count inside a breakpoint. This is required for watchdog purposes.
670/690
register)
and
Section 26.15.3: Debug MCU
2
C
RM0008
Need help?
Do you have a question about the STM32F102 Series and is the answer not in the manual?
Questions and answers