The Ignition Trigger handler and the SA interrupt
handler are tied together at the hip. The Ignition handler will allow
the SA interrupt to occur during the Ignition handler's execution.
I did not know the significance of the 300us delay in the ignition handler
when it found that the plug was fired. It is the time almost to the
cycle to the CLI instruction at L90D2. This clearing
of the I bit in the CCR register allows the SA interrupt handler to grab
a little time to setup for the next plug firing.
Plug firings will always normally occur outside
the Ignition Trigger routine but it is not the case for the start of the
dead time period to recharge the coil. Three possible conditions
can occur:
#1 | The compare raising the SA output happen before the Ignition event. The SA handler gets its interrupt but can't compute the next firing event until the Ignition trigger handler has acknowledged the coil firing. The SA handler needs to know what the clock count was when the trigger event occurred to compute the next coil firing edge. |
#2 | The compare raising the SA output happens after the start of the Ignition handler so the SA interrupt did not occur but Ignition handler found the condition of the SA output line High. The Ignition handler will enable the SA interrupts and force one in 64us. Nothing happens until the CLI instruction where a SA interrupt occurs and the handler computes when to fire the next plug. |
#3 | The compare raising the SA output happens after the test at L8F05. The the SA handler will take control after the CLI instruction at L90D2 and compute the next plug firing edge. |
Legend:
1 - SA Output
2
- When SA Interrupt is active
3
- Ignition trigger edge (inverted)
Condition #1 where the SA output compare occurred before the Ignition Trigger. You can see the quick (RTI only) response of the SA interrupt handler. 300us later another SA interrupt occurs that calculates when to fire then next plug. | |
Condition #2 where the SA output compare occurred after the start of the Ignition Trigger handler. The handler found the SA state high and setup a quick compare to generate another interrupt so that the SA handler will have a good clock count to compute when the next plug firing needs to happen. | |
Condition #3 where the SA output clearly changed states after the Ignition Trigger code had made its checks. The correct clock has been stored to let the SA interrupt compute next firing after the CLI instruction. |
Below is a set of simplified flow charts for the SA interrupt handler and the Ignition Trigger interrupt handler.
L9652: Is the SA output line low firing the coil ? | | NO YES | | | Signal we fired the coil - set L005B xx1xxxxx | Compute the plug firing time. | Setup next OC4 to go High. | | | RTI | | (Output high now starting dead time.) Has the Dist Trigger Intr Acknowledged the Coil Firing ? | | YES NO | | | | Compute when to fire the next cylinder. | Setup OC4 to go Low at next Compare. | | | |<---------------------------------+ | RTI
L8EE7: Has the coil been fired by the SA interrupt (L005B xx1xxxxx) ? | | YES NO | | | Fire the coil Now ! | Setup the SA Output Compare to trigger | a SA interrupt in 300us. This gets us | close to the 'cli' instruction at L90D2. | | | Done | | | | | | Is the SA output low now ? | | | | | +---> YES --------------------+ | NO | | | | | Setup SA output to go High at next compare. | | Enable the SA interrupt. | | Force output high in 64us to assure | | an SA interrupt occurs at the 'cli' | | instruction at L90D2. | | | | | | | | | | | +-----------------------+---------------+ | | | | | Acknowledge Coil firing | by clearing L005B xx1xxxxx. | | | +<-------------------+ |