Configuring Advanced Settings on Kinetis

To configure advanced settings for tracing and profiling on Kinetis:

  1. Click Advanced Settings on the Trace and Profile tab of the Debug Configurations dialog box.

    The Preferences dialog box appears. For Kinetis Cortex M4, the default page is ETM Settings.

    Note: Use the Advanced Settings button if you want to configure advanced settings for collecting trace.
    Note: If you are configuring Kinetis Cortex M4 project, the Preferences dialog box displays ETM, ITM, and ETB trace settings since Kinetis Cortex M4 supports ETM and ITM trace. Kinetis Cortex M0+ supports MTB trace, therefore, the Preferences dialog box for a Kinetis Cortex M0+ project displays MTB trace settings only.
  2. If you are configuring settings for Kinetis Cortex M4, ensure that the Enable ETM Tracing checkbox is checked.
    Figure 1. Preferences Dialog Box
    Preferences Dialog Box

    The table below describes the various options available on the ETM Settings page.

    Table 1. Options Available in ETM Settings Page
    Group Option Description
    General Settings Stall Processor If checked, enables the FIFOFULL output that causes the processor to stall when the FIFO is close to overflow. When cleared, the FIFOFULL output remains low and the FIFO overflows if there is a large number of trace packets.
    Trace All Branches If checked, all branch addresses are collected. Otherwise, only indirect branches are collected. It enables reconstruction of the program flow with the information from the binary executable.
    Enable Timestamps Enables timestamping when checked.
    FIFOFULL Level (no. of bytes) Specifies the number of bytes left in the FIFO, below which it is considered full. When the space left in the FIFO gets lower than the specified value, the FIFOFULL or SupressData signal is asserted. For example, setting the value to 15 causes data trace suppression or processor stalling, if enabled, when there are less than 15 free bytes in the FIFO.
      Trace Conditions  
    Trace Start/Stop Control   Specifies the watchpoint comparator inputs that are used as trace start and stop resources.

    NOTE: The same settings are displayed for configuring MTB trace in case you are using a Kinetis M0+ project. The difference is that in ETM, there are 4 address comparators, and in MTB, there are only 2.

    Start Resource Selects the corresponding DWT comparator to control trace start.

    NOTE: Data Watchpoint and Trace (DWT) is an optional debug unit that provides watchpoints, data tracing, and system profiling for the processor.

    Stop Resource Selects the corresponding DWT comparator to control trace stop.
    Trigger Control   Defines an event that generates on meeting a condition and appears in the trace data.

    You can define resource A and resource B and a function between A and B. When the function occurs, the event is generated and is seen in the Trace Data viewer.

    Function Specifies the condition that must be met to generate a trigger signal on the trace port.
    A Is the ETM event resource used for triggering. It can take four values:
    • DWT comparator - Any of the four comparators
    • ETM - Counter at zero - 16-bit counter reload value
    • Start/stop - Start or stop tracepoint set in the application
    • Always true - Default option that triggers all the time
    B Same as A.
    Index Specifies the value of the comparator if you select DWT comparator in the A or B fields.
    Collect Trace after Trigger When selected, changes the value of Trigger Counter to 480 words in the Trigger Settings section of the ETB Settings page. This means that 480 words of trace will be collected after trigger hit and 32 words will be collected before trigger hit.
      Collect Trace before Trigger When selected, changes the value of Trigger Counter to 32 words in the Trigger Settings section of the ETB Settings page. This means that 32 words of trace will be collected after trigger hit and 480 words will be collected before trigger hit.
    Collect Trace about Trigger When selected, changes the value of Trigger Counter to 256 words in the Trigger Settings section of the ETB Settings page. This means that 256 words of trace will be collected after trigger hit and 256 words will be collected before trigger hit.
    Trace Enable Event   Enables the trace when an event occurs.
    NOTE: It is not guaranteed that trace will be generated exactly when the event occurs. It may have a few cycles delay. Function Specifies the condition that must be met to enable trace collection. For example, if you set A as DWT comparator 1 and set DWT comparator 1 to fire at instruction at address 0x800 with mask 0xF, and specify Function as A then the Trace enable will be active continuously between addresses 0x800 and 0x80F.
    A Is the ETM event resource used for collecting trace. It can take four values:
    • DWT comparator - Any of the four comparators
    • ETM - Counter at zero - 16-bit counter reload value
    • Start/stop - Start or stop tracepoint set in the application
    • Always true - Default option that enables the trace
    B Same as A.
    Index Specifies the value of the comparator if you select DWT comparator in the A or B fields.
    Timestamp Event   Generates a timestamp in trace when the event gets activated.
    Function Specifies the condition that must be met to generate the timestamp event.
    A Is the ETM event resource used for triggering. It can take four values:
    • DWT comparator - Any of the four comparators
    • ETM - Counter at zero - 16-bit counter reload value
    • Start/stop - Start or stop tracepoint set in the application
    • Always true - Default option that triggers all the time
    B Same as A.
    Index Specifies the value of the comparator if you select DWT comparator in the A or B fields.
    ETM - Counter Reload Value   Is the value with which the counter is automatically loaded when the register is programmed and when the ETM Programming bit is set. This is a 16- bit field that should be specified in hexadecimal form.

    The ETM counter decrements at each ETM cycles. Once it reaches 0, it generates an ETM - Counter at zero event.

    Comparator Settings Comparator 1, Comparator 2, Comparator 3, Comparator 4 Allows choosing one of the four DWT comparators to configure trace conditions.
    Generate Comparator Match Event On Allows selecting the event that generates a comparator match.
    Value Indicates the reference value against which comparison is done.
    No. of bits to ignore Indicates the size of the ignore mask (0 - 31 bits) applied to the matching address range.
    Match Data Size Defines the size of the data in the associated comparator register for value matching.
    Note: Timestamps provide information on the timing of event generation with respect to their visibility at a trace output port.
  3. Click ITM Settings on left to display its corresponding options on right.
    Figure 2. ITM Settings Page
    ITM Settings Page

    The table below describes the various options available on the ITM Settings page.

    Table 2. Options Available in ITM Settings Page
    Group Option Description
    Enable ITM Tracing   Enables ITM tracing
    Synchronize Packages   Enables packages synchronization when checked.
    Timestamp   Enables ITM timestamping (delta).
    No Timestamps Disables timestamping.
    Local Timestamps Defines the number of ITM clock ticks on which the timestamp counts. ITM clock is a clock on 20 bits.

    Timestamp Prescaler: Modifies the scaling of the timestamps clock. For example, if set to 16, the timestamp counts once every 16 clock ticks.

    Global Timestamps Defines the number of ATCLK (or Advanced Trace Clock) ticks on which the timestamp counts. ATCLK is a clock on 48 bits, and it is common to ETM and ITM.

    Global Timestamp Frequency : Decides when the global cycle count is written in the trace buffer, that is every 128/ 8192 cycles or at every packet.

    Enable Stimulus Registers Each bit location corresponds to a virtual stimulus register. When a bit is set, a write to the appropriate stimulus location results in a packet being generated, except when the FIFO is full.

    Use Select All or Clear All to check or clear all the checkboxes.

    Cycle Counter Enable Enables cycle counter which counts the number of core cycles. The counting is suspended when the core halts in debug state.
    Extension Counter Reload Value (hex) Defines the cycle count event combining with Cycle Counter Tap and Synchronization Packet Rate.
    Cycle Counter Tap Selects a tap on the cycle counter register - Tap at cycle count bit 6 or Tap at cycle count bit 10. This means that the Cycle Counter Tap event fires at every change of either bit 6 or bit 10 of the cycle counter.

    NOTE: Cycle count is a 32-bit, incrementing (up) cycle counter.

    Synchronization Packet Rate Selects a synchronization packet rate. CYCCNTENA and ITM_TCR.SYNCENA must also be enabled for this feature. Synchronization packets (if enabled) are generated on tap transitions (0 to1 or 1 to 0).
    Event Generation Enable PC Sample Controls PC sample event generation.
    Enable Cycle Count Event Generation Enables cycle count, allowing it to increment and generate synchronization and count events.
    Enable Exception Trace Enables exception trace that traces exception entry, exit and return to a pre-empted handler or thread.
    Enable Exception Overhead Count Enables exception overhead event.

    NOTE: The exception overhead counter counts the total cycles spent in exception processing. For example, entry stacking, return unstacking, or pre-emption. An event is emitted on counter overflow which occurs after every 256 cycles.

    Enable CPI Count Enables the CPI count event.
    Enable Sleep Overhead Count Enables sleep overhead count event.
    Enable LSU Count Enables the Load Store Unit (LSU) count event.

    NOTE: The LSU counter increments on the additional cycles required to execute all load and store instructions.

    Enable Folded Instruction Count Enables the folded instruction count event.

    NOTE: The folded instruction counter increments on any instruction that executes in zero cycles.

  4. Click ETB Settings on left to display its corresponding options on right.
    Figure 3. ETB Settings Page
    ETB Settings Page

