dsPIC30F Family Reference Manual
DS70063C-page 16-16 © 2004 Microchip Technology Inc.
16.6 Using QEI as an Alternate 16-bit Timer/Counter
When the QEI module is configured QEIM<2:0> = 001, the QEI function is disabled and the QEI
module is configured as a 16-bit timer/counter. The setup and control for the auxiliary timer is
accomplished through the QEICON register.
The QEI timer functions similar to the other dsPIC30F timers. Refer to Section 12. “Timers”
for a general discussion of timers.
When configured as a timer, the POSCNT register serves as a timer register similar to the
TMRn registers of the GP timers. The MAXCNT register serves as a period register similar to
the PRn registers of the GP timers. When a timer/period register match occurs, the QEIF flag
asserts.
Figure 16-10: QEI as Timer/Counter Block Diagram
Note: Changing operational modes, i.e., from QEI to Timer or Timer to QEI will not affect
the Timer/Position Count Register contents.
16-bit Up/Down Counter
Comparator/Zero Detect
Max Count Register
Programmable
Digital Filter
QEA
Programmable
Digital Filter
QEB
(POSCNT)
(MAXCNT)
QEIF
Event
Flag
Reset
Equal
1
0
TQCKPS
2
1, 8, 64, 256
Prescaler
Q
Q
D
CK
TQGATE
Synchronize
Det
0 0
UDSRC
UPDN
1
0
TQGATE
0 1
1 0
TQCS
TQGATE
1 1
Gated
T
CY
T
CY