AN2897 Freescale Semiconductor / Motorola, AN2897 Datasheet - Page 25

no-image

AN2897

Manufacturer Part Number
AN2897
Description
Using the eTPU Angle Clock
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
4.2.7
Once the gap is verified, the system can go to Half_Sync or even Full_Sync mode. The tooth position is
now known, and subsequent gaps can be anticipated. An angle can be written to the TCR2, although if the
mode is Half_Sync, the angle could be off by 360 degrees.
4.2.8
Once wheel sync has been achieved, the Angle Clock system executes repeated cycles of tooth detection
and period timing, driving the TCR2 in wheel synchronization. The rate of the ticks following a tooth are
extrapolated from the previous period by the software when it programs the Tick Rate register.
The Tick Rate register is organized as a 15-bit whole number and a 9-bit fraction and is programmed in
terms of TCR1 counts. The eTPU can automatically capture the TCR1 time of each tooth edge, so the
period is trivial to determine. The new edge time is then stored for the next period calculation. To
determine the tick period, the software need only divide the measured tooth period by the number of tick
counts per tooth. This division can present some problems for the designer depending on the selected
resolution of TCR1 and the speed range of the wheel. See
the TCR1 is properly selected, the software engineer needs to ensure that the intermediate result of the
fixed point calculation does not overrun a register or truncate needed resolution of the tick rate.
At low wheel speeds, the period is long and a left shift can be done after dividing by the ticks per tooth. If
the shift is done before the division, the value may overflow. However, at high speeds, the period is short
and dividing by the ticks per tooth could result in gross errors before the shift is done. The algorithm in the
example below is designed to implement the 9-bit shift in two steps to minimize loss of resolution.
Freescale Semiconductor
/* More */
break;
if (IsTransALatched())
{
ToothTime = EdgeCaptureTime;
TempTicks
left shift by 9 bits and a div by 60
TickRate = TempTicks;
Gap Verified
Counting
Last_State = PossibleGapVerifying;
The value in the Tick Rate Register must never be programmed to less than
1.0. If the integer value is set to 0, it will be interpreted as 32768.
EdgeCaptureTime = GetCapRegA();//Capture the edge transition time
TempToothPeriod = EdgeCaptureTime-ToothTime;
=
((TempToothPeriod*8)/TicksPerTooth)*64;//
Using the eTPU Angle Clock, Rev. 0
//If the Tooth edge is detected
EXAMPLE
NOTE
Section 3.1.3, “Angle
Resolution.” Even when
eTPU Software Design
implements
25
a

Related parts for AN2897