English
Language : 

W79E217A Datasheet, PDF (136/207 Pages) Winbond – 8-bit Microcontroller
Preliminary W79E217A Data Sheet
CHA*/CHB* - QEA/B after going through noise filter. See Figure 15-10.
Figure 15-11: QEA/QEB/IC2 timing requirement.
15.2.1 Free-counting mode
Pulse counter up or down counts according to direction index (DIR). When overflow or underflow
occurs, it sets flag QEIF.
15.2.2 Compare-counting mode
Pulse counter up or down counts according to direction index (DIR). On up counting, QEIF will be
asserted when PLSCNT overflows from MAXCNT to zero on the next QEA edge for x2 counting
mode, and on QEA/QEB edge for x4 counting mode. On down counting, QEIF will be asserted
when PLSCNT underflows from zero to MAXCNT on the next QEA edge for x2 counting mode, and
on QEA/QEB edge for x4 counting mode. This mode provides the position of a rotor to user. If a
quadrature encoder output 1024 pulses to QEA per round, user can write MAXCNT with 4095 in x4
mode or 2047 in x2 mode and reset PLSCNT at initial before rotor runs. When the PLSCNT reaches
MAXCNT, it means rotor runs one round on next QEA edge.
15.2.3 X2/X4 Counting modes
In X2 counting mode, the pulse counter increases or decreases one on every QEA edge based on
the phase relationship of QEA and QEB signals, however:-
In X4 counting mode, the pulse counter increases or decreases one on every QEA and QEB edge
based on the phase relationship of QEA and QEB signals.
15.2.4 Direction of Count
If QEA lead QEB, the pulse counter is increased by 1. If QEA lags QEB, the pulse counter is
decreased by 1. The QEI control logic generates a signal that sets the DIR bit (QEICON.3); this in turn
determines the direction of the count. When QEA leads QEB, DIR is set (= 1), and the position counter
increments on every active edge. When QEA lags QEB, DIR is cleared, and the position counter
decrements on every active edge. Refer to below table.
- 136 -
Publication Release Date: December 14, 2007
Revision A3.0