| The Infineon C167CR For F1 Fuel Injection Control |
Introduction
The C167 family is perhaps unique in having 32 high speed IO pins coupled to a capture and compare (CAPCOM) unit that can be used either as pulse generators or event detectors. The combination of a very fast RISC-like CPU and a 32 channel capture and compare unit allows the easy generation of multiple pulse trains, all locked to a single timebase. Consequently, the C167 finds many applications in areas such as motor control and automotive engine management where the production of precisely timed pulse trains are required. As the CAPCOM unit is an integral part of the CPU, it can be fully configured and controlled directly from assembler or C and does not require the use of microcode, as in some lower performance microcontrollers.
This application note outlines how 13 such C167 CAPCOM channels can be used to provide 12 sequential fuel injector waveform drives, as used on a 12 cylinder formula 1 engine. The overall CPU loading to acheive this is just 3.6% at 18000rpm, even when programmed in C!
How It Works
The input pulse train from a crankshaft-mounted position sensor is fed into input capture channel 15. The sensor gives a negative edge at each cylinders TDC (top dead centre). In a 12 cylinder engine, successive TDCs are 60 degrees apart and at the maximum operating speed of 18000rpm, this corresponds to a time of 555us between TDC references.
At each TDC, the capture register CC15 latches the value of a free running 16-bit timer, T0, running at a rate of 1.6us per count. An interrupt service routine is subsequently called, during which the C167 must make an analog to digital conversion of the throttle position (and hence mass airflow), read the injector firing angle, relative to the TDC from a table and then create a turn-on timeout using a compare output to turn that cylinders injector on. It must also immediately switch off the injector, in case it is still on from the previous cycle, as might happen under high acceleration conditions. This foreshortening of the truncated pulse requires the fuel deficit to be made up by a transient fuelling strategy which is outside the scope of this piece.
Software To Measure The Time Between TDCs
/*** Crankshaft TDC Interrupt ***/ void tdc_int(void) interrupt 0x1f using TDCREGS { unsigned int temp, time_for_60 ; // Make this a register variable unsigned int time_last_60 ; // These are really static but dedicated unsigned int tooth_count ; // regbank TDCREGS makes them like static // register variables /*** Read Pressure Channel For Synchronous Fuelling ***/ ADCON = 0 ; // Set AN0 ADST = 1 ; // Start conversion time_for_60 = CC15 - time_last_60 ; // Find time between referencesIn a conventional processor, the CPU working registers would have to be pushed onto the stack on entry to the interrupt routine, resulting a delay of many microseconds before the CPU is in a position to start processing the time data from the crankshaft sensor. The C167 allows a simple context switch to be performed to make available a fresh set of working registers. This uses the SCXT (switch context) instruction and takes 100ns - the USING control in the function prototype above performs the switch from C. With this dedicated set of registers, all the data used can be held purely in registers so that most instructions take just 100ns - in keeping with the RISC-like CPU design.
The injector firing angle relative to the crankshaft is programmed by the user in terms of angle. However, the CAPCOM unit is in this application, running as a timer unit. The subsequent conversion from the angle domain into the time domain, necessary to create the injector firing angle timeout, is performed by a scaling calculation, based on the measured time since the last TDC interrupt. As the compare registers are attached to the same timer as the input capture, the calculated firing angle timeout is simply added to the captured value of the time at the start of the TDC interrupt, held in capture-compare register CC15.
The preceeding calculations give sufficient time to allow the A/D conversion to be completed. The result is fed into a two-dimensional look-up table interpolator, along with the engine speed to obtain the required injector pulsewidth, based on the A/D reading and the engine speed. By structuring the C source for the interpolator function to take best advantage of the C166 core design, the run time can be got down to just 24us.
Overall, the software effectively simulates the fuel distributor found in a
mechanical system, such as Bosch K-Jetronic. The distribution
of injector pulses is performed via a reference count, which allows each individual
cylinders TDC to be identified and hence the appropriate
injector to be fired via one of the 12 CAPCOM outputs.

When the compare register matches the timer value after the calculated timeout
period, the corresponding compare pin changes state to
switch the injector on. A simple interrupt routine is now required to set the
turn off timeout, to define the injector opening time. This
injector-off interrupt takes a total of just 0.4us!
Software For Creating The Injector On-Period
/*** Injector On Interrupts To Determine On-Time ***/ void CC0_int(void) interrupt 0x10 { CC0 += inj_PW ; CC0IE = 0 ; // No more interrupts until next ref }
Coping With Rapid Acceleration
A problem arises when the engine is accelerating hard as the injector firing
angle to timeout conversion will be wrong as it was based on a time
between references that is no longer current. As the time between TDCs is reducing
the firing angle will lag behind its true position.
The overall run time of the whole TDC interrupt is 45.9us, including 25us for
the 2-dimensional look up table interpolation, at a CPU clock of 20MHz with
a
16-bit non-multiplexed bus. The overall CPU load to perform the
injector drive signal amounts to just 3.6% at 18000 rpm or 7% when the interpolation
is included.
© Hitex (UK) Ltd. 1994