Initialization and Configuration
1572
SLAU723A – October 2017 – Revised October 2018
Copyright © 2017–2018, Texas Instruments Incorporated
Quadrature Encoder Interface (QEI)
24.4 Initialization and Configuration
Perform these steps to configure the QEI module to read back an absolute position:
1. Enable the QEI clock using the RCGCQEI register in the System Control module (see
).
2. Enable the clock to the appropriate GPIO module via the RCGCGPIO register in the System Control
module (see
3. In the GPIO module, enable the appropriate pins for their alternate function using the GPIOAFSEL
register. To determine which GPIOs to configure, see the device-specific data sheet.
4. Configure the PMCn fields in the GPIOPCTL register to assign the QEI signals to the appropriate pins
(see
and the device-specific data sheet).
5. Configure the quadrature encoder to capture edges on both signals and maintain an absolute position
by resetting on index pulses. A 1000-line encoder with four edges per line, results in 4000 pulses per
revolution; therefore, set the maximum position to 3999 (0xF9F) as the count is zero-based.
a. Write the QEICTL register with the value of 0x0000.0018.
b. Write the QEIMAXPOS register with the value of 0x0000.0F9F.
6. Enable the quadrature encoder by setting bit 0 of the QEICTL register.
NOTE:
After the QEI module has been enabled by setting the ENABLE bit in the QEICTL register, it
cannot be disabled. The only way to clear the ENABLE bit is to reset the module using the
Quadrature Encoder Interface Software Reset (SRQEI) register.
7. Delay until the encoder position is required.
8. Read the encoder position by reading the QEI Position (QEIPOS) register value.
NOTE:
If the application requires the quadrature encoder to have a specific initial position, this value
must be programmed in the QEIPOS register after the quadrature encoder has been enabled
by setting the ENABLE bit in the QEICTL register.