
eTPU Software Design
Using the eTPU Angle Clock, Rev. 0
Freescale Semiconductor
23
4.2.3
First Period
When the second edge is detected, the function can make the first measurement of the tooth period. The
period should be stored as a global variable, as it is the best measure of the wheel speed and may be used
by other drivers. Before it is overwritten, the previous period should be stored off for use in detecting the
gap.
4.2.4
Testing for a Possible Gap
When the third edge is detected, enough information finally exists to test for the missing tooth gap. This
routine is now the default for subsequent teeth. This state is repeated until the gap test is satisfied after
which a confirming test needs to performed on the following period.
It is necessary from this point on to count the teeth that are detected. For example, if a 36-1 tooth wheel
produces more than 35 tooth periods without a gap detection, an exception might be raised with the host.
Typically the tooth count is rectified when the first gap is detected. After that, the software can anticipate
subsequent gap detections.
If the wheel is to be tracked over 720 degrees as is necessary for a four-cycle automotive engine, a separate
search needs to be conducted for the unique cam information indicating which of the two crankshaft cycles
are currently being tracked. Note that the cam information and the crank synchronization are both needed
to determine full synchronization.
In addition to tracking the tooth period and count, the angle clock software should provide status to the
host and other applications using the angle information. The status selections might include:
1.
Stall
indicates that the Angle Clock has not yet determined a valid period, or the time since the last
tooth transition exceeded a specified limit.
2.
Searching_Gap
is used to indicate that teeth have been detected at an acceptable rate, but the first
gap has not yet been detected and confirmed.
3.
Half_Sync
in a 720 degree system indicates that the gap has been verified, but the cam cycle
information has not been determined.
4.
Full_Sync
indicates that the TCR2 counter is synchronized with the wheel and the cam shaft.
5.
Error
indicates that the Angle Clock system has detected an incorrect state change.
Note that in a four-cycle engine, some limited operation is possible in
Half_Sync
mode.
EXAMPLE
case Testing_Possible_Gap:
{
ToothPeriodLast = ToothPeriod;
ToothPeriod= TempToothPeriod;
ToothTime = EdgeCaptureTime;
ToothCount = ToothCount + 1;
if (ToothPeriod > (ToothPeriodLast*GapRatio + ToothPeriodLast))