User manual

UM0036 In-circuit debugging
Doc ID 7705 Rev 11 229/385
Note: ST7 MCUs with XFlash memory do not allow software breakpoints in memory sector 0. This
sector cannot be written to when the microcontroller is in USER mode. In some cases, the
size of sector 0 can be configured. If this is the case, STVD requires sector 0 to be
programmed to its minimum size.
With the ICC protocol, software breakpoints are created by introducing a TRAP instruction,
which causes the application to stop running. For this reason, STVD cannot be used for in-
circuit debugging of ST7 applications that contain TRAP instructions in the code.
With the SWIM protocol, there is a dedicated software break instruction. This instruction
stalls the core, and the peripherals that you previously specified on the Options tab in the
MCU configuration window are frozen by the debug module.
For in-circuit debugging with SWIM, there is no restriction on using TRAP instructions in
your code. However, you must not use software breakpoints on the BOOT area (write
protected pages), and it is not possible to debug the protected code area (readout protected
pages).
7.2.2 Hardware breakpoints
All microcontrollers that support in-circuit debugging contain debug modules. The number of
debug modules determines how many hardware breakpoints you can place at any given
time. Each debug module allows you to place two instruction breakpoints, or one advanced
breakpoint.
Allocating hardware breakpoint resources
If you have placed an instruction breakpoint (as explained in Section 5.8.1: Setting an
instruction breakpoint on page 183 ), which uses up part of a debug module, it appears in
the Instruction Breakpoints field to the left of the Advanced Breakpoints window shown
in Figure 165. From this field, you can disable the instruction breakpoints, in order to place
an advanced breakpoint.
In addition, the stepping commands Step Over, Step Out and Run to Cursor, require the
use of a hardware-based instruction breakpoint when using an MCU with ROM or HDFlash
memory. If you do not have enough hardware breakpoints available when using these
commands, STVD will have to temporarily disable breakpoints to execute these commands.
STVD will warn you that it is disabling your instruction, or advanced breakpoints in order to
perform the command. Click on OK to continue. Once the command has been executed,
STVD automatically re-enables your breakpoints.
Example
Imagine that you are debugging your application on an ST7 microcontroller that has the
following characteristics:
1024 bytes of RAM memory in the address range 0080h to 047Fh,
32 Kbytes of program memory in the address range 8000h to FFDFh,
3 debug modules.
You will be able to place the following breakpoints:
an unlimited number of software instruction breakpoints in the RAM memory address
range (0080h to 047Fh)
up to six hardware instruction breakpoints in the program memory address range
(8000h to FFDFh), or up to 3 hardware advanced breakpoints in any address range.