AN2577
System design
3.1.2
3.1.3
Free running angle clock
To avoid the step-over problem mentioned above, a designer might choose to use the
greater-or-equal comparator in the eTPU channel with a free running angle clock. In this
case, the trigger angle for any function must be offset by the angle at a reference point on
the wheel. For example, the software driver could maintain the top dead center (TDC) value
for the current cylinder. If the spark is set to 12 degrees before TDC, the driver need only
subtract the 12 degrees from the TDC angle to get an absolute firing point. Regardless
when the software is updated, the greater-or-equal compare will ensure that a event is not
missed. Then at some point in the cycle, for each driver the TDC angle must be updated for
the next cycle.
The disadvantage of using a free running angle clock is that a host read of TCR2 will not
directly yield the absolute position of the engine. The value will have to be reduced by a
reference angle, modulus 360/720 degrees, and the reference angle will have to be updated
every revolution.
Either the periodic or the free running angle clock can be applied successfully to an engine
control system.
Angle resolution
The eTPU angle clock can resolve the angle between the teeth into as many as 1024 ticks.
However the proper selection of the TICKS value in the TPR must take into account other
considerations. To understand the limits for TICKS in a given system, the engineer must
consider the configuration of the toothed wheel, the maximum and minimum speed that
must be processed, and the selected resolution of the TCR1 counter.
The TCR1 counter resolution is usually a compromise between the finest resolution required
by the eTPU channel drivers and the maximum pulse width that must be measured or
driven. In fact, arbitrarily long pulses can be processed regardless of the TCR1 resolution by
using software intervention, so the maximum time is seldom a great consideration. The
minimum TCR1 resolution is two times the period of the MCU system clock. However, many
systems engineers choose a convenient value derived from the clock. A typical TCR1
resolution might be 100 nanoseconds. The would enable the eTPU to time out pulses up to
about 0.8 seconds with a single write to a match register. (Using the greater-than-or-equal
comparison, the future equals half the range of the counter. Values larger than 0x800000
above the TCR value are considered in the past, and will match immediately using the
greater-than-or-equal comparison.)
Now consider the TRR. It is organized as a 1-bit integer and a 9-bit fraction.This means that
the largest value for a single tick would be 0X7FFF.1FF (32767.998) times the period of the
TCR. Since a zero value in the integer field is processed as 32768, the minimum TRR value
is actually 1. There are reasons to avoid both of these extremes, so the user should build in
a little margin when setting the limits.
The maximum number of ticks per tooth should ensure that there is more than one TCR1
time per tick at the maximum speed for the wheel. The minimum number of ticks per tooth
should ensure that the maximum value of TRR is not exceeded at the minimum wheel
speed.
13/34