Teeth Register
TCNT
=
+1
Gap Flag
PCNT (n)
+1
PCNT (n-1)
P(n) >
2 x P ( n-1 )
Criteria
£
SCNT
+/-
Step Register
ACNT
+
Angle Tick
Tick CNT
-1
“1”
Tickcount<>0
& teeth’event
Toothed wheel
Input
Teeth’event
ACNT Inc.
Angle Functions
832
SPNU503C – March 2018
Copyright © 2018, Texas Instruments Incorporated
High-End Timer (N2HET) Module
20.3.2.2.1.2 Angle Tick Generation Implementation
The time-interpolation algorithm, which generates ticks based on the toothed wheel tooth period, consists
of the following five main counters linked together:
•
Tooth counter (TCNT): Current tooth
•
Period counter (PCNT): Period between two teeth
•
Step counter (SCNT): Angle step
•
Tick counter (TCKC): Angle ticks
•
Angle counter (ACNT): Angle value
The algorithm also includes differences comparison, adder, and working registers as shown in
Figure 20-38. New Angle Tick Generation Architecture
The TCNT is an 8-bit counter. It counts teeth until it reaches the teeth register value then generates a gap
flag signal. The gap flag signal which changes the behavior of the HWAG during the singularity and resets
the TCNT on the next active edge of the toothed wheel input.
The PCNT calculates the period P(n) between two teeth (two active edges on the toothed wheel input).
The active edge (falling or rising) is selected by setting the TED bit in the HWAG global control register 2
(HWAGCR2). On an active edge from the toothed wheel input, the PCNT is saved in the HWAG previous
tooth period value register (HWAPCNT1).
The SCNT counts by K steps up to the previous period value, which is contained in the HWAPCNT1
register. When the SCNT overflows PCNT(n-1), an angle tick is generated and SCNT is reset to the
remainder between the SCNT and PCNT(n-1). The resulting period of the SCNT is the fraction PCNT(n-
1)/K.
The TCKC counts every angle tick until it reaches K and then stops the SCNT. If an active edge occurs
before the TCKC has reached K, the remainder is added directly to the ACNT.
When encountering an earlier active edge, the ACNT accumulates the fractions (angle ticks) generated by
the SCNT and the remainder of the TCKC. For an example of angle generation using the time-based
algorithm, see
.