
Enhanced Time Processing Unit (eTPU2)
MPC5644A Microcontroller Reference Manual, Rev. 6
Freescale Semiconductor
901
24.5.7.4.1
Calculating the angle tick period integer and fraction
On each tooth the microcode has to update the exact period of a single angle tick used for counting the
internal angle in the tooth. The period of an angle tick or a tooth is measured in units of TCR1 clocks (if
TCR1CS = 0) or TCR1 clocks divided by 2 (if TCR1CS = 1). The microcode can use the eTPU MAC
Divider unit (see
Section 24.5.8.3, MAC and Divide Unit (MDU)
) to divide the tooth period by the number
of angle ticks per tooth, which is stored in the TICKS field of TPR (refer to
). This division yields the integer part of the angle tick period and the remainder. Dividing again
the remainder shifted left nine positions, by the number of angle ticks per tooth translates the remainder to
a 9-bit fraction. The microcode concatenates the 15-bit integer and the 9-bit fraction to a 24-bit value and
writes it to TRR. The new rate is effective immediately after the next Angle Tick is generated by the Angle
Tick Generator
1
.
For high RPM, note that shifting the tooth period value nine positions to the left prior to the first divide
operation would calculate, in one operation, the integer and the fraction. For example: On 60-tooth
flywheel running at 1000 RPM, tooth period is 1 ms. If TCR1 counts @ 25 MHz, it counts 25,000 times
in a tooth, which can be represented by 15 bits. Therefore the tooth period can be shifted nine positions to
the left prior to divide operation, and be represented with 24 bits.
Using shift left nine positions and one divide operation would get the result in MACL register (in MDU)
which holds the integer and nine bits of the fraction:
Angle_Tick_Rate {Integer[14:0], Fraction[8:0]} = (TCR1ToothPeriod
2
<<9) / Ticks
TRR = Angle_Tick_Rate {Integer[14:0], Fraction[8:0]}
On low RPM the initial tooth period, measured in TCR1 counts, may be too big to be shifted nine positions
to the left. For lower RPM (for example 500 RPM) the tooth period cannot be represented by 15 bits, and
shifting it nine positions to the left would lose the MSB. In this case, two divide operations are required as
follows: first divide the Tooth Period by the number of TICKS—the integer is stored in MACL and
remainder in MACH. MACL is saved in another register. MACH is shifted 9 positions to the left and
divided again by TICKS. In parallel with the second divide, the register which saved the original MACL
is shifted left 9 positions. After the divide MACL contains the 9 bits fraction and the other register contains
the 15-bit integer, shifted left nine times. The logical OR of the two registers is written to the TRR:
Angle_Tick_Rate {Integer[14:0]} = (TCR1ToothPeriod) / Ticks
Remainder[9:0] = TCR1ToothPeriod) mod Ticks
Angle_Tick_Rate {Fraction[8:0]} = (Remainder[9:0] << 9) / Ticks
TRR = Angle_Tick_Rate {Integer[14:0], Fraction[8:0]} = (Integer[14:0] << 9) | Fraction[8:0]
1. In High-rate mode, the tick keeps being updated at the rate of system clock/8 until it goes back to Normal mode, when the new
TRR value is used.
2. The tooth period (TCR1ToothPeriod) is not, in general, the value of estimated tooth time. It is obtained by microcode by
subtracting TCR1 values between two teeth detections. Its comparison with the estimated tooth time indicates acceleration (if
minor) or deceleration (if greater) to the microcode.
Summary of Contents for MPC5644A
Page 2: ...MPC5644A Microcontroller Reference Manual Rev 6 2 Freescale Semiconductor...
Page 24: ...MPC5644A Microcontroller Reference Manual Rev 6 24 Freescale Semiconductor...
Page 26: ...MPC5644A Microcontroller Reference Manual Rev 6 26 Freescale Semiconductor...
Page 52: ...Introduction MPC5644A Microcontroller Reference Manual Rev 6 52 Freescale Semiconductor...
Page 56: ...Memory Map MPC5644A Microcontroller Reference Manual Rev 6 56 Freescale Semiconductor...
Page 1228: ...Decimation Filter MPC5644A Microcontroller Reference Manual Rev 6 1228 Freescale Semiconductor...
Page 1440: ...FlexCAN Module MPC5644A Microcontroller Reference Manual Rev 6 1440 Freescale Semiconductor...