AN2577
5
Angle clock application
Angle clock application
The angle clock was implemented in the reference design with little more software than is
listed in this section. Several variations of the angle clock software have been written for
various applications. ST provides the reference design with a complete working angle clock
and several drivers. See your ST representative.
As described above, the eTPU angle clock can implement a free running angle counter or a
periodic wheel angle indicator. Each alternative has advantages as well as problems, which
are discussed briefly below.
5.1
Free running angle counter
If the LAST bit is not set periodically by the angle clock software, the wheel angle will
accumulate 16777215 ticks then roll over to zero. If this is applied to a 60-2 tooth wheel with
60 ticks per tooth, each revolution of the engine will increment the count by 0xE10 (3600)
counts. Thus a specific point on the wheel which is represented by 0xABC in TCR2 will on
the next revolution be represented by 0x18CC, and on the next cycle by 0x26DC. In order to
find the absolute position on the wheel at any time, the software must subtract the angle at
some reference point from the indicated angle. While this seems tedious, the free running
angle counter offers one clear advantage: match comparisons for angles can be done using
the greater-or-equal compare. Any angle which previously occurred up to about 2300
revolutions in the past can be immediately matched with respect to the current angle.
However, if a free running angle counter is used, each system function using the angle
needs to use the reference point to schedule or capture a channel action. If spark is to be
scheduled for 12 degrees before top dead center (BTDC), the spark driver function needs to
know a reference point in order to program the correct TCR2 value into the match register.
In general the host software may change the spark angle at any time. If a change is made
which would require a spark to occur in the past, the greater-or-equal compare would trigger
a match immediately.
The free running counter design is much simpler if the number of teeth on the wheel and
number of ticks between the teeth were each powers of 2. For example, if a 64-2 tooth wheel
was used in a system with 128 ticks per tooth, the number of ticks per revolution would be
64 (0x40) times 128 (0x80) or 8192 (0x2000). In this case the counter would count exactly
2048 (0x800) revolutions and roll over. The TCR2 counter value would simply be a
concatenation of an 11-bit revolution number, a 6-bit tooth number, and a 7-bit tick number.
5.2
Periodic angle clock
The obvious advantage of the periodic angle clock is that there is a one-to-one
correspondence between the TCR2 value and the instantaneous angle of the wheel,
regardless of the tooth and ticks configuration. The angle can be read at any time both by
the host and by the eTPU functions. Periodic matches are always programmed with the
same value.
However, the greater-or-equal compare in the channel match registers will not function
properly with a periodic angle counter. For example, an angle of 719 degrees will always test
greater than 0 degrees.
31/34