; ; EFI.ASM - Edelbrock Pro-Flo dis-assembly ; Started: 10/18/98 ; comment ~ This code as it sits will assemble into the same binary image as what is in the Edelbrock PN. 3516 EPROM. Note that the code between $8000 and $EFFF is the same for all of the Edelbrock ROM's. The calibration portion between $F000 and $FFD6 that contain all of the constants and tables for a particular application is the only difference. 09/04/99 - Added comments and definitions found in WS's dis-assembly. Should help understanding this code. As usual take with a grain of salt. Probably will never update this version again. My working copy of the code is much better documented. ~ yes equ -1 no equ 0 ; my_cl_parms equ no ; use my closed loop RPM/Vacuum values cl_upper_rpm_lim equ 4200/25 ; 4,200 RPM upper limit (nc) cl_lower_rpm_lim equ 600/25 ; try bring all the way to Idle cl_upper_vac_lim equ 55 ; ~22" MAP cl_lower_vac_lim equ 194 ; ~6" MAP ; my_rpm_trip equ no ; use my RPM trip table (fuel cutoff) my_dashpot_table equ no ; use my dashpot table ; no_fills equ no ; skip un-needed fills mis1x equ no ; skip........... mis2x equ no ; skip mis4x equ no ; skip mis5x equ no ; skip mis6x equ no ; skip mis7x equ no ; skip mis8x equ no ; clear all unused bits of L00ba mis9x equ no ; skip mis10x equ no ; skip mis11x equ no ; skip - multiple push/pops of same register mis12x equ no ; skip mis13x equ no ; skip mis14x equ no ; skip associated code (mis44) mis15x equ no ; clean up excessive IAC code and wastes mis16x equ no ; skip - takes care of mis24 mis17x equ no ; injector firing code that never gets called mis18x equ no ; skip mis19x equ no ; skip mis20x equ no ; skip mis21x equ no ; skip mis22x equ no ; skip - may not be a problem - 09/04/99 mis25x equ no ; skip mis26x equ no ; skip (closed loop stuff) mis_clsd_lp1 equ no ; bunch of extra calculation done in trying ; to calculate closed loop PW stuff ; mis27: mis28: mis29 mis30: mis31: mis32x equ no ; TPS closed Spark Angle lookup (mis32,mis33) mis34x equ no ; replace with constant mis35x equ no ; replace with constant mis36x equ no ; cut out usless spark stuff (mis37:, mis37a:) mis38x equ no ; takes care of mis38, mis47, mis23, mis46 mis39x equ no ; cut out mis42x equ no ; skip mis43x equ no ; skip mis45x equ no ; skip mis48x equ no ; skip ; ; Some of this needs to be added back in - 09/04/99 mis49x equ no ; all the L0008 MAP ADC offset stuff ; mis51x equ no ; skip mis52x equ no ; skip mis53x equ no ; skip mis55x equ no ; mis56x equ no ; skip (also takes care of mis66:) mis57x equ no ; Lf01d XORing - Ign Coil Driver Mode mis58x equ no ; skip mis60x equ no ; skip mis61x equ no ; skip mis62x equ no ; skip mis63x equ no ; skip mis64x equ no ; skip mis65x equ no ; skip mis67x equ no ; skip L6000_skip equ no ; wire arround L6000 stuff ; misc1 equ no ; un-needed test batt_mis equ no ; un-needed test ; ;============================================================================== ; Code sub-routine Map: ; ; 8010 - 83ae Main Entry - Initialization ; 83af - 8ca8 Main Calibration Run Loop ; 8ca9 - 9512 IC1 Distributor Trigger Interrrupt Handler ; 8ca9 - 8f70 Ign Trigger stuff and #1 detector ; 8f85 - 9121 #8 #3 #5 #2 path ; 9124 - 9238 #1 #4 #6 #7 path ; 923b - 92ee path join-up ; 92f5 - 936b slower than 5,500 rpm ; 936b - faster than 5,500 rpm or faster than Idle Target RPM ; 9373 - faster than Target Idle RPM ; 9398 re-join ; 93ea - 9490 below 5,000 rpm ; 9490 above 5,000 rpm re-join ; ; 9513 - 9651 TOF Timer Overflow Interrupt Handler ; 9652 - 9720 OC4 Ignition Amp (SA) Driver Interrupt Handler ; 9721 - 972f OC3 EEPROM Timer ; 9730 - 973f OC2 Injector-D Interrupt handler ; 9740 - 97dd OC1 Idle Air Motor Interrupt Handler ; 97de - cfff No Code - 14k gap...... ; d000 - d47d IAS and dashpot ; d47e - d6e9 Returns new Injector Pulse width subroutine ; d6ea - d8a4 Save/Restore Dataset subroutine ; d8a5 - da7d Numerous subroutines - math - lookups ; da7e - db06 Fire specified Injector ; db07 - dbc7 Checks for warning and sensor Errors ; dbc8 - dc9c more subroutines .... ; dc9d - ddf6 SCI Serial System Interrupt Handler ; ddf7 - efff No Code - 4.6k gap...... ; f000 - ffc0 Look-up Tables and Constants ; ffc0 - ffff CPU Interrupt vectors ; ; ============================================================================= ; Mistake Log . . . . . . . ; ; Distributor Trigger Handler. . . . . ; * mis1: mis2: ; The code that modifies L0043 checks for roll. Even if all byte values ; are 255 there is no way for the value to ever get over 255.... ; * mis3: ; The code that detects the narrow #1 cylinder timing pulse does not work. ; * mis10: ; Bit 1xxxxxxx of L005b is set but never used. ; * mis11: ; A push/pop that does nothing..... ; * mis12: ; Will never take this branch because a compare of zero and a BCS.. ; * mis13: ; Bit xxxx1xxx of L005d (ram_005d) is cleared but never tested anywhere ; * mis4: ; L0038 is cleared but never used anywhere. ; * mis5: ; L003e is cleared twice almost in a row. ; * mis6: ; The xxxxx11x bits of L00bc are tested but are never set anywhere. ; * mis7: ; Will always take this branch because they are comparing a zero to a ; value and jumping on carry-clear, which it can never set Carry. ; * mis8: ; Bits xxxxx1xx and xxxxxx1x of L00ba are set but never used anywhere. ; * mis9: ; Cannot find this target label and jump being used anywhere. ; * mis14: mis14a: mis14b: ; Never execute this code because above tests always by-passes it. ; * mis15: ; A mess of code in the IAC computations is usless because of what the ; tables are set at. Goes thru a whole bunch of work to always come ; up with the exact same results. ; * mis16: ; Never take some code because A is loaded with a zero followed by BEQ. ; * mis17: ; Looks like this code to fire the injectors (maybe during starting) ; never gets called... ; * mis18: ; Will never take this jump. No byte can be higher than the 255 constant. ; * mis19: mis20: ; Couple place that will always take a jump needlessly ; * mis21: mis56: ; Will always take this branch because comparing zero to a non-zero ; number followed with a bhi. Comparing a zero will always clear carry. ; * mis22: ; Stashed something into L0000 then a few lines later stashed something ; else into it. ; 09/03/99 - This may be needed because the next instructions turns on the ; interrupts so maybe to assure some value stash now ? ; * mis23: mis24: mis48: ; Can never take this branch ; * mis25: mis46: ; more piss-poor logic and needless tests ; * mis26: ; multiply a number by 16 then divide it by 16 ????? - makes sense ; * mis27: mis28: mis30 ; these stashs are not used anywhere in the following calculations ; * mis29: mis31: ; a bunch of calculations that always result in zero...... ; * mis32: mis33: ; more bs because tables contain all the same entries...... ; * mis34: mis35: ; don't need to do these calculations - just use constant ; * mis36: ; more usless lookup because table has all the same entries ; * mis37: mis37a: ; section of code assumes that the A reg still contains the spark angle ; * mis38: mis39: ; stash that does nothing because only a zero ever gets loaded ; * mis40: ; bit x1xxxxxx of L005c gets set but is never cleared anywhere ; Left because low usage and absolutely sure why they did this ; * mis41: ; bit 1xxxxxxx of L005c gets set but is never cleared anywhere ; Left because low usage and absolutely sure why they did this ; ; * mis42: (several locations) ; with constants used adding a 1 to L0014 will never roll. ; * mis43: ; with constant used result will always be zero ; * mis44: ; L0073 never gets used. Where it is bumped never gets called ; * mis45: ; storing and loading back the same register ; * mis47: ; bit 1xxxxxxx of L0058 useless because of mis38: ; * mis49: mis49a: mis49b: mis49c: mis49d: mis49e: ; problems with the MAP offset that gets loaded into L0008 and applied ; to L0000. The whole MAP correction may not do anything !!!!! ; This would mean all the corrected values I applied with L0000 ; are wrong ! ; 12/28/98 - They are. L0008 is always zero !!!!!!!! ; 09/03/99 - Well it looks like I was wrong. The initial value computed ; into is a valid altitude compression value. ; 09/04/99 - There still is a problem with some of the code were it looks ; like it is trying to re-compute this compression factor ; while the motor is running. The TPS values choosen will ; always by-pass this section of code. ; ; * mis50: ; why calculate when just get the darn thing ; 01/03/99 - left because low usage and might be needed ; ; * mis51: mis51a: mis51b: ; needless loads into IY ; * mis52: mis53: ; needless clc ; * mis54: ; I believe this bit will always be zero at this point because prev clear ; 01/03/99 - Left because it may affect a situation where the motor was ; running then stoped without loosing power to EMU. ; ; * mis55: ; bit xxxxx1xx of L0058 useless because never tested anywhere ; * mis57: ; xor with a 0 does nothing.... ; * mis58: mis58a: mis58b: mis58c: ; with values used can never take branch ; * mis59: mis59a: mis59c: mis59d: ; can jump arround these calculations because results are always zero ; * mis60: mis60a: ; why test when load sets the flags ; * mis61: mis61a: ; with L004e and L004f limited to +-127 and the scaling multipliers used ; the results can never be this high. ; * mis62: ; subtract zero from a value ; * mis63: ; don't think need to clear this work stash...... ; * mis64: ; subtracting zero then branching on carry ; 01/03/99 - left this as I may experiment with it ; * mis65: ; not needed register set ; * mis66: ; bunch of do nothing code ; * mis67: ; another sub-routine that is never called ; * mis68: ; now that I see where L6000 comes from it can be wired arround ; mis69: ; The COP system is not being enabled. The NOCOP bit in the CONFIG ; register is set to one (1) disabling the COP watch dog timer !!!! ; 12/13/98 - read the CONFIG register = 00001101 ; 01/03/99 - Left it in for the time being. ; ; mis70: ; If the only difference in the first dist trigger path decision (over ; 4,500 rpm is that #1 shutter is looked at maybe can reduce code lines. ; mis71: ; Might check and see how often L004e and L004f are zero. If a lot then ; maybe be able to skip some code here. If these stash are used alot ; then maybe not. ; ; ============================================================================== ; The following is what is sent to the command module. This sequence is the ; current operating conditions...... ; ; ECU RPM is ignition trigger period times 125,000 ; ;ram_003e equ $003e 00c2 ; RPM from the ECU hi byte ;ram_003f equ $003f 00c3 ; .....RPM low byte ;ram_0041 equ $0041 00c5 ; current Vacuum from ECU hi byte ;ram_0042 equ $0042 00c6 ; .....VAC lo byte ;ram_0043 equ $0043 00c7 ; SPK - Spark Angle stash ;ram_0044 equ $0044 00c8 ; FUEL - injector Pulse Width hi byte ;ram_0045 equ $0045 00c9 ; .....FUEL lo byte ;ram_0046 equ $0046 00ca ; TAIR - Air Temperature ;ram_0047 equ $0047 00cb ; Battery Voltage ;ram_0048 equ $0048 00cc ; TPS - Throttle Position Sensor ;ram_0049 equ $0049 ; TH2O - Water Temp from ECU ;ram_004a equ $004A ; Idle Target RPM ;ram_004b equ $004B ; Idle Motor Activity ;ram_004c equ $004C ; Mixture flags ; ; 0xxxxxxx - Both LED's Off ; ; 1xxxxxxx - Both LED's On ; ; x1xxxxxx - Only One LED is on ; ; x0xxxxxx - Both LED's are On or Off ; ; xxxx0xxx - Red LED On (lean) ; ; xxxx1xxx - Green LED On (rich) ; ;ram_004d equ $004D ; Warning message index ; ; 1xxxxxxx - MAP Sensor Error ; ; x1xxxxxx - H20 Temp. error ; ; xx1xxxxx - Voltage Hi/Low ; ; xxx1xxxx - Throttle Input Error ; ; xxxx1xxx - AIR Temp. error ; ; xxxxx1xx - O2 Sensor error ; ; ----------------------------------------------------------------------------- ; Message sent to the ECU to request data ; ; NOTE: The third byte sent is the number of bytes being transmitted..... ; ; 7B 05 12 80 00 - return ECU software revision information ; 16 ascii characters starting with the 5th received ; 7B 05 0A F0 00 - return CAL info from ECU ; 8 ascii characters starting with the 5th received ; 7B 02 7D - request for engine operating conditions ; ; 7B 06 03 00 7F 91 - Save dataset 'A' ; 7B 06 03 00 7F 92 - Save dataset 'B' ; 7B 06 03 00 7F 93 - Save dataset 'C' ; 7B 06 03 00 7F A0 - Restore Base dataset ; 7B 06 03 00 7F A1 - Restore 'A' dataset ; 7B 06 03 00 7F A2 - Restore 'B' dataset ; 7B 06 03 00 7F A3 - Restore 'C' dataset ; ; The following are sent to the ECU to verify that the Save/Restore was ; successful. Notice that the only difference is in the 2nd byte (05) between ; a command to do and a request for success. If a failure occured then the ; 6th byte (ram_0029) is NZ. Success then ram_0029 = 0. ; ; 7B 05 03 00 7F 91 - Success saving dataset 'A' ? ; 7B 05 03 00 7F 92 - Success saving dataset 'B' ? ; 7B 05 03 00 7F 93 - Success saving dataset 'C' ? ; 7B 05 03 00 7F A0 - Success Restoring Base dataset ? ; 7B 05 03 00 7F A1 - Success Restoring 'A' dataset ? ; 7B 05 03 00 7F A2 - Success Restoring 'B' dataset ? ; 7B 05 03 00 7F A3 - Success Restoring 'C' dataset ? ; ; These are from thescreens..... ; ; Query: 7B 05 03 00 B0 - ask for target Idle RPM value ; Response: 7B 05 03 00 B0 xx - Target_RPM = (xx-128) * 25 ; Update: 7B 06 03 00 B0 VL - VL = (work_value/25) + 128 ; ; Query: 7B 05 03 00 B2 - ask for Rev Limiter RPM ; Response: 7B 05 03 00 B2 xx - Rev_Limit_RPM = (xx * 250) ; Update: 7B 06 03 00 B2 VL - VL = (work_value / 250) ; ; Query: 7B 05 03 00 AB - ask for Idle Fuel Mod +/-50% ; Response: 7B 05 03 00 AB xx - Idle_Fuel = (xx-128) * .78125 {round up} ; Update: 7B 06 03 00 AB VL - VL = (work_value/.78125) + 128 ; ; Query: 7B 05 03 00 AF - ask for Idle Spark Mod +/-16% ; Response: 7B 05 03 00 AF xx - Idle_Spk = (xx-128) * .25 ; Update: 7B 06 03 00 AF VL - VL = (work_value/.25) + 128 ; ; Query: 7B 05 03 00 B1 - ask for Idle Speed Activity +/-50% ; Response: 7B 05 03 00 B1 xx - Idle_Activity = (xx-128) * .78125 {round up} ; Update: 7B 06 03 00 B1 VL - VL = (work_value/.78125) + 128 ; ; Query: 7B 05 03 00 B3 - on/off flags ; Response: 7B 05 03 00 B3 xx - 1xxxxxxx - Base Timing Set: On ; 0xxxxxxx - Base Timing Set: Off ; x1xxxxxx - Closed Loop Fuel: Off ; x0xxxxxx - Closed Loop Fuel: On ; xx1xxxxx - Idle Control: Off ; xx0xxxxx - Idle Control: On ; Update: 7B 06 03 00 B3 VL - mask byte set to above conditions ; ; The following are for the Spark Modifier pages............................... ; ; All Spark modifiers are +8 degrees / -16 degrees ; ; Query: 7B 05 03 00 98 - Sprk @ WOT @ 1000 RPM ; Query: 7B 05 03 00 99 - Sprk @ WOT @ 1750 RPM ; Query: 7B 05 03 00 9A - Sprk @ WOT @ 2500 RPM ; Query: 7B 05 03 00 9B - Sprk @ WOT @ 3500 RPM ; Query: 7B 05 03 00 9C - Sprk @ WOT @ 4500 RPM ; Query: 7B 05 03 00 9D - Sprk @ WOT @ 6000 RPM ; ; Query: 7B 05 03 00 9E - Sprk @ 09" @ 1000 RPM ; Query: 7B 05 03 00 9F - Sprk @ 09" @ 1750 RPM ; Query: 7B 05 03 00 A0 - Sprk @ 09" @ 2500 RPM ; Query: 7B 05 03 00 A1 - Sprk @ 09" @ 3500 RPM ; Query: 7B 05 03 00 A2 - Sprk @ 09" @ 4500 RPM ; Query: 7B 05 03 00 A3 - Sprk @ 09" @ 6000 RPM ; ; Query: 7B 05 03 00 A4 - Sprk @ 18" @ 1000 RPM ; Query: 7B 05 03 00 A5 - Sprk @ 18" @ 1750 RPM ; Query: 7B 05 03 00 A6 - Sprk @ 18" @ 2500 RPM ; Query: 7B 05 03 00 A7 - Sprk @ 18" @ 3500 RPM ; Query: 7B 05 03 00 A8 - Sprk @ 18" @ 4500 RPM ; Query: 7B 05 03 00 A9 - Sprk @ 18" @ 6000 RPM ; Query: 7B 05 03 00 AE - Global Spark ; ; All Responses are at ram_0029 (6th byte) in the format of: ; Sprk = (xx-128) * .25 ; ; To Update, the byte at ram_0025 (2nd byte) is changed to 06. The 6th ; location (ram_0029) contains the value to update: ; VL = (work_value / .25) + 128 ; ; ............................................................................. ; The following are from the FUEL modifier pages...... ; ; All Fuel modifiers are +50% to -30% ; ; Query: 7B 05 03 00 80 - Fuel @ WOT @ 1000 RPM ; Query: 7B 05 03 00 81 - Fuel @ WOT @ 2000 RPM ; Query: 7B 05 03 00 82 - Fuel @ WOT @ 3000 RPM ; Query: 7B 05 03 00 83 - Fuel @ WOT @ 4000 RPM ; Query: 7B 05 03 00 84 - Fuel @ WOT @ 5000 RPM ; Query: 7B 05 03 00 85 - Fuel @ WOT @ 7000 RPM ; ; Query: 7B 05 03 00 86 - Fuel @ 06" @ 1000 RPM ; Query: 7B 05 03 00 87 - Fuel @ 06" @ 2000 RPM ; Query: 7B 05 03 00 88 - Fuel @ 06" @ 3000 RPM ; Query: 7B 05 03 00 89 - Fuel @ 06" @ 4000 RPM ; Query: 7B 05 03 00 8A - Fuel @ 06" @ 5000 RPM ; Query: 7B 05 03 00 8B - Fuel @ 06" @ 7000 RPM ; ; Query: 7B 05 03 00 8C - Fuel @ 12" @ 1000 RPM ; Query: 7B 05 03 00 8D - Fuel @ 12" @ 2000 RPM ; Query: 7B 05 03 00 8E - Fuel @ 12" @ 3000 RPM ; Query: 7B 05 03 00 8F - Fuel @ 12" @ 4000 RPM ; Query: 7B 05 03 00 90 - Fuel @ 12" @ 5000 RPM ; Query: 7B 05 03 00 91 - Fuel @ 12" @ 7000 RPM ; ; Query: 7B 05 03 00 92 - Fuel @ 18" @ 1000 RPM ; Query: 7B 05 03 00 93 - Fuel @ 18" @ 2000 RPM ; Query: 7B 05 03 00 94 - Fuel @ 18" @ 3000 RPM ; Query: 7B 05 03 00 95 - Fuel @ 18" @ 4000 RPM ; Query: 7B 05 03 00 96 - Fuel @ 18" @ 5000 RPM ; Query: 7B 05 03 00 97 - Fuel @ 18" @ 7000 RPM ; ; Query: 7B 05 03 00 AD - Transient Fuel ; Query: 7B 05 03 00 AC - Cold Start Fuel ; Query: 7B 05 03 00 AA - Global Fuel ; ; All Responses are at ram_0029 (6th byte) in the format of: ; Fuel = (xx-128) * .78125 {round up} ; ; To Update, the byte at ram_0025 (2nd byte) is changed to 06. The 6th ; location (ram_0029) contains the value to update: ; VL = (work_value / .78125) + 128 ; ;============================================================================== ; ; The following is what I know (I hope) about the ECU hardware and PAL mapping. ; ; ; Memory Map ............ ; ; ; +---------------------- A15 PAL ; |+--------------------- A14 PAL ROM ; ||+-------------------- A13 PAL ROM ; |||+------------------- A12 ROM Timer(CS1) ; ||||+------------------ A11 ROM ; |||||+----------------- A10 ROM Timer(RS2) ; ||||||+---------------- A9 ROM Timer(RS1) ; |||||||+--------------- A8 ROM Timer(RS0) ; |||||||| +------------- A7 ; |||||||| | +------ A0 A0-A7 PAL only ; |||||||| | | ; 0000 00000000 00000000 Base of System RAM (512 bytes) ; 00FF 00000000 11111111 Top of System RAM ; ; 1000 00010000 00000000 Base of 64-byte register block ; 103F 00010000 00111111 Top of register block ; ; 3000 00110000 00000000 Control Register #1 and #3 ; 3100 00110001 00000000 Control Register #2 ; 3200 00110010 00000000 MSB Buffer Register #1 ; 3300 00110011 00000000 Timer #1 Latchs ; 3400 00110100 00000000 MSB Buffer Register #2 ; 3500 00110101 00000000 Timer #2 Latches ; 3600 00110110 00000000 MSB Buffer Register #3 ; 3700 00110111 00000000 Timer #3 Latches ; ; 4000 01000000 00000000 Fuel Pump PAL latch ; 6000 01100000 00000000 PAL - reads L9112D Invertor ; ; 8000 10000000 00000000 First block of code ; 97DD 10010111 11011101 End of first block of code ; ; B600 10110110 00000000 Base of EEPROM (512 bytes) ; B7FF 10110111 11111111 Top of EEPROM ; ; D000 11010000 00000000 Start of second block of code ; DDF6 11011101 11110110 End of second block ; ; F000 11110000 00000000 ; Look up tables and constants ; FFB6 11111111 10111111 ;...... ; ; FFC0 11111111 11000000 ; start of interrupt tables ; FFFF 11111111 11111111 ; Top of 64k address space ; ; ---------------------------------------- ; Look-up tables...... ; ; First we check out EEPROM. If the checksum computes transfer it to RAM. ; If checksum incorrect then get data from ROM..... ; ; EEPROM B600-B63E (checksum at B63F) - This is where Dataset 'A' lives ; B640-B67E (checksum at B67F) - Dataset 'B' ; B680-B6BE (checksum at B6BF) - Dataset 'C' ; ; RAM 0080-00B5 - modifiers are here ; ROM F740-F775 - get from here if bad EEPROM ; ; ----------------------------------------------------------------------------- ; System Clock...... ; ; 8 MHz XTAL ; 2 MHZ 'E' clock ; The main system timers prescaler is set to divide by 4. This would ; set its freq to 500 KHz with a period of 2 us. ; Input into the 6840 time is divided by 8 to 250 KHz (4us) ; ; ----------------------------------------------------------------------------- ; External Timer ....... ; ; SG Thompson EF68B40PV - Three 16 bit timers ; Same as EF3840, MC6840, or HD6340 ; ; All the clock inputs are fed with a 250 KHz clock ( E clock / 8) ; 4us per per count ; All the gates are tied to ground. ; The are configured in 16 bit Single shot mode... ; ; Timer #1 (O1) - drives INJ-A (cylinders 1 and 8) ; Timer #2 (O2) - drives INJ-C (cylinders 4 and 3) ; Timer #3 (O3) - drives INJ-B (cylinders 6 and 5) ; ; Addressing: ; A12 is tied to the CS1 ; A11 - is qualified by the PAL - *CS0 ; A10 - RS2 ; A9 - RS1 ; A8 - RS0 ; ; Address Write Read ; ; $3000 Control Register #3 0 ; Control Register #1 0 ; $3100 Control Register #2 Status Register ; $3200 MSB Buffer Register #1 Timer #1 Counter ; $3300 Timer #1 Latchs LSB Buffer Register ; $3400 MSB Buffer Register #2 Timer #2 Counter ; $3500 Timer #2 Latches LSB Buffer Register ; $3600 MSB Buffer Register #3 Timer #3 Counter ; $3700 Timer #3 Latches LSB Buffer Register ; timer_cntr_regx equ $3000 timer_cntr_reg2 equ $3100 timer_1_msb equ $3200 timer_1_lsb equ $3300 timer_2_msb equ $3400 timer_2_lsb equ $3500 timer_3_msb equ $3600 timer_3_lsb equ $3700 ; ; ; ----------------------------------------------------------------------------- ; ADC....... ; ; The ADC's are referenced to the +5 volt supply. ; Full scale ADC voltage --> 5 * (255/256) = 4.98046875 volts ; Bit sensitivity --> 4.98046875 / 255 = 19.53125 mv/bit ; ; AN0 - Its input is selected thru one of three switches. ; SW1 - PAL-13 selected - HY3-2 which is not loaded ; SW2 - PAL-39 selected - HY2-7 which does what ?????? ; SW3 - PAL-40 selected - PT1 which is not loaded ; ; AN1 - conditioned input from Pin-9 which is a No Connect ; ; AN2 - MAT input from HY1-7. The conditioned input is: ; ; 4.3 - Vadc ; Vadc - ( ------------ * 358 ) ; 2720 ; Rmat = -------------------------------- ; 4.3 - Vadc ; ---------- ; 2720 ; ; or much simpler........ ; ; R_sensor + 358 ; Vadc = ( ---------------------- ) * 4.3 ; 2720 + 358 + R_sensor ; ; ; AN3 - COOL temperature sensor. Its input follows the same rules as MAT. ; ; AN4 - O2 Sensor - Gain from Pin-2 (O2 sensor input) to the input ; of the ADC is * 2.972 with a 46 mv offset. ; O2v = ((ADC-2) * Vadc_bit) / 2.972 ; ; AN5 - TPS - 1:1 relationship between the input signal and the ADC ; ; AN6 - BATT - The battery voltage is divided by 3.2103 before reaching ; the ADC. ; ADC = ( BATT / 3.2102728725 ) / .01953125 or ; ADC = BATT / .0625 ; BATT = ADC * .0625 ; 255 = 16 volts ; ; AN7 - MAP - 1:1 relationship between the input signal and the ADC ; ; ----------------------------------------------------------------------------- ; Misc MPU I/O..... ; ; -IRQ (pin 19) - pulled up thru a 1.5k to +5v only - Not Used ; -XIRQ (pin 18) - pulled up thru a 1.5k to +5v only - Not Used ; RESET (pin 17) - comes from the input voltage regulator. ; PA7/pai/OC1 - (pin 27) - goes to the IAC driver. ; PA4/OC4/oc1 - (pin 30) - goes to the SA (Ign Amplifer) ; PA2/IC1 - (pin 32) - conditioned input from the distributor trigger. ; PD1/TxD - (pin 21) - thru a hi-current driver to Pin-27 (ECU TX) ; PA6/OC2/oc1 - (pin 28) - to the MUX (INJ-D driver) ; PD0/RxD - (pin 20) - from the MUX (Pin-8 ECU RX) ????? ; ; ; OC1 - IAC driver (pin 27) ; Output from OC1 directed to PA7 (pin 27) $100C ; Output a 1 (High) to PA7 (pin 27) after successful compare $100D ; ; OC3 - Used for progaming the EEPROM. ; ; OC4 - Ignition Amplifier drive ; ; IC1 - Distributor trigger input ; ; ----------------------------------------------------------------------------- ; The PAL ...... (SG F22HA9231) ; ; Outputs: ; xxxx PAL-1 MUX-15 (always hi) ; xxxx PAL-3 MUX-12 (always hi) ; xxxx PAL-4 MUX-2 (always hi) ; xxxx PAL-5 MUX-6 (always hi) ; xxxx PAL-38 AN0 switch select (1E) always lo-off ; xxxx PAL-39 AN0 switch select (2E) always lo-off ; xxxx PAL-40 AN0 switch select (3E) always lo-off ; xxxx PAL-41 Thru Hi_current driver to Pin-12 - N/C ; xxxx PAL-43 Fuel Pump relay driver ; xxxx PAL-44 YY2-7 reset transistor starts low then hi before PAL-43 ; ; pal_4000_latch equ $4000 ; latch driving fuel pump and ???? ; ; x1xxxxxx - turn on PAL-44 ; ; xx1xxxxx - turn on Fuel Pump PAL-43 ; ;============================================================================== ram_base equ $0000 ; base of RAM eeprom_base equ $b600 ; start of EEPROM ; ; ----------------------------------------------------------------------------- ; register_base equ $1000 ; base of the register block ; ; Vacuum(in) = 28.9 - (ECU_VAC * .01152) ; ; ; ----------------------------------------------------------------------------- ; TPS(degrees) = (ECU_TPS * .4519) - 7.0 ; ; These values where measured on car. DVM on the TPS sensor. The degrees ; were read off the command module. It was somewhat difficults to push the ; throttle in with precession but values were pretty close. What is a little ; puzzling is that the voltage range varied so widely, between 35mv to 61mv. ; If you take the 14 degree to 90 degree readings and divide by 76 steps ; you get about 43mv per step with a 313mv offset to get to zero degrees... ; Well that 313mv offset is the 7.0 that is subtracted in the equation to ; display degrees above. ; ; Degrees Voltage range ADC ; 14 0.906 - 0.941 46-48 ; 15 0.941 - 0.981 48-50 ; 16 0.981 - 1.042 50-53 ; 17 1.042 - 1.079 53-55 ; 20 1.160 - 1.194 59-61 ; 25 1.362 - 1.423 70-73 ; 30 1.582 - 1.640 81-84 ; 35 1.795 - 1.856 92-95 ; 40 2.032 - 2.077 104-106 ; 50 2.461 - 2.500 126-128 ; 60 2.892 - 2.930 148-150 ; 70 3.323 - 3.361 170-172 ; 80 3.75 - 3.79 192-194 ; 90* 4.18 - 214- ; ; * Controller won't disp more than 90 degrees ; * Throttle was floored.......... ; ; ----------------------------------------------------------------------------- ; Idle Air(%) = (ECU_Idle * .78125) ; ; ----------------------------------------------------------------------------- ; This is the altitude compression compensated MAP ADC stash. At initial ; key on the MAP ADC is read and if the atmospheric barometric pressure is low ; enough (high altitude) and MAP ADC correction amount is computed into L0008 ; and is added to the MAP ADC values. It is a relatively small amount ranging ; from 0 to 6 adc counts (about one inch). Look at the L0008 location for ; more details as to where the breakpoints are located. I had originaly ; thought that the whole L0008 thing was in error because it was alwasy zero. ; Well it is at sea level. Above about 1500' it isn't though. Learning some ; of the constant's meanings from the WS dis-assembly got me thinking along the; correct track. ; ; NOTE: The modifications to this value from the actual ADC reading is ; done by the Calibration routine (new L83e5) where it is increased by ; ~1.56%. L0008 is the altitude compression corections so at extended ; elevations a small amount is added to the ADC reading. ; L0000 equ $0000 ; slope adjusted MAP ADC reading ; ; The below table is what I measured for the MAP sensor that is in the '34 ; (11/14/98) ; The displayed VAC was obtained from the simulator............12/29/98 ; ; TAIR: 59 degrees ; ; Vacuum Voltage ADC L0000 VAC ; (in) (L002a) TAIR=59 ; 0 4.55 237 240 -3.2" ; 1 4.44 231 234 -2.4" ; 2 4.32 225 228 -4.7" ; 3 4.15 216 219 -0.6" ; 4 4.00 208 211 0.2" ; 5 3.82 199 202 1.4" ; 6 3.65 190 192 2.5" ; 7 3.463 180 182 3.7" ; 8 3.302 172 174 4.7" ; 9 3.141 163 165 5.6" ; 10 2.953 154 156 6.8" ; 11 2.809 146 148 7.8" ; 12 2.632 137 139 8.8" ; 13 2.415 126 127 10.2" ; 14 2.263 118 119 11.0" ; 15 2.136 111 112 11.9" ; 16 1.954 102 103 13.0" ; 17 1.783 93 94 14.0" ; 18 1.607 84 85 15.2" ; 19 1.437 75 76 16.1" ; 20 1.238 64 65 17.4" ; 21 1.061 55 55 18.6" ; 22 .874 45 45 19.9" ; 23 .695 36 36 20.9" ; 24 .510 27 27 22.0" ; 25 .316 16 16 23.2" ; 26 .134 7 7 24.3" ; 27 .024 1 1 25.0" ; 28 .024 1 1 25.0" ; 29 .024 1 1 25.0" ; ; ALL BELOW IS WRONG - WRONG - WRONG !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ; ; The below table is what I measured for the MAP sensor that is in the '34 ; (11/14/98) ; ; Input Voltage: 4.92 TAIR: 59 degrees H20: 55 degrees ; ; Vacuum Voltage ADC L0008 L0000 VAC Difference ; (in) (Displayed) (34-booster) ; 0 4.55 237 0 237 0.0 +1 ; 1 4.44 231 0 229 0.0 +1 ; 2 4.32 225 0 225 0.0 +4 ; 3 4.15 216 1 217 0.1 +4 ; 4 4.00 208 2 210 0.9 +5 ; 5 3.82 199 3 202 1.9 +4 ; 6 3.65 190 4 194 3.0 +4 ; 7 3.463 180 5 185 4.2 +2 ; 8 3.302 172 6 178 5.1 +3 ; 9 3.141 163 6 169 6.1 +3 ; 10 2.953 154 6 160 7.3 +2 ; 11 2.809 146 6 152 8.1 0 ; 12 2.632 137 6 143 9.1 +1 ; 13 2.415 126 6 132 10.6 +1 ; 14 2.263 118 6 124 11.5 0 ; 15 2.136 111 6 117 12.2 +2 ; 16 1.954 102 6 108 13.2 +5 ; 17 1.783 93 6 99 14.3 +5 ; 18 1.607 84 6 90 15.3 +3 ; 19 1.437 75 6 81 16.5 +5 ; 20 1.238 64 6 70 17.6 +3 ; 21 1.061 55 6 61 18.6 +4 ; 22 .874 45 6 51 19.9 +3 ; 23 .695 36 6 42 20.9 +3 ; 24 .510 27 6 33 22.0 +3 ; 25 .316 16 6 22 23.2 +1 ; 26 .134 7 6 13 24.2 +2 ; 27 .024 1 6 7 25.0 0 ; 28 .024 1 6 7 25.0 0 ; 29 .024 1 6 7 25.0 0 ; ; V_Step ~= 169.36 mv / in ; ADC_step(uncorrected) ~= 8.8 / in ; ; ----------------------------------------------- ; The below table is what I measured for the MAP sensor I used on the vacuum ; booster pump controller.... ; ; Vacuum Voltage ADC L0008 L0000 ; (in) ; 0 4.61 236 0 236 ; 1 4.45 228 0 228 ; 2 4.29 220 1 221 ; 3 4.13 211 2 213 ; 4 3.96 203 2 205 ; 5 3.80 195 3 198 ; 6 3.63 186 4 190 ; 7 3.475 178 5 183 ; 8 3.30 169 6 175 ; 9 3.12 160 6 166 ; 10 2.971 152 6 158 ; 11 2.85 146 6 152 ; 12 2.656 136 6 142 ; 13 2.444 125 6 131 ; 14 2.301 118 6 124 ; 15 2.123 109 6 115 ; 16 1.890 97 6 103 ; 17 1.713 88 6 94 ; 18 1.574 81 6 87 ; 19 1.368 70 6 76 ; 20 1.201 61 6 67 ; 21 1.000 51 6 57 ; 22 .825 42 6 48 ; 23 .637 33 6 39 ; 24 .460 24 6 30 ; 25 .285 15 6 21 ; 26 .100 5 6 11 ; 27 .026 1 6 7 ; 28 .026 1 6 7 ; 29 .026 1 6 7 ; ; V_step ~= 173.4mv / in ; ADC_step(uncorrected) ~= 9 / in ; ----------------------------------------------------------------------------- L0001 equ $0001 ; flags ; ; xxxxxxx1 - Stop IAC 250ms periods (initial) ; ; xxxxxx1x - water over 60 degrees or ; ; motor over 5000 RPM (IAC flags) ; ; xxxxx1xx - computed Idle Air at max limit ; ; xxxx1xxx - computed Idle Air at min limit ; ; xxx1xxxx - TPS - Throttle plates Not closed ; ; x1xxxxxx - WOT throttle ! ; ; 1xxxxxxx - Partial throttle only. Not closed ; ; or WOT. ; ----------------------------------------------------------------------------- ; Air = (ECU_Air * 1.2375) - 103.0 ; ; Note: These adjusted numbers seem to be about 2 degrees too high for ; how the controller reports the Air Temperature. I have noticed ; that on a cold start the Air always seems higher than the water ; when you would think they would have stablized to the same..... ; L0002 equ $0002 ; TAIR - Air Temperature (Not ADC reading) ; ; Temp Res Vadc ADC ADC L0002 Ajusted ; -40 93000 4.18 214 D6 56 38 ; -20 45000 4.06 208 D0 71 47 ; 0 24200 3.87 198 C6 85 55 ; 20 12850 3.57 183 B7 101 65 ; 40 7130 3.15 161 A1 138 8A ; 50 5736 2.97 152 98 124 7C ; 60 4182 2.69 138 8A 133 85 ; 70 3207 2.44 125 7D 142 8E ; 80 2543 2.22 114 72 149 95 ; 90 1957 1.98 101 65 158 9E ; 100 1577 1.79 92 5C 165 A5 ; 110 1260 1.60 82 52 174 AE ; 120 1028 1.45 74 4A 182 B6 ; 130 814 1.29 66 42 190 BE ; 140 666 1.18 60 3C 199 C7 ; 150 557 1.08 55 37 207 CF ; 160 445 0.98 50 32 215 D7 ; 170 366 0.90 46 2E 223 DF ; 180 317 0.85 44 2C 228 E4 ; 185 289 0.83 42 2A 232 E8 ; 189 260 0.80 41 29 235 EB ; 193 248 0.78 40 28 237 ED ; 200 230 0.76 39 27 239 EF ; 203 206 0.74 38 26 242 F2 ; 220 162 0.69 35 23 249 F9 ; 248 106 0.63 32 20 255 FF ; 284 64 0.58 30 1E 255 FF ; ; All ADC values lower than $21 are $Ff (255) ; All ADC values higher than $DA are $00 (00) ; ; ----------------------------------------------------------------------------- ; TH20 = (ECU_TH20 * 1.35) - 67.0 ; L0003 equ $0003 ; TH2O - Water Temperature (Not ADC reading) ; ; Temp Res Vadc ADC ADC L0003 Ajusted ; -40 93000 4.18 214 D6 21 15 ; -20 45000 4.06 208 D0 38 26 ; 0 24200 3.87 198 C6 50 32 ; 20 12850 3.57 183 B7 66 42 ; 40 7130 3.15 161 A1 82 52 ; 50 5736 2.97 152 98 87 57 ; 60 4182 2.69 138 8A 95 5F ; 70 3207 2.44 125 7D 102 66 ; 80 2543 2.22 114 72 109 6D ; 90 1957 1.98 101 65 118 76 ; 100 1577 1.79 92 5C 124 7C ; 110 1260 1.60 82 52 132 84 ; 120 1028 1.45 74 4A 139 8B ; 130 814 1.29 66 42 147 93 ; 140 666 1.18 60 3C 154 9A ; 150 557 1.08 55 37 162 A2 ; 160 445 0.98 50 32 169 A9 ; 170 366 0.90 46 2E 177 B1 ; 180 317 0.85 44 2C 181 B5 ; 185 289 0.83 42 2A 187 BB ; 189 260 0.80 41 29 190 BE ; 193 248 0.78 40 28 193 C1 ; 200 230 0.76 39 27 197 C5 ; 203 206 0.74 38 26 200 C8 ; 220 162 0.69 35 23 214 D6 ; 248 106 0.63 32 20 235 EB ; 284 64 0.58 30 1E 246 F6 ; ; All ADC values lower than $20 are $F6 (246) ; All ADC values higher than $DA are $00 (00) ; -------------------------------------------------------- ; Upper four bits of L0003 when used as index. ; ; Temp L0003 ; < -40 00 0000 0000 ; < -40 16 0001 0000 ; -27 32 0010 0000 ; - 3 48 0011 0000 ; 18 64 0100 0000 ; 38 80 0101 0000 ; 61 96 0110 0000 ; 83 112 0111 0000 ; 105 128 1000 0000 ; 126 144 1001 0000 ; 148 160 1010 0000 ; 169 176 1011 0000 ; 192 192 1100 0000 ; 212 208 1101 0000 ; 233 224 1110 0000 ; 264 240 1111 0000 ; ; ----------------------------------------------------------------------------- L0004w equ $0004 ; Fuel requirement work stash and used by IAS L0005w equ $0005 ; work stash L0006w equ $0006 ; work stash L0007w equ $0007 ; work stash ; ----------------------------------------------------------------------------- ; This stash is an altitude compression correction factor that is applied to the ; MAP ADC value. The initial call to Ldc0e: at key on checks how high we are ; and computes an altitude compression correction factor in L0008. It looks ; like a minimum elevation of around 1500 feet is needed before anything ; starts happening. At 8000' or so a maximum of about 1" of correction is ; applied. ; ; ADC Aprox ; Entry MAP L0008 ; 000 - 173 29" - 8" > 8000' 6 ; 174 - 183 8" - 6.5" 6500'-8000' 5 ; 184 - 193 6.5" - 5" 5000'-6500' 4 ; 194 - 203 5" - 4" 4000'-5000' 3 ; 204 - 213 4" - 3" 3000'-4000' 2 ; 214 - 223 3" - 1.5" 1500'-3000' 1 ; 224 - 255 1.5" - 0" 0000'-1500' 0 ; L0008 equ $0008 ; MAP offset value ; ----------------------------------------------------------------------------- ; Battery correction value (Adjusted ADC reading) ; L0009 equ $0009 ; ----------------------------------------------------------------------------- ; Battery = (ECU_Batt_ADC * .0625) = ADC / 16 ; ADC = Battery * 16 ; L000a equ $000a ; BATT - Battery Voltage (in ADC counts) ; ; Battery ADC (ADC-95)*1.5 ; 16.0 255 240 ; 15.375 246 226 ; 15.0 240 217 ; 14.0 224 223 ; 13.0 208 169 ; 12.0 192 145 ; 11.0 176 121 ; 10.0 160 97 ; 9.0 144 73 ; 8.0 128 49 ; 7.0 112 25 ; 6.0 96 0 ; ; ----------------------------------------------------------------------------- L000bw equ $000b ; general usage local work stash L000cw equ $000c ; \ L000dw equ $000d ; \ L000ew equ $000e ; \ L000fw equ $000f ; \ L0011w equ $0011 ; \ L0012w equ $0012 ; \ L0013w equ $0013 ; \ ; ---------------------------------------------------------------------------- L0014 equ $0014 ; This is the lowest MAP ADC reading (highest ; ; vacuum) ever detected this session. It is ; ; fed by the MAP average stash L002a. ; ; It only gets set under extreme conditions, ; ; like over 7324 rpm and extreme hi vacuum.... ; ---------------------------------------------------------------------------- L0015 equ $0015 ; revolution counter for ????? ; Only get bumped in the Dist Trigger Handler ; Always counts down to zero. Once it hits zero ; it will not roll back to 255. Each count is ; one motor revolution (4 ignition events). ; It also looks like once the motor is running ; this counter is never re-seeded.. ; L0016 equ $0016 ; counter for ????? ; ; Will only count to zero and stop. ; ; Only bumped by Dist Trigger handler ; L0017 equ $0017 ; RPM (timing_period/16) vs TH20 for dashpot ; ; threshold tests L0018 equ $0018 ; RPM (timing_period/16) vs TH2O for potential ; ; fuel cutoff during deceleration that starts ; ; above this RPM. L0019 equ $0019 ; TH2O adjusted Transient Fuel Modifier L001a equ $001a ; TH2O adjusted Cold Start Fuel Modifier L001bw equ $001b ; work stash ; ------------------------------- L001c equ $001c ; TPS closed threshold ADC value. This value ; ; is initially set to ADC 53 but is adjusted ; ; down to where the TPS actually is by L001d. ; ----------------------------------------------------------------------------- ; This stash is a running value of the lowest TPS ADC reading ever read. It ; converges to the lowest value at a max rate of two ADC counts per itteration. ; Lf48c sets how fast it can increase and Lf48b sets how fast it can decrease. ; Its only purpose is to give us a real time throttle plates closed ADC value ; to keep L001c (the stash that gets compared) updated. ; L001d equ $001d ; lowest TPS ADC reading (throttle closed) ; ----------------------------------------------------------------------------- L001e equ $001e ; Another last ADC TPS reading. This stash ; ; is another last TPS ADC reading. ; ------------------------------- mis39: L001f equ $001f ; Some kind of counter that never gets used ; ; because it is seed with a zero and never can ; ; go below zero ;-------------------------------- mis38: L0020 equ $0020 ; Whatever this is supposed to do it actually ; ; does nothing. Only zero ever gets loaded ; ; into it. ; ----------------------------------------------------------------------------- L0021 equ $0021 ; counter - .131ms tics ; ; Only increase the lowest TPS ADC stash (L001d) ; ; every 8 seconds and this is the counter. ; ----------------------------------------------------------------------------- ; TPS(degrees) = (ECU_TPS * .4519) - 7.0 ; L0022 equ $0022 ; Current TPS ADC reading. This stash is always ; ; the last ADC reading taken. ; ----------------------------------------------------------------------------- L0023 equ $0023 ; MAT ADC reading L0024 equ $0024 ; COOL ADC Reading ; ; ; ; Temp Res Vadc ADC ; ; -40 93000 4.18 214 ; ; -20 45000 4.06 208 ; ; 0 24200 3.87 198 ; ; 20 12850 3.57 183 ; ; 40 7130 3.15 161 ; ; 50 5736 2.97 152 ; ; 60 4182 2.69 138 ; ; 70 3207 2.44 125 ; ; 80 2543 2.22 114 ; ; 90 1957 1.98 101 ; ; 100 1577 1.79 92 ; ; 110 1260 1.60 82 ; ; 120 1028 1.45 74 ; ; 130 814 1.29 66 ; ; 140 666 1.18 60 ; ; 150 557 1.08 55 ; ; 160 445 0.98 50 ; ; 170 366 0.90 46 ; ; 180 317 0.85 44 ; ; 185 289 0.83 42 ; ; 189 260 0.80 41 ; ; 193 248 0.78 40 ; ; 200 230 0.76 39 ; ; 203 206 0.74 38 ; ; 220 162 0.69 35 ; ; 248 106 0.63 32 ; ; 284 64 0.58 30 ; ; ----------------------------------------------------------------------------- ; Fuel(ms) = (ECU_Fuel * .004) ; L0025 equ $0025 ; Injector Pulse Width (4us / count) hi byte L0026 equ $0026 ; ...... lo byte ; ---------------------------------------------------------------------------- ; ; SPK(degrees) = (ECU_Spk * .25) + 10.0 ; L0027 equ $0027 ; Spark Angle (.25 degrees / count) ; ---------------------------------------------------------------------------- L0028 equ $0028 ; calculated optimum injector timing group L0029 equ $0029 ; what injector phase group we are in ; 12 - 450 degrees BTDC ; 8 - 540 degrees BTDC ; 4 - 630 degrees BTDC ; 0 - 720 degrees BTDC ; L002a equ $002a ; average of the last two MAP ADC readings ; ; ; The following four locations are used to store the averaged MAP ADC readings ; per cylinder pair. The Distributor Trigger handler stores and uses these ; for ??????? ; L002b equ $002b ; averaged MAP ADC for cylinders 1,8 L002c equ $002c ; 4,3 L002d equ $002d ; 6,5 L002e equ $002e ; 7,2 ; ------------------------------------------------------------------------------ L002f equ $002f ; MAP ADC stash ; This one used in the Calibration routine and ; the Dist Trigger handler (#8 #3 #5 #2) event. ; L0030 equ $0030 ; another MAP ADC reading stash ; This one is only used in the Dist Trigger ; handler on the #1 #4 #6 #7 firing event. ; ; This counter gets bumped each (most) time the main timer overflows. It is ; reset by the distributor trigger interrupt handler though... ; L0031 equ $0031 ; Main timer overflow count (every 131ms) ; L0032 equ $0032 ; Ign Trigger Timing Stash - timer count ; ; timer count when trigger got there L0034 equ $0034 ; Ign Tigger - last tic-timer count L0036 equ $0036 ; This is the period of time when the output ; ; from the distributor was high L0038 equ $0038 ; Not Used ????? L003a equ $003a ; accumulator used during shutter detect ; ---------------------------------------------------------------------------- ; L003c and L003e and L0040 are timing periods in 8us units. ; ; L003e is the current timing period we just processed.... ; L003c is the previous timing period processed... ; L0040 is the predicted next timing period... ; ; ; Timing_Period = ECU_x * 8us or ECU_x / 125000 ; ; RPM = 1,875,000 / ECU_x ; ; 1,875,000 comes from.... 125,000 / events_per_rev (dist one-half engine) ; time 60 (Revs per minute) ; 1,875,000 = (125,000 / 4) * 60 ; L003c equ $003c ; Previous timing period (in 8us units). This ; ; one will not get reset to zero if a restart ; ; occures ; L003e equ $003e ; Current Timing period (in 8us units) ; ; (cleared at re-start) ; ------------------------------- ; If we take the current timing pulse minus the period that occured two ; pulses back plus the last one we can predict what the next one may be. ; ; L0040 = (t) - (t-2) + (t-1) ; ; If the motor was decelerating and the last three pulses were: .018 .019 .020 ; then (.020) - (.018) + (.019) = .021 - predicted next timing pulse width ; L0040 equ $0040 ; Predicted next timing period ; ; (cleared at re-start) ; ------------------------------- ; ; RPM = (1/Pulse_Width) * 15 ; Pulse_Width = 1 / (RPM/15) ; Timing_period = Pulse_Width / .000008 ; L0042 = Timing_period / 16 = Pulse_Width / .000128 ; RPM = ( 1/(L0042 * .000128) ) * 15 ; ; What the controller has to do to display RPM...... ; ; RPM = (187500 / ECU_RPM) * 10 ; From ECU Displayed RPM ; 493E (18750) 100 ; 0EA6 (3750) 500 ; 0753 (1875) 1000 ; 0271 (625) 3000 ; 0138 (312) 6009 ; 010C (268) 6996 ; 00EA (234) 8010 ; ; It looks like the ECU is transmitting the timing period times 125,000. ; At 1000 rpm, 16.666 revs / sec, 4 firings per rev so firing at 66.666 hertz, ; which has a period of .015 sec, so .015 * 125,000 = 1,875 ; ----------------------------------------------------------------------------- ; This value is the timing period divided by 16. It has the same scale as ; the target idle stash at L0061. The 11,718.75 at L0061 is 187,500 / 16 ; L0042 equ $0042 ; this is the ignition timing period * 16 / 256 ; ----------------------------------------------------------------------------- ; This value is either the high byte of the current timing period if bit ; xxx1xxxx of L0059 is set or a value that slowly approaches it if the ; bit is cleared. If the bit is set we are at or above 610 RPM. ; L0043 equ $0043 ; ; 2100 00100001 222 rpm ; 2000 00100000 229 rpm ; 1F00 00011111 236 rpm ; 1E00 00011110 244 ; 1D00 00011101 253 ; 1C00 00011100 262 ; 1B00 00011011 271 ; 1A00 00011010 282 ; 1900 00011001 293 ; 1800 00011000 305 ; 1700 00010111 318 ; 1600 00010110 333 ; 1500 00010101 349 ; 1400 00010100 366 ; 1300 00010011 385 ; 1200 00010010 407 ; 1100 00010001 431 rpm ; 1000 00010000 458 rpm ; 0F00 00001111 488 rpm ; ; 1E00 244 rpm 0D00 563 rpm ; 1D00 253 rpm 0C00 610 rpm ; 1C00 262 rpm 0B00 666 rpm ; ----------------------------------------------------------------------------- L0044 equ $0044 ; This stash indicates which cylinder is firing. ; If bit 0 clear do Not fire injector this timing event. ; The #1 shutter detector will set this value after ; it is sure that it got #1 shutter followed ; immediately by a normal duty-cycle (#8) it will ; then set this sequencer to 2. This means that ; when L0044=2 we just hit TDC #8. ; ; 0000 #2 ; 0001 #1 ; 0010 #8 ; 0011 #4 ; 0100 #3 ; 0101 #6 ; 0110 #5 ; 0111 #7 ; ---------------------------------------------------------------------------- L0045 equ $0045 ; looks to be the pointer to fire an injector pair ; ; 0 - 1,8 ; ; 2 - 4,3 ; ; 4 - 6,5 ; ; 6 - 7,2 ; ; ; ------------------------ ; When changing the injector timing we will actually fire two sets (four ; injectors) of injectors during one ignition trigger event. This is done ; to ease the transition period while changing timing. If we just changed ; the timing a couple of cylinder would get no fuel when they needed it. ; The pulse widht needed during this transition is put into the the below ; 16 bit stash... ; L0046 equ $0046 ; extra pulse width needed when changing injector ; L0048 equ $0048 ; new injector pulse width L004aw equ $004a ; works stash in Dist Trigger and IGN Amp handlers L004bw equ $004b ; work stash ; L004c equ $004c ; This fuel is used during the transition period when ; ; the injector timing need to change. It is derived ; ; from the regular pulse width but the MAP ADC is ; ; factored into it. If the MAP ADC was 128 it would ; ; be the same value as what is in L0048, but as vacuum ; ; goes up (>>>29") and the ADC goes down this value ; ; increases..... ; ; Centered arround 13" then ?????? ; ;------------------------------------------------------------------------------ ; The two stashs below and the two counters below them, look to be used by the ; Dist Trigger handler in calculating magnitude of change (MAP ADC changes) ; and decay rates for transient fuel responses. Both L004e and L004f are ; initially seeded with a percentage of delta MAP (56% of ADC change), then ; when the L0050 counter hits zero (12 trigger events) start reducing it ; at a TH2O determined rate. When the L0051 counts down (6 ignition events) ; start reducing L004f at a constant rate (19% of its current value). These ; two stashs are then summed together and used to determine along with ; the user deterimined transient fuel modifier how much extra fuel is needed. ; L0052 and L0054 are later used in these calculations. ; L004e equ $004e L004f equ $004f ; L0050 equ $0050 ; L004e decay rate counter L0051 equ $0051 ; L004f decay rate counter ; L0052 equ $0052 ; how much and what direction we changed Pulse Width L0054w equ $0054 ; just a work stash for transient fuel calculations ; ----------------------------------------------------------------------------- L0056 equ $0056 ; flags ; xxxx1xxx - Turning Slower than Idle Target RPM ; xxxx0xxx - Turning Faster than Idle Target RPM ; xxxxx1xx - Turning Faster than 5,500 RPM ; xxxxx0xx - Turning Slower than 5,500 RPM ; xxxxxx1x - Last Pulse Width was made longer or No ; change last ignition event. ; xxxxxxx1 - Throttle closed and MAP ADC is decreasing ; Vacuum is increasing. ; ----------------------------------------------------------------------------- L0057 equ $0057 ; Last TPS ADC reading. This stash is the last ADC ; reading taken. It its loaded from L0022 before ; L0022 is updated with the new ADC reading. ; ----------------------------------------------------------------------------- L0058 equ $0058 ; flags ; 1xxxxxxx - Hard to tell what this was supposed to do ; because of mistakes. TPS set/clr'd. ; mis38: mis47: ; x1xxxxxx - This be gets set the first time we make it ; all the way thru the calibration routine. ; It is cleared when then initialization ; code is run. ; xx1xxxxx - To set this bit we need to be: ; RPM above fuel cutoff, throttle plates ; closed and counter(L0016) = zero. ; - or - ; Faster than 7,324 and under No Load ; condition and counter(L0016) = zero. ; - or - ; In a high speed high vacuum condition. ; ; xxx1xxxx - To set this bit we need to be: ; Not in high speed high vacuum situation ; - and - ; RPM above fuel cutoff threshold and ; throttle closed ; - or - ; Faster than 7,324 rpm and under no load ; ; When this bit gets set the counter at ; L0016 is seeded (6) ; ; xxxx1xxx - To set this bit we need to be: ; Slower than dashpot rpm or partial/WOT ; condition ; - and - ; slower than 3,662 rpm or under some Load. ; ; xxxxx1xx - This bit gets toggled every time we run ; thru the Calibration loop. ; Useless because it is never tested. mis55: ; xxxxxx1x - Water is hot or over 3 min running. ; xxxxxxx1 - We have a current MAP ADC reading. ; This be only gets set every other Dist ; trigger event. The Calibration loop will ; wait till it gets a new MAP ADC reading. ; This bit holds the Calibration loop. ; ----------------------------------------------------------------------------- L0059 equ $0059 ; ; xxxxxxx1 - Engine operating parms requested ; xxxxxx1x - Used during IAC motor activity computaions. ; Can't tell exactly what it does because ; it always gets set. Looks to be sign flag ; xxxxx1xx - Signal 8x8 cell lookup table matrix ; xxxxx0xx - Signal 8x16 cell matrix ; xxxx1xxx - Signal Load (MAP) out of bounds ; xxx1xxxx - When set timing period accumulator (L0043) ; is updated directly by the hi-byte of the ; current timing period. When set we are ; at or above 610 RPM. ; xx1xxxxx - RPM is past Rev Limit set +500 rpm. ; Motor is being shut down NOW ! ; x1xxxxxx - During the Fuel requirement calculations ; we got an overflow. ; ----------------------------------------------------------------------------- L005a equ $005a ; this byte is used to determine when an injector pair ; is to be fired. It is used for injector timing. ;------------------------------------------------------------------------------ L005b equ $005b ; flags ; 1xxxxxxx - Gets set when we have a completed Dist ; Trigger period - Not used ??? ; x1xxxxxx - A Dist Trigger interrupt has occured after ; after intialiaztion. Got the TCNT count ; when this happened into L0032. ; xx1xxxxx - Signals we drove the SA output line low ; firing the Coil. ; xxx1xxxx - The first time we get the #2-#1-#8 sequence ; immediately sync the injector timing. We ; the set this bit. From that point on it ; will take another confirmed sequence to ; bring us into sync again. ; xxxx1xxx - Signals firing order sequencer is in sync. ; If not wait for next #2-#1-#8 sequence ; to come along before bringing sequencer ; into sync again. ; xxxxx1xx - Above 4,500 RPM ; xxxxxx1x - Signals that we have confirmed the #1 ; shutter. ; xxxxxxx1 - Signals that we have confirmed a non #1 ; shutter. ; ----------------------------------------------------------------------------- L005c equ $005c ; flags ; 1xxxxxxx - Signals dashpot is zero. NEVER gets ; cleared anywhere. mis41: ; x1xxxxxx - Set by timer overflow when dashpot ; counter has changed But NEVER cleared ; anywhere. mis40: ; xx1xxxxx - Dashpot modification of idle rpm is in ; operation. ; xxx1xxxx - Throttle closed and RPM is below dashpot ; trip point. Signal to continue dashpot ; till countdown or throttle opened. ; xxxx1xxx - Set if IAS saw that motor was slowing ; down. Will only get reset when throttle ; is opened again.. ; xxxxx1xx - IAS acknowledged motor slowing down. Will ; only get reset when throttle plates are ; opened again. ; xxxxxx1x - Allow min IAS counter to tic ; xxxxxxx1 - Idle activity counter in L0072 has rolled ; thru zero. ; ----------------------------------------------------------------------------- L005d equ $005d ; flag byte ; xxxxxxx0 - Pulse Width < $8000 (65ms) ; xxxxxxx1 - Pulse Width > $8000 ; xxxxxx1x - Only could have been set or cleared in a ; section of code that never gets executed. ; See below.... ; xxxxx1xx - This bit gets set when the first valid ; Dist Trigger came in. The only place it ; can get cleared is in a section of code ; that never gets executed (mis21). It looked ; like it could have been part of the ; revolution counter stuff. ; xxxx1xxx - Timer has Overflowed - NEVER USED ; xxx1xxxx - EEPROM progaming in effect now ; xx1xxxxx - EEPROM erase/prgm operation active ; x1xxxxxx - EEPROM erase/prgm timer active ; ----------------------------------------------------------------------------- L005e equ $005e ; Mixture flag (LED control) ; 0xxxxxxx - Open Loop conditions ; 1xxxxxxx - Closed Loop operations ; x1xxxxxx - Only One LED is on ; x0xxxxxx - Both LED's are On or Off ; xx1xxxxx - Water Temp under 120 degrees ; xx0xxxxx - Water Temp over 120/140 degrees ; xxx1xxxx - Air Temp Above 248 degrees ; xxx0xxxx - Air Temp below 248 degrees ; xxxx0xxx - Red LED On (lean) ; xxxx1xxx - Green LED On (rich) ; xxxxx1xx - Dist Trigger handler knows mixture is Rich. ; xxxxx0xx - Dist Trigger handler knows mixture is Lean. ; xxxxxxx1 - Outside RPM range for closed loop operation ; xxxxxxx0 - Inside closed loop RPM range ; ----------------------------------------------------------------------------- L005f equ $005f ; flags - All of these bits (except bit 7) gets cleared ; every (most?) the Calibration routine runs ; thru. They also get set there. ; 1xxxxxxx - To get this set the motor had to be turning ; faster than 7,324 rpm and with highest ; vacuum (>>>29") we have ever seen before. ; Like we were really screaming and let off ; the gas ! ; This is the only bit that gets set by ; another routine (Dist Trig) than the ; Calibration loop. ; x1xxxxxx - RPM above TH2O set trip RPM. If ; deceleration starts above this RPM the ; fuel is shut off. ; xx1xxxxx - Slower than TH2O set dashpot RPM ; xxx1xxxx - Motor turning faster than 7,324 rpm ; xxxx1xxx - Slower than 3,662 rpm ; xxxxx1xx - We are under some Load ; xxxxxx1x - We are under no/light Load ; xxxxxxx1 - In high speed high vacuum condition. ; This bit gets set by the Calibration loop ; when the 1xxxxxxx bit is set. ; ----------------------------------------------------------------------------- L0060 equ $60 ; Fuel pump and PAL-44 (and what else) control ; ; x1xxxxxx - turn on PAL-44 ; ; xx1xxxxx - turn on Fuel Pump PAL-43 ; ; ----------------------------------------------------------------------------- ; Target Idle RPM = (11,718.75 / ECU_Target) * 10.0 ; Note: Look at L0042 for scaling information... ; Remember, Bigger number lower rpm ; L0061 equ $0061 ; Target Idle RPM ; ; 0 52 2254 104 1127 156 751 208 563 ; 1 117188 53 2211 105 1116 157 746 209 561 ; 2 58594 54 2170 106 1106 158 742 210 558 ; 3 39063 55 2131 107 1095 159 737 211 555 ; 4 29297 56 2093 108 1085 160 732 212 553 ; 5 23438 57 2056 109 1075 161 728 213 550 ; 6 19531 58 2020 110 1065 162 723 214 548 ; 7 16741 59 1986 111 1056 163 719 215 545 ; 8 14648 60 1953 112 1046 164 715 216 543 ; 9 13021 61 1921 113 1037 165 710 217 540 ; 10 11719 62 1890 114 1028 166 706 218 538 ; 11 10653 63 1860 115 1019 167 702 219 535 ; 12 9766 64 1831 116 1010 168 698 220 533 ; 13 9014 65 1803 117 1002 169 693 221 530 ; 14 8371 66 1776 118 993 170 689 222 528 ; 15 7813 67 1749 119 985 171 685 223 526 ; 16 7324 68 1723 120 977 172 681 224 523 ; 17 6893 69 1698 121 968 173 677 225 521 ; 18 6510 70 1674 122 961 174 673 226 519 ; 19 6168 71 1651 123 953 175 670 227 516 ; 20 5859 72 1628 124 945 176 666 228 514 ; 21 5580 73 1605 125 938 177 662 229 512 ; 22 5327 74 1584 126 930 178 658 230 510 ; 23 5095 75 1563 127 923 179 655 231 507 ; 24 4883 76 1542 128 916 180 651 232 505 ; 25 4688 77 1522 129 908 181 647 233 503 ; 26 4507 78 1502 130 901 182 644 234 501 ; 27 4340 79 1483 131 895 183 640 235 499 ; 28 4185 80 1465 132 888 184 637 236 497 ; 29 4041 81 1447 133 881 185 633 237 494 ; 30 3906 82 1429 134 875 186 630 238 492 ; 31 3780 83 1412 135 868 187 627 239 490 ; 32 3662 84 1395 136 862 188 623 240 488 ; 33 3551 85 1379 137 855 189 620 241 486 ; 34 3447 86 1363 138 849 190 617 242 484 ; 35 3348 87 1347 139 843 191 614 243 482 ; 36 3255 88 1332 140 837 192 610 244 480 ; 37 3167 89 1317 141 831 193 607 245 478 ; 38 3084 90 1302 142 825 194 604 246 476 ; 39 3005 91 1288 143 819 195 601 247 474 ; 40 2930 92 1274 144 814 196 598 248 473 ; 41 2858 93 1260 145 808 197 595 249 471 ; 42 2790 94 1247 146 803 198 592 250 469 ; 43 2725 95 1234 147 797 199 589 251 467 ; 44 2663 96 1221 148 792 200 586 252 465 ; 45 2604 97 1208 149 786 201 583 253 463 ; 46 2548 98 1196 150 781 202 580 254 461 ; 47 2493 99 1184 151 776 203 577 255 460 ; 48 2441 100 1172 152 771 204 574 ; 49 2392 101 1160 153 766 205 572 ; 50 2344 102 1149 154 761 206 569 ; 51 2298 103 1138 155 756 207 566 ; ; ----------------------------------------------------------------------------- L0062 equ $0062 ; an accumulator used in IAS calculations L0064 equ $0064 ; always zero because of mis14a: ; ----------------------------------------------------------------------------- ; All of these values are in 1Mhz (1us) units. They are divided by 2 in the ; IAC motor interrupt handler before being added to the timer's counter ; register which is being updated at the tic-count rate of 500 KHz (2us). ; A number like 6666 is .006666 seconds, 6.666ms ; L0066 equ $0066 ; New IAC motor On time L0068 equ $0068 ; New IAC total period L006a equ $006a ; last IAC motor On time. L006c equ $006c ; last IAC total period stash ; ----------------------------------------------------------------------------- L006e equ $006e ; This is the electronic dashpot counter ; ; Other than seeding and clearing, the only ; ; place it is bumped is by the timer overflow ; ; handler (at a max 131ms rate). L0070 equ $0070 ; last min IAS% requirement L0071 equ $0071 ; min IAS% required for a particular rpm L0072 equ $0072 ; up counter used in idle activity. Max rate ; ; of change is 131ms from timer overflow. L0073 equ $0073 ; counter that never gets used !!!!! mis44: L0074 equ $0074 ; O2 Sensor ADC reading L0075 equ $0075 ; How much to change the injectors pulse width ; during closed loop operation. ; ----------------------------------------------------------------------------- ; this timer is usless because when true the number that gets multiplied by 16 ; is then it is divided by 16 ???? mis26: L0076 equ $0076 ; when counts down zero would have allowed ; ; the closed loop rate of change value to be ; ; further adjusted. (X*16)/16 ; ----------------------------------------------------------------------------- ; This counter is used to determine if we have an O2 sensor error. If both ; LED are on for more than 255 iterations and we have been running more than ; one minute and closed loop fuel is on then signal an error... ; L0077 equ $0077 ; O2 sensor error counter ; ----------------------------------------------------------------------------- L0078 equ $0078 ; delay counter before Closed Loop is activate ; L0079 equ $0079 ; This value is a scaled accumulated amount that ; ; is added/subtracted from the injectors PW. It ; ; accumulates how much the mixture needs to ; ; change. This value is limited to +-16,000 ; ; A negative value will increase the Fuel PW. ; L007b equ $007b ; As long as this counter is Not zero a new rate ; ; of change value is calculated. Every time ; ; we get a rich/lean state change it goes to ; ; zero ; L007c equ $007c ; Warmup timer. If the water is below 120 deg ; ; at startup this timer starts counting. ; ; It is used in determining when we can go ; ; closed loop and believe the O2 sensor. ; ; When the water then gets over 140 degrees ; ; it is pushed to the max count ($ffff). ; ; Set only in the timer overflow handler. ; ; Note: Once this counter hits $ffff it will ; ; stay there forever. ; ; L007e equ $007e ; How much time to add or subtract from the ; ; injector pulse width to lean/richen the ; ; mixture. It is returned from the Calibration ; ; routine and is added/subtracted from the ; ; PW during each ignition event. ; ; ----------------------------------------------------------------------------- L007f equ $007f ; Commands to Save and Restore Datasets here ; ; If Second Byte = 06 then ; 10010001 91 - Save dataset 'A' ; 10010010 92 - Save dataset 'B' ; 10010011 93 - Save dataset 'C' ; 10100000 A0 - Restore Base dataset ; 10100001 A1 - Restore 'A' dataset ; 10100010 A2 - Restore 'B' dataset ; 10100011 A3 - Restore 'C' dataset ; ; If Second byte = 05 then ; return success(zr) or fail code(nz) ; 10010001 91 - Saving dataset 'A' ? ; 10010010 92 - Saving dataset 'B' ? ; 10010011 93 - Saving dataset 'C' ? ; 10100000 A0 - Restoring Base dataset ? ; 10100001 A1 - Restoring 'A' dataset ? ; 10100010 A2 - Restoring 'B' dataset ? ; 10100011 A3 - Restoring 'C' dataset ? ; ; If an error occured this location gets set to the following. This is what ; goes back to the controller signaling success or failure..... ; ; 01000000 40 - Checksum or command structure error occured ; Operation not completed. ; 00000000 00 - Save / Restore operation completed to Success ; ; ---------------------------------------------------------------------------- ; The current modifier table is stored here. Normally the Dataset 'A' at ; EEPROM $b600 is loaded. If it is bad then load from ROM at $f740 into ; this location. Dataset 'B' and 'C' can also be loaded into this list. ; ; All the values between $0080 thru $0097 are the Fuel Modifiers. Each is ; adjustable between +50% and -30% That means their range is from 90 to ; 192. The scaling factor of .78125 comes from (Max_Percentage / 64). ; ; NOTE: This address must stay the same (or atleast be on a boundry) to ; allow the EEPROM programing to work correctly.... ; L0080 equ $0080 ; - Fuel @ WOT @ 1000 RPM L0081 equ $0081 ; - Fuel @ WOT @ 2000 RPM L0082 equ $0082 ; - Fuel @ WOT @ 3000 RPM L0083 equ $0083 ; - Fuel @ WOT @ 4000 RPM L0084 equ $0084 ; - Fuel @ WOT @ 5000 RPM L0085 equ $0085 ; - Fuel @ WOT @ 7000 RPM ; ; L0086 equ $0086 ; - Fuel @ 06" @ 1000 RPM L0087 equ $0087 ; - Fuel @ 06" @ 2000 RPM L0088 equ $0088 ; - Fuel @ 06" @ 3000 RPM L0089 equ $0089 ; - Fuel @ 06" @ 4000 RPM L008a equ $008A ; - Fuel @ 06" @ 5000 RPM L008b equ $008B ; - Fuel @ 06" @ 7000 RPM ; ; L008c equ $008C ; - Fuel @ 12" @ 1000 RPM L008d equ $008D ; - Fuel @ 12" @ 2000 RPM L008e equ $008E ; - Fuel @ 12" @ 3000 RPM L008f equ $008F ; - Fuel @ 12" @ 4000 RPM L0090 equ $0090 ; - Fuel @ 12" @ 5000 RPM L0091 equ $0091 ; - Fuel @ 12" @ 7000 RPM ; ; L0092 equ $0092 ; - Fuel @ 18" @ 1000 RPM L0093 equ $0093 ; - Fuel @ 18" @ 2000 RPM L0094 equ $0094 ; - Fuel @ 18" @ 3000 RPM L0095 equ $0095 ; - Fuel @ 18" @ 4000 RPM L0096 equ $0096 ; - Fuel @ 18" @ 5000 RPM L0097 equ $0097 ; - Fuel @ 18" @ 7000 RPM ; ; The following are the Spark Modifiers. They occupy the ram space between ; $0098 and $00AE. All Spark modifiers are +8 degrees / -16 degrees. ; Each value is weighted by .25 degrees. The controller changes them with ; a stepsize of 4 counts which represents 1 degree change. A count of 128 ; equals a zero degree modifier. 160 = +8 degrees 64 = -16 degrees ; L0098 equ $0098 ; - Sprk @ WOT @ 1000 RPM L0099 equ $0099 ; - Sprk @ WOT @ 1750 RPM L009A equ $009A ; - Sprk @ WOT @ 2500 RPM L009B equ $009B ; - Sprk @ WOT @ 3500 RPM L009C equ $009C ; - Sprk @ WOT @ 4500 RPM L009D equ $009D ; - Sprk @ WOT @ 6000 RPM L009E equ $009E ; - Sprk @ 09" @ 1000 RPM L009F equ $009F ; - Sprk @ 09" @ 1750 RPM L00A0 equ $00A0 ; - Sprk @ 09" @ 2500 RPM L00A1 equ $00A1 ; - Sprk @ 09" @ 3500 RPM L00A2 equ $00A2 ; - Sprk @ 09" @ 4500 RPM L00A3 equ $00A3 ; - Sprk @ 09" @ 6000 RPM L00A4 equ $00A4 ; - Sprk @ 18" @ 1000 RPM L00A5 equ $00A5 ; - Sprk @ 18" @ 1750 RPM L00A6 equ $00A6 ; - Sprk @ 18" @ 2500 RPM L00A7 equ $00A7 ; - Sprk @ 18" @ 3500 RPM L00A8 equ $00A8 ; - Sprk @ 18" @ 4500 RPM L00A9 equ $00A9 ; - Sprk @ 18" @ 6000 RPM ; ; L00aa equ $00aa ; Global Fuel Modifier (xx-128)*.78125 ; ; This value can range from 90 to 192 which ; ; represents -30% to +50% The scaling factor ; ; comes from 50/64 = .78125 ; ; L00ab equ $00ab ; Idle Fuel Modifier (xx-128)*.78125 +-50% ; ; This value can range from 64 to 192 which ; ; represents +-50% The scaling factor ; ; comes from 50/64=.78125 ; ; L00ac equ $00ac ; Cold Start Fuel (xx-128)*.78125 ; ; This value can range from 90 to 192 which ; ; represents -30% to +50% The scaling factor ; ; comes from 50/64 = .78125 ; ; L00ad equ $00ad ; Transient Fuel (xx-128)*.78125 ; ; This value can range from 90 to 192 which ; ; represents -30% to +50% The scaling factor ; ; comes from 50/64 = .78125 ; ; L00ae equ $00ae ; Global Spark Modifier +8 / -16 degrees ; ; Each count is .25 degrees. 160 = +8 degrees ; ; 64 = -16 degrees ; ; L00af equ $00af ; Idle Sprk modifier (xx-128)*.25=percentage ; ; Each percenatge of change is 4 counts ; ; centered arround 128. So the max 16% = 192 ; ; The min (-16%) equals 64... ; ; L00b0 equ $00b0 ; Target Idle RPM modifier - stepsize = 25 rpm ; ; Each value weight is 25 rpm. The ROM default ; ; is 134. This value is 128 biased. Each ; ; count is a +-25 rpm modification of the ; ; current idle rpm in L0061. ; ; L00b1 equ $00b1 ; Idle Speed Activity (xx-128) * .78125 ; ; This value can range from 64 to 192 which ; ; represents +-50%. The scaling factor ; ; comes from 50/64=.78125 ; ; L00b2 equ $00b2 ; Rev Limiter RPM - stepsize = 250 rpm ; ; This value times 250 equals the Rev Limit. ; ; Min=20 (5000rpm) max=38 (9500rpm) ; ; L00b3 equ $00b3 ; control flags ; ; 1xxxxxxx - Base Timing Set: On ; ; 0xxxxxxx - Base Timing Set: Off ; ; x1xxxxxx - Closed Loop Fuel: Off ; ; x0xxxxxx - Closed Loop Fuel: On ; ; xx1xxxxx - Idle Control: Off ; ; xx0xxxxx - Idle Control: On L00b4 equ $00b4 ; ???? - not modifed by controller - Spare ? L00b5 equ $00b5 ; ...... always seens to be zero - Spares ?? ; ----------------------------------------------------------------------------- L00b6 equ $00b6 ; This byte is used to point to the start of ; ; the correct EEPROM row/byte that is being ; ; erased or written to. ; ----------------------------------------------------------------------------- L00b7 equ $00b7 ; This value is the current timing period ; ; converted into RPM/25 ;------------------------------------------------------------------------------ L00b8 equ $00b8 ; current MAP ADC reading ; ----------------------------------------------------------------------------- L00b9 equ $00b9 ; Warning message flags ; ; 1xxxxxxx - MAP Sensor Error ; ; x1xxxxxx - H20 Temperature Error ; ; xx1xxxxx - Voltage Hi/Low ; ; xxx1xxxx - Throttle Input Error ; ; xxxx1xxx - AIR Temp. error ; ; xxxxx1xx - O2 Sensor error ; ----------------------------------------------------------------------------- L00ba equ $00ba ; flags - Most never tested !!!!!!!! ; cleared 01/02/99 ; 1xxxxxxx - never set here ! one test ; ; x1xxxxxx - H20 Temperature Error ; ; cleared 01/01/99 ; xxx1xxxx - MAP above 21" - never tested ; cleared 01/01/99 ; xxxx1xxx - TPS - - never tested ; cleared 01/01/99 ; xxxxx1xx - - never tested ; cleared 01/01/99 ; xxxxxx1x - - never tested ; ----------------------------------------------------------------------------- L00bb equ $00bb ; flags - NEVER USED ANYWHERE !!!!!!!!! ; ; xxxxxx1x - MAT out of range too Hot ; ; xxxxxx0x - MAT out of range too Cold ; ; xxxxx1xx - H20 out of range too Hot ; ; xxxxx0xx - H20 out of range too Cold ; ; xxxx1xxx - TPS out of range too low ; ; xxxx0xxx - TPS out of range too high ; ; 1xxxxxxx - MAP voltage too Low ; ; 0xxxxxxx - MAP voltage too High ; ; ----------------------------------------------------------------------------- ; These locations are used by the Serial handler routines and communication ; with the remote controller... ; L00bc equ $00bc ; Serial flags ; 1xxxxxxx - If this bit stays high more than ; 131ms (one timer overflow period) ; the overflow routine will clr L00bc ; x1xxxxxx - first byte (7B) received ; xx1xxxxx - data set/requested (2nd=06/05) ; xxx1xxxx - have a completed request ; xxxx1xxx - need to transmitt data to controler ; xxxxx00x - can't find where set but are tested ; xxxxx001 - allow engine status data to be ; sent to the controller. ; ; --------------------------------------------- L00bd equ $00bd ; number of bytes sent/received L00be equ $00be ; index into the Serial Buffer L00c0 equ $00c0 ; start of Serial work buffer L00c1 equ $00c1 ; number of characters sent/received location L00c2 equ $00c2 ; either adddress or data start ; ----------------------------------------------------------------------------- L00fb equ $00fb ; This location has some testmode only meaning ; ; It has something to do with the Ignition Coil ; ; driver mode. What it could do sitting in ; ; the middle of the stack makes no sense. ; ============================================================================= ; timer_tcnt_reg equ $100e ; TCNT - Timer Count toc1_data_reg equ $1016 ; OC1 data register IAC toc2_data_reg equ $1018 ; TOC2 - Timer Output Compare 2 data register toc4_data_reg equ $101c ; TOC4 - IGN Amp data register OC4 L1020 equ $1020 ; Timer Control register 1 baud_register equ $102b ; BAUD - Baud Rate prescaler register sccr1_register equ $102c ; SCI Control register scsr_register equ $102e ; Serial SCI Status Register scdr_register equ $102f ; Serial SCI Data Register adc_control_reg equ $1030 ; ADC Control/Status Register adc_result_adr1 equ $1031 ; ADR1 ADC result register adc_result_adr3 equ $1033 ; ADR3 ADC result register adc_result_adr4 equ $1034 ; ADR4 ADC result register ; ; The whole COP thing is usless because of mis69: !!!!!!!!!!!!!!!!!!!!!!!!!! ; coprst_register equ $103a ; COPRST - COP arm/reset register ; ; Write $55 to this register to arm the COP ; ; timer, then immediately write $AA to it ; ; to clear the timer. If this sequnce isn't ; ; performed within the specified timer rate ; ; period a system reset will occure. ; cop_arm equ $55 ; to arm COP cop_reset equ $AA ; to reset the COP ; ; ----------------------------------------------------------------------------- ; This seven section invertor (L9112D) is a strange part. All of its inputs ; seem to have a 4.7k resistor to ground, so with nothing pulling it up ; that sections output will be high. One section (pins 3,4) is used to drive ; INJ-D from the 68HC11's internall timer, and another section is the serial ; interface reciever. All the others, with the exception of the one that seems ; to be monitoring the IAC motor driver transistor collector (pins 1,2), have ; some connection to the outside world thru J1. Some are pulled up and some ; pulled down either internally and/or externally. The below displayed bits ; are the defualt conditions observed. ; ; The only bit that is tested in this code is 00000100. It is tested several ; places. Noting is connected to J1-21 so it is always high. ; ; 08/29/99 - Found what J1-21 purpose is. It is an input that is connected to ; the AC to detect if it is on. If the ECU senses that an AC is on ; there is another 6.6% added to the IAC motor duty cycle to keep the; the RPM up. ; L6000 equ $6000 ; The PAL loacation reads information from ; the L9112D invertor ; xxxxxxx1 - PAL-1 L9912-15 - J1-14 ; xxxxxx0x - PAL-2 L9112-7 - J1-13 ; xxxxx1xx - PAL-3 L9112-12 - J1-21 - AC Sense ; xxxx1xxx - PAL-4 L9112-2 - IAC motor ; xxx1xxxx - PAL-5 L9112-6 - J1-16 ; ; ; ; ============================================================================= ; This is the start of the ROM......................... ; org $8000 ; L8000: fcc "Q1.3(c)WEBER'93f" ; our signature ; ; This is the main entry point. Most all interupt vectors point to here ; along with the RESET vector. ; L8010 lds #ram_base+$ff ; set the stack to top of ram sei ; set interrupt mask - mask all maskable intrpt ldx #register_base ; point to the register block bset $39,X %10101001 ; Setup the Option Regusrer 1039 ; ; 1xxxxxxx - Power up the ADC ; ; xx1xxxxx - Set IRQ to edge-sensitive operation ; ; xxxx1xxx - Clock Monitor Enabled ; ; xxxxxxx1 - Setup up COP timer to timeout.... bclr $39,X %00000010 ; .... in 65.5 ms bset $24,X %00000001 ; Set the Timer Prescaler to /4 bclr $35,X %00001111 ; Unprotect all of EEPROM (now it is writeable) bclr $3c,X %00001111 ; Setup to promote the Timer Input Capture 1... bset $3c,X %00001000 ; ... interrupt to highest priority bset $08,X %00000010 ; set PD1 (pin 21) TxD serial output high bset $09,X %00000110 ; set PD1(TxD) and PD2(???) as outputs bclr $00,X %11000000 ; IAC and INJ-D Off bclr $08,X %00000100 ; set PD2 high bset $26,X %10000000 ; configure PA7 (IAC) as an Output bset $0d,X %10000000 ; Output Compare 1 data (hi) to OC1 pin 27 - IAC ; ; Setup the external MC6840 Timer..... ; ldaa #%00100000 ; xxxxxxx0 - Control Register #3 may be written ; ; xxxxxx0x - Use External Clock Source ; ; xxxxx0xx - Use Normal 16 bit Counting Mode ; ; xx100xxx - Single Shot Mode ; ; x0xxxxxx - Mask IRQ ; ; 0xxxxxxx - Outputs Disabled (Low) ; ; staa timer_cntr_reg2 ; setup timer #2 ; ; ; With Bit 0 set to 0 the External clock ; is not prescaled (set in Cntl Reg #3) staa timer_cntr_regx ; setup timer #3 inca ; set bit 0 to select Control Register #1 staa timer_cntr_reg2 ; do it deca ; ; ; Bit0 = 0 so all timers are allowed to operate staa timer_cntr_regx ; setup timer #1 ldd #$0028 ; set pulse width to 160us staa timer_1_msb ; hi byte stab timer_1_lsb ; low staa timer_2_msb ; timer #2 next stab timer_2_lsb staa timer_3_msb stab timer_3_lsb ; ldaa #%11111111 staa $23,X ; clear Timer Interrupt Flag Register 1 staa $25,X ; and Timer Interrupt Flag 2 bclr $0c,X %11111111 ; clear output compare mask bset $0c,X %10000000 ; enable OC1 (pin 27) IAC driver bset $20,X %00001000 ; OC4 line to zero after Successful Compare ldd timer_tcnt_reg ; read the timer addd #$0014 ; plus 40 us (20 * 2 us) std toc2_data_reg ; stash in TOC2 output compare register ldaa $3c,X ; get interrupt priority value anda #%01100000 ; mask out SMOD and MDA bits cmpa #%00100000 ; are in Expanded mode now ? L807e: bne L807e ; no - some kind of test mode then ??? ldx #ram_base+$ff ; point to the top of system RAM clra ; lets preset it all to 0 L8084: staa $00,X dex ; move down ward bne L8084 ; more to do ldaa #cop_arm ; reset the COP watchdog timer staa coprst_register ldaa #cop_reset staa coprst_register ldx #eeprom_base ; point to start of EEPROM ldy #eeprom_base+$3f ; scan to checksum clrb ; clear result stash jsr Ldc78 ; compute checksum byte cmpb $00,Y ; does it checksum ? beq L80a9 ; yes ldy #Lf740 ; nope - get from ROM bra L80ad ; ; Move Data Set 'A' from EEPROM into ram.... ; L80a9: ldy #$b600 ; good checksum so get from EEPROM ; L80ad: ldx #L0080 ; put here L80b0: ldaa $00,Y ; get a byte from the source (EEPROM/ROM) staa $00,X ; stash into memory iny ; bump pointers inx cpx #$00b6 ; end of table yet ? bcs L80b0 ; nope jsr Ldc87 ; setup the serial interface ; ; The below has something to do with the Ignition Coil Driver Mode. It compares ; a constant to some location in RAM right in the middle of the stack. ; Needles to say it does not work. ; if not mis57x ldaa Lf01d ; Ignition Coil Driver Mode anda L00fb ; no matter what this is we will always endup 0 beq L80ca ; ok - has to be jmp L807e ; error - jump to drop dead loop endif ; L80ca: ldaa Lf690 ; do we need to turn on alt IAC motor driver ? ; Boost Control Driver - 09/01/99 (WS) bne L80d7 ; nope ldy #register_base bset $00,Y %00001000 ; turn on PA3 - alt IAC motor driver L80d7: bset L0060 %01000000 ; turn on PAL-44 bclr L0060 %00100000 ; assure the Fuel Pump is Off ldaa L0060 staa pal_4000_latch ; ldd Lf47c ; seed the dashpot counter 4.6 seconds 7000 std L006e ; seed the dashpot ldaa Lf48e ; Counter value for Idle Threshold Update ; 8 second counter 64*131ms - 8.3sec staa L0021 ; reset counter ldd #%00000111 ; Single Scan, Single Channel, AN7 (MAP) stab adc_control_reg ldab #$06 ; wait a bit L80f4: decb bne L80f4 nop ldaa adc_result_adr1 ; get the results (MAP) staa L00b8 ; stash new current MAP ADC ; ; Check the key-on MAP value for a high altitude condition. If we are at a ; high altitude location at engine start then compute an altitude compression ; compensation value into L0008. ; jsr Ldc0e ; compute MAP ADC altitude compression value ; ...and stash in L0008 ; ; .............................................................................. ; ldaa L00b8 ; get MAP back and.... staa L002f ; ...stash here also bset L0060 %00100000 ; turn On the Fuel Pump ldaa L0060 staa pal_4000_latch ldx #register_base ldaa #cop_arm ; reset the COP watchdog timer staa $3a,X ldaa #cop_reset staa $3a,X bclr $23,X %00000000 ; clear all timer interrupt flags bclr $23,X %01111111 ; clear OC1F timer interrupt flag bset $0c,X %10000000 ; Point OC1 Output to PA7 (pin 27) - IAC bset $0d,X %10000000 ; set IAC Output Compare data to 1 after compare ldd $0e,X ; get the current timer count addd #$0019 ; plus 50 us (25 * 2us) std $16,X ; stash in TOC1 (Output Compare reg 1) ; ; ----------------------------------------------------------------------------- ; ; Re-enter here if motor off or ........ ; If Dist Trigger Handle (IC1) couldn't determine which trigger edge ; If Timer Overflow sent us here after Fuel Pump was turned off (motor off) ; 780ms with no activity ; L812a: ldx #register_base ldaa #%00010000 ; setup IC1 to detect rising edge only staa $21,X ; bset $22,X %10000100 ; enable OC1 (IAC) and IC1 (Ign Trig) interrupts bclr $25,X %01111111 ; clear the Timer Overflow Flag (TOF) bset $24,X %10000000 ; enable Timer Overflow interrupt ldaa #cop_arm ; reset the watchdog timer staa $3a,X ldaa #cop_reset staa $3a,X clra clrb staa L0029 ; clear injector phase group staa L0027 ; clear Spark Angle std L0058 ; clear flags staa L005b ; clear IGN and SA flags std L003e ; clear current timing period std L0040 ; clear the predicted next timing period std L0036 ; clear dist trig high time period ; if not mis4x mis4: std L0038 ; Not Used ?????? endif ; std L003a ; clear #1 cylinder firing stash staa L0031 ; clear timer overflow counter ; if not mis5x mis5: std L003e ; clear current timing_period - AGAIN ???? endif ; staa L0042 ; clear timing_period / 16 stash std L0004w ; clear Fuel work stash - why ???????? std L0025 ; Injector Pulse Width to zero brclr L005d %00000100 L817e ; first time here before a distributor ; trigger pulse has occured ldaa L1020 ; get current Timer Control 1 register value oraa #%00001000 anda #%11111011 ; OC4 line to zero after Successful Compare if not mis57x eora Lf01d ; xor flag - Ign Coil Driver Mode endif staa L1020 ; update Timer Control 1 ldd L003c ; get previous timing period beq L817e ; motor stopped cpd #$01a1 ; below 4500 RPM ? bhi L817e ; yes bset L005b %00000100 ; signal above 4,500 RPM L817e: if not mis8x mis8: bclr L00ba %00000110 ; clear what - Never used Anywhere endif ; cli ; enable interrupts now L8182: brclr L005b %01000000 L8189 ; a Dist Trigger intr has not happened yet jmp L82d6 ; We got a Dist Trigger interrupt ; L8189: ldx #register_base sei ; interrupts off brclr $30,X %00000100 L81f6 ; branch if AN0 thru AN3 was read last ldab #%00010000 ; turn MULTI mode on (read AN0 thru AN3) stab adc_control_reg ldaa #cop_arm ; reset the watch dog timer staa $3a,X ldaa #cop_reset staa $3a,X L819e: brclr $30,X %10000000 L819e ; loop here till ADC is finished ldd adc_result_adr3 ; read ADC --> A = AN2(MAT) B = AN3(COOL) std L0023 ; stash MAT and COOL ADC readings cli ; interrupts back on ldx #Lf268 ; point to adjustment table tba ; a copy into A anda #%11110000 ; leave only upper four bits ; ; If the coolant temperature circuit was open the highest ADC (lowest temp) ; reading possible would be 4.3 volts - ADC=220 $E0 ; cmpa #$e0 ; warmer than 224 ? bcs L81b5 ; yes - circuit probably not bad (open) clra ; goto max Hot bra L81d8 ; L81b5: cmpa #$30 ; warmer than about 160 degrees ? bcs L81c6 ; yes ;--------------------------------------------- ; TEXPNDH ; EXPANDED TEMPERATURE TABLE ; FOR FORD TEMP SENSORS ; ENTRIES IN THIS TABLE EXPAND TABH2O ; H ABOVE FROM 208 to 233d A/D ; ;--------------------------------------------- cmpa #$d0 ; between -40 to -20 degrees or so ? bne L81ce ; nope ldx #Lf278 ; point to Ford Expanded Table lslb ; * 2 lslb lslb lslb ; * 16 bra L81d0 ; ; coolant warmer than 160 degrees or so.... ; L81c6: subb #$20 bcs L81d5 ; warmer than 246 degrees - use constant lslb ; * 2 lslb ; * 4 bra L81d0 ; L81ce: addb #$10 ; between -20 and 160 degrees L81d0: jsr Ld9f6 ; lookup adjusted coolant temperature bra L81d8 ; stash result ; L81d5: ldaa Lf267 ; load max hot water temp value (246) L81d8: staa L0003 ; stash adjusted TH2O - Water Temperature ; ldab L0023 ; get MAT ADC reading tba ; stash a copy in A anda #%11110000 ; upper 4 bits for now cmpa #$d0 ; -20 thru -40 ? bne L81ec ; nope ldx #Lf257 ; on cold correction table lslb ; * 2 lslb ; * 4 lslb ; * 8 lslb ; * 16 bra L81ef ; only looking at the lower four bits * 16 ; L81ec: ldx #Lf247 ; normal adjustment table L81ef: jsr Ld9f6 ; lookup adjusted value staa L0002 ; stash TAIR - Air Temperature (adjusted) bra L8182 ; loop back till something happens ; L81f6: ldab #%00010100 ; MULTI On, AN4 thru AN7 selected stab adc_control_reg ldaa #cop_arm ; reset the watch dog timer staa $3a,X ldaa #cop_reset staa $3a,X L8203: brclr $30,X %10000000 L8203 ; loop till conversion completed ldd adc_result_adr1 ; read ADC --> A = AN4(O2) B = AN5(TPS) staa L0074 ; stash O2 ADC reading stab L0022 ; stash TPS reading stab L001e ; last ADC TPS also ldd adc_result_adr3 ; read ADC --> A = AN6(BATT) B = AN7(MAP) staa L000a ; stash Battery Voltage stab L00b8 ; stash MAP ADC stab L002f ; ..... mis22: stab L0000 ; hold here - why ? Maybe because following CLI cli ; interrupts on ; ; ; If at key-on we were at a high altitude the correct for it now. ; tba ; put a copy of MAP into A jsr Ldc2a ; add in compression correction to ADC reading staa L0000 ; stash corrected MAP ADC value ; ; ldaa L0002 ; get TAIR - adjusted ldab Lf021 ; MAT Rescaling Factor B = 88 ($58) mul ; D = TAIR_adj * 88 D=A*B adda Lf022 ; MAT Lower Threshold (Adder) 99 beq L8255 psha clra ldab L0000 ; get slope/offset corrected MAP ADC reading addb Lf023 ; Pressure Sensor Offset, Scaling (Adder) ; + 4" of vacuum 32 adca #$00 ; update hi byte if needed xgdx ldaa Lf024 ; Re-Scaler for DENSAR. (Multi) 184/256 = .72 jsr Ld8a5 ; D = (A*IX)/256 xgdx ; put in IX pulb ; get TAIR value clra std L000fw ; stash air portion here xgdx ; MAP value back to D ldy #$000c ; multiplier (2^11 - 2048) jsr Ld8d1 ; D = (D / L000fw) * 2048 tst Lf025 ; 3.00 DENSAR, Upper Limit 3072 beq L8258 ; constant wasn't zero cpd Lf025 ; 3.00 DENSAR, Upper Limit ; 3072 - would be -6.5" computed air density bls L8258 ; lower - use calculated air density L8255: ldd Lf025 ; 3.00 DENSAR, Upper Limit ; max air density (-6.5") L8258: std L0006w ; stash computed air density (Vacuum) jsr Ldb07 ; check for any sensor errors ldab L00b2 ; get Rev limiter value (B*250=Limit RPM) cmpb #5000/250 ; set to at or above 5000 RPM ? bcc L8267 ; yep ldab #5000/250 ; no lower than 5000 rpm allowed bra L826d ; stash new limiter value ; L8267: cmpb #9500/250 ; over 9500 RPM ? bls L826f ; nope - it's ok ldab #9500/250 ; set upper limit L826d: stab L00b2 ; new Rev Limiter value stashed L826f: brclr L0059 %00000001 L82d0 ; Controller does Not want current status bclr L0059 %00000001 ; clear request flag ; if not mis6x ldaa L00bc ; get the serial flags mis6: anda #%00000110 ; these bits are always zero ????????? bne L82d0 ; never take this branch then ???????? endif ; sei ; interrupts off ldx #L00c2 ; point to the start of the serial data buffer ldaa L0000 ; corrected MAP ADC value staa $02,X ; Not used by controller ldaa L0006w ; get computed air density staa $03,X ; Stash Vacuum - high byte ldaa L0007w staa $04,X ; Vacuum - low byte ldaa L0002 ; get TAIR adjusted staa $08,X ldaa L000a ; get Battery Voltage staa $09,X ldaa L0022 ; get TPS staa $0a,X ; stash TPS reading ldaa L0003 ; get TH2O - Water Temperature (adjusted) staa $0b,X ldaa L00b9 ; get any warning messages staa $0f,X ldaa #%00100000 ; water under 120 degrees ? staa $0e,X ; stash mixture flag clra clrb std $00,X ; no RPM - motor not turning staa $05,X ; no spark angle yet std $06,X ; no Injector Pulse width std $0c,X ; no idle target RPM or IAC % yet std $10,X ; always clear last two locations ldaa #$02 ; second byte back to controller ldab #$12 ; 18 bytes back to the controller std L00c0 ; stash first two bytes ldx #register_base ldab #%00001000 ; signal something needed to be transmitted stab L00bc ; stash into serial flags bset $2d,X %10001000 ; enable the Serial Transmitter and Interrupt ldaa #$7b ; $7B to the serial data register staa $2f,X ldab L00c1 ; get number needed to send to controller addb #$02 ; plus two for prefix stab L00bd ; stash character to send ldd #L00c0 ; start of our serial buffer std L00be ; stash serial buffer index cli ; interrupts on L82d0: jsr Ld6ea ; do any Dataset saving/restoring now jmp L8182 ; loop back for a while ; ; We have had at least one Dist Trigger interrupt to get here since a restart ; L82d6: ldaa L0003 ; get TH2O - Water Temperature (adjusted) cmpa Lf571 ; TJ Correction Percentage Coolant Threshold ; water over 120 degrees ? 140 bhi L82e2 ; yes bset L005e %00100000 ; signal water under 120 degrees bra L82e5 ; ; Water over 120 degrees..... ; L82e2: bclr L005e %00100000 ; signal water over 120 degrees L82e5: cmpa Lf564 ; Threshold above which FLGPWO is set at key on ; over 300 degrees ? 255 bhi L82ed ; no - of coarse not bset L0058 %00000010 ; signal hot water L82ed: cmpa #$60 ; water under 60 degrees ? 96 bls L82f4 ; yes bset L0001 %00000010 ; water over 60 degrees (IAC flag) L82f4: ldx #register_base ; ; Wait in the loop below till the motor starts turning over. If we spend more ; than 780ms here then loop back to the top.... ; L82f7: ldaa L0031 ; get timer overflow count cmpa #$06 ; been over .78 seconds without a reset ? bls L8300 ; nope - still ok jmp L812a ; loop back to top and restart again ; L8300: ldaa #cop_arm ; reset the watch dog timer staa $3a,X ldaa #cop_reset staa $3a,X ldd L003e ; get current timing period beq L82f7 ; none - motor is not turning over ; ldaa #%00000111 ; Single Scan, Single Channel, AN7 (MAP) staa adc_control_reg L8311: brclr $30,X %10000000 L8311 ; wait for the ADC to finish ldd adc_result_adr3 ; last two MAP reading in A and B std L002f ; stash ADC counts staa L00b8 ; current MAP ADC reading staa L002a ; stash MAP ADC average also bset L0058 %00000001 ; signal we have a MAP ADC reading ldaa L0043 ; get hi-byte timing period accumulator value suba Lf50c ; Upper threshold to determine if engine started ; above 610 RPM ? 12 bcs L8333 ; yes mis54: brset L0058 %01000000 L8336 ; been thru calibration routine already ldaa Lf515 ; init revolution counter 255 staa L0015 ; set revolution counter bra L8336 ; ; At or above 610 RPM.... ; L8333: bset L0059 %00010000 ; signal stash the high-by timing period L8336: ldaa L0043 ; get the timing period accumulator bita #%11110000 ; at or below 458 RPM ? bne L8343 ; yes brset L005d %00000100 L8343 ; we have had a dist trig event ; ; This next line is not clear. We should have never gor here unless the motor ; is turning over and have had an ignition trigger event. Well because we ; have had an ign trigger then the above line will always jump around this ; line. ; mis49a: clr L0008 ; clear MAP ADC slope/offset correction factor ; ; The below IAC values are what I see when the motor is cranking over ; during starting. ; L8343: ldx #register_base ldd Lf466 ; 6 msec, Actuation Duty Cycle Max Limit ; 5999 / 2 * 2us = 5.999ms std L0066 ; 5.999ms IAC motor On time std L006a ; 5.999ms IAC last motor On time ldd Lf45c ; Nominal Period for VAE (IAC) Control Signal std L0068 ; 6.666ms IAC total period std L006c ; 6.666ms IAC last total period bclr $23,X %01111111 ; reset OC1 (IAC) interrupt ldd $0e,X ; get the current Timer count addd #$0019 ; plus 50 us (25 * 2us) std $16,X ; set new IAC (OC1) compare count bset $0d,X %10000000 ; output data (h) to PA7 (Idle Motor) when done bset L0001 %00000001 ; stop IAC from doing 250ms initial banging ldaa Lf48d ; set TPS threshold to 1.035 volts 53 staa L001c ; stash initial starting point ldaa L0022 ; get current ADC TPS reading staa L001e ; stash last TPS ADC staa L0057 ; this is the last TPS ADC reading stash cmpa L001c ; thottle plates closed ? bls L8375 ; yes ldaa L001c ; get TPS closed threshold value L8375: staa L001d ; seed stash - lowest TPS ADC reading ever read bclr $23,X %11101111 ; reset OC4 (IGN AMP Driver) compare flag ; if mis57x bset $20,X %00001100 ; force IGN AMP Diver Output to go High else ldaa $20,X ; get current timer control state oraa #%00001100 ; force IGN AMP Driver output to go high eora Lf01d ; 0 - Ign Coil Driver Mode staa $20,X ; update endif ; ldd $0e,X ; get current count addd #$000f ; in 30 us std $1c,X ; set new compare point ldab L0003 ; get TH2O - Water Temperature (adjusted) ldx #Lf217 ; on dashpot rpm vs TH2O table lsrb ; / 2 lsrb ; / 4 lsrb ; / 8 lsrb ; / 16 lsrb ; / 32 adcb #$00 ; one more if last bit out was a one ; This offsets the divide by 32 by 16 cmpb #$07 ; max 8 entries ? ble L839c ; nope ldab #$07 ; max L839c: abx ldaa $00,X ; get it staa L0017 ; stash initial - dashpot RPM threshholds ldx #Lf21f ; on rpm (timing_period/16) vs TH2O abx ldaa $00,X ; get it staa L0018 ; stash initial - deceleration fuel cuttof clr L0014 ; clear lowest MAP ADC reading ever read bclr L0058 %01000000 ; signal no Calibration data yet ; ; End of Initialization code - wont ever pass this way again as long as we ; keep running........... ; ; ============================================================================= ; This is the top of the Calibration run loop............... ; ; If we don't have a current MAP ADC reading from the Distributor Trigger ; handler (every timing event) then wait here till we do..... ; L83af: ldaa #cop_arm ; reset the COP watchdog timer staa coprst_register ldaa #cop_reset staa coprst_register brclr L0058 %00000001 L83af ; wait till we get a new MAP ADC reading brclr L0059 %00000001 L83c7 ; controller does not need current parms bclr L0059 %00000001 ; clear request bit bset L00bc %00000001 ; allow engine parms to be sent to controller L83c7: ldaa #cop_arm ; reset the COP watchdog timer staa coprst_register ldaa #cop_reset staa coprst_register bclr L0058 %00000001 ; signal we used this MAP ADC reading value ldaa L002a ; get average of last two MAP readings ; ; If we started the motor in a high altitude condition add the elevation ; compression factor in here. ; mis49d: jsr Ldc2a ; add in altitude compression correction factor staa L0000 ; stash adjusted MAP ADC reading ; ; Increase the MAP ADC reading by 1.56% (130/128 = 1.015625) ; ldaa #$82 ; 130 ldab L0000 ; get correct ADC reading mul lsld bcc L83e5 ; didn't overflow ldaa #$ff ; 255 upper limit L83e5: staa L0000 ; stash adjusted MAP ADC reading jsr Ld000 ; do all IAS work ldd L003e ; get the current timing period cpd #$1000 ; over 458 RPM ? (1,875,000/4096) bcs L83f5 ; yes - not cranking over ldd #$0fff ; limit to 458 L83f5: lsld ; * 2 lsld ; * 4 lsld ; * 8 lsld ; * 16 jsr Ldc56 ; convert timing period into RPM/25 stab L00b7 ; stash rpm/25 ; ldab L0022 ; get the TPS ADC count brclr L00b9 %00010000 L8408 ; Do Not have a Throttle Input Error ldab Lf560 ; get 197 (82 degrees) decb ; (81.5 degrees) L8408: ldaa L0001 ; get flags cmpb Lf48d ; TPS below 1 volt ? 53 bcs L8413 ; yes oraa #%00010000 ; signal plates where opened bra L8456 ; ; TPS below a volt (throttle plates closed).... ; ; The below code is mostly responsible for determing the lowest TPS ADC reading. ; We can bring down the lowest stash (L001d) fairly quickly but can only ; increase it at a 2 count rate once every 8 seconds. ; L8413: cmpb L001e ; did TPS change from the last reading ? bne L845a ; yes cmpb L001d ; lower now that what we thought was lowest ? bcs L843f ; yes - set new low value bhi L8421 ; TPS higher than our lowest reading anda #%11101111 ; signal throttle plates closed bra L8456 ; L8421: bita #%00100000 ; 8 second counter active ? bne L842f ; yes bita #%00010000 ; where the throttle plates opened ? beq L846e ; nope oraa #%00100000 ; turn 8 second counter on anda #%11101111 ; signal throttle plates closed staa L0001 ; replace updated flags L842f: ldaa L0021 ; get 8 second counter bne L846e ; has not counted down yet ldaa L001d ; get the lowest read TPS ADC value adda Lf48c ; plus max rate of stash change 2 cba ; is lowest read too high ? bhi L8452 ; yes - stash current ADC as lowest then staa L001d ; was too low - bring up slowly bra L845a ; L843f: anda #%11101111 ; signal throttle plates closed staa L0001 ; replace updated flags ldaa L001d ; get lowest TPS ADC read so far suba Lf48b ; less max rate of change 2 bcc L844b ; didn't go below zero clra ; yep L844b: cba ; current ADC higher than old lowest ? bls L8452 ; yes - use it then as new lowest staa L001d ; was too high - bring down slowly bra L8454 ; L8452: stab L001d ; use current ADC as lowest ever read L8454: ldaa L0001 ; get flag byte L8456: anda #%11011111 ; turn 8 second counter off staa L0001 ; replace updated flags L845a: ldaa Lf48e ; Counter value for Idle Threshold Update ; 8 second counter 64*131ms = 8.3sec staa L0021 ; reset it ldaa L001d ; get lowest TPS ADC reading adda Lf48f ; Min Delta Throttle between TPS A/D and FARSM cmpa Lf48d ; over TPS closed threshold ? 53 bls L846c ; nope - use it as TPS throttle plate closed ; ; threshold then ldaa Lf48d ; get TPS closed threshold (1.035 volts) 53 L846c: staa L001c ; stash new throttle plates closed threshold L846e: stab L001e ; stash new last TPS ADC reading cmpb L001c ; throttle plates closed ? bls L84b4 ; yes ldaa L00b7 ; get rpm/25 ; if mis38x ; new 01/02/99 ; ; This all boils down to wether we are WOT or partial plates..... ; cmpb Lf561 ; 197 3.8 volts 82 degrees WOT ? bhi L84bc ; yes - WOT bset L0001 %10000000 ; signal throttle plates are opened bclr L0001 %01000000 ; ...but Not WOT bra L84c2 ; else ; old code ; ; No matter if rpm > 3500 or over 3 minutes because the same tests and the ; same branchs are always taken.............................................. ; mis46: cmpa #$8c ; above 3,500 RPM ? 140*25=3500 bhi L8485 ; yes brset L0058 %00000010 L8485 ; water is hot / over 3 minutes running cmpb Lf560 ; 197 3.8 volts 82 degrees TPS bhi L8498 bra L848a ; ............................................................................. ; Above 3,500 rpm or Water is hot or been over Three minutes..... ; and everything else because of mis46:........... ; L8485: cmpb Lf561 ; 197 3.8 volts 82 degrees WOT ? bhi L8498 ; yes - WOT L848a: clr L0020 ; ???? mis38: bclr L0058 %10000000 ; useless mis47: ; L8490: bset L0001 %10000000 ; signal throttle plates are opened bclr L0001 %01000000 ; ...but Not WOT bra L84c2 ; ; WOT <<<<<< ; Lots of useless code because of mistakes. When all is said and done we will ; always end up at L84bc .................................................... ; L8498: brset L0058 %10000000 L84a4 ; usless jmp because L0020 always zero ldaa Lf588 ; WOT Enrichment Enable Delay 0 mis38: staa L0020 ; always get a zero stashed into it ????? mis47: bset L0058 %10000000 ; useless L84a4: ldaa L0000 ; get the adjusted MAP ADC reading cmpa Lf58a ; MAP value for Immediate WOT Enrichment 0 mis23: bls L84ae ; Will never take this jump because min L0000 ; ; can ever be is 7 ; ; NOTE: with L0008=0 then will get lower..... ; clr L0020 ; ????? mis38: L84ae: ldaa L0020 ; will always the below jump because always zero beq L84bc ; always take this jump ?????? bra L8490 ; never take this branch endif ; ; ............................................................................. ; throttle plates are closed..... ; L84b4: if not mis38x bclr L0058 %10000000 ; useless bit mis47: endif ; bclr L0001 %11000000 ; signal plates are closed and Not WOT bra L84c2 ; ; WOT <<<<<<< ; L84bc: bset L0001 %01000000 ; signal WOT bclr L0001 %10000000 ; signal not partial throttle ; ; B = TPS ADC reading.... ; ; ............................................................................ ; This below is all questionable. If the rpm is between 1,670 and 2,070 ; or 2,461 to 2,619 then if the TPS was above a trip point in Lf507/Lf508 ; the MAP correction factor in L0008 would have been computed. The problem ; is that we will always jump arround the MAP correction call because the TPS ; ADC reading can never be over 255. This means that what gets stashed into ; L0008 is always zero. ; ; 09/03/99 - Well it looks like this whole L0008 thing needs to be revisited. ; What looks like is happening is that the value in L0008 is a ; altitude compression factor that is applied to the MAP ADC value. ; The initial call to Ldc0e: at key on checks how high we are at and ; computes an altitude compression correction factor in L0008. ; Where I mad my error is in thinking only in terms of a low lander ; (sea level operation) where the value in L0008 is always zero. ; At higher initial key-on altitudes this will not always be the ; case. The routine at L84c2: is disabled though. This routine is ; in the main Calibration loop. It checks to see if the current ; RPM is between two windows, either 1670-2070 or 2460-2620, and if ; it is then it checks the TPS for a certain threshold value. If ; it passes all these tests it will then recompute the altitude ; compression factor in L0008. The problem is that the TPS check ; values are 255. Well the TPS ADC will never get that high so the ; recomputations done by Ldc0e: will never happen and the initial ; turn on value in L0008 will remain the same. So this all boils ; down to that the L0008 stash has a valid number in it and the ; routine at L84c2: is usless... ; Now the fun to back out my mis49: mistake !!! ; mis49: ; ; This has something to do with altitude correction ; L84c2: if not mis49x ldx L0040 ; get the predicted next timing period cpx Lf4ff ; Lower RPM Threshold for 1st Window ; Slower than 1,670 RPM ? (1123 - 1670 RPM) bcc L84e8 ; yes - ignore cpx Lf501 ; Upper RPM Threshold for 1st Window ; Faster than 2,070 RPM ? (906 - 2070 RPM) bls L84d3 ; yes ldaa Lf507 ; TPS for first RPM Window 255 bra L84e0 ; ; Faster than 2,070 RPM.... ; L84d3: cpx Lf503 ; Lower RPM Threshold for 2nd Window, ; Slower than 2,461 RPM ? (762 - 2461 RPM) bcc L84e8 ; Yes - ignore cpx Lf505 ; Upper RPM Threshold for 2nd Window ; Faster than 2,619 RPM ? (716 - 2619 RPM) bls L84e8 ; yes ldaa Lf508 ; TPS for 2nd RPM Window 255 L84e0: cba ; A-B 255-TPS_ADC bcc L84e8 ; will always take this jump because TPS ADC ; ; can never get over 255 to set CY..... ldaa L002a ; get average of last to MAP ADC readings jsr Ldc0e ; compute MAP altitude compression correction ; ...and stash in L0008 endif ; ............................................................................. ; L84e8: brclr L00ba %01000000 L84f2 ; Do Not have a Coolant Error ldaa #$78 ; Error - default to 95 degrees staa L0003 ; stash TH2O - Water Temperature bra L852a ; continue with TAIR stuff ; L84f2: ldx #Lf268 ; point to the correction table ldab L0024 ; get COOL ADC reading tba ; put a copy into A anda #%11110000 ; leave only upper four bits ; ; If the coolant temperature circuit was open the highest ADC (lowest temp) ; reading possible would be 4.3 volts - ADC=220 $E0 ; cmpa #$e0 ; warmer than 224 ? bcs L8501 ; yes - circuit probably not bad (open) clra ; signal trouble - max Hot bra L8524 ; L8501: cmpa #$30 ; warmer than about 160 degrees ? bcs L8512 ; yes ;--------------------------------------------- ; TEXPNDH ; EXPANDED TEMPERATURE TABLE ; FOR FORD TEMP SENSORS ; ENTRIES IN THIS TABLE EXPAND TABH2O ; H ABOVE FROM 208 to 233d A/D ; ;--------------------------------------------- cmpa #$d0 ; between -40 to -20 degrees or so ? bne L851a ; nope ldx #Lf278 ; point to Ford Expanded Table lslb ; * 2 lslb lslb lslb ; * 16 bra L851c ; ; coolant warmer than 160 or so degrees.... ; L8512: subb #$20 ; bcs L8521 ; warmer than 246 degrees - use constant lslb ; * 2 lslb ; * 4 bra L851c ; use lookup table ; L851a: addb #$10 ; between -20 and 160 degrees L851c: jsr Ld9f6 ; return temp from look-up table bra L8524 ; stash results ; ; coolant is warmer than 246 degrees ; L8521: ldaa Lf267 ; load highest water temp constant (246) L8524: ldx #L0003 ; point to COOL adjusted stash jsr Ld8f0 ; update the RAM stash ; L852a: brclr L00b9 %00001000 L8540 ; do Not have a TAIR error (air temp) ; ; We have a bad TAIR sensor. Warning sent. Use the water temperature to ; get us some kind of in the ball park air temp value... ; ldaa L0003 ; get TH2O - Water Temperature adda #$20 ; TAIR adjusted is about 32 higher bcc L8536 ; didn't roll - not too hot (over ~220) ldaa #$ff ; max at 255 L8536: ldab #$98 ; don't let TAIR go above about 90 degrees cba ; is adjusted temp lower than 90 degress ? bcs L853c ; yes tba ; nope - use the 90 degree value L853c: staa L0002 ; stash new TAIR - Air Temperature bra L856c ; ; don't have MAT sensor error so use it's value L8540: ldab L0023 ; get MAT ADC reading tba ; a copy into A anda #%11110000 cmpa #$d0 ; -20 thru -40 ? bne L8552 ; nope ldx #Lf257 ; on cold table lslb ; * 16 so we are only looking at lower 4 bits lslb lslb lslb bra L8555 ; L8552: ldx #Lf247 ; normal range adjustment table L8555: jsr Ld9f6 ; lookup ajusted value (return in A) brclr L0001 %11000000 L855e ; throttle plates are closed ! bra L8566 ; either partial or WOT ; L855e: cmpa Lf50e ; D3 (211) - lower than 150 degrees ? bls L8566 ; yes ldaa Lf50e ; force 150 degrees max L8566: ldx #L0002 ; point to MAT adjusted stash jsr Ld8f0 ; update the RAM stash ; ; ; ; (MAP_ADC+32)*.72 ; Air_Charge = ( -------------------------------- ) * 2048 ; Air Temp+103 ; ( ------------ ) * .34375 ) + 99 ; 1.2375 ; ; ; Air = Air * .34375 (air * (88/256)) ; L856c: ldab Lf021 ; MAT Rescaling Factor B = 88 ($58) mul ; D=A*B ; ; Air - Air + 99 ; adda Lf022 ; MAT Lower Threshold (Adder) 99 beq L859d ; use max air density psha clra ldab L0000 ; get adjusted MAP ADC value addb Lf023 ; Pressure Sensor Offset, Scaling (Adder) ; + 4" of vacuum 32 adca #$00 xgdx ; into IX ldaa Lf024 ; Re-Scaler for DENSAR. (Multi) ; 72% 184/256 = .72 jsr Ld8a5 ; D = (A*IX)/256 xgdx ; IX = (MAP + 3.56") * .72 pulb clra std L000fw ; stash air portion here xgdx ldy #$000c ; time 2048 (2^11) jsr Ld8d1 ; D = (D / L000fw) * 2048 tst Lf025 ; 3.00 DENSAR, Upper Limit ; test max air density constant (3072) beq L85a0 ; constant not zero so will never take this bra cpd Lf025 ; 3.00 DENSAR, Upper Limit ; more dense than max ? bls L85a0 ; nope - use calculated air density L859d: ldd Lf025 ; 3.00 DENSAR, Upper Limit ; use max constant (-6.5") ; ; Displayed_Vacuum(in) = 28.9 - (L0006w * .01152) ; L85a0: std L0006w ; stash computed air density (displayed Vacuum) psha ldaa L00bc ; ok to send current status to controller ? anda #%00000111 cmpa #%00000001 bne L85d0 ; nope pshx ldx #L00c2 ; point to the serial buffer ldaa L0040 ; get predicted next timing period staa $00,X ldaa L0040+1 staa $01,X ; .... low byte ldaa L0000 ; get adjusted MAP ADC value staa $02,X ; stash in buffer ldaa L0006w ; get computed air density staa $03,X ; stash current Vacuum ldaa L0007w staa $04,X ; .... low byte ldaa L0002 ; get TAIR - Air temperature - adjusted staa $08,X ; stash ldaa L001e ; get last TPS ADC reading staa $0a,X ldaa L0003 ; get TH2O - Water Temperature staa $0b,X ; stash pulx L85d0: pula ldab Lf018 ; 10 stab L001bw ; 11 entries in look-up table ldd L0006w ; get computed air density ldx #Lf047 ; point to Load index table jsr Ld907 ; look up indexs stab L0012w ; stash distance from the exact match entry ldab L001bw ; get the matched major index bne L85e9 ; within legal MAP bounds bset L0059 %00001000 ; signal out of bounds (too hi a Load) bra L85ec ; L85e9: bclr L0059 %00001000 ; signal in bounds L85ec: lslb ; * 2 lslb ; * 4 lslb ; * 8 lslb ; * 16 - 16 RPM ranges per Load index stab L0005w ; stash major index*16 (Fuel Load Index) ldab #$0f stab L001bw ; 16 entries in look-up table ldd L0040 ; get the predicted next timing period ldx #Lf027 ; point to RPM index table jsr Ld907 ; look up rpm indexes stab L000bw ; stash distance from the exact match entry stab L0011w ; here also ldab L001bw ; get the matched major index stab L0013w ; stash for later use addb L0005w ; plus major index from Load lookup ldx #Lf067-16-1 ; Fuel matrix Lf056 jsr Ld970 ; lookup Fuel Pulse width xgdx ; result in to IX ldaa Lf020 ; 15% of the lookup table value 38 jsr Ld8a5 ; D = (A*IX)/256 std L0004w ; stash new fuel requirements ; brclr L0059 %00001000 L862d ; found Load in table (not out of bounds) mis50: ldx #Lf047 ; point to the highest Load in lookup table ldab Lf018 ; 10 lslb ; * 2 --> 20 (words) abx ; IX = $f047+20 = $f05b ldd $00,X ; D=2765 = -3" std L000fw ldd L0006w ; get computed air density (Load) subd L000fw ; less highest Load in lookup table bcc L8631 ; computed is larger than what is in table max ; ; Computed Load is smaller than what is in the lookup table so go with what ; we have so far.... ; L862d: ldd L0004w ; get current work Fuel PW into D bra L8641 ; ; Computed Load is larger than the max value in the lookup table. ; At this point 'D' is how much above the tables largest and L000fw is the ; largest entry in the lookup table. It looks like they are projecting outward ; to come up with the fuel required. ; L8631: ldy #$000a ; times 512 (2^9) jsr Ld8d1 ; D = (D / L000fw) * 512 tba ; into A ldx L0004w ; get what we got from the table jsr Ld8a5 ; D = (A*IX)/256 lsrd ; / 2 addd L0004w ; plus what we got out of the table L8641: std L0004w ; stash work fuel requirements so far ldaa L0022 ; get the ADC TPS count cmpa L001c ; throttle plates closed ? bhi L8653 ; nope - opened ldaa L0017 ; dashpot threshold rpm cmpa L0042 ; compared to timing_period / 16 bhi L8653 ; faster than threshold rpm ldab L00ab ; get the Idle Fuel modifier value bra L868d ; join modifer ; L8653: ldab Lf700 ; 3, TCIC: num DENSAR BREAKPTS. - 1 stab L001bw ; 4 entries in look-up table ldd L0006w ; get computed air density (Load) ldx #Lf706 ; point to Load index table jsr Ld907 ; look up Load indexes stab L0012w ; stash fractional component ldab L001bw ; get the major matched index ldaa Lf701 ; get number-1 RPM rows 5 inca ; loose the minus 1 mul pshb ; save Load index ldab Lf701 ; number-1 RPM cells 5 stab L001bw ; 6 items in RPM look-up table ldd L0040 ; get the predicted next timing period ldx #Lf70e ; point to the RPM index table jsr Ld907 ; look up stab L000bw ; stash distance from the exact match entry ; if mis35x ldx #$0079 else mis35: ldx #L0080-$fe-2 ; point to the timing period table (RPM) Lff80 ldab #$fe ; -2 subb Lf701 ; 5 abx ; IX = $0079 endif ; pulb ; get Load base index back addb L001bw ; plus RPM base index abx ; IX points to RPM cell in previous Load column ldab Lf701 ; number-1 RPM cells 5 jsr Ld9bf ; get the interpolated Fuel modifier value tab ; into B ; ; Now modifiy Fuel by the user modifier in B. This could either be from the ; user RPM-vs-Load lookup above or if the throttle is closed from the user ; idle fuel modifier. ; ; Remember: Zero modification value is 128 ......... ; L868d: ldx L0004w ; get current calculated Fuel jsr Ldbe9 ; D = IX * (B/128) ; ; So at this point we have 15% of what was found in the table plus-or-minus ; the modifier percentage..... ; std L0004w ; stash new Fuel pshb ; get it into IX to multiply psha pulx ldab L00aa ; get the Global Fuel modifier jsr Ldbe9 ; D = IX * (B/128) std L0004w ; stash new work pulse width ; ............................................................................. ; End of Fuel calibration, Spark next................ ; brclr L0059 %00010000 L86c7 ; Below 610 RPM - zero spark advance brset L00b3 %10000000 L86c7 ; Base Timing Set is On ! - zero Spk Adv ldaa L0015 ; get the current revolution counter cmpa Lf516 ; Number of revolutions threshold for SA ; decreasing updating. ; over 128 revolutions past by ? 128 bls L86b0 ; yes jmp L876d ; join spark calculations ; L86b0: ldab L0043 ; get the timing period accumulator bitb #%11110000 ; above about 458 RPM ? beq L86ce ; yes bitb #%11100000 ; at or below 229 RPM ? bne L86c7 ; yes - zero spark advance then ; ; between 236 and 458 RPM ..... ; andb #%00001111 ; low bits only ldx #Lf35c ; point to Spark lookup table abx ldaa $00,X ; get advance for RPM staa L0006w ; stash in our work spark advance jmp L8849 ; done spark angle calculations ; ; Above 610 RPM and Base Timing Set is active ; Below 610 RPM..... ; Below 229 RPM..... ; L86c7: ldaa #$00 ; zero spark advance staa L0006w ; stash jmp L8849 ; skip timing computations ; ; Above 458 RPM.... ; L86ce: ldaa L0022 ; get the ADC TPS count cmpa L001c ; throttle plates closed ? bls L86d7 ; yes jmp L876d ; calculate spark here ; if mis32x ; always comes up with the same value L86d7: ldaa #$6c ; 37 degrees else ; ; Thottle plates are closed, above 458 RPM, more than 128 revolutions.......... ; L86d7: ldaa #$0f staa L001bw ; 16 items in look-up tables ldaa L0003 ; get TH2O - Water Temerature cmpa Lf484 ; If COOL > than this then use TPNOM (Lf485) ; at or below 170 degrees ? 176 bls L86ed ; yes - use current target RPM ldaa L0061 ; get Idle Target RPM suba Lf485 ; Delta Period to be subtracted from TPNOM if ; COOL > Lf484 when calculating Idle Spark ; advance. ; -148 - If the target RPM was equal to or ; ; slower than 792 RPM then no Carry bcc L86ef ; slower or equal to 792 RPM ldab #$ff ; target is above 792 RPM - make like 460 rpm bra L86f3 ; look it up ; ; Entry: Water is at or below 170 degrees, use current Target Idle RPM.... ; L86ed: ldaa L0061 ; get current Target Idle RPM ; ; Entry: Target RPM (L0061) is equal to or below 792 RPM. ; 'A' = L0061 - 148 ; L86ef: clrb ; clear low byte jsr Ldc56 ; convert the timing period into RPM/25 ; ; Target RPM was above 792 rpm, stash 255 (460 rpm).... ; L86f3: stab L0012w ldab L00b7 ; get current rpm/25 subb L0012w ; less target idle RPM/25 bcs L872e ; we are below the target Idle rpm clra ; ; 'B' is how far above the target Idle RPM we are (25 rpm units).... ; ; Of coarse all of this is bull shit because the table at Lf38c contains all ; of the same entries...... ; mis32: ldx #Lf36c ; point to rpm index table jsr Ld907 ; lookup ldx #Lf38c ; point to actual spark angle table tstb ; exact match ? bne L870f ; nope - didn't get an exact match ldab L001bw ; get index of match abx ; point into second table ldaa $00,X ; get new spark angle bra L8763 ; join Idle Spark Modifier ; ; didn't get an exact match so interpolate between two entries... (BS) ; L870f: tba ; put distance into A ldab L001bw ; get major index abx ; IX now points to first spark modifier ldab $00,X ; get it stab L000bw ; stash dex ; point to second ldab $00,X ; get it subb L000bw ; B = difference bcc L8725 ; positive difference negb ; change sign mul ; times distances suba L000bw ; less first nega ; change sign back bra L8763 ; join Idle Spark Modifier ; L8725: mul ; times distance adda L000bw ; plus first bcc L8763 ; ok - join Idle Spark Modifier now ldaa #$ff ; max out bra L8763 ; join Idle Spark Modifier ; ; we are below the target idle rpm.... ; ; Of coarse all of this is bull shit because the table at Lf3bc contains all ; of the same entries...... ; mis33: L872e: ldab L0012w ; get target rpm/25 subb L00b7 ; less current rpm/25 clra ldx #Lf39c ; point to rpm/25 table jsr Ld907 ; look up ldx #Lf3bc ; point to actual spark angle table tstb ; exact match ? bne L8746 ; nope - need to interpolate ldab L001bw ; get index abx ; point to spark angle ldaa $00,X ; get it bra L8763 ; join Idle Spark Modifier ; ; not exact match so we need to interpolate between entries ; L8746: tba ; distance into 'A' ldab L001bw ; get major index abx ; point to spark angle ldab $00,X ; get it stab L000bw ; stash dex ; point to next ldab $00,X ; get it subb L000bw ; B = difference bcc L875c ; positive negb ; change signs mul ; interpolate suba L000bw ; less first nega ; change sign back bra L8763 ; join Idle Spark Modifier ; L875c: mul ; interpolate adda L000bw ; plus first bcc L8763 ; ok - join Idle Spark Modifier ldaa #$ff ; max spark of 255 (63.75 degrees) ; endif ; 'A' contains the new calculated spark angle (in .25 degree units) ; L8763: ldab L00af ; get the Idle Spark Modifier jsr Ldbc8 ; adjust the Spark value staa L0006w ; stash work value Spark Angle jmp L87de ; join Global Spark modifier ; ; ...................END Throttle Plates Closed Spark ........................ ; ; ----------------------------------------------------------------------------- ; Above 610 RPM and 128 revolutions have Not past by yet ...................... ; Above 458 RPM and more than 128 revolutions and throttle plates opened ...... ; ; L0006w still contains the calculated air density charge..... ; Displayed_Vacuum(in) = 28.9 - (L0006w * .01152) ; ; We are going to calculate which spark table cell to use. Our internal ; spark table consists of 128 cells (16 rpm x 8 load) ; ; First look up the Load indexes............................................... ; L876d: ldab Lf019 ; 7 stab L001bw ; 8 items in look-up table ldd L0006w ; get computed air density ldx #Lf2a8 ; on air charge lookup table jsr Ld907 ; lookup stab L0012w ; stash distance from the exact match entry ldab L001bw ; get the matched index lslb ; * 2 lslb ; * 4 lslb ; * 8 lslb ; * 16 - 16 rpm cells per Load pshb ; save Load index ; ; Next the RPM indexes......................................................... ; ldab #$0f stab L001bw ; 16 items in RPM look-up table ldd L0040 ; get the predicted next timing period ldx #Lf288 ; point to RPM table jsr Ld907 ; lookup index and fractional stab L000bw ; stash distance from the exact match entry pulb ; get Load base index back addb L001bw ; plus RPM base index ; ; Now that we have both indexes lookup into the main Spark Matrix.... ; ldx #Lf2bc-16-1 ; point to Spark Matrix table Lf2ab jsr Ld970 ; look up Spark Angle ; ............................................................................. ; ; Now we will look-up from the user modification matrix (3 columns x 6 rows) ; ; First lookup the Load indexes...... ; ldx L0006w ; get air charge back staa L0006w ; stash new spark angle ldab Lf702 ; 2 stab L001bw ; 3 items in the lookup table xgdx ; D = Air Charge (Load) ldx #Lf71a ; point to index table jsr Ld907 ; look up index stab L0012w ; stash distance from the exact match entry ldab L001bw ; get major index of located entry ldaa Lf703 ; 5 - number RPM ranges for each MAP column inca ; plus 1 mul ; B = index * 6 pshb ; save column index (air charge) ; ; Now the RPM indexes.......................................................... ; ldab Lf703 ; 5 stab L001bw ; 6 items in the RPM table ldd L0040 ; get the predicted next timing period ldx #Lf720 ; point to RPM index table jsr Ld907 ; look it up stab L000bw ; stash distance from the exact match entry ; ; Now look up the user adjustable modifier..................................... ; if mis34x ldx #$0091 else mis34: ldx #L0098-$fe-2 ; point to timing period (RPM) table Lff98 ldab #$fe ; seems strange ???? subb Lf703 ; less rows-1 5 abx ; IX = $0091 ???? - just use this then..... endif ; pulb ; Load base index addb L001bw ; plus RPM base index abx ; IX points to RPM cell in previous Load column ldab Lf703 ; RPM-1 ranges in table 5 jsr Ld9bf ; get interpolated spark modifier tab ; in to B ldaa L0006w ; get Spark advance value jsr Ldbc8 ; adjust it by modifier value in B staa L0006w ; new user adjusted spark advance value ; ; At this point both 'A' and L0006w contain the new Spark Angle ; L87de: ldab L00ae ; get Global Spark Modifier jsr Ldbc8 ; adjust Spark value staa L0006w ; stash adjusted spark advance ; if not mis36x ldaa L0000 ; get MAP ADC adjusted value cmpa Lf50d ; MAP Threshold above which Spark is Retarded ; Vacuum >= ~6" (6" --> 29") 195 bls L880a ; yes - light to moderate Load ; ; Fairly heavy load, < 6" ...... ; Adjust spark for Air Temperature............................................. ; ; of coarse more BS because all entries are 128 (zero modifier !) ; ldab L0023 ; get MAT ADC reading mis36: ldx #Lf613 ; point to adjustment table jsr Ld9f6 ; lookup how much to mod spark verses Air Temp suba #$80 ; remove 128 bias tab ; into B bcc L8802 ; positive ldaa L0006w ; get current calculated spark negb ; change sign sba ; modify bcc L8808 ; not below zero clra ; zero min bra L8808 ; L8802: adda L0006w ; plus current spark bcc L8808 ; didn't overfow ldaa #$ff ; max at at 63.75 degrees L8808: staa L0006w ; stash MAT adjusted spark ; ............................................................................. ; L880a: ldab L0022 ; get the ADC TPS count cmpb L001c ; throttle plates closed ? bhi L882b ; nope - opened ; ; Throttle plates closed....................................................... ; Further adjust the spark if the RPM is above the TH2O RPM set point. ; ; BIG mistake here. The below code assumes that 'A' still contains the current ; spark angle. That would be true if we came from the above code that ended at ; L8808, but if we got here from the branch that tested the MAP ADC (which ; trashed the A register) just below L87de the 'A' register does not contain ; the current spark angle value and we end up storing the MAP ADC value ; instead. ; ; 01/03/99 - Makes no difference anyhow because the value at Lf4fb is 128 ; which 128 gets subtracted fromit leaving 0 to add/subtract !! ; ; mis37: ldab L0042 ; get the timing_period / 16 cmpb L0017 ; below dashpot threshold rpm ? bcc L882b ; yes - skip this spark angle adjustment mis37a: ldab Lf4fb ; SA Offset during Deceleration with Throttle ; at Idle. subb #$80 ; remove bias bcc L8824 ; positive modifier negb ; change sign sba ; adjust spark angle bcc L8829 ; didn't go below zero clra ; it did bra L8829 ; L8824: aba ; increase spark angle bcc L8829 ; didn't go too high ldaa #$ff ; max out L8829: staa L0006w ; stash high speed adjusted spark angle ; endif ; mis36: and mis37: ; ; Next adjust the Spark Angle for Water Temperature............................ ; L882b: ldab L0003 ; get TH2O - Water Tempe