Texas Instruments Development Kit for TM4C129x,Tiva™ ARM® Cortex™ -M4 Microcontroller DK-TM4C129X DK-TM4C129X 데이터 시트

제품 코드
DK-TM4C129X
다운로드
페이지 2182
could use a load value of 82, resulting in 32,800 as the divisor, which is 0.09% above 2
14
. In this
case a shift by 15 would be an adequate approximation of the divide in most cases. If absolute
accuracy were required, the microcontroller's divide instruction could be used.
The QEI module can produce a controller interrupt on several events: phase error, direction change,
reception of the index pulse, and expiration of the velocity timer. Standard masking, raw interrupt
status, interrupt status, and interrupt clear capabilities are provided.
29.4
Initialization and Configuration
The following example shows how to configure the Quadrature Encoder module to read back an
absolute position:
1.
Enable the QEI clock using the RCGCQEI register in the System Control module (see page 415).
2.
Enable the clock to the appropriate GPIO module via the RCGCGPIO register in the System
Control module (see page 398).
3.
In the GPIO module, enable the appropriate pins for their alternate function using the
GPIOAFSEL register. To determine which GPIOs to configure, see Table 31-4 on page 2070.
4.
Configure the
PMCn
fields in the GPIOPCTL register to assign the QEI signals to the appropriate
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.
■ Write the QEICTL register with the value of 0x0000.0018.
■ Write the QEIMAXPOS register with the value of 0x0000.0F9F.
6.
Enable the quadrature encoder by setting bit 0 of the QEICTL register.
Note:
Once 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.
29.5
Register Map
Table 29-2 on page 2016 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 415). There must be a delay of 3 system clocks after the QEI module clock is enabled before
any QEI module registers are accessed.
2015
December 13, 2013
Texas Instruments-Advance Information
Tiva
TM4C129XNCZAD Microcontroller