English
Language : 

W79E217A Datasheet, PDF (138/207 Pages) Winbond – 8-bit Microcontroller
Preliminary W79E217A Data Sheet
Figure 15-13: X2 Counting Mode
QEI x2 Counting mode is selected by setting the QEI Mode Select bits (QEIM1:QEIM0) to ‘01b’ or
‘11b’. In this mode, the QEI logic detects every edge on the QEA input only. Every rising and falling
edge on the QEA signal clocks the pulse counter.
15.2.5 Up-Counting
Under the forward direction the DIR bit is 1 when up-counting. Software needs to clear the QEIF flag.
For the free-counting mode counter will counts until it matches 65535 and next edges on the forward
direction will set the QEIF high and reset the PLSCNT to zero. For compare-counting mode counter
counts until the MAXCNT value and reload the counter to zero and starts counting up. Changes of
direction trigger a down-count and PLSCNT decreasing in counter value. For X2 mode, only CHA
edge will set QEIF while for X4 mode both CHA and CHB edges will set QEIF.
15.2.6 Down-Counting
A change of direction will causes the counter to down-count for x2/x4 counting mode. It is indicated
with the DIR bit as 0 and DIRF flag is set to 1. At this stage the PLSCNT will starts to down-count
from the MAXCNT value for compare-counting mode and while in free-counting mode it will starts to
down-count from 65535. The pulse counter will reload with MAXCNT when it down counts to zero in
compare-counting mode and sets QEIF to high in the next edge. In free-counting mode the counter
will count to 16 bits value before it reload the pulse counter with the value 65535 and set the QEIF
high in the next edge. For X2 mode, only CHA edge will set QEIF while for X4 mode both CHA and
CHB edges will set QEIF.
- 138 -
Publication Release Date: December 14, 2007
Revision A3.0