Atmel Xplained Pro Evaluation Kit ATSAM4E-XPRO ATSAM4E-XPRO Data Sheet

Product codes
ATSAM4E-XPRO
Page of 1506
981
SAM4E [DATASHEET]
Atmel-11157D-ATARM-SAM4E16-SAM4E8-Datasheet_12-Jun-14
39.6.16.5      Speed Measurement
When SPEEDEN is set in the TC_BMR, the speed measure is enabled on channel 0. 
A time base must be defined on channel 2 by writing the TC_RC2 period register. Channel 2 must be configured in
waveform mode (WAVE bit set) in TC_CMR2. The WAVSEL field must be defined with 0x10 to clear the counter
by comparison and matching with TC_RC value. Field ACPC must be defined at 0x11 to toggle TIOA output.
This time base is automatically fed back to TIOA of channel 0 when QDEN and SPEEDEN are set.
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.
39.6.16.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
quadradure signals because the detection requires a valid phase signal to detect the contamination on the other
phase signal.
Figure 39-22. 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.
PHA
PHB
Missing pulse due to a contamination (dust, scratch, ...)
Not a change of direction
detection
1
2
3
4
5
6
7
10
12
13
14
15
16
corrections