23.4.3.4 Recoverable Faults

Recoverable faults can restart or halt the timer/counter. Two faults, called Fault A and Fault B, can trigger recoverable fault actions on the Compare/Capture Channel n register (CC0 and CC1) of the TCC. The compare channels' outputs can be clamped to the inactive state either for as long as the fault condition is present, or from the first valid fault condition detection on until the end of the timer/counter cycle.

Fault Inputs

The first two channel input events (TCCnMC0 and TCCnMC1) can be used as Fault A and Fault B inputs, respectively. Event system channels connected to these fault inputs must be configured as asynchronous. The TCC must operate in a PWM mode.

Fault Filtering

There are three filters available for each input, Fault A and Fault B. They are configured in the corresponding Recoverable Fault Control x registers (FCTRLA and FCTRLB). The three filters can either be used independently or in any combination.

Input Filtering
By default, event detection is asynchronous. When the event occurs, the fault system will immediately and asynchronously perform the selected fault action on the compare channel output, even in device power modes where the clock is not available. To avoid false fault detection on external events (e.g., due to a glitch on an I/O port), a digital filter can be enabled and configured by the Recoverable Fault Filter Value bit field in the Recoverable Fault Control x register (FCTRLx.FILTERVAL). If the event width is less than FCTRLx.FILTERVAL (in clock cycles), the event will be discarded. A valid event will be delayed by FCTRLx.FILTERVAL clock cycles.
Fault Blanking
This ignores any fault input for a certain time immediately after a selected waveform output edge. This can be used to prevent false fault triggering due to signal bouncing, as shown in the figure below. Blanking can be enabled by writing an edge triggering configuration to the Recoverable Fault n Blanking Operation bit field (FCTRLx.BLANK). The desired duration of the blanking must be written to the Recoverable Fault x Blanking Value bit field (FCTRLx.BLANKVAL).

The blanking time, tb is calculated by

t b = 1 + BLANKVAL f GCLK_TCCn_PRESC

Where,

fGCLK_TCCn_PRESC is the frequency of the prescaled peripheral clock, fGCLK_TCCn. The prescaler is enabled by writing '1' to the Recoverable Fault n Blanking Value Prescaler bit (FCTRLx.BLANKPRESC). When disabled, fGCLK_TCCn_PRESC=fGCLK_TCCn. When enabled, fGCLK_TCCn_PRESC=fGCLK_TCCn/64.

The maximum blanking time (FCTRLx.BLANKVAL = 
255) at fGCLK_TCCn=96 MHz is 2.67 µs (no prescaler) or 170 µs (with prescaling). For fGCLK_TCCn=1 MHz, the maximum blanking time is either 170 µs (no prescaling) or 10.9 ms (with prescaling enabled).

Figure 23-23. Fault Blanking in RAMP1 Operation with Inverted Polarity
Fault Qualification
This is enabled by writing a '1' to the Recoverable Fault x Qualification bit (FCTRLx.QUAL). When recoverable fault qualification is enabled (FCTRLx.QUAL is set), the fault input is disabled whenever the corresponding channel output has an inactive level, as shown in the figures below.
Figure 23-24. Fault Qualification in RAMP1 Operation
Figure 23-25. Fault Qualification in RAMP2 Operation with Inverted Polarity

Fault Actions

Different fault actions can be configured individually for Fault A and Fault B. Most fault actions are not mutually exclusive; therefore, two or more actions can be enabled at the same time to achieve a result that is a combination of fault actions.

Keep Action
This is enabled by writing a '1' to the Recoverable Fault x Keep bit (FCTRLx.KEEP) . When enabled, the corresponding channel output will be clamped to zero as long as the fault condition is present. The clamp will be released at the start of the first cycle after the fault condition is no longer present, see next Figure.
Figure 23-26. Waveform Generation with Fault Qualification and Keep Action
Restart Action

This is enabled by writing to '1' the Recoverable Fault x Restart bit (FCTRLx.RESTART). When enabled, the timer/counter will be restarted as soon as the corresponding fault condition is present. The ongoing cycle is stopped, and the timer/counter starts a new cycle (see the following figures). In Ramp 1 mode, when the new cycle starts, the compare outputs will be clamped to the inactive level as long as the fault condition is present.

Note: For RAMP2 operation, when a new timer/counter cycle starts, the cycle index will change automatically (see the following figures). Fault A and Fault B are qualified only during the cycle A and cycle B, respectively: Fault A is disabled during cycle B, and Fault B is disabled during cycle A.
Figure 23-27. Waveform Generation in RAMP1 mode with Restart Action
Figure 23-28. Waveform Generation in RAMP2 mode with Restart Action
Capture Action
Several capture actions can be selected by writing to the Recoverable Fault x Capture Action bit field (FCTRLx.CAPTURE). When one of the capture operations is selected, the counter value is captured when the fault occurs. These capture operations are available:
  • CAPT - The equivalent to a standard capture operation. For further details, refer to the Capture Operations Section
  • CAPTMIN - Captures the minimum time stamped value: On each new local minimum captured value, an event or interrupt is issued
  • CAPTMAX - Captures the maximum time stamped value: On each new local maximum captured value, an event or interrupt (IT) is issued. For additional information, refer to the following figure, Capture Action “CAPTMAX”.
  • LOCMIN - Notifies by event or interrupt when a local minimum captured value is detected
  • LOCMAX - Notifies by event or interrupt when a local maximum captured value is detected
  • DERIV0 - Notifies by event or interrupt when a local extreme captured value is detected, For more information, refer to the following figure Capture Action “DERIV0”

CCn.CC Content:

In CAPTMIN and CAPTMAX operations, CCn.CC stores the respective extreme captured values, For more information, refer to the following figure, Capture Action “CAPTMAX”. In LOCMIN, LOCMAX or DERIV0 operations, CCn.CC reflects the counter value at fault time, For more information, refer to the following figure, Capture Action “DERIV0”.

Before enabling CAPTMIN or CAPTMAX mode of capture, the user must initialize the corresponding CCn.CC bit field to a value to other than ZERO (for CAPTMIN) or TOP (for CAPTMAX). If the initial value of the CCn.CC bit field initial value is ZERO (for CAPTMIN) or TOP (for CAPTMAX), no captures will be performed using the corresponding channel.

When using advanced capture functions such as CAPTMIN, CAPTMAX, LOCMIN, LOCMAX and DERIV0, standard capture functions (CAPT) must be assigned to the lower CCn channels when used. See the example below.

Example: CC[0] = CAPT, CC[1] = CAPT, CC[2] = CAPTMIN, CC[3] = CAPTMAX.

MCx Behaviour:

In LOCMIN and LOCMAX operation, capture is performed on each capture event. The Match or Capture Channel n Interrupt Flag in the Interrupt Flag Status and Clear register (INTFLAG.MCx) is set only when the captured value is greater than or equal to (for LOCMIN) or less than or equal to (for LOCMAX) the previous captured value. Thus, the interrupt flag is set when a new relative local minimum (for CAPTMIN) or maximum (for CAPTMAX) value has been detected. DERIV0 is equivalent to a logical OR function of (LOCMIN, LOCMAX).

In CAPT operation, capture is performed on each capture event. The INTFLAG.MCx interrupt flag is set on each new capture.

In CAPTMIN and CAPTMAX operation, capture is performed only when, at the time of the capture event, the counter value is lower (for CAPTMIN) or higher (for CAPMAX) than the last captured value. The INTFLAG.MCx interrupt flag is set only at the time of the capture event, the counter value is higher or equal (for CAPTMIN) or lower or equal (for CAPTMAX) to the value captured on the previous event. Thus, the interrupt flag is set when a new absolute local minimum (for CAPTMIN) or maximum (for CAPTMAX) value has been detected.

Interrupt Generation

In CAPT mode, an interrupt is generated on each filtered Fault n and on each dedicated CCn channel capture counter value. In other modes, an interrupt is generated only on an extreme captured value.

Figure 23-29. Capture Action “CAPTMAX”
Figure 23-30. Capture Action “DERIV0”
Hardware Halt Action

This is configured by writing 0x1 to the Recoverable Fault x Halt Operation bit field (FCTRLx.HALT). When enabled, the timer/counter is halted, and the cycle is extended for as long as the corresponding fault is present.

The next figure ('Waveform Generation with Halt and Restart Actions') shows an example where both the restart action and hardware halt action are enabled for Fault A. The Compare channel 0 output is clamped to the inactive level as long as the timer/counter is halted. The timer/counter resumes counting operation as soon as the fault condition is no longer present. Since the restart action is enabled in this example, the timer/counter is restarted after the fault condition is no longer present.

The following figure ('Waveform Generation with Fault Qualification, Halt, and Restart Actions') shows a similar example, but with fault qualification additionally enabled. In this case, counting is resumed after the fault condition is no longer present.

Note that in RAMP2 and RAMP2A operations, when a new timer/counter cycle starts, the cycle index will automatically change.

Figure 23-31. Waveform Generation with Halt and Restart Actions
Figure 23-32. Waveform Generation with Fault Qualification, Halt, and Restart Actions
Software Halt Action

This is configured by writing 0x2 to the FCTRLx.HALT bit field. The software halt action is similar to the hardware halt action, but to restart the timer/counter, the corresponding fault condition must no longer be present, and the corresponding Non-recoverable Fault x State bit in the Status register (STATUS.FAULTx) must be cleared by software.

Figure 23-33. Waveform Generation with Software Halt, Fault Qualification, Keep and Restart Actions