Datasheet
1052
32117D–AVR-01/12
AT32UC3C
34.6.1.4 Position counter
The 16-bit position counter is incremented or decremented on every count pulse, generated by
the quadrature decoder module. The counting direction is displayed in SR.CNTDIR.
If the position counter reaches the TOP.PCTOP value when counting up or the 0 value when
counting down, the counter wraps around. The Position Counter Roll Over (PCRO) interrupt is
generated.
Usually, the TOP.PCTOP value should always be set to the total number of quadrature states
minus one, which is (quadrature_encoder_lines_count *4) -1.
34.6.1.5 Index detection
The optional index signal QEPI may be used to correct the position counter if quadrature states
have been missed due to noise. If the Index Enable bit (CF.IDXE) is written to one, detection of
the QEPI signal will reset the position counter to 0 on a selected phase of quadrature signals.
This selected phase is configured via the Detection Phase field (CF.IDXPHS).
The Index Error (IDXERR) interrupt is triggered if the index detection occurs and the position
counter value is not 0.
34.6.1.6 Revolution counter
The revolution counter is incremented/decremented each time the position counter rolls over. It
rolls over when it reaches the TOP.RCTOP value.
34.6.1.7 Waveforms
Figure 34-5. Quadrature Clock and Direction Decoding (TOP.PCTOP = 4)
QEPA
QEPB
QPulse
CNTDIR
021 3401 2 104321
PC
0
1
0
RC