AN2897 Freescale Semiconductor / Motorola, AN2897 Datasheet - Page 28

no-image

AN2897

Manufacturer Part Number
AN2897
Description
Using the eTPU Angle Clock
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Angle Clock Application
5.2
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.
In an equals-only setup, when a function sets up a channel for action at a future angle, that angle can be
any value in the range of the Angle Clock and the match will occur in the next occurrence of that angle.
This is true even if the angle is 719 degrees in the future. The corollary of this is that if a system update
results in a decision that an action that was scheduled should occur in the past, the match will wait until
the next revolution.
The discrimination between reprogramming to the past rather than the future is left to the eTPU software.
The designer must insure that, for example, if a spark is about to occur and the spark fire angle is updated
to occur at an earlier angle, the match is forced immediately. If the earlier angle is simply written to the
match register, the spark will be missed until the next cycle.
There is one additional situation to consider when using equals-only matches with the angle clock. If the
tick rate is slow, it is possible to get a service request on an angle match and execute part of a thread before
the angle changes. If a function is trying to set up a future match exactly 360 (or 720) degrees after the
current one, care must be taken that the register is not written with the current value of TCR2.
Please refer to the Reference Design for examples of how to use a periodic Angle Clock.
5.3
If the Angle Clock is used in the continuous angle mode, angles parameters can be added, subtracted, and
compared like any other 24-bit integer. However, when the user selects a periodic reset of the Angle Clock,
modulus arithmetic must be used. If the Angle Clock is reset every cam revolution (= two crank
revolutions), the modulus is 720 degrees expressed in terms of the tick resolution. For example if a
60-tooth wheel is used with 60 ticks per tooth, there would be 7200 ticks per cam cycle (Ticks_Per_Cycle).
Adding two angles in such an application would be done thusly:
This operation is mathematically correct, but it might not generate the most efficient code. This is because
the modulus is normally generated as a divide instruction. A more efficient coding would be to add the
numbers, and if the sum is greater than Ticks_Per_Cycle, subtract Ticks_Per_Cycle. Macros or
subroutines for handling this math can be found in the Reference Design.
28
Periodic Angle Clock
Angle Math
New_Angle = (First_Angle + Second_Angle) % Ticks_Per_Cycle;
In the eTPU Angle Clock, no counts will be skipped. Any in-range
equals-only match will always be satisfied on the next occurrence of the
angle.
Using the eTPU Angle Clock, Rev. 0
NOTE
Freescale Semiconductor

Related parts for AN2897