System design
AN2577
3.4.2
Note:
Note:
Error recovery
The tick counter in the eTPU angle clock ensures that there are exactly TICKS counts
between physical teeth. If the angle clock acquires an error less than one tooth count, the
only possible reason is a software error. Nevertheless, if even if the count acquires a small
error, the count will rectify when the LAST tooth is processed.
The most common cause of a small TCR2 angle error is writing the initial angle to the angle
clock when synchronization occurs. When gap synchronization is first verified, if the tick rate
timer expires just as the TCR2 value is incremented by the tick counter, the tick counts for
subsequent teeth count may fall short by one tick until the last tooth re-synchronizes the tick
counter.
All other sources of error for the angle clock involve detecting an extra tooth or missing one
which should have been detected. The angle clock hardware cannot automatically correct a
tooth detection error. If a lost or extra tooth error is possible, the application software must
provide some means to detect the error. The most obvious method is to continually monitor
the position of the gap by repeating the gap detection and verification algorithm. If the gap is
detected at the wrong tooth position, or not detected at the expected one, the angle count
can be corrected. The decision to correct an apparent error can be made in the CPU or the
eTPU software, although prudence dictates that the decision is left to the more powerful
host processor.
The eTPU angle clock provides two features to correct a TCR2 counter that has become
untracked by one tooth. Each of these corrections can be repeated to make a multiple tooth
correction.
Inserting a tooth
If the angle clock hardware has missed counting a tooth, the software can assert IPH in the
TPR to add a single tooth. The effect of this assertion is to force the eTPU to recognize a
physical tooth immediately. If the tick counter is in Halt mode, the angle clock counts the
inserted tooth, then begins a new sequence of tick counts exactly as if a tooth had been
detected by the channel. If the tick counter is in Normal mode, it immediately goes into High
Rate mode until the tick count is complete, then the inserted count is counted as a physical
tooth, and finally the angle clock returns to Normal mode. Note that if IPH is asserted when
the angle clock is in High Rate mode, it will be ignored.
The effect of inserting a tooth is that the angle clock will advance the angle count by one
tooth without missing any ticks. If a match is scheduled for an angle between the asserting
of IPH and the time the count is rectified, it will occur.
Asserting IPH (except when asserted during High Rate mode) will always add exactly one
tooth to the TCR2 angle count. The correction will be made using the High Rate mode, and
no count will be skipped.
Deleting a tooth
If the angle clock hardware has mistakenly counted an extra tooth, the software can assert
HOLD in the TPR to stop the count for exactly one tooth count. The effect of this assertion is
to stop the tick count immediately until the next tooth is detected. When that tooth is
detected, the tick counter continues where it left off, meaning that the tick count will count a
portion of TICKS before the assertion of HOLD, and the balance after the next tooth.
Do not use IPH to cancel a HOLD in progress. To correct the correction, simply negate
HOLD.
20/34