Chapter 20 S12X Debug (S12XDBGV3) Module
MC9S12XDP512 Data Sheet, Rev. 2.17
Freescale Semiconductor
775
bit in the DBGC1 register is cleared, returning the module to the disarmed state0. If tracing is enabled a
breakpoint request can occur at the end of the tracing session. If neither tracing nor breakpoints are enabled
then when the nal state is reached it returns automatically to state0 and the debug module is disarmed.
20.4.5
Trace Buffer Operation
The trace buffer is a 64 lines deep by 64-bits wide RAM array. The S12XDBG module stores trace
information in the RAM array in a circular buffer format. The S12XCPU accesses the RAM array through
a register window (DBGTBH:DBGTBL) using 16-bit wide word accesses. After each complete 64-bit
trace buffer line is read via the S12XCPU, an internal pointer into the RAM is incremented so that the next
read will receive fresh information. Data is stored in the format shown in
Table 20-39. After each store the
counter register bits DBGCNT[6:0] are incremented. Tracing of S12XCPU activity is disabled when the
BDM is active but tracing of XGATE activity is still possible. Reading the trace buffer whilst the BDM is
active returns invalid data and the trace buffer pointer is not incremented.
20.4.5.1
Trace Trigger Alignment
Using the TALIGN bits (see
Section 20.3.2.3”) it is possible to align the trigger with the end, the middle,
or the beginning of a tracing session.
If End or Mid tracing is selected, tracing begins when the ARM bit in DBGC1 is set and State1 is entered.
The transition to Final State if End is selected signals the end of the tracing session. The transition to Final
State if Mid is selected signals that another 32 lines will be traced before ending the tracing session.
Tracing with Begin-Trigger starts at the opcode of the trigger. Using End or Mid-Trigger or when the
tracing is initiated by writing to the TRIG bit whilst congured for Begin-Trigger, tracing starts at the
second opcode after writing to DBGC1 if written in the CPU thread, .
20.4.5.1.1
Storing with Begin-Trigger
Storing with Begin-Trigger, data is not stored in the Trace Buffer until the Final State is entered. Once the
trigger condition is met the S12XDBG module will remain armed until 64 lines are stored in the Trace
Buffer. If the trigger is at the address of the change-of-ow instruction the change of ow associated with
the trigger will be stored in the Trace Buffer. Using Begin-trigger together with tagging, if the tagged
instruction is about to be executed then the trace is started. Upon completion of the tracing session the
breakpoint is generated, thus the breakpoint does not occur at the tagged instruction boundary.
20.4.5.1.2
Storing with Mid-Trigger
Storing with Mid-Trigger, data is stored in the Trace Buffer as soon as the S12XDBG module is armed.
When the trigger condition is met, another 32 lines will be traced before ending the tracing session,
irrespective of the number of lines stored before the trigger occurred, then the S12XDBG module is
disarmed and no more data is stored. If the trigger is at the address of a change of ow instruction the
trigger event is not stored in the Trace Buffer. Using Mid-trigger with tagging, if the tagged instruction is
about to be executed then the trace is continued for another 32 lines. Upon tracing completion the
breakpoint is generated, thus the breakpoint does not occur at the tagged instruction boundary.