AN2577
System design
3.3
3.3.1
Note:
3.3.2
Startup system design
Starting the angle clock requires three essential steps. First, the initial values must be
written to the function parameters and control registers. Second, the tooth signal is
acquired, the periods are tracked, and the tooth pattern is tested for a reference point,
usually the first gap. Third, when the angle is determined, the actual angle is written to the
TCR2, synchronizing it to the wheel and the rest of the angle based control system can be
started.
Initial parameter values
The angle clock hardware must be setup in the eTPU by writing certain control registers by
the host. This includes writing the AM bit in the ETPUTBCR and configuring the TCRCLK
input for the selected eTPU. If the angle clock is to be used as a server for another eTPU or
for the eMIOS, the shared timing and control (STAC) bus must be set up. The essential
software steps will be detailed below.
The Channel 0 parameters must be written to initial values by the host at startup. Most
important are the angle clock hardware register values (which are subsequently written by
the eTPU software to the registers) and the initial position of the angle clock.
While the software is searching for the reference point, the angle clock may be held to a
particular value, or it may be counting from some arbitrary point. The system designer
should take care that other drivers in his system do not trigger on arbitrary value of TCR2
before the angle clock in synchronized.
There are several ways to avoid spurious matches and pin action during startup:
● The eTPU may be kept out of Angle Mode until the channel hardware has searched
and found the reference point. TCR2 can be disabled by writing 0b111 to the TCR2CTL
field of the ETPUTBCR.
Do not set TCR2CTL to 0b111 unless the angle mode is disabled by setting AM to 0.
● The angle clock can be allowed to run during startup, but other drivers dependent on
the angle clock must be kept disabled until synchronization. While this strategy is used
in the Reference Design, it is not the preferred strategy.
● TCR2 can be maintained at a large negative and/or out of range value during
acquisition and synchronization.
The main advantage of letting the angle clock run during startup and synchronization is to
reduce the number of special cases handled in the software.
Acquisition and synchronization
The first detected tooth edge indicates that the wheel is moving. The only information that
can be gathered is the TCR1 time of the edge.
The second tooth provides a new edge time and the first tooth period. Note that in most
systems the period value alone cannot distinguish between a normal tooth separation or the
multiple tooth width of the gap. However, with the first period recorded, the system can now
start to search for the first gap.
Once the third tooth edge is detected, a second tooth period is known and the search for the
gap can begin. There are various ways to identify the gap using the time between
consecutive pairs of teeth. The larger the gap, that is the more teeth are missing, the easier
it is to discriminate between normal teeth and the tooth gap. However, variations in period
17/34