
eTPU Software Design
Using the eTPU Angle Clock, Rev. 0
Freescale Semiconductor
21
4.2.1
Initialize Crank
The first state is entered by a host service request. The eTPU parameters are initialized and hardware is
setup for the specific application.
EXAMPLE
if (hsrInitAngleClock) // Sets Entry Vector for the eTPU
{
/* Initialize Parameters */
State1:
// Set the channel mode to detection one input transition and two match
events
SetChannelMode(m2_st);
/* ... */
// Setup action unit A to capture high to low transition
SetupCaptureTrans_A(Capture_tcr1, high_low);
/* Match2SingleTransition mode requires a MatchA before the transition can be detected. Force
the first match in a couple of microseconds. */
// Setup match to block out transition too close to current time
SetupMatch_A((tcr1+20), Mtcr1_Ctcr1_ge, match_no_change);
}
4.2.2
First Edge
The eTPU will wait until a transition is detected on the input pin. The channel service request vector for
TransitionA is shared with Match B. Also, the channel cannot distinguish between the initial startup tooth
transitions and subsequent ones. Therefore the software must sort out the service requests from the channel
when they are received.
EXAMPLE
NewRev
if AngleClock = 0 then ToothCount = 0
If ActiveEdge
ToothTime
= Time(ActiveEdge)
If AdjustAngle() //return
BlankTimer =
Period
*
BlankingRatio
If timeout (StallTimer)
AdjustAngle
EngineAngle
=
EngineAngle
+
AngleCorrection
Return to last state.
x
Do Not Change State Number
Table 1. Angle Clock System State (continued)
S
Reference
Name
Action
Exit Condition
G