English
Language : 

LM3S3749 Datasheet, PDF (794/898 Pages) Texas Instruments – Stellaris® LM3S3749 Microcontroller
Quadrature Encoder Interface (QEI)
1. Enable the QEI clock by writing a value of 0x0000.0100 to the RCGC1 register in the System
Control module.
2. Enable the clock to the appropriate GPIO module via the RCGC2 register in the System Control
module.
3. In the GPIO module, enable the appropriate pins for their alternate function using the
GPIOAFSEL register.
4. Configure the quadrature encoder to capture edges on both signals and maintain an absolute
position by resetting on index pulses. Using a 1000-line encoder at four edges per line, there
are 4000 pulses per revolution; therefore, set the maximum position to 3999 (0xF9F) since the
count is zero-based.
■ Write the QEICTL register with the value of 0x0000.0018.
■ Write the QEIMAXPOS register with the value of 0x0000.0F9F.
5. Enable the quadrature encoder by setting bit 0 of the QEICTL register.
6. Delay for some time.
7. Read the encoder position by reading the QEIPOS register value.
19.5
Register Map
Table 19-2 on page 794 lists the QEI registers. The offset listed is a hexadecimal increment to the
register’s address, relative to the module’s base address:
■ QEI0: 0x4002.C000
Note that the QEI module clock must be enabled before the registers can be programmed (see
page 230). There must be a delay of 3 system clocks after the QEI module clock is enabled before
any QEI module registers are accessed.
Table 19-2. QEI Register Map
Offset Name
Type
0x000 QEICTL
R/W
0x004 QEISTAT
RO
0x008 QEIPOS
R/W
0x00C QEIMAXPOS
R/W
0x010 QEILOAD
R/W
0x014 QEITIME
RO
0x018 QEICOUNT
RO
0x01C QEISPEED
RO
0x020 QEIINTEN
R/W
0x024 QEIRIS
RO
Reset
0x0000.0000
0x0000.0000
0x0000.0000
0x0000.0000
0x0000.0000
0x0000.0000
0x0000.0000
0x0000.0000
0x0000.0000
0x0000.0000
Description
QEI Control
QEI Status
QEI Position
QEI Maximum Position
QEI Timer Load
QEI Timer
QEI Velocity Counter
QEI Velocity
QEI Interrupt Enable
QEI Raw Interrupt Status
See
page
796
798
799
800
801
802
803
804
805
806
794
November 17, 2011
Texas Instruments-Production Data