814
SAM4CP [DATASHEET]
43051E–ATPL–08/14
37.6.12 External Event/Trigger Conditions
An external event can be programmed to be detected on one of the clock sources (XC0, XC1, XC2) or TIOB.
The external event selected can then be used as a trigger.
The EEVT parameter in TC_CMR selects the external trigger. The EEVTEDG parameter defines the trigger edge for
each of the possible external triggers (rising, falling or both). If EEVTEDG is cleared (none), no external event is defined.
If TIOB is defined as an external event signal (EEVT = 0), TIOB is no longer used as an output and the compare register
B is not used to generate waveforms and subsequently no IRQs. In this case the TC channel can only generate
a waveform on TIOA.
When an external event is defined, it can be used as a trigger by setting bit ENETRG in the TC_CMR.
As in Capture Mode, the SYNC signal and the software trigger are also available as triggers. RC Compare can also be
used as a trigger depending on the parameter WAVSEL.
37.6.13 Output Controller
The output controller defines the output level changes on TIOA and TIOB following an event. TIOB control is used only if
TIOB is defined as output (not as an external event).
The following events control TIOA and TIOB: software trigger, external event and RC compare. RA compare controls
TIOA and RB compare controls TIOB. Each of these events can be programmed to set, clear or toggle the output as
defined in the corresponding parameter in TC_CMR.
37.6.14 Quadrature Decoder Logic
37.6.14.1 Description
The quadrature decoder logic is driven by TIOA0, TIOB0, TIOB1 input pins and drives the timer/counter of channel 0 and
channel 1. Channel 2 can be used as a time base in case of speed measurement requirements (refer to
Figure 37-15
”Predefined Connection of the Quadrature Decoder with Timer Counters”
).
When writing a 0 to bit QDEN of the TC_BMR, the quadrature decoder logic is totally transparent.
TIOA0 and TIOB0 are to be driven by the two dedicated quadrature signals from a rotary sensor mounted on the shaft of
the off-chip motor.
A third signal from the rotary sensor can be processed through pin TIOB1 and is typically dedicated to be driven by an
index signal if it is provided by the sensor. This signal is not required to decode the quadrature signals PHA, PHB.
Field TCCLKS of TC_CMRx must be configured to select XC0 input (i.e., 0x101). Field TC0XC0S has no effect as soon
as quadrature decoder is enabled.
Either speed or position/revolution can be measured. Position channel 0 accumulates the edges of PHA, PHB input
signals giving a high accuracy on motor position whereas channel 1 accumulates the index pulses of the sensor,
therefore the number of rotations. Concatenation of both values provides a high level of precision on motion system
position.
In speed mode, position cannot be measured but revolution can be measured.
Inputs from the rotary sensor can be filtered prior to down-stream processing. Accommodation of input polarity, phase
definition and other factors are configurable.
Interruptions can be generated on different events.
A compare function (using TC_RC) is available on channel 0 (speed/position) or channel 1 (rotation) and can generate
an interrupt by means of the CPCS flag in the TC_SRx.