820
SAM4CP [DATASHEET]
43051E–ATPL–08/14
Channel 0 must be configured in capture mode (WAVE = 0 in TC_CMR0). The ABETRG bit of TC_CMR0 must be
configured at 1 to select TIOA as a trigger for this channel.
EDGTRG can be set to 0x01, to clear the counter on a rising edge of the TIOA signal and field LDRA must be set
accordingly to 0x01, to load TC_RA0 at the same time as the counter is cleared (LDRB must be set to 0x01).
As a consequence, at the end of each time base period the differentiation required for the speed calculation is
performed.
The process must be started by configuring bits CLKEN and SWTRG in the TC_CCR.
The speed can be read on field RA in TC_RA0.
Channel 1 can still be used to count the number of revolutions of the motor.
37.6.14.6 Missing Pulse Detection and Auto-correction
The QDEC is equipped with a circuitry which detects and corrects some errors that may result from contamination on
optical disks or other materials producing the quadrature phase signals.
The detection and autocorrection only works if the count mode is configured for both phases (EDGPHA = 1 in TC_BMR)
and is enabled (AUTOC = 1 in TC_BMR).
If a pulse is missing on a phase signal, it is automatically detected and the pulse count reported in the CV field of the
TC_CV0/1 is automatically corrected.
There is no detection if both phase signals are affected at the same location on the device providing the quadrature
signals because the detection requires a valid phase signal to detect the contamination on the other phase signal.
Figure 37-20. Detection and Auto-correction of Missing Pulses
If a quadrature device is undamaged, the number of pulses counted for a predefined period of time must be the same
with or without detection and auto-correction feature.
Therefore, if the measurement results differ, a contamination exists on the device producing the quadrature signals.
This does not substitute the measurements of the number of pulses between two index pulses (if available) but provides
a complementary method to detect damaged quadrature devices.
When the device providing quadrature signals is severely damaged, potentially leading to a number of consecutive
missing pulses greater than 1, the downstream processing may be affected. It is possible to define the maximum
admissible number of consecutive missing pulses before issuing a Missing Pulse Error flag (MPE in TC_QISR). The
threshold triggering a MPE flag report can be configured in field MAXCMP of the TC_BMR. If the field MAXCMP is
cleared, MPE never rises. The flag MAXCMP can trigger an interrupt while the QDEC is operating, thus providing a real
time report of a potential problem on the quadrature device.
PHA
PHB
Missing pulse due to a conta
m
ination (dust, scratch, ...)
Not a change of direction
detection
1
2
3
4
5
6
7
10
12
13
14
15
16
corrections