Engine Management Timing Functions With The Motorola TPU
Introduction
The three
basic TPU functions - PMMX, PSP12, and PSP3 - have been designed to provide the
angle-based engine management operations needed to control fuel injection
timing, ignition timing and knock window timing.
PMMX is an
input function which is specifically designed to correctly process the input
signals from the Bosch ‘60 teeth plus 2 missing teeth’ crankshaft timing wheel.
Key
features of PMMX:
• Missing
teeth gap is handled automatically, with no CPU intervention.
• A
number of different noise rejection algorithms eliminate the effect of spurious
signals on the input pin.
• Separate
counters provide angular references based on crankshaft and camshaft positions.
• User controlled Camshaft
synchronisation.
• Two
different forms of crankshaft speed measurement are simultaneously maintained.
These may be used to assist in the detection of engine misfires.
PSP12 is an
output function which can be configured to provide fuel injection timing pulses
or ignition timing pulses. Once initialised, the pulses will be scheduled
automatically in every crankshaft or camshaft cycle, as specified by timing
parameters supplied by the host CPU.
The CPU may
at any time initiate an additional fuel injection pulse without loss of the
normally scheduled pulse.
Key
features of PSP12:
• The
ignition pulses may be directly specified as a dwell time and spark advance
angle.
• The
fuel injection pulses may be specified as a fuelling time and a valve closure
time.
• Additional
fuel pulses may be asychronously initiated by the CPU.
• Cycle-based
scheduler allows CPU to update pulse angles completely asynchronously to
currently scheduled pulses.
• Automatically
compensates for changes in engine speed.
• Output
pulses may be scheduled normally to start or stop at any point within the
missing teeth gap.
• Output
pin may be forced permanently low or high.
PSP3 is an output function which can be
configured to generate knock window pulses, based on angular position alone.
Once initialised by the CPU, the pulses will be automatically scheduled at a
programmable rate related to the crankshaft or camshaft position.
Key features of the PSP3:
• Active
low or active high pulses may be selected.
• Automatically
compensates for changes in engine speed.
• Output
pulses may be scheduled normally to start or stop at any point within the
missing teeth gap.
• Crankshaft
timing pulses may be reconstructed with the elimination of missing teeth gap.
• Output
pin may be forced permanently low or high.
The PMMX Function
PMMX is used to measure engine speed
and maintain separate angular position counters referenced to the crankshaft
cycle (360°) and the engine cycle (720°). It is designed to work with a
particular toothed wheel arrangement consisting of 58 evenly spaced teeth, plus
a spacing which is equivalent to two missing teeth (refered to as the gap).
Figure 1 shows a linearised pattern of the toothed wheel.
Instantaneous engine speed is obtained
by measuring the period between two normal tooth transitions. Either the
positive or negative edge of the transition may be used. The gap period is not
measured as such. Instead, the gap is divided into 3 segments separated by two
simulated transitions which are generated automatically by the PMMX function.
The first 2 segments have the same period, each of which is the same as the
last period before the gap. The period of the third segment is the difference
remaining in the gap after the first two segments have been subtracted. The
period of the third segment is neither measured nor stored by the PMMX
function. Figure 2 shows the actual periods obtained in the gap.
In addition, the PMMX function may be
used to measure the total period accumulated over a user defined angle,
commencing at a user defined angle. The accumulated angle is buffered, to allow
the host CPU to read the latest accumulated value at any time. Figure 3 shows
an example timing diagram for this measurement.
There are 2 tooth counters,
representing angular position of the crankshaft and engine cycle to a
resolution of 6°. The 360° tooth counter counts from 0 to 59, and the 720°
tooth counter counts from 0 to 119. The counters are incremented only after the
PMMX function recognises a synchronising condition, and places itself in the
Synchronised State. The synchronising condition is determined by a tooth period
which is at least greater than the last period by a user defined amount. This
value is specified as a fractional ratio multiplier (RATIO) in the range 0 to
3.98.
In the pre-synchronised state, (i.e.
before the first gap is detected), the PMMX function may be programmed to
ignore a number of transitions which occur immediately after start up of the
function. This number is user programmable, and defines the Wait State. During
this time, the period is not measured and the tooth counters are not
incremented. If insufficient transitions occur during the Wait State, an error
message is placed in parameter RAM to indicate a stalled condition, and an
interrupt is generated to the host CPU.
Entering
the Synchronised State
Once the Wait State has passed, every
input transition causes the PMMX function to search for the synchronising gap
by scheduling a timeout match at a time given by the equation (PERIOD * RATIO).
When the match occurs, the PMMX function is set to the Synchronised State, and
both the 360° and 720° angle counters are reset to 0. In addition, a status
code is placed in parameter RAM to indicate that the PMMX is in its
Synchronised State, and an interrupt is generated to the host CPU.
In addition, a timeout match is
rescheduled to allow for the possibility that a stalled condition rather than a
gap has occurred. If this match occurs, then the Synchronised status code is
replaced with a Stall status code, and an interrupt is issued to the host CPU.
The PMMX function is maintained in the
Synchronised State.
Synchronised
State
While running in the Synchronised
State, every subsequent transition, up to and including the 58th transition,
causes the 360° and 720° counters to be incremented.
Starting at the second transition after
the gap, the tooth period is also updated on every transition, up to and
including the 58th transition.
In addition, a stall detection timeout
match is scheduled for a time of (PERIOD*RATIO).
Missing
Tooth Filler
When the 58th transition occurs, a
tooth filler match is scheduled for a time of PERIOD after the time of the
current transition. This effectively simulates the occurance of a tooth within
the gap, at a point which corresponds to the expected position if the toothed
wheel were rotating at a constant speed. When the match for the first simulated
tooth occurs, the 360° and 720° counters are incremented as normal, but the
period is unchanged. Following the first simulated tooth, a second simulated tooth
is scheduled in exactly the same manner. When the match for the second
simulated tooth occurs, the 360° counter is reset to 0. The 720° counter is
incremented.
If a transition is detected during the
tooth filling operation, an error code is returned in parameter RAM and an
interrupt is issued to the host CPU. No other action is taken by the PMMX
function until the next transition.
Under normal operating conditions, the
360° counter is reset on the second simulated tooth of every gap, while the 720°
counter is reset on the second simulated tooth of every second gap. Figure 4
shows how the counters increment across gaps.
Allowance
for Deceleration Across Gap
To optimise the performance of the PMMX
function, the period parameter is not updated in the gap. This may result in a
significant discrepancy between the period used by the PMMX function and the
actual period of the toothed wheel if there is a great change in engine speed.
To allow for this situation, the value used to schedule the stall detection timeouts
is automatically modified at 2 points:
» On
the second simulated tooth within the gap.
» On
the first transition after the gap.
At these 2 points, the stall detection
timeout is increased to (PERIOD*RATIO^4). See figure 4.
This compensates for a potential
increase in the period of the third segment within the gap and the first normal
tooth period after the gap, caused by engine deceleration.
Noise
Suppression
Two methods are implemented to reduce
the effects of noise on the operation of the PMMX function.
The first method ignores certain
transitions which occur at an interval which is less than an expected value,
given by the equation PERIOD/RATIO. i.e. If the latest period multiplied by
RATIO is less than the previous period, then the transition is regarded as
spurious, and is ignored. An error code is written to parameter RAM and an
interrupt is issued to inform the host CPU that a noise pulse was detected. To
allow for acceleration within the gap, the spurious transition test is not
performed on the first transition after the gap. Figure 5 shows the timing of
the spurious extra transition detector.
The second method detects the loss of
an expected tooth transition, and inserts a simulated transition at the
expected point. The simulated tooth is placed at a time after the last valid
transition which corresponds to a constant speed of rotation of the toothed
wheel. i.e.the measured period does not change. Figure 6 shows the timing of
the spurious missing transition detector.
Angle
Interrupter
Apart from those generated by the
Synchronising condition or error conditions, interrupts may be automatically
generated by the PMMX function, either at a single angular position (resolved
to 6°), or at every 6°. The choice is user defined. The user defined interrupt
feature can be disabled.
Accumulated
Periods
In addition to measuring and storing in
parameter RAM, the instantaneous engine speed every 6°, the PMMX function may
be used to measure and store the period taken by the toothed wheel to cover an
angle defined by the user, starting at an angle defined by the user. The
resolution of the accumulating and starting angle is 6° with a range of 0° to
720°. Once the accumulated period measurement starts, it continues indefinitely
or until the user specifies an invalid starting angle (e.g. 726°). The
accumulated result is buffered to allow the host CPU to read the latest value
asynchronously at any time.
Camshaft
Synchroniser
Since the initial synchronisation
causes the 720° counter to be reset to 0, it is possible that this value could
be 360° out of phase with the actual engine cycle. The PMMX function includes a
feature which allows the host CPU to asynchronously adjust the value of the 720°
counter to the correct engine cycle angle.
Error
Detection and Handling
When the PMMX detects an error, it
returns an 8 bit error code, and issues an interrupt to the host CPU.
Further transitions and matches are
processed as if the error had not occurred.
This may result in a new error code
overwriting the previous value. This places the onus of error processing on the
host CPU.
The PMMX function can generate the
following error codes:
Error
Type Error
Condition
Error_Code_Stall Insufficient transitions occurred
in Wait State.
Error_Code_Shortgap Unexpected transition occurred in gap.
Error_Code_Noise Unexpected transition occurred
outside gap.
Error_Code_Sync_Stall Tooth period exceeds expected maximum in
Synchronised State.
Error_Code_Match_Range Timeout match exceeds $8000.
When an error code is generated, the rescheduling
of timeout matches is inhibited in all cases except for Error_Code_Sync_Stall,
which is processed as if a transition had occurred. (See Noise Suppression,
above)
Activating
the Output Functions PSP12 and PSP3.
Once the Synchronised State is
attained, the PMMX function may generate service requests to the output
functions PSP12 and PSP3, so that they can properly schedule their output
pulses. This is achieved by using the LINK_START and LINK_COUNT parameters of
the PMMX function. The output functions which receive service requests are user
defined, and the service requests are only sent after the PMMX has completed
all its calculations and parameter updates. This ensures coherency of data
usage between the PMMX and PSP functions.
System
Requirements and Performance
The function must use TCR1 as its
free-running timebase. TCR2 is unused.
The PMMX function takes a maximum of
approximately 18 µS to execute, including the generation of service requests to
a maximum of 15 output functions.
The minimum crankshaft speed at which
the PMMX can run is limited by the clock rate of TCR1 and the minimum value of
RATIO.
With a 2 µS clock rate and a RATIO
value of 1.5, the minimum crankshaft speed is approximately 24 rpm. Note that,
under these conditions, the PMMX function will generate a range error on the
last simulated tooth within the gap and on the 1st tooth following the gap.
Apart from failing to schedule a stall detection match at those points, the
errors do not affect the operation of the PMMX function.
The maximum crankshaft speed which may
be processed without losing tooth transitions is a function of the number of
active TPU channels. In practice, the maximum speed is approximately 10000 rpm.
Due to the functional operation of the
additional fuel pulse in the PSP12 function, the PMMX is restricted to channel
numbers 0 to 7.
The PMMX function takes a maximum of
approximately 18 µS to execute with a 16.78MHz system clock. The actual time
taken depends on the state being executed. The following table gives the
execution times for various states at 16.78MHz:
Function State Execution Time
Initialisation 0.238µS
Synchronisation 5.7µS
Normal
Tooth 14.4µS
Last
Tooth Before Gap 11.5µS
1st
Missing Tooth in Gap 8.7µS
2nd
Missing Tooth in Gap 15.1µS
1st
Tooth After Gap 17.1µS
Cam
Synchronisation 0.7µS
Parameter Ram Definitions for PMMX function
CONFIG
This 9 bit value should be initialised
by the CPU prior to starting the function. It contains the channel latch
controls and configures the PSC, PAC and TBS fields. For correct operation of
this function, the channel must be configured as an input, with capture and
match on TCR1 only. The PAC field may be set up to detect either rising edge or
falling edge.
Table 1 shows the allowable values for
this parameter.
Table
1.
Config Action
$004 Detect Rising Edge,
Capture and Match TCR1.
$008 Detect Falling Edge,
Capture and Match TCR1.
LONG_PERIOD
This 16 bit value is updated by the TPU
only when the function is running in the synchronised state. The parameter
contains the latest complete accumulation of tooth periods defined by
NUMBER_OF_PERIODS, and START_PERIOD. The parameter is updated only after
NUMBER_OF_PERIODS has elapsed, starting from the transition defined by
START_PERIOD. The CPU may read the parameter at any time to obtain the latest
completed result. A value of $FFFF indicates that LONG_PERIOD has overflowed.
Note 1: Because of the algorithm used,
the first occurance of the transition defined by START_PERIOD will result in an
update to LONG_PERIOD.
Note 2: LONG_PERIOD shares the same
parameter RAM location as CONFIG.
WAIT_TEETH
This 8 bit value should be initialised
by the CPU prior to starting the function. The parameter contains the number of
teeth to ignore before searching for the first synchronising condition
immediately after the function is started. The TPU decrements the parameter by
1 on every transition during the pre-synchronised state, until it reaches a
value of 0. The function then starts searching for the synchronising condition.
There are no further decrements to WAIT_TEETH.
ACCU_LONG_PERIOD
This 16 bit value is updated by the TPU
only when the function is running in the synchronised state. It contains the
latest uncompleted accumulation of periods defined by NUMBER_OF _PERIODS and
START_PERIOD. When NUMBER_OF_PERIODS has elapsed, ACCU_LONG_PERIOD is copied to
LONG_PERIOD and then cleared to zero.
Note 1: Because of the algorithm used,
the parameter is updated on every transition between the first synchronising
condition and the first occurance of the transition defined by START_PERIOD, at
which point the parameter is copied to LONG_PERIOD and then cleared to zero.
Note 2: ACCU_LONG_PERIOD shares the
same parameter RAM location as WAIT_TEETH.
STATUS_NUMBER
This 8 bit value is valid in both the
pre-synchronised and synchronised states of the function. The parameter is
updated by the TPU, and should be cleared by the CPU after the CPU has read the
parameter.
It defines the status of the function
at the time of the last interrupt to the CPU. A value less than $80 provides
functional status information, while a value greater than $80 indicates an
error condition.
Table 2 and 3 show valid functional and
error status values.
Table
2 - Functional Status
Status_Number Condition
$00 Tooth Interrupt
Occurred.
$01 First Synchronising
Condition Detected.
Table
3 - Error Status
Status_Number Condition
$81 Insufficient
transitions occurred in Wait State.
$82 Unexpected transition
occurred in gap.
$83 Unexpected transition
occurred outside gap.
$84 Tooth period exceeds
expected maximum in Synchronised State.
$85 Timeout match exceeds
$8000.
Note 1: Under certain severe
application dependant conditions, the TPU may issue interrupts faster than the
CPU can handle them. In this case only the latest Status or Error code will be
available to the CPU.
Note 2: Error conditions do not cause
loss of the synchronised state.
INT_TOOTH
This 8 bit value may be updated by the
CPU at any time. It defines the tooth number(s) at which an interrupt is
generated to the CPU when the function is operating in either the
pre-synchronised or synchronised state. The parameter is compared against
COUNT_720. An interrupt is generated when the two parameters match. To generate
an interrupt on every tooth including the tooth filler positions, the most
significant bit of INT_TOOTH must be set to ‘1’ (i.e. a value in the range $80
to $FF). To inhibit tooth interrupts, INT_TOOTH must be greater than the
maximum value attainable by COUNT_720, and less than $80.
START_PERIOD
This 8 bit value may be updated by the
CPU at any time, but it is used only in the synchronised state. It defines the
number of the transition at which ACCU_LONG_PERIOD is initialised and starts
accumulating periods. The transition number is obtained from COUNT_720. Refer
to LONG_PERIOD and ACCU_LONG_PERIOD sections for more information.
Note: When LONG_PERIOD is updated, the
TPU increments START_PERIOD by the value stored in NUMBER_OF_PERIODS.
NUMBER_OF_PERIODS
This 8 bit value may be updated by the
CPU at any time, but it is used only in the synchronised state. It defines the
number of periods which are accumulated in ACCU_LONG_PERIOD before the result
is copied to LONG_PERIOD. Refer to LONG_PERIOD and ACCU_LONG_PERIOD for more
information.
RATIO
This 8 bit value may be updated by the
CPU at any time and is used in both the pre-synchronised and synchronised
states of the function. In the pre-synchronised state, it is used to search for
the first synchronising condition. In the synchronised state, it is normally
used to detect tooth periods which are less than the previous PERIOD/RATIO or
are greater than the previous PERIOD*RATIO.
RATIO is scaled to the fractional range
0 to 4-(1/64), i.e. 0 to 3.98.
The value of RATIO may be calculated
using the following formula:
RATIO
= Fraction Ratio * 64
Where Fractional Ratio is the required
value in the range 0 to 3.98.
Refer to the earlier sections “Allowance
for Deceleration Across Gap” and “Noise Suppression” for more information on
the functional operation of this parameter.
COUNT_360
This 8 bit value may be updated by the
CPU prior to enabling the function. In the pre-synchronised state the parameter
is not changed by the TPU. It is cleared to zero by the TPU on detection of the
first synchronising condition.
In the synchronised state, the TPU
increments this parameter by 1 on every tooth transition and on every missing
tooth filler, until the next synchronising condition for this parameter is
detected. The TPU then clears the parameter to zero. The range of this tooth
counter parameter is 0 to 59.
LINK_START:LINK_COUNT
These 4 bit values are usually updated
by the CPU prior to enabling the function, but they may be updated at any other
time. The values define which channels are linked to once the function has
completed processing the current tooth transition event. LINK_START defines the
first linked channel, and LINK_COUNT defines the total number of channels
linked. The link operation only occurs when the function is in the synchronised
state.
If LINK_START+LINK_COUNT exceeds the
maximum channel number, then the link will ‘wrap around’. i.e. If LINK_START=15
and LINK_COUNT=4, then the linked channel numbers are 15,0,1,2.
Note 1: A LINK_COUNT value of 0 is
invalid and will produce unpredictable operation of the TPU.
COUNT_720
This 8 bit value may be updated by the
CPU prior to enabling the function. In the pre-synchronised state the parameter
is not changed by the TPU. It is cleared to zero by the TPU on detection of the
first synchronising condition.
In the synchronised state, the TPU
increments this parameter by 1 on every tooth transition and on every missing
tooth filler, until the next synchronising condition for this parameter is
detected. The TPU then clears the parameter to zero. The range of this tooth
counter parameter is 0 to 119.
PERIOD
This 16 bit value is updated by the TPU
in both the pre-synchronised and synchronised states. It contains the time
between the last two transitions measured in TCR1 counts. The CPU may read this
parameter at any time.
Note: PERIOD is not updated during the
missing teeth gap, nor is it updated if the current period is less than the
previous PERIOD/RATIO.
LAST_TRANSITION
This 16 bit value is updated by the TPU
in both the pre-synchronised and synchronised states. It contains the time of
the latest transition measured in TCR1 counts. The CPU may read this parameter
at any time.
Host
Interface to PMMX function
Initialisation
1) The
CPU must write to the following parameter RAM locations while the PMMX function is disabled:
i) CONFIG.
This
parameter should be set to one of the values in Table 1.
ii) WAIT_TEETH.
This
parameter should be set to the number of transitions which should be ignored
before the search for the synchronising condition starts.
iii) STATUS_NUMBER,
INT_TOOTH.
STATUS_NUMBER
would normally be cleared to zero.
INT_TOOTH
should be set to generate no interrupt, interrupt on one tooth, or interrupt on
every tooth.
iv) START_PERIOD,
NUMBER_OF_PERIODS
START_PERIOD
should be set to the tooth number at which LONG_PERIOD measurements should
start.
NUMBER_OF_PERIODS
should be set to the number of periods over which LONG_PERIOD is accumulated.
v) RATIO,
COUNT_360.
RATIO
should be set to a value which guarantees discrimination between the
synchronising condition and normal periods under all speed changes.
COUNT_360
may be set to any arbitrary value.
vi) LINK_START:LINK_COUNT,
COUNT_720.
LINK_START
should be set to the first output channel which references the PMMX parameters,
and LINK_COUNT to the total number of output channels which reference the PMMX
parameters.
COUNT_720
may be set to any arbitrary value.
Note: If the PMMX function is disabled
by the host CPU while the function is already running, the host must wait at
least 20µS before modifying the parameter RAM.
2) The
CPU should issue the Host Service Request %11, and then enable the channel by
assigning it a high priority.
Camshaft
Synchroniser
1) The
CPU should issue the Host Service Request %01, while the PMMX is in the Synchronised
State.
Before
the next transition is serviced, the PMMX function executes the following
algorithm:
COUNT_720
:= (COUNT_720 + 60) MOD 120
If
the PMMX is currently servicing a transition when the HSR is made, then the HSR
is left pending until the PMMX finishes servicing the transition. This ensures
data coherency.
The PSP12 Function
This function is designed to produce a
logic high output pulse. Through the use of the Host Sequence bits, it may be
operated in one of two basic ways:
» Time-Angle
» Angle-Time
TIME-ANGLE OPERATION
The falling edge of the output pulse is
defined by an angular position referenced from one of the 2 tooth counters (
COUNT_360 and COUNT_720) maintained by the PMMX function. Since the tooth
counters resolve to only 6°, an interpolation algorithm is used to increase the
positional resolution of the edge to better than 0.1°. The falling edge is
defined by a 16 bit parameter consisting of an 8 bit tooth count, and an 8 bit
binary-weighted tooth fraction. The parameter is called End_Angle. The range of
the fraction is 0 to 0.996 of a tooth count.
The rising edge of the output pulse is
defined as a constant time prior to the falling edge. This time is specified as
a 16 bit value, and is called High_Time. The scheduling of the rising edge is
based on a predictive algorithm which is executed every 6°, as a result of a
service request from the PMMX function (See Figure 7). In this way, the angular
placement of the falling edge becomes essentially independent of the period of
the toothed wheel.
Through the use of the Host Sequence
bits, the user may configure the Time-Angle function of PSP12 to operate in one
of two different modes:
» Time
Priority.
» Angle
Priority.
Time
Priority
Provided the CPU does not change the
High_Time parameter, once the rising edge occurs in Time Priority mode, the
duration of the high pulse is held constant, irrespective of change in the
tooth period. This means that the falling edge may occur at a different angle
to the one specified in End_Angle if the tooth period changes while the output
is high (See Figure 8).
The High_Time parameter is unbuffered.
This means that if the host CPU changes its value, the TPU will use the new
value immediately at the next edge of the output pulse, or at the next tooth
transition, irrespective of whether the output is high or low.
Pulse
Angle Scheduling
The CPU specified End_Angle is buffered
by the TPU which stores it in the parameter End_Angle_Active. End_Angle_Active
is the working value used by the TPU to schedule the current pulse edges. Under
normal conditions the CPU would write the new desired angular position of the
next fuel pulse falling edge in the parameter End_Angle. At the next tooth
edge, the TPU performs a calculation to determine if the new End_Angle value
can be used. If so, the End_Angle parameter is copied by the TPU into the
parameter End_Angle_Active. If not, the TPU uses the existing End_Angle_Active
parameter. In this way, the CPU may asynchronously update the pulse angle
without inadvertant loss or addition of a pulse. Because of the cyclical nature
of the angular system, the maximum change in End_Angle is restricted to ±60
degrees per cycle.
Additional
Pulse
The High_Time and End_Angle parameters define the duration and angle of a
pulse which is scheduled by the TPU to occur once every crankshaft or engine
cycle. The TPU's pulse scheduling algorithm would normally prevent the
occurance of additional pulses within one crank or engine cycle. A special host
service request is available to allow controlled asynchronous pulses to occur
in addition to the one normally scheduled. The parameter Extra_Time defines the
duration of the additional pulse. As the CPU initiates this pulse immediately
via a host service request, no angular parameter is used.
Depending on the angular position of
the CPU request, the cyclically generated pulse might or might not be disturbed
by the additional pulse.
Figure 16 and 18 show a CPU requested
additional pulse without disturbance to the cyclical pulses. Figure 17 and 19
show the merging of the additional pulse with the cyclical pulse when the CPU
request is sufficiently close to or coincident with the cyclical pulse.
The effects of TPU latency might cause
an additional fuel pulse to move the position of the cyclical pulse. An example
of this is shown in Figure 17a.
Special
Cases for the Time Priority Mode
If the rising edge is predicted to be
in the past, the rising edge is forced immediately. This permits output pulses
to extend over a period exactly equal to or greater than one revolution of the
referenced angle counter without anomalous operation of the PSP12 Time Priority
Function. Under these circumstances, there will be a short low going pulse
whose width is determined by the TPU latency.
Angle
Priority
Every 6°, the Angle Priority mode
calculates the angular position of the falling edge, irrespective of whether
the output is low or high. This means that while the output pin is high, the
actual duration of the high pulse may change as a result of a change in tooth
period, to ensure the best case angular position of the falling edge (See
Figure 9).
In Angle Priority mode, both the
High_Time and End_Angle parameters are buffered by the TPU into working
parameter RAM locations, called High_Time_Active and End_Angle_Active. If both
High_Time and End_Angle parameters are to be changed, then the CPU should write
to these parameters using a 32 bit instruction to ensure coherency of the
changed data.
Pulse
Angle Scheduling
As in the Time Priority mode, Angle
Priority uses the same pulse scheduling algorithm to ensure no pulses are
inadvertantly added or lost because of CPU updates to the End_Angle parameter.
Figure 11 shows how a CPU requested
change is deferred to avoid spurious additional output pulses. Angular values
are referenced to the second missing tooth in the missing teeth gap. At this
point in the gap the crank counter is reset to zero, corresponding to 0°. In
this example, a CPU request for change in End_Angle from 51° to 99° (angle
retarding) does not affect the first pulse. If the 99° request were immediately
scheduled while the first pulse was active, then the original pulse width would
be extended erroneously by 48°. If the 99° request were scheduled immediately
after the falling edge of the first pulse, then it is possible that an
additional pulse would occur immediately. The algorithm implemented in TPU
microcode ensures that the 99° pulse occurs in the next crank or engine cycle,
as required, and shown in figure 11.
The microcoded scheduler also ensures
that a CPU requested advance in End_Angle does not cause truncation or loss of
an already scheduled pulse. Figure 12 shows a typical example of this
situation.
In the event that a CPU request to
advance the End_Angle is executed late in the crank or engine cycle, but before
the output pulse is active, then the actual falling edge might be displaced, as
shown in figure 13. In this case the actual advance in angle is less then
requested. This is caused by the fact that the rising edge of the pulse is
calculated to be in the past, which results in the rising edge occurring
immediately, but later than required.
Limitation
of Angle Priority Mode
The maximum High Time of the Time-Angle
function in Angle Priority Mode must not exceed a value which causes the next
rising edge to occur within 60° of the current falling edge. Figure 20 is a
graphical representation of the limit case. If High Time exceeds this limit,
then spurious pulses can occur.
Time
and Angle Priority mode - Common Features
The output pulse may be scheduled every
crankshaft cycle or every engine cycle by referencing the appropriate tooth
counter in the PMMX function.
The actual level of the output pin is
stored in a single bit of parameter RAM. The bit is updated on every transition
of the pulse.
Interrupts may be optionally generated
on the falling transition.
The output pin level may be forced
continuously low by the host CPU. To do this, the output pin must have a low
impedance to Vss. The CPU can then re-initialise the Time_Angle function with
the pin configured for input, and a High_Time of zero. The function will
continue to execute normally, but the output pin will remain low. The advantage
of this technique is that the function can still generated interrupts to the
CPU at the specified End_Angle value.
Limitations
of Time_Angle Function
Figure 14 shows a limitation in pulse
scheduling due to microcode implementation. If acceleration causes both the
rising and falling edges of a pulse to become scheduled in the next tooth
period to the expected one, the pulse is re-scheduled for the next cycle by the
microcoded pulse scheduler. This means that the expected pulse will not occur.
This problem only arises for short pulse widths and high acceleration. The
problem can be fixed by a microcode change.
ANGLE-TIME OPERATION
The Angle_Time function must be
operated with Time Priority Mode selected.
The rising edge of the output pulse is
defined by an angular position referenced from one of the 2 tooth counters
maintained by the PMMX function. The rising edge is defined by a 16 bit
parameter consisting of an 8 bit tooth count, and an 8 bit binary-weighted
tooth fraction. The parameter is called Start_Angle. The range of the fraction
is 0 to 0.996 of a tooth count.
The falling edge of the output pulse is
defined as a constant time after the rising edge. This time is specified as a
16 bit value, and is called High_Time. The scheduling of the rising edge is
based on a predictive algorithm which is executed every 6°, as a result of a
service request from the PMMX function (See Figure 7a). In this way, the
angular placement of the rising edge becomes essentially independent of the
period of the toothed wheel. Once the rising edge occurs, the duration of the
high pulse is defined solely by High_Time, and is independant of any change in
the tooth period. The High_Time value may be changed by the CPU at any time.
Limitations
of the Angle-Time Function
Anomalous operation will occur if the
High_Time equals or exceeds the period of the cycle of the referenced tooth
counter.
System
Requirements and Performance
Both Time-Angle and Angle-Time
functions have the same requirements and performance.
The functions must use TCR1 as their
free-running timebase. TCR2 is unused.
The maximum value of High_Time which
may be specified by the host CPU is $8000 TCR1 counts. Note however that in
Angle Priority mode, the actual duration of the pulse might extended beyond
$8000 as a result of deceleration of the toothed wheel.
Correct operation of the functions is
ensured even if the duration of the pulse lies within a single tooth period -
i.e. if the rising and falling edges occur without a change in the value of the
referenced counter.
Specifying a High_Time value in excess
of $8000 will cause incorrect operation of the PSP12 functions. Specifying a
High_Time of zero will produce a pulse width which is determined by TPU
latency.
An output pulse may be orthogonally
scheduled to start and/or end at any point within the gap of the toothed wheel.
i.e. The host CPU does not need to make allowances for the gap.
The PSP12 function takes a maximum of
approximately 17 µS to execute with a 16.78MHz system clock. The actual time
taken depends on the state being executed. The following table gives the
execution times for various states at 16.78MHz:
Function State Output Level Execution Time
Initialisation X 0.95µS
Link
from PMMX 0 16.4µS Note 1
Link
from PMMX (Time Priority) 1 2.1µS
Link
from PMMX (Angle Priority) 1 6.8µS
Rising
Edge of Pulse (Time Priority) 1 3.3µS
Rising
Edge of Pulse (Angle Priority) 1 8.0µS
Falling
Edge of Pulse 0 17.8µS Note 2
Note 1: Execution
time can be reduced to 7.7µS if the microcoded pulse scheduler is removed.
Note 2: Execution
time can be reduced to 9.1µS if the microcoded pulse scheduler is removed.
The PSP12 functions are designed to
process links generated by the PMMX function on every real and simulated tooth
edge. This implies that the PMMX and all pulse output functions should be
processed within a tooth period. However, the combination of the TPU's
scheduler and the design of the PMMX and PSP functions can allow correct output
pulse operation to occur at tooth periods less than the total system latency.
To ensure valid operation of these functions when the total system latency
exceeds the tooth period, the PMMX function must be set to high priority, and
the PSP12 and PSP3 functions must be set to middle or low priority.
Two additional global parameter RAM
locations (PSPTEMP1, PSPTEMP2) are used by the PSP12 functions to guarantee
parameter coherency between the host CPU and the TPU. Two additional global
parameter RAM locations (PERIOD and LAST_TRANSITION) are used to interpolate
the output pulse position. The PERIOD and LAST_TRANSITION parameters are
maintained by the PMMX function.
Parameter
Ram Definitions for PSP12 functions
CONFIG/EXTRA_TIME
During initialisation, this parameter
is refered to as CONFIG. It is a 9 bit value and should be initialised by the
CPU prior to starting the function. It contains the TPU channel latch controls
and configures the PSC, PAC and TBS fields. For correct operation of the
function, the channel must be configured as an output, with match on TCR1 only.
TCR2 is not used by these functions.
Before initialisation of the selected
function, this parameter should normally be set to a value of $8A.
This parameter may also used to
permanently force the pin low. See section ‘Host Interface to PSP12 Function’
for details.
Table 4 shows the normal options for
the CONFIG parameter.
Table
4.
Config Action
$8A Pin is output, forced
low, use TCR1 timebase.
$89 Pin is output, forced
high, use TCR1 timebase.
$13 Pin is input, use TCR1
timebase.
During normal operation of the
function, this parameter may be used to provide asynchronous CPU-requested
pulses in addition to the cyclically scheduled pulses. In this case, the
parameter is refered to as EXTRA_TIME, and all 16 bits of the are used to define
the duration of the additional pulse in TCR1 counts. The range of values is 0
to $8000. Note however that EXTRA_TIME + HIGH_TIME must not exceed $FFFF.
HIGH_TIME
This 16 bit value may be updated by the
CPU at any time.
In Time Priority mode, it defines the
duration of the high time of the next or current output pulse, in TCR1 counts.
In Angle Priority mode, it specifies
the duration of the high time of the next output pulse, in TCR1 counts.
Refer to section ‘Time-Angle Operation’
for more details.
END_ANGLE/START_ANGLE
This 16 bit value may be updated by the
CPU at any time.
The name END_ANGLE is used by the
Time-Angle functions, where it defines the angular position of the falling edge
of the next output pulse. The name START_ANGLE is used by the Angle-Time
function, where it defines the angular position of the rising edge of the next
output pulse.
The parameter is divided into two 8 bit
fields called END_TOOTH and END_RATIO (or START_TOOTH and START_RATIO).
END_TOOTH (or START_TOOTH) is in the
most significant byte. It defines the integer part of the angular position
resolved to tooth counts as specified by either of the tooth counters COUNT_360
or COUNT_720.
END_RATIO (or START_RATIO) is in the
least significant byte. It defines the fractional part of the angular position
as a fraction of the most recently measured tooth period. The range of
END_RATIO (or START_RATIO) is 0 to 255/256 (i.e. 0 to 0.996).
Note: As this parameter is continuously
scheduled ahead of time, on every tooth transition and on every tooth filler,
the falling edge (or rising edge in the case of START_ANGLE) may be specified
to occur coincidently with a tooth transition, or at any point within the gap.
HIGH_TIME_ACTIVE/RISING_EDGE_TIME
This 16 bit value is used by the TPU
only.
In Time Priority mode, the parameter
holds the time in TCR1 counts of the last low to high transition of the output
pulse.
In Angle Priority mode, it holds the
duration of the high time of the currently scheduled output pulse. Refer to ‘Time-Angle
Operation’ section for more details.
END_ANGLE_ACTIVE/START_ANGLE_ACTIVE
This 16 bit value is used by the TPU
only.
For the Time-Angle function, it holds
the angular position of the falling edge of the currently scheduled output
pulse.
For the Angle-Time function, it holds
the angular position of the rising edge of the currently scheduled output
pulse.
This parameter is defined in the same
way as END_ANGLE/START_ANGLE.
Refer to ‘Time-Angle Operation’ section
for more details.
AD:SPACING, EX:COUNT_PTR:PIN_LEVEL
AD occupies bit 15 of this parameter
and is used as a flag by the TPU to indicate that a CPU requested additional
pulse is in progress. The CPU should reset this flag to zero prior to
initialising the function.
SPACING occupies bits 8 to 14 of this
parameter and is used to define the scheduling cycle of the output pulses. It
should be updated by the CPU prior to starting the function.
Table 5 shows the valid values for
SPACING.
Table
5.
Spacing Action
60 Pulses scheduled on
crankshaft cycle.
120 Pulses scheduled on
engine cycle.
EX occupies bit 7 of this parameter and
is used as a flag by the TPU to indicate that a CPU request for an additional
pulse has caused extension of the cyclical pulse. The CPU should reset this
flag to zero prior to initialising the function.
COUNT_PTR occupies bits 1 to 6 of the
least significant byte. It should be updated by the CPU prior to starting the
function. It specifies the relative address of the required tooth counter. This
should be either COUNT_360 for crankshaft cycle pulses, or COUNT_720 for engine
cycle pulses.
Note: An even address should be specified.
When the TPU uses this parameter, bit 0 is ignored. Also, because bit 7 is
unavailable the referenced address is restricted to TPU channels 0 to 7.
PIN_LEVEL occupies bit 0 of the least
significant byte. It is updated by the TPU, and may be updated by the CPU prior
to enabling the function. It indicates the state of the output pin after the
last output transition.
Note: PIN_LEVEL is not updated by the
TPU until the first output edge occurs.
PSPTEMP1
This 16 bit parameter is used by the
TPU only, to provide coherency between the HIGH_TIME and END_ANGLE (or
START_ANGLE) parameters. The parameter is used temporarily during execution of
certain states of the function.
PSPTEMP2
This 16 bit parameter is used by the
TPU only, to provide coherency between the HIGH_TIME and END_ANGLE (or
START_ANGLE) parameters. The parameter is used temporarily during execution of
certain states of the function.
Host
Interface to PSP12 function
Initialisation
1) The
CPU must write to the following parameter RAM locations while the PSP12
function is disabled:
i) CONFIG/EXTRA_TIME.
The name CONFIG applies to bits 0 to 8 during initialision of the function.
These should be set to one of the values in Table 4.
(The name EXTRA_TIME applies to all 16 bits during normal operation of the
function. In this case, the parameter defines the duration, in TCR1 counts, of
the CPU requested additional pulse.)
ii) HIGH_TIME.
This
parameter should be set to the required duration of the cyclical output pulse
width in TCR1 counts. Note that the range of values is restricted to 0 to
$8000. Values outside this region will cause anomolous operation of the
function.
iii) END_ANGLE/START_ANGLE.
The
name END_ANGLE is used by the Time-Angle functions, and the parameter should be
set to the required falling edge angle of the cyclical output pulse.
The
name START_ANGLE is used by the Angle-Time function, and the parameter should
be set to the required rising edge angle of the cyclical output pulse.
iv) HIGH_TIME_ACTIVE.
In
Angle Priority mode only, this parameter should be set to the same value as
HIGH_TIME, to avoid spurious generation of output pulses.
v) END_ANGLE_ACTIVE.
This
parameter should be set to the same value as END_ANGLE, to avoid spurious
generation of output pulses.
vi) AD:SPACING,
EX:COUNT_PTR:PIN_LEVEL.
AD should be reset to zero.
SPACING
should be set to one of the values given in Table 5.
EX should be reset to zero.
COUNT_PTR
should be set to the address of the reference tooth counter. Note that the
tooth counter is restricted to channels 0 to 7.
PIN_LEVEL
may be set to 0 or 1 if desired.
2) The
CPU should set the Host Sequence bits according to the function and mode
required. Refer to Programmers model for details.
3) The
CPU should issue the Host Service Request %11, and then enable the channel by
assigning it a middle or low priority.
Additional
Pulse
1) The
CPU must write to the following parameter RAM locations at any time the PSP12
function is enabled.
i) EXTRA_TIME.
This
16 bit parameter should contain the duration of the additional pulse in TCR1
counts. The maximum value of this parameter is $8000. In addition, EXTRA_TIME +
HIGH_TIME must not exceed $FFFF.
2) The
CPU should then issue the Host Service Request %01.
Note: If an additional pulse is already
in progress, then this request is ignored.
Force
Pin Low
1) The
CPU must write to the following parameter RAM locations while the PSP12
function is enabled, and not processing an additional pulse request:
i) CONFIG.
This
parameter should be loaded with $13.
ii) HIGH_TIME.
This
parameter should be set to zero.
2) The
CPU should then issue the Host Service Request %11.
Note 1: The
output pin must have a pulldown resistor to Vss to ensure the pin goes low.
Note 2: Interrupts
may still be generated to the CPU at the angle defined by End_Angle..
Note 3: To
restart the function, the CPU should ensure all appropriate parameter RAM is
set up correctly and issue an Initialisation Host Service Request (%11).
The PSP3 Function
This function is designed to produce an
output pulse whose rising and falling transitions are both specified by angles.
The angles, called Start_Angle and End_Angle, are defined in an identical
manner to that of End_Angle in the PSP12 function. Through the use of the Host
Sequence Bits, PSP3 has two different operating modes:
» Logic
High
» Logic
Low
When Logic High mode is specified, the
output pin is at Vdd when the pulse is asserted and at Vss when the pulse is
de-asserted. Start_Angle defines the rising edge of the pulse and End_Angle
defines the falling edge. The converse applies to the pulse in Logic Low mode,
where Start_Angle defines the falling edge and End_Angle the rising edge. All
other operations are identical in either mode.
To function correctly, PSP3 must
reference the 720° tooth counter (COUNT_720) maintained by PMMX.
A separate 8 bit value called Spacing,
is used to define the rate at which the output pulses should be rescheduled.
This allows pulses to be repeated at regular angular intervals (See Figure 10).
The actual level of the output pin is
stored in a single bit of parameter RAM. The bit is updated on every transition
of the pulse.
Interrupts may be optionally generated
on every transition.
Limitations
of the Angle-Angle Function
In either Logic High or Logic Low mode,
the tooth numbers for Start_Angle and End_Angle may be the same provided that
Start_Angle is less than End_Angle. This means that a pulse may be placed
within a single tooth period.
Start_Angle may be greater than
End_Angle, provided that their tooth numbers differ.
Since the TPU updates Start_Angle and
End_Angle at the end of each pulse, the CPU may only update these parameters
when the function is disabled, or immediately after an interrupt from the PSP3
function.
System
Requirements and Performance
The function must use TCR1 as its
free-running timebase. TCR2 is unused.
An output pulse may be orthogonaly
scheduled to start and end at any point within the gap of the toothed wheel.
i.e. The host CPU does not need to make allowances for the gap.
The PSP3 function, in either Logic High
or Logic Low mode, takes a maximum of approximately 5 µS to execute.
Two additional global parameter RAM
locations (PSPTEMP1, PSPTEMP2) are used by the PSP3 functions to guarantee
parameter coherency between the host CPU and the TPU. One additional global
parameter RAM location (PERIOD) is used to interpolate the output pulse
position.
The PSP3 function takes a maximum of
approximately 5 µS to execute with a 16.78MHz system clock. The actual time
taken depends on the state being executed. The following table gives the
execution times for various states at 16.78MHz:
Function State Output Level Execution Time
Initialisation X 0.95µS
Link
from PMMX De-asserted 9.0µS
Link
from PMMX Asserted 8.2µS
Start
Angle Edge Asserted 9.4µS
End
Angle Edge De-asserted 3.9µS
Parameter Ram Definitions for PSP3 function
CONFIG
This 9 bit value should be initialised
by the CPU prior to enabling the function. It contains the channel latch controls
and configures the PSC, PAC and TBS fields. For correct operation of these
functions, the channel must be configured as an output, with match on TCR1
only. TCR2 is not used by this function.
Before initialisation of the Logic High
mode, this parameter should normally be set to a value of $8A.
Before initialisation of the Logic Low
mode, this parameter should normally be set to a value of $89.
Table 6 shows the normal options for
the CONFIG parameter.
Table
6.
Config Action
$8A Pin is output, forced
low, use TCR1 timebase.
$89 Pin is output, forced
high, useTCR1 timebase.
START_ANGLE
This 16 bit value should be updated by
the CPU before the function is started.
The TPU updates this parameter at the
end of every output pulse.
In Logic High mode, it defines the
angular position of the rising edge of the next output pulse. In Logic Low
mode, it defines the angular position of the falling edge of the next output
pulse.The parameter is divided into two 8 bit fields called START_TOOTH and
START_RATIO.
START_TOOTH is in the most significant
byte. It defines the integer part of the angular position resolved to tooth
counts as specified by the tooth counter COUNT_720 only.
START_RATIO is in the least significant
byte. It defines the fractional part of the angular position as a fraction of
the most recently measured tooth period. The range of START_RATIO is 0 to
255/256 (i.e. 0 to 0.996).
Note: As START_ANGLE is continuously
scheduled ahead of time, on every tooth transition and on every tooth filler,
the rising (or falling) edge may be specified to occur coincidently with a
tooth transition, or at any point within the gap.
END_ANGLE
This 16 bit value should be updated by
the CPU before the function is started.
The TPU updates this parameter at the
end of every output pulse.
In Logic High mode, it defines the
angular position of the falling edge of the next output pulse. In Logic Low
mode, it defines the angular position of the rising edge of the next output
pulse.The parameter is divided into two 8 bit fields called END_TOOTH and
END_RATIO.
END_TOOTH is in the most significant
byte. It defines the integer part of the angular position resolved to tooth
counts as specified by the tooth counter COUNT_720 only.
END_RATIO is in the least significant
byte. It defines the fractional part of the angular position as a fraction of
the most recently measured tooth period. The range of END_RATIO is 0 to 255/256
(i.e. 0 to 0.996).
Note: As END_ANGLE is continuously
scheduled ahead of time, on every tooth transition and on every tooth filler,
the falling (or rising) edge may be specified to occur coincidently with a
tooth transition, or at any point within the gap.
START_ANGLE_ACTIVE
This 16 bit value is used by the TPU
only. In Logic High mode, it holds the angular position of the rising edge of
the currently scheduled output pulse. In Logic Low mode, it holds the angular
position of the falling edge of the currently scheduled output pulse.
The value of START_ANGLE_ACTIVE is
defined in the same way as START_ANGLE.
END_ANGLE_ACTIVE
This 16 bit value is used by the TPU
only. In Logic High mode, it holds the angular position of the falling edge of
the currently scheduled output pulse. In Logic Low mode, it holds the angular
position of the rising edge of the currently scheduled output pulse.
The value of END_ANGLE_ACTIVE is
defined in the same way as END_ANGLE.
SPACING, COUNT_PTR:PIN_LEVEL
SPACING occupies the most significant
byte of this parameter and is used to define the repetition rate of the output
pulses. It should be updated by the CPU prior to enabling the function. It
should take a value in the range of the required PMMX tooth counter, COUNT_360
or COUNT_720.
COUNT_PTR occupies bits 1 to 7 of the
least significant byte. It should be updated by the CPU prior to enabling the
function. It should contain the address of the tooth counter COUNT_360 or
COUNT_720.
Note: An even address should be
specified. When the TPU uses this parameter, bit 0 is ignored.
PIN_LEVEL occupies bit 0 of the least
significant byte. It is updated by the TPU, and may be updated by the CPU prior
to enabling the function. It indicates the state of the output pin after the
last output transition.
Note: PIN_LEVEL is not updated by the
TPU until the first output edge occurs.
PSPTEMP1
This 16 bit parameter is used by the
TPU only, to provide coherency between the START_ANGLE and END_ANGLE
parameters. The parameter is used temporarily.
PSPTEMP2
This 16 bit parameter is used by the
TPU only, to provide coherency between the START_ANGLE and END_ANGLE parameters.
The parameter is used temporarily.
Host
Interface to PSP3 function
Initialisation
1) The
CPU must write to the following parameter RAM locations while the PSP3 function
is disabled:
i) CONFIG.
This
parameter should be set to one of the values in Table 6.
ii) START_ANGLE.
This
parameter should be set to the required rising (or falling) edge angle of the
output pulse.
iii) END_ANGLE.
This
parameter should be set to the required falling (or rising) edge angle of the
output pulse.
iv) START_ANGLE_ACTIVE.
This
parameter should be set to the same value as START_ANGLE, to avoid spurious
generation of output pulses.
v) END_ANGLE_ACTIVE.
This
parameter should be set to the same value as END_ANGLE, to avoid spurious
generation of output pulses.
vi) SPACING,
COUNT_PTR:PIN_LEVEL.
SPACING
should be set to a value in the range of the reference tooth counter + 1.
COUNT_PTR
should be set to the address of the reference tooth counter.
PIN_LEVEL
may be set to 0 or 1 if desired.
2) The
CPU should set the Host Sequence bits according to the mode required. Refer to
Programmers Model for details.
3) The
CPU should issue the Host Service Request %11, and then enable the channel by
assigning it a middle or low priority.