The table below describes the various options available on the ETM Settings page.

Table 3. Options Available in ETB Settings Page
Group Option Description
Enable ETB Trace Capture   Enables ETB tracing.
Continuous Trace Collection   Allows you to collect continuous trace data.
Enable Enables the continuous trace collection when checked. It also enables the Almost Full Level checkbox.
Almost Full Level (no. of words) Indicates the number of words (of 4 bytes) for which the trace buffer is considered almost full, and trace must be read from the hardware memory. This mode offers the possibility to collect the trace data when the buffer gets full to prevent data loss.

When the Embedded Trace Buffer (ETB) becomes almost full, a signal is asserted to cause an interrupt on the core or to cause the core to halt. For now, the profiling tools offer support only for halting the core.

NOTE: The maximum and minimum value for the Almost Full Level field is application-dependant. However, the safe maximum and minimum values are 450 and 50. The trace and profile results might not be collected for any value above 450 and below 50.

Trace Formatting Settings   Trace formatting inserts the source ID signal into a special format data packet stream. Trace formatting is done to enable trace data to be re-associated with a trace source after data is read back out of the ETB.
Enable Formatting When checked, prevents triggers from being embedded into the formatted stream.
Continuous Formatting Enables the continuous mode. In the ETB, this mode corresponds to the normal mode with the embedding of triggers.
Stop on Flush Completion Stops trace formatting when a flush is completed. This forces the FIFO to drain off any partially completed packets.
Stop on Trigger Event Stops trace formatting when a trigger event is observed. A trigger event occurs when the trigger counter reaches zero (where fitted) or the trigger counter is zero (or not fitted) when the TRIGIN signal is HIGH.
Trigger Settings   A trigger event occurs when the trigger counter reaches zero, or when the trigger counter is zero, when TRIGIN is HIGH. The trigger counter register controls how many words are written into the trace RAM after a trigger event. After the formatter is flushed in the normal or continuous mode, a complete empty frame is generated. This is a data overhead of seven extra words in the worst case. If the formatter is in bypass mode, a maximum of two additional words are stored for the trace capture postamble.
Trigger Counter (no. of words) Defines the number of 32-bit words remaining to be stored in the ETB Trace RAM.

NOTE: The hardware buffer can hold upto 512 words of trace. Trigger Counter indicates how many words of trace will be collected in the buffer before and after the trigger gets activated. The value in Trigger Counter is the number of words of trace that will be collected after trigger hit, the rest will be collected before trigger hit. For example, if the value is 32 then 32 words of trace will be collected after trigger hit and 480 will be collected before trigger hit.

The value of Trigger Counter depends on the option selected from ETM Settings page in the Trigger Control tab.

Indicate Trigger on TRIGN Indicates a trigger on TRIGIN being asserted.
Indicate Trigger on Trigger Event Indicates a trigger on a trigger event.
Indicate Trigger on Flush Completion Indicates a trigger on flush completion.
Flush Control Settings   There are three flush generating conditions that can be enabled together. If more flush events are generated while a flush is in progress, the current flush is serviced before the next flush is started. Only one request for each source of flush can be pended. If a subsequent flush request signal is deasserted while the flush is still being serviced or pended, a second flush is not generated. Flush from FLUSHIN takes priority over Flush from Trigger, which in turn is completed before a manual flush is activated.
Generate Flush Using FLUSHIN Generates flush using the FLUSHIN interface.
Generate Flush Using Trigger Event Generates flush using the trigger event.