AN2577
eTPU software design
Note:
4.2.9
Note:
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.
Example
detected
if (IsTransALatched()) //If the Tooth edge is
{
EdgeCaptureTime = GetCapRegA();//Capture the edge
transition time
TempToothPeriod = EdgeCaptureTime-ToothTime;
ToothTime = EdgeCaptureTime;
TempTicks = ((TempToothPeriod*8)/TicksPerTooth)*64;//
implements a left shift by 9 bits and a div by 60
TickRate = TempTicks;
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.
The angle clock tick counter begins timing out when the tooth edge occurs. The calculation
of a new value for the Tick Rate Register will take some time to complete. While this is being
done the old value is used for the tick rate. At steady state this makes no difference, but
when the wheel is accelerating, the first tick is necessarily late. If the acceleration continues,
all of the tick counts will be late and the angle clock will have to go into High Rate mode to
catch up.
It is possible to compensate for the accelerating wheel by adjusting the tick rate so that the
next tooth is counted a bit faster than a simple extrapolation. This adjustment can be added
to the software design at the engineer’s discretion.
This state is repeated for each new tooth detection until one of the following occurs:
1. The tooth count indicates that the gap is following next.
2. The tooth count indicates that the next tooth is the zero angle reference point.
3. The host requests service, for example to correct an error.
4. The following tooth is not detected within a specified time (stall).
Gapping
When the tooth count indicates that a new gap is expected, the system must verify that
measured gap times pass the designated test. If the gap is correctly placed, no host action
is required. If the gap period is outside the range of acceptability, the information should be
passed up to the host by setting the status to Error. The application can then analyze the
error and execute a correction procedure.
Once synchronized, the angle clock system can proceed indefinitely without further host
action, unless a signal anomaly occurs.
29/34