AN2897 Freescale Semiconductor / Motorola, AN2897 Datasheet

no-image

AN2897

Manufacturer Part Number
AN2897
Description
Using the eTPU Angle Clock
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Freescale Semiconductor
Application Note
Using the eTPU Angle Clock
by: Mike Pauwels
This document describes the Angle Clock feature of the
Enhanced Time Processor Unit and offers practical
advise on the application and use of this feature. The note
assumes a familiarity with the eTPU and the eTPU_C
language used in the Byte Craft compiler. Code
examples presented below are taken from a Reference
design which is available from your Freescale
representative.
1
The Enhanced Time Processor Unit (eTPU) is an
autonomous slave processor offered on various families
of Freescale microcontrollers. The processor is tightly
coupled to up to 32 channels, each associated with an
input and an output signal. The input/output channels
each have a pair of Match and Capture units interfaced to
one of two timer/counter (TCR) registers. Logic in the
channel enabled the hardware to detect or drive pin
transitions with a high degree of timing precision.
In a typical application, at least one of the TCRs is driven
by a real time clock derived from the MCU clock
frequency. The second TCR can be driven by an
© Freescale Semiconductor, Inc., 2004. All rights reserved.
TECD Systems Applications Engineering
Overview
1
2
2.1
2.2
2.3
2.4
2.5 Error Recovery ....................................................7
3
3.1
3.2
3.3
3.4
3.5
4
4.1
4.2
5
5.1
5.2
5.3
6
Overview .............................................................1
System Design ....................................................8
Summary ...........................................................29
Tooth Wheel Input..............................................5
Steady State System Design.............................9
Free Running Angle Counter ...........................27
eTPU Angle Clock Hardware.............................3
Tick Counter ......................................................5
Missing Teeth.....................................................6
Zero Count Synchronization ..............................7
Acceleration and Deceleration.........................11
Startup System Design....................................13
Anomalies........................................................15
Tooth Circuit Failure.........................................18
eTPU Software Design ....................................18
Host Setup.......................................................18
State Machine Description...............................19
Angle Clock Application ...................................27
Periodic Angle Clock........................................28
Angle Math ......................................................28
Table of Contents
Rev. 0, 11/2004
AN2897

Related parts for AN2897

AN2897 Summary of contents

Page 1

... System Design ....................................................8 3.1 Steady State System Design.............................9 3.2 Acceleration and Deceleration.........................11 3.3 Startup System Design....................................13 3.4 Anomalies........................................................15 3.5 Tooth Circuit Failure.........................................18 4 eTPU Software Design ....................................18 4.1 Host Setup.......................................................18 4.2 State Machine Description...............................19 5 Angle Clock Application ...................................27 5.1 Free Running Angle Counter ...........................27 5.2 Periodic Angle Clock........................................28 5.3 Angle Math ......................................................28 6 Summary ...........................................................29 AN2897 ...

Page 2

Overview asynchronous external signal real time clock with a different time base special Angle Clock circuitry on the eTPU. The purpose of the Angle Clock is to synchronize with the angle of a spinning shaft and ...

Page 3

Angle Clock Hardware The eTPU Angle Clock provides a counter that can be synchronized to a periodic input signal such as would be produced by a sensor detecting teeth on a wheel attached to a rotating shaft. A ...

Page 4

Angle Clock Hardware Programmable Window from Channel 0 in Angle Mode TCRCLK PIN Angle Tick Generator Din Hold Tick Prescaler Angle Tick 10 Ticks Tooth Program Register 10 2 Dummy Tooth Count Last Tooth Angle Counter Logic . 4 ...

Page 5

Tooth Wheel Input When an eTPU is placed into Angle Clock mode by programming the AM bit in the register ETPUTBCR, the input to Channel 0 of the device is connected internally to the external clock input TCRCLK. This ...

Page 6

Angle Clock Hardware 2.3 Missing Teeth Typically a toothed wheel used in automotive applications has a series of equally spaced teeth with one or more teeth removed to provide a reference point. The Angle Clock hardware has circuitry to ...

Page 7

If the Angle Clock completes the count of the missing teeth plus all of the inserted ticks, and a new tooth is not detected, the Angle Clock goes into Halt mode as described above. 2.4 Zero Count Synchronization For continuous ...

Page 8

System Design Inserting a tooth by asserting IPH will increase the TCR2 count by exactly one tooth angle by counting forward to the new angle. No counts are skipped. If the application determines that the Angle Clock is ahead of ...

Page 9

Steady State System Design There are two basic angle counting modes that can be supported by the eTPU. In the periodic mode, the TCR2 can be programmed to maintain a real time representation of the absolute angle of the ...

Page 10

System Design 3.1.3 Angle Resolution The eTPU Angle Clock can resolve the angle between the teeth into as many as 1024 ticks. However the proper selection of the TICKS value in the TPR must take into account other considerations. To ...

Page 11

Selecting an absolute reference for the 720 degree cycle must be done using an external reference such as a cam shaft sensor. The Angle Clock will automatically reset to zero if a physical tooth edge is detected with the LAST ...

Page 12

System Design Typically, the detection of the tooth edge causes the Channel 0 logic to request service from the eTPU engine. This service request is granted by a scheduler in a manner determined by the following the eTPU ...

Page 13

As can be seen from the example, the Angle Clock can track a typical automotive toothed wheel quite well under normal operating conditions. Also, the faster the speed, the less the effect of a given acceleration rate. 3.2.2 Deceleration When ...

Page 14

System Design 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 ...

Page 15

Subtracting adjacent tooth times yields the following periods: Period[1] = 0x196E6 Period[2] = 0x2F0C3 Period[3] = 0x16612 We can use a “Gap Ratio” algorithm to test if this represents a gap detection. Use Gap_Ratio = 0.7 Is_Gap = if ((Period[2] ...

Page 16

System Design tooth edge signal, the Angle Clock design can only help detect the problem, and pass the information on to the host for corrective action. 3.4.1 Error Prevention The eTPU Angle Clock provides means to reject tooth edges detected ...

Page 17

All other sources of error for the Angle Clock involve detecting an extra tooth or missing one which should have been detected. The angle clock hardware cannot automatically correct a tooth detection error lost or extra tooth error ...

Page 18

Software Design 3.5 Tooth Circuit Failure If the tooth circuit fails and the failure is detected by the host, the software may implement a limp home strategy. The eTPU Angle Clock provides a method to disconnect the Angle Clock ...

Page 19

State Machine Description Table 1shows a simplified state table for an Angle Clock system, similar to the implementation in the Reference Design. The states are referenced in the following description of an angle clock system implementation. Reference Name InitializeCrank ...

Page 20

Software Design Table 1. Angle Clock System State (continued) Reference Name PossibleGapVerifying StallTimer = StallPeriod at startpoint Time(activeEdge) PeriodLast = Period Period = Time(ActiveEdge) - ToothTime ToothTime = Time(ActiveEdge) ToothCount += 1 TickRate = Period/TicksPerTooth BlankTimer = Period * ...

Page 21

Table 1. Angle Clock System State (continued) Reference Name NewRev if AngleClock = 0 then ToothCount = 0 ToothTime = Time(ActiveEdge) BlankTimer = Period * BlankingRatio AdjustAngle EngineAngle = EngineAngle + AngleCorrection Do Not Change State Number 4.2.1 Initialize Crank ...

Page 22

Software Design else if (matchB_transA) //Here on MatchB (stall) or TransitionA (Tooth edge (IsTransALatched()) { /* Do some common tasks... */ switch(Last_State) { case InitializeCrank: // State 2 CrankStatus = Waiting_Gap; SetChannelInterrupt();//Inform the host that the crank ...

Page 23

First Period When the second edge is detected, the function can make the first measurement of the tooth period. The period should be stored as a global variable the best measure of the wheel speed and ...

Page 24

Software Design { Last_State = Apparent_Gap; } else { Last_State = Testing_Possible_Gap the test fails, we continue testing... */ } break; 4.2.5 Apparent Gap When the gap test is satisfied it may be necessary to confirm the ...

Page 25

Last_State = PossibleGapVerifying; /* More */ break; 4.2.7 Gap Verified Once the gap is verified, the system can go to Half_Sync or even Full_Sync mode. The tooth position is now known, and subsequent gaps can be anticipated. An angle can ...

Page 26

Software Design The Angle Clock tick counter begins timing out when the tooth edge occurs. The calculation of a new value for the Tick Rate Register will take some time to complete. While this is being done the old ...

Page 27

Full_Sync mode. If the correction is made in error, the system software will indicate this at the next gap. 4.2.12 Stall Provision should be made to detect the cessation of the tooth signals. Typically the system resets ...

Page 28

Angle Clock Application 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. ...

Page 29

Summary The eTPU is particularly suited to applications where input and output actions are synchronized to the position of a rotating wheel. The eTPU Angle Clock provides hardware which, when combined with the proper software, can track the wheel ...

Page 30

THIS PAGE INTENTIONALLY LEFT BLANK 30 Using the eTPU Angle Clock, Rev. 0 Freescale Semiconductor ...

Page 31

THIS PAGE INTENTIONALLY LEFT BLANK Freescale Semiconductor Using the eTPU Angle Clock, Rev ...

Page 32

... Freescale Semiconductor was negligent regarding the design or manufacture of the part. Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners.© Freescale Semiconductor, Inc. 2004. All rights reserved. AN2897 Rev. 0 11/2004 ...

Related keywords