msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 1 MC68HC908GP32 User Bootloader 1 ********************************************************* ****************** 2 ********************************************************* ****************** 3 ** MegasquirtnSpark - extra + enhanced 4 ** by James Murray (james@nscc.info) 5 ** and Phil Ringwood (philip.ringwood@ntlworld.com) 6 ** 7 ** IMPORTANT!!! Complain to us, not the orignal authors whose code we have used. 8 ** 9 ** 10 ** Adds lots of new features, see the website for details 11 ** http://megasquirt.sourceforge.net/extra 12 ** 13 ** 006 looks ok on stim. Simulated crank signal on middle LED 14 ** coil outputs on top and bottom 15 ** 007 - make simulator a config option. Can only be changed at compile time 16 ** at present. May need to implement paged tables in future. 17 ** 008 - added 'S' signature command 18 ** called it MSnS-extra009 - software config of code type via Megatune 19 ** userdefined can choose between MSnS / Neon with or without crank simulator 20 ** 21 ** Think coila and coilb are transposed for some reason? FIXED 22 ** 010 fix bug that caused MSnS mode not to work. Interrupt disarm/re-arm 23 ** was half implemented 24 ** 011 add initial support for 36-1 and 60-2 wheels (simulators) 25 ** 012 jumped onto multiple tables 26 ** VE tables+req fuel will be flash or RAM. All other constants flash only 27 ** Initial page allocation: 0 variables ; 1,2 fuel ; 3 spark 28 ** 012d try spark as 10x10. Not yet supported by MT so put back to 8x8 29 ** 013 start rolling in DT code - pretty radical changes!! 30 ** 014 Extended spark table to 12x12. OK on scope. Injectors to fix. 31 ** 014b no. squirts + mode always from table 1. Alternati ng only in single table. 32 ** 014c Added 10deg timing offset and start of EDIS support 33 ** 014d fixed up rev limiters. dropped cool off period and removed duplication 34 ** 014e work on 36-1 decoder 35 ** 014f fix up FIDLE spark output 36 ** 014h kpa fix by Phil 37 ** 015b changes to DT mode selection 38 ** (changelog continues lower) 39 ********************************************************* msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 2 MC68HC908GP32 User Bootloader ****************** 40 ********************************************************* ****************** 41 ********************************************************* ****************** 42 ** Added MSnS-Enhanced functions to James' MSnS-Extra - P Ringwood 43 ** (Aug 2004) 44 ** 45 ** I/O Structure: 46 ** 47 ** X0 - Flyback 48 ** X1 - Flyback 49 ** X2 - Water Injection Pump Output 50 ** X3 - Water Injection Pulsed Output @ Injector #2 rate 51 ** X4 - Output 1 52 ** X5 - Output 2 53 ** X6 - EGT Input (0-5V) 54 ** X7 - Fuel Pressure Input (0-5V) 55 ** 56 ** TOMI HEADER JP1 57 ** Pin 4 - Launch control Input (Low Active) 58 ** pin 5 - Knock Input (Low Active) 59 ** pin 6 - NOS System Feedback (low active) 60 ** 61 ** Added knock detection system: See help file for details or the 62 ** knock part of the code 63 ** Knock detected on pin 5 of the HEADER TOM (JP1) when it is low it 64 ** detects a knock 65 ** 66 ** Added an Ignition Advance relative to Coolant temp 67 ** 68 ** The Launch Control has been Modified with an idea by Matt, now you 69 ** have the option of a variable hard cut rev limit point. If its 70 ** selected in MT then the rpm the engine is running at when the 71 ** launch button/switch is pressed is set as the hard limit. this 72 ** is to enable you to alter the setting at the track without having 73 ** to get the laptop out. I wouldnt recommend this with a clutch switch 74 ** as every time you put your foot on the clutch it will take in the 75 ** rpm and use that as the limit, I would use a thumb switch or 76 ** something similar as the launch switch. 77 ** 78 ** If you dont like it just select it off in MT:-) 79 ** 80 ** Added an Over boost protection rev cut and soft cut settings 81 ** msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 3 MC68HC908GP32 User Bootloader 82 ** Added Water Injection Control comes on when IAT and boost above 83 ** set-points 84 ** Water pump output (X2) Pulsed output @ injector #2 rate to fast 85 ** acting solenoid (X3) 86 ** 87 ** Added fuel pressure monitoring (X7) and EGT monitoring (X6) 88 ** 89 ** Added Target AFR's (Dave Edge's Code) <45KPa >90KPa (Full closed 90 ** loop mode) 91 ** 92 ** Added Ignition Retard with IAT temperature at a rate of 93 ** 1 degree retard / user defined degrees of IAT (thanks to Eric 94 ** for his help) 95 ** 96 ** KPa open loop for O2 added, optional between Throttle or KPa 97 ** Throttle Position Open loop is now adjustable. 98 ** N.B. Only works when not in "Target AFR Mode" 99 ********************************************************* ****************** 100 * 015c Weird spark and irq led glitch that has been present for a number of 101 * releases now 99% fixed with some tweaks to TIMERROLL 102 * Cranking advance calc fixed (was 10deg offset) 103 * 015d Make high/low speed spark calc based on cycle time not fixed rpm so 104 * it works at the right set point for any number of cylinders 105 * Support for 1-8 cylinders even-fire now. 9+ don't work 106 * Made ve1x,2,3 into macro instead of subroutine to save a little stack. 107 * 015d4 Try to optimise 8,10,12,16. Assume 9,11,13,14,15 illegal. 108 * 015d5 Rectify some spark calc errors to do with 10deg offset 109 * 015e Move code to 8MHz (altered burner.asm too) 110 * 015e1,2 Add EDIS support (timing 1-2 retarded at low advance for some reason) 111 * 015e3 Dual EDIS 112 * 015e4 some fixes by PR 113 * 016 Added Fan control from MSnEDIS. Left retard input for now. 114 * 017a Changed from "A" = 31 back to 25 and added "a" = 31 for enhancements 115 * 017b Added seperate fuel and spark cut selections for launch and revlimiter 116 * also option for the base number to cut sparks from. - PR 117 * 017c Added Roger Enns' Staging Injection System - PR 118 * 017d Changed the Barometric Correction so as it can msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 4 MC68HC908GP32 User Bootloader be set to a max KPa and 119 * a min KPa value, incase of a processor reset during running. - PR 120 * 017e Bug fix for PW1 in DT Mode 121 * Added a second O2 sensor option to run EGO on VE Table2 122 * and page2 enrichments. - PR 123 * 017e1 Added fuel and or spark cut to over boost protection - PR 124 * 017e2 Added cli to P and B SCI routines to help stumbles when using MT 125 * 017e3 ?????? 126 * 017e4 Boost Control check added before doing output1 as same pin used - PR 127 * 017e5 Tidied up some DT functions (ASECnt EgoCnt) - PR 128 * 017e6 Added NOS Anti-turbolag - PR 129 * 018 Added another 12x12 spark table. Can be used with NOS or Just 130 * with JP1 Pin6 input, this can be switched in on the run. -PR 131 * 018a Changes to Neon code to keep ign outputs on right channel 132 * 018b (aborted changes to Neon code to make 24bit hi-res timer) 133 * 018c Changes to TIMERROLL. Just add on 0.1ms to current value. 134 * 018d More optimisation on cycle calcs in TIMERROLL to speed it up 135 * 018e Moved NOS and Staging PW checks to main routine - PR 136 * 018f Added adjustable timer for Spark Table 2 to cut in at after input on. - PR 137 * 018g Can turn off Magnus' false trigger fix (test option) 138 * 019 Added to VE table 1 to make it 11x11 - PR 139 * 019a Went to 12x12 for VE table1 - PR 140 * 019b Both VE tables now 12x12 - PR 141 * 019c Idle PWM Bug fix. Added a window operation to the Outputs 1 and 2 - PR 142 * 019d Changes to Target AFR, to allow tps to change target when MAP >90KPa 143 * Also added VE table 3 for use with the extra Spark Table - PR 144 * 020 Changes to target afrs so now it has user setpoints for the KPa points. 145 * Increased pages to 8, removed page8 = 0 as per James' instructions - PR 146 * 020a Made output duty cycle configurable 50%/75% Mod to EDIS so 147 * "zero delay" is now 64us I found the output unreliable before. 148 * 020a1 Change to EDIS multispark mode. 2048us always sent during crank 149 * (fixed 10BTDC) 150 * 020b Added 12x12 afr target table to both VE tables 1 and 3. 151 * Removed D.Edge's Targets - PR 152 * 020c Bug fix for prime pulse, was always 25.5mS. msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 5 MC68HC908GP32 User Bootloader Added priming pulse 153 * after 2 seconds 154 * option and Prime pump without prime pulse and 2 x priming pulses 155 * option. - PR 156 * 020d Anti-Rev System added, crude Traction Control. - PR 157 * 020e Refined Anti-Rev system, fixed a few bugs in it, working well 158 * on stim - PR 159 * 020f Bug fixes to Boost Controller - PR 160 * 020g We think 12x12 AFR targets is confusing, so brought it down to 8x8. 161 * Added RPM to Boost Controller and Knock can now remove boost 162 * via Boost conroller - PR 163 * 020h Optimisation of the header file for the enhanced stuff, to stop 164 * stack over writing - PR 165 * 020i Rolled JSM strand 020a+020a1 into this release. Added multi-spark 166 * set point 167 * 020j True (crude) dwell control for MSnS needs more testing 168 * Next cylinder mode if < 20 deg trigger angle. Part way to TFI. 169 * 020k Some changes to the Anti-Rev system - PR 170 * 020m Now Anti-Rev has a counter for counting engine cycles - PR 171 * 020n Changes to make the AFR target in AFR rather than volts - PR 172 * 020o Reorganised position of AFR inc files, added speed inputs and 173 * calculations to Anti-Rev - PR 174 * 020p Removed all WB inc files, no need to have incs MT can do it now. 175 * Also changed the outputs so as all can be inverted, should have 176 * done this a while ago. 177 * 020p1 Added page zero check and reload all the feature bits - JSM 178 * 020p2 Removed wheel ENcoders. Accel/decel ctime correction in DOSQUIRT 179 * At high rpm dwell period reduces to minimum 0.2ms off time 180 * Changed output state in bootload and stall mode to avoid 181 * overheating coil - JSM 182 * 020p3 (ignore testing stack) 183 * 020p4 Traction and AFR changes - PR 184 * 020q 7pin HEI - JSM 185 * 020r Removed toothsync, ignore_small,HoldSpark variables. See notes in .h 186 * Changes to Neon for low speed 187 * 020r3 Continue Neon (works) 188 * 020r4 Added Megaview fix to 'A' command 189 * 020s Added ability to switch to targets above tps setpoint and Alpha-n. msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 6 MC68HC908GP32 User Bootloader 190 * Re-organised Spark Angle Additions to clear a byte from the h 191 * file and limits minimum angle to MSnS or 192 * Edis limit - PR 193 * 020t Combined 020s and 020r branches. Took out some of the limits 194 * from 020s as it didn't work? 195 * 020t1 Fixed the Limits in subracting nos, etc, angles (BCS rather than 196 * BMI, thanks James) - Phil 197 * 020t2 Bug fix to the Shift Light code. - Phil 198 * 020t3 PWM idle warmup open loop 199 * 020t4 Cranking mode blocked until stall or restart (For low rpm rock 200 * climbers) 201 * 020i1 turn off DOSQUIRT cli, interrupt protection in TIMERROLL 202 * 020i2 turn off TIMERROLL cli 203 * 020i3 Bandaid for rpmp/rpmc calc to stop drop to zero. MV fix 204 * 020i4 Undid i2 change 205 * 020i5 Check to see if we missed a 0.1ms int during 0.1ms, if we did 206 * then repeat section 207 * 020i6 Removed i3 bandaid. Added hi speed/low spd LED 208 * 020i7 Changed hi/low speed calc to MSnS style rpm based 209 * 020i7a Commented 'ACK IRQ' in TIMERROLL - fixed stumble?!?!?!?!?! 210 * No spikes visible. 211 * 020i8 Revert to ctime based hi/low selection. Keep ACK commented. 212 * 020i9 Fixed real issue, I'd changed re-enabling around RPMLOWBYTECHK, 213 * put back to std) 214 * 020u Included all fixes from 020i9 215 * 020v Try to support Page Chunk write 216 * 020v1 Small boost controller changes (Matt Dupuis idea) 217 * 020v2 Added interpolated allowable traction slip and traction indicator 218 * to OUTPUTS - PR 219 * 020v3 Fixed up chunk write "X" command. 220 * 020v4 Added hysterisis to outputs 1 and 2 - Phil 221 * 020w Added two new tables for 3d mapped boost control 222 * 020w1 Textual config error messages 223 * 020w2 Looking at Neon mode. Fixed silly error in .asm + .h 224 * 020w3 Boost controller changes 225 * 020w4 Make flood clear TPS setting configurable 226 * 020w5 Rolled out NOS and Knock subraction of angles and BCS changes 227 * to cure int miss - PR 228 * 021 new version number. Changed signature. 229 * 021a Timing angle error crept in at 020w5. Fixed. 230 * 021b Added 1 second delay before cant_crank applied. Stall timer now 231 * 0.25s if not cranking. msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 7 MC68HC908GP32 User Bootloader 232 * 021c Send the ports a-d in realtime data 233 * 021d Added facility to cut decel enrichment when above user setpoint 234 * in KPa, and added timer to over run - PR 235 * 021e Added 300 KPa sensor capability - PR 236 * 021f Make 7.37MHz again for MV testing, only partial change. 0.1ms 237 * and EDIS calc untouched 238 * 021f1 Back to 8MHz. Code now sets MV mode if we receive an 'A' command. 239 * Then W is ignored 240 * to save corrupting data and V returns 125 zeros. 241 * 021f2 Make Megaview emuluation mode the default until S,P,R,X received 242 * 021f3 Increase running stall timeout to 0.5s 243 * 021g Fix to 300kpa baro correction and make it one-shot - PR 244 * 021h Change stall timeout so FP runs as normal on startup and 0.5s 245 * stall limit only comes into effect once we've left crank mode for sure 246 * 021i Yet another fix to 300KPa stuff and added 400KPa sensor capability - PR 247 * 021j Added an IAT related boost reduction to the boost controller, 248 * fixed bug in ASE - PR 249 * 021k Added another 6x6 boost table KPa based to switch to on the run - PR 250 * 021l Another output added, LED18 can now be reused for output4 or for 251 * Fan Control as well as X2 - PR 252 * 021m Bug fix to Fixed Angle, found MT not sending a perfect #00 when 253 * -10 deg set so now we check if its lower than #03 - PR 254 * 021n Finally managed to get the adv angle limit for traction control 255 * to work - PR 256 * 021n1 Rolled back some of the code to how it was in 021h/021i, to fix a 257 * Neon problem - LJ 258 * 021o Fixed Fuel Pump prime timer and interpoled prime now works on 259 * first pulse - PR 260 * 021p Cranking PW can use CLT or MAT or average (hot start on cold 261 * day issues) 262 * 021q Generic wheel decoder, started LED18. 263 * 021q1 Looking good. Added third wasted spark coil output on middle LED 264 * 021q2 Mode was hard coded to wheel decoder, fixed 265 * 021q2 Make <21 teeth use low-res timer for decoding 266 * 021q3 Fixed a bug preventing time based cranking working with wheel 267 * decoder in ChkHold 268 * Tidied up a few sections in that area to remove some bra. 269 * Increased Neon initial sync from 3 pulses to 5. msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 8 MC68HC908GP32 User Bootloader 270 * Fixed a silly error that stopped low-res from working (add 271 * instead of adc) 272 * 021r Added "late leading" feature. Sort of works? 273 * No O2 correction in Overrun fuel cut mode 274 * 021s Over flow fixed by adding supernorm into calculations - PR 275 * 021t Undid 021n1 cranking changes. Looks ok on stim. 276 * 021u Toyota DLI ignition multiplex output. D17 is IGt, D19 is IGdA, 277 * D18 is IGdB 278 * 021v Tiny MV/Megatunix compatability tweak. Added 'T' Text version of 279 * release. Send back some real data to MV 'V' command to get 280 * correct map reading with 4250 sensor. Add low speed check for 281 * wheel decoders to prevent false sparking at too low rpm 282 * Make trigger return cranking only apply when cranking, not when "slow" 283 * Took out en_ack and falsetrig advanced options 284 * 021w1 Changes to spark output selection, big tidy up into macro and 285 * new hei4 dwell setting 286 * 021w2 Remove some feature ram variables to make space for dwell timers. 287 * 021w3 Tried a super short 5us dwell for HEI - didn't work.) 288 * 021w4 The trigger return for cranking only fix broke the Neon decoder. Oops. 289 * 021w5 Included Lee's crank phase fix for Neon mode. Fixed low speed spark. 290 * Two line error in dwell timer code was to blame. 291 * Dwell and multi outputs still not working, needs more resolution. 292 * 021w6 Added config checks for wasted spark outputs, more work on dwell. 293 * Make 75%,50% what they say when in wasted spark 294 * 021w7 Removed RAM copies of feature3,4,5,6 to allow more space. All 295 * features need re-testing 296 * 021w8 Made dwell timers 16bit. Had to stack h in TIMERROLL and SPARKTIME. 297 * Beware of stack overflow. 298 * 021w9 Combination of HEI4 + real dwell. Can choose to turn coil on at 299 * trigger during cranking 300 * 021w10 Added MV compatability to 300 and 400 KPa sensors, limit is 255KPa, 301 * untested - PR 302 * 021w11 Cosmetic change only 303 * 021x Added compatability with Eric's Aceleration Wizard in MT and bug 304 * fix to Knock angle - PR 305 * 021x1 Added MAPlast and TPSlast into real time variables sent to MT - PR 306 * 021x2 Re-write of Neon section. This is designed to msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 9 MC68HC908GP32 User Bootloader improve cranking 307 * decoding. - LJ 308 * 021x2 fixes were merged in later by JSM) 309 * 021x3 Fix to check7 section for 3 spark outputs. More work on dwell 310 * 021x4 Added accel/decel correction for dwell. (try to fix wacky HEI7 311 * behaviour) 312 * add check for missed sparktime, caused by 'early' trigger 313 * 021x5 When in "low speed" and doing dwell control, schedule dwell at same 314 * time as spark 315 * In "high speed" the dwell control is still poor during varying rpm 316 * 021x6 Bug fix to MAP based Accel stuff,added decel as a seperate option 317 * for MAP or TPS - PR 318 * 021x7 Added coolant check to over run fuel cut off and decay to accel 319 * enrichment - PR 320 * 021x7a No code changes just comments added to the Flash area for tuning 321 * software writters to see whats where - PR 322 * 021x8 Really fixed(?) spark output checking in check7 and added 323 * another couple of checks on the outputs 324 * 021x9 Bug fix to Accel decay also added X6 and X7 checks to Outputs 325 * 1 and 2 and the facility to have output3 switch on if Output1 326 * and Source or Output2 on- PR 327 * 021x10 Another bug fix to Accel Decay - PR 328 * 022 Re-arranged/shrunk data tables to give more variable space - PR 329 * Renamed to 022 because data format is incompatib le. 330 * 022a Made min nitrous rpm for interpolated fuel a user setting - JSM 331 * Fix to nitrous duty cycle cut - JSM 332 * Added Ryan's PWM idle improvements (using diff 021u vs 021u-idle) 333 * and made settings flashable. Not tested yet - JSM 334 * 022b Removed InjOCFuel_f 1 and 2 from code as not used and causing 335 * trouble in MT - PR 336 * 022b1 Fix to V command, was sending 212 rather than 200, thanks Dave - PR 337 * 022b2 More comments added for Tuning software writers - PR (No code changes) 338 * 022c Added Table for cranking Pulse Widths - PR 339 * 022c1 Bug fix to Priming PW in table mode - PR 340 * 022d Added Table for ASE - PR 341 * 022d1 Slight change to outputs to allow it to work better with MTx - PR 342 * 022e Dwell calc based on batt voltage 343 * Reduce multiplication of period correction msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 10 MC68HC908GP32 User Bootloader 344 * Dwell delay timed with hi-res timer where dwell period fits 345 * between trigger and spark 346 * (to-do: change spark cut/hold spark to omit coil on instead of 347 * coil off) 348 * Testing required. Wheel decoder looks odd, but could be test 349 * bench not code? 350 * 022e1 Changed some comments for Tuning Software writters - PR 351 * 022e2 More comments for software writters, grrrrrr :-) - PR 352 * 022e3 Entire msns-extra.asm file comments cleaned and beautified. 353 * comments are now tabbed and a best effort has been made to keep 354 * them from wrapping over an 80 col display and to keep them as close 355 * to lined up as possible. Only 1 code change in load_table: to 356 * switch to 201 from 212 - DJA 02-15-2005 357 * 022e4 Bug fix found by DJA after comments - PR 358 * 022f Added lineto clear megaview compat mode when a "P" command arrives 359 * handles the case where the ecu resets in use, it'll go back to 360 * enahanced mode. upon recept of next P cmd. should help megatune 361 * and megatunix. (megatunix detected it) 362 * 022g work on moving some dwell calcs to mainloop to avoid dropouts in wheel decoder mode 363 * Added equates in .h to allow temp storage in burner ram area (when 364 * not burning of course!) e.g. DOSQUIRT, TIMERROLL , SPARKTIME 365 * Revised check at end of TIMERROLL to avoid missing the next int 366 * 022h Added the ability to turn accel enrich off during ase - PR 367 * 022i Major movement and optimising of main loop, removed items like fuel and spark 368 * calculations from being done within a subroutine . - PR 369 * 022i1 Even more optimising of main loop - PR 370 * 022i2 ? - PR 371 * 022i3 Uncommented some CLIs in TIMERROLL and commented some in "B" command. 372 * Also some CLI taken out of burnconst (burner8b.a sm) to ensure that nothing 373 * can clobber the burner ram while it is in use. Hopes to fix serial comms 374 * symptoms since 022g 375 * 022i4 Replaced a line that got deleted in error. 376 * 022i5 Bug fix for DT, makes single table modes better too - PR 377 * 022i6 Removed old ASE settings and Cranking PW, all done with the tables now - PR msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 11 MC68HC908GP32 User Bootloader 378 * 022i7 Bug fix for DT, req_fuel ram not correct and ALT/SIM removed from VE2 - PR 379 * 022j Moved Page2 in line with Page1 so RAM lines up again, so rolled out 022i7 fix, 380 * Also made the new output bits after secl + 30 - PR 381 * 023 Rolled code version forward as Page 2 moved in 022j - PR 382 * 023a Added the facility to have normal Prime Pulse and interpoled, also added IAT 383 * check when firing up ADC so its stored ready for Prime Pulse Calcs - PR 384 *-> 023b released by Phil.... code not in here yet <-* 385 * 023c1 Spark changes 386 * Rename some variables, HRcTime -> global iTime, next cyl mode cleanup to 387 * remove nasty hack. Should work on any num cyls now. 388 * Extended T2 to 24bits in software, very small overhead every 65ms 389 * 023c2 Send iTimeX out with realtime data so hi-res rpm calc gauge works at all rpm 390 * iTime to get zeroed on stall. Why no fuel < 100rpm? A fix in place 391 * Make dwell settings in 0.05ms. Do period calcs in us then convert to 0.1ms 392 * afterwards. Hope to reduce jittering of dwell period when predicting many 393 * periods ahead 394 * 023c3 More of the same 395 * 023c4 Fix what got broken in wheel decoder 396 * 023c5 Include Phil's 023b fixes 397 * 023c6 Fixed up my typos in Neon section 398 * Bumped up default values for very cold crank PW and ASE to give users the idea. 399 * These tables should have a 1/x type decay, really ramping up when cold. 400 * 023c7 Next cyl low rpm/dwell issue? Set spark angle as trigg angle when NC/cranking 401 * iTime calc was getting missed 402 * 023c8 Make spark output pos/neg a quick byte for tiny speedup in ints 403 * 023c9 Added second input for wheel decoder in pin10 404 * 023c10 Change ddrc only the fly after a B. Put output on correct pin! 405 * 023c11 10deg offset in next cyl displayed crank angle 406 * Known limitation. Next cyl and wheel decoder do not work correctly 407 * I'll look into this as it could be great for dual VR pickup bikes 408 * 023c12 At ~500 rpm seeing phantom misdecoded outputs. Can't be sure if this 409 * is real or testbench. Seems ok now with no code changes??! 410 * 024 Same code new name 411 * 024a Changes to HEI7 bypass code to be closer to GM 412 * 024b Added Fixed ASE period to ASE - PR 413 * 024c Added fixed VE value period during Fixed ASE msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 12 MC68HC908GP32 User Bootloader timer and jump past warmup 414 * section if its not needed to save some time - PR 415 * 024d Changed from fixed VE to fixed MAP during ASE, also tidied up the spark-fuel 416 * cut options as they were difficult to fault find - PR 417 * 024e Changes to 300-400KPa stuff, added supernorm to the calcs - PR 418 * 024f Increased hires/lowres dwell margin aiming to eliminate observed problem 419 * as the dwell start point goes earlier than the trigger 420 * Fixed a silly typo (JSM) that had broken Neon - JSM 421 * 024g Removed one shot from error message so MTx can display errors, also 422 * added the 300-400KPa fix to the DT stuff - PR 423 * 024h Add an option to allow better testing of wasted spark outputs on the stim. 424 * It takes the normal tach input and steps through the outputs. DO NOT USE 425 * ON THE CAR! 426 * 024h1 Block v.low speed misdecoding for wheel and add a failsafe "turnallspkoff" 427 * in the mainloop when not running 428 * 024h2 Had to make the error message one-shot again or it cocks up Megatune 429 * 024i Moved sparkcut to cut dwell not spark to avoid module overheating 430 * 024i2 Start of output support for twin rotor 431 * 024i3 Increased hires/lowres dwell margin as missed sparks still evident 432 * 024i4 More twin rotor. Fixed 1ms split working for testing. 433 * 024i5 Added maps for split, not used yet 434 * 024i6 Added vars to use split map and fixed split for testing 435 * 024i7 Inital checks for rotary outputs 436 * Got it working on scope both with fixed and mapped split 437 * Changed the way trigger return is used in MSnS slightly (PR reported problem) 438 * 024i8 Dwell was half what it should be due to remenants of test code 439 * 024j Fix to 3-400KPa stuff - PR 440 * 024k Ensure all spark outputs are inactive at power on 441 * 024l Fixed the IAT from being altered during fixed MAP - PR 442 * 024l2 Fixup wheel decoding not picking up. Fixup excessive dwell at cranking rpm 443 * 024l3 Rotary - make sure trailing coil is off when it ought to be. 444 * Dwell is still imperfect under changing rpm 445 * 024m Bug fix to second O2 sensor correction limit - PR 446 * 024n (024l3 change got lost.. put back in) 447 * Wheel decoder fix used mask of $3f, should have msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 13 MC68HC908GP32 User Bootloader been $5f 448 * Changed dwell calcs a bit, found that accel/dece l correction wasn't 449 * working because iTimep wasn't being stored correctly 450 * 024n2,3,4,5 internal releases 451 * 024o DT test to see if alt - sim modes work (worked OK)- PR 452 * 024p Added the 3-400KPa fix to the DT code - PR 453 * 024q Work on wheel decoder sync issue. Works on scope. To be tested on bench. 454 * Now picks up 36-1 on bench fine. Trigger return with dwell gives odd 455 * results. 456 * 024r Added personality checks to spark stuff, if personality = 00 then no spark 457 * stuff needs to be run. Tidied up a few bra instructions to jmp - PR 458 * 024s Added the ability to use the MAP sensor as constant baro corr when in 459 * alpha-n mode - PR 460 * 024s1 Realised constant baro wasnt what was needed, it was the KPa calcs, 461 * so added that to the calcs as an option for alpha-n - PR 462 * 024s2 Test code - added bandaid to check if 0.1ms got missed, fire off in mainloop 463 * 024s4 Test code make dwell delay fixed 1ms - no dropouts 464 * 024s5 Remove unused UMUL32 465 * 024s6 Check for negative iTime caused by missed T2X increment 466 * 024s7 Forgot to remove fixed 1ms.. 467 * 024s8 False trigger protection was still commented out 468 * 024s9 Odd fire averaging back into code (was never in MSnS) 469 * 024s12 Wheel decoder false trigger protection at tooth level. 470 * Rolling filtered average tooth time stored. If IRQ trigger comes far too 471 * early then must be a false trigger, gets ignored. Missing tooth period 472 * also compared to rolling average instead of just previous period. 473 * 025a Logging of wheel decoder teeth time - page 9 ($F0) 474 * 025b Logging of "trigger" time - page 10 ($F1) Data reduced to 99 x byte pairs 475 * 199th byte is pointer to next byte to be written 476 * 200th byte low bit =0 for us, 1 = 0.1ms units 477 * 025c Added hysteresis to Rotary split and other trailing fixups 478 * 025d Include Ryan Davidson idle code. Add configurabl e tach output 479 * 025e Hopefully included all of Ryan's code this time. 480 * 025f Added a way to trigger extra cranking fuel by making TPS go above floodclear 481 * 3 times whilst engine not running or cranking. msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 14 MC68HC908GP32 User Bootloader - PR 482 * 025g Added a RPM based Accel Enrichment, triggers from MAP or TPS as usual, but 483 * the fuel added is based on the engine rpm not rate of change. - PR 484 * 025g1 Small change to RPM AE - PR 485 * 025g2 Added a check to see if RPM AE lower than decay value also bug 486 * fix to AE stuff - PR 487 * 025h Rolled in Ken Culver's (KC) rotary fixes that were against 025e 488 * 025i Big changes to the way dwell is handled when multiple coils are used. 489 * When Launch is on, nitrous is off. 490 * 025i3 Work in progress. Make dwelldelay1,2,3,4 work from flash for testing only. 491 * CalcSpk dwell working as expected. 492 * 025i4 Test dwelldelay1,2,3,4 calcs 493 * 025i5 Dwelldelay calcs fixups. Looks ok on scope and in logged debug data. 494 * 025i6 Removed debug data from "R" command 495 * 025j Moved the RPM based AE stuff to a different page - PR 496 * 025j1 Warmup Idle bug fix, in Warmup mode only - PR 497 * 025j2 Fixup fixed "dwell" duty cycle for single output - JSM 498 * 025k Merged in KC's 025i6mod rotary changes - JSM 499 * 025l Added Mass Air Flow Meter as an option for fuel calculations - PR 500 * 025l2 Bug fix to Idle PWM as noticed by Caaarlo - PR 501 * 025m Bug fix in major error to KPa and MAF stuff - PR 502 * 025n Poor wheel pickup after stall. Tiny change in stall section. 503 * 025n1 If >20 teeth then 3/4 rolling average else use last tooth 504 * 025n2 Zero lowres on stall 505 * 025n3 Don't check for false triggers in wheel until synced up 506 * 025n4,5,6,7 Working on dwell calc + dwell accel correction. Sign was wrong 507 * 025n8 Reduced amount of accel factor added in all those sections of dwell delay calc. 508 * 025n9 Removed "double it in accel" dwell correction 509 * 025p Bug fix for Hot Idle PWM - PR 510 * 025q Added Air Density Factor as an option for MAF stuff - PR 511 * 025q1 Added Constant Baro Correction using a Standard 4250 map sensor on X7 - PR 512 * 025v Changes to IAT air density, now uses CLT sensor too - PR 513 * 025v1 Bug fix to IAT correction air density, have to do airtemp calcs first - PR 514 * 025w Changed fixed Temperature values to variable in coolant Air Density - PR 515 * 025x Roll in KC's Idle-adcance code and revert a few small changes from 025k, 025n9 516 * For testing purposes, make hi-res dwell optional 517 * 025x1 Typo in "fix" msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 15 MC68HC908GP32 User Bootloader 518 * 025y Flat shift and launch have own limits 519 * Launch to nitrous on delay, flat shift to nitrous on delay 520 * Start of nitrous fuel hold-on in code. 521 * 025z Flat shift has own retard limit and setting. 522 * 026a Next-cyl railing at trigger fix from Baldur. 523 * 026b Minor tweak to when SparkAngle gets saved for better next cyl stability at low advance 524 * Config option to bypass "new" 025 wheel decoder element 525 * 026c SparkD now gets turned off in stall. Soft rev limiter fixed. 526 * SparkAngle now stored once all calcs done. 527 * 026d Added config data for 2nd stage nitrous and updates to .ini. Code does not use it yet. 528 * Fixed false "config error" when choosing fuel only. JSM 529 * 026e Included PR's fix for realtime baro correction 530 * 026f Experimental oddfire ignition offset code. Dwell WILL NOT work correctly. 531 * 026g Save ram by combining stHp, avgtoothh and low bytes. Added another byte 532 * Add hysteresis to hi-res dwell. 533 * 026g2 Turn on fuel pump as soon as any trigger received. 534 * 026h Constant baro correction for alpha-n 535 * 026h2 Undid 026g2 fuel pump as it was half hearted and caused problems for some. 536 * 026i Re-write rpm calc for better odd-fire averaging. Avg now done before calc 537 * with period data not avg of 8 bit answer 538 * 026j Added 5th and 6th spark outputs and 5 & 6 o/p dwell 539 * Code went beyond $D000 and collided with flash tables. Tables moved to $E000. 540 * Added "dual dizzy" output option, allows 4,6 triggers to control 2 alternate coils 541 * Some work on oddfire dwell, dwells across two periods only to avoid "oddness".. perhaps 542 * **Reversed sense of 2nd trigger input** so it is the same as the IRQ 543 * Extended the oddfire offset stuff to the six outputs. 544 * (No feedback on whether this code is any use yet.) 545 * TO-DO review dwell calcs for 5 and 6 outputs, working but imperfect 546 * 027a Same code. Bumped up number as so much changed. 547 * 027a1 Fixed a false config error in dual dizzy mode 548 * 027b Prevent dual dizzy if not in wheel decoder. Fix? for low speed TFI 549 ********************************************************* ******************* 550 ********************************************************* ******************* 551 ** M E G A S Q U I R T N S P A R K - 2 0 0 3 - V2.986 552 ** 553 ** By Magnus Bjelk (magnus@r16site.com) msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 16 MC68HC908GP32 User Bootloader 554 ** 555 ** Fuel injection and ignition controller 556 ** based on the work of Bowling and Grippo 557 ** 558 ** Large chunks of code is from MegaSquirtDT by Eric Fahlgren/Guy Hill 559 ********************************************************* ****************** 560 ********************************************************* ****************** 561 562 ********************************************************* ****************** 563 ********************************************************* ****************** 564 ** M E G A S Q U I R T - 2 0 0 1 - V2.00 565 ** 566 ** (C) 2002 - B. A. Bowling And A. C. Grippo 567 ** 568 ** This header must appear on all derivatives of this code. 569 ** 570 ********************************************************* ****************** 571 ********************************************************* ****************** 572 573 574 ;-------------------------------------------------------- ------------------ 575 ; Version 2.0 576 ;-------------------------------------------------------- ------------------ 577 ; 2003-07-08 MBJ First release 578 ; 579 ;-------------------------------------------------------- ------------------ 580 ; Version 2.01 581 ;-------------------------------------------------------- ------------------ 582 ; 2003-07-16 MBJ Bugfix. rpm not zero until 2.5 seconds after start 583 ; resulting in lots of advance at cranking if you're 584 ; quick on the key 585 ;-------------------------------------------------------- ------------------ 586 ; Version 2.02 587 ;-------------------------------------------------------- ------------------ 588 ; 2003-08-04 MBJ Bugfix. Ignition module output always on for 3.2ms 589 ; resulting in high rpm (more than 6000 for 4 cyl) 590 ; late ignition. Added kind of dwell control 591 ;-------------------------------------------------------- ------------------ msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 17 MC68HC908GP32 User Bootloader 592 ; Version 2.986 593 ;-------------------------------------------------------- ------------------ 594 ; 2003-09-16 MBJ Updated to be compatible with MegaSquirt 2.986 595 ;-------------------------------------------------------- ------------------ 596 ; Version 3.0 597 ;-------------------------------------------------------- ------------------ 598 ; 2003-10-08 MBJ Adding new features: 599 ; Long triggers, up to 135 deg, different angle calc 600 ; Timebased cranking timing, for VR pickups 601 ; Invert output option 602 ; Rev limiters, soft and hard 603 ; Programable outputs 604 ; Fixed high speed rpm calculation 605 ;-------------------------------------------------------- ------------------ 606 ;-------------------------------------------------------- ------------------ 607 ; Version 3.01 608 ;-------------------------------------------------------- ------------------ 609 ; 2004-05-08 MBJ Bugfix. Extra long triggers (over 89.5 deg) not 610 ; working as intended 611 ;-------------------------------------------------------- ------------------ 612 613 ;.base 10t 614 ;.set simulate 615 0040 616 org ram_start 0040 617 include "msns-extra.h" 618 ;**************************************************** 619 ; msns-extra.h - code mods based on megasquirtnspark JSM 620 ; Lots of stuff used from Dual table 621 ; 622 ; MegaSquirt.h Include File - V1.9999 623 ; 624 ; (C) Bruce A. Bowling / Al C. Grippo 625 ; 626 ; This header must appear on all derivatives 627 ; of this file. 628 ;**************************************************** 629 ; V2.0 Include File For megasquirt.asm 630 ;**************************************************** 631 ;* 632 ;* MegaSquirt Hardware Wiring 633 ;* 634 ; 635 636 ;Port A 637 ; PTA0 - FP 638 ; PTA1 - FIDLE 639 ; PTA2 - Output 2 (X5) 640 ; PTA3 - Output 1 (X4) 641 ; PTA4 X3 642 ; PTA5 X2 643 ; PTA6 - Flyback 644 ; PTA7 - Flyback 645 646 ;Port B (ADC inputs) 647 ; PTB0/AD0 - MAP 648 ; PTB1/AD1 - MAT 649 ; PTB2/AD2 - CLT 650 ; PTB3/AD3 - TPS 651 ; PTB4/AD4 - BAT 652 ; PTB5/AD5 - EGO 653 ; PTB6/AD6 - "X7" spare, EGO2, fuel pressure or 2nd MAP 654 ; PTB7/AD7 - "X6" spare, EGT 655 656 ;Port C 657 ; PTC0 - Squirt LED or coil a 658 ; PTC1 - Accel LED or coil b or HEI7 bypass 659 ; PTC2 - Warmup LED or coil c or output 4 660 ; PTC3 } multiplexed shift { or coil e 661 ; PTC4 } light outputs { or 2nd trig input 662 663 ;Port D 664 ; PTD0/~SS - unused or coil d 665 ; PTD1/MISO - nitrous in / table switch 666 ; PTD2/MOSI - knock in / coil f 667 ; PTD3/SPSCK - launch in 668 ; PTD4/T1CH0 - Inj1 669 ; PTD5/T1CH1 - Inj2 670 671 672 ;portd 0040 673 NosIn: equ 1 0040 674 KnockIn: equ 2 0040 675 launch: equ 3 0040 676 inject1: equ 4 0040 677 inject2: equ 5 678 679 ;porta 0040 680 fuelp: equ 0 0040 681 iasc: equ 1 0040 682 output2: equ 2 0040 683 output1: equ 3 0040 684 water2: equ 4 0040 685 water: equ 5 ; or used for X2 Electric fan output 686 0040 687 boostP equ 3 0040 688 Output3: equ 0 689 690 ;portc 0040 691 sled: equ 0 ; LED17 0040 692 aled: equ 1 ; LED19 0040 693 wled: equ 2 ; also IRQ LED18 only used in "fuel only" code 0040 694 coila equ 0 ; LED17 0040 695 coilb equ 1 ; LED19 0040 696 pin10 equ 3 ; ptc3 - 2nd trigger for wheel decoder or shiftlight 0040 697 pin11 equ 4 ; ptc4 698 0040 699 c13_of equ %00000001 ; defined but rarely used in code 0040 700 c13_o2 equ %00000010 0040 701 c13_cs equ %00000100 0040 702 c13_bc equ %00001000 703 704 ;dtmode equates. Now Simplified. 705 ;alt_dt equ %00000001 ; 1=dual table 0=single table 706 ;alt_i1t1 equ %00000010 ; from 015b Inj 1 always table 1 707 ;alt_i1t2 equ %00000100 708 ;alt_i2t1 equ %00001000 0040 709 alt_i2t2 equ %00010000 ; inj2: 0 = t1, 1 = t2 0040 710 alt_i1ge equ %00100000 0040 711 alt_i2ge equ %01000000 712 0040 713 WHEELINIT equ %11000101 714 715 ;Sparkconfig1 equates 0040 716 M_SC1LngTrg equ $01 ; Spark config 1 (0) Long trigger +22.5 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 18 MC68HC908GP32 User Bootloader 0040 717 M_SC1XLngTrg equ $02 ; Spark config 1 (1) Extra Long trigger +45 0040 718 M_SC1TimCrnk equ $04 ; Spark config 1 (2) Time based cranking (not trigger return) 0040 719 M_SC1InvSpark equ $08 ; Spark config 1 (3) Invert spark output 0040 720 M_SC1oddfire equ $10 ; Spark config 1 (4) Oddfire ignition 721 722 ;oddfire offset setting equates 0040 723 outoff_22b equ $01 0040 724 outoff_45b equ $02 0040 725 outoff_90b equ $04 726 727 ;**************************************************** 728 ;* 729 ;* MegaSquirt RAM Variables 730 ;* 731 ;* We wish we had plenty of RAM to burn 732 ;**************************************************** 733 ms_ram_start: 734 735 ; RAM Variables - Ordered List for RS232 realtime download - delivered in one pack 0040 736 secl: ds 1 ; low seconds - from 0 to 255, then rollover 737 0041 738 squirt: ds 1 ; Event variable bit field for Injector Firing 739 ; Squirt Event Scheduling Variables - bit fields for "squirt" variable 0042 740 inj1: equ 0 ; 0 = no squirt 1 = squirt 0042 741 inj2: equ 1 ; 0 = no squirt 1 = squirt 0042 742 sched1: equ 2 ; 0 = nothing scheduled 1 = scheduled to squirt 0042 743 firing1: equ 3 ; 0 = not squirting 1 = squirting 0042 744 sched2: equ 4 0042 745 firing2: equ 5 746 0042 747 engine: ds 1 ; Variable bit-field to hold engine current status 748 ; Engine Operating/Status variables - bit fields for "engine" variable 0043 749 running:equ 0 ; 0 = engine not running 1 = running 0043 750 crank: equ 1 ; 0 = engine not cranking 1 = engine cranking 0043 751 startw: equ 2 ; 0 = not in startup warmup 1 = in warmup enrichment 0043 752 warmup: equ 3 ; 0 = not in warmup 1 = in warmup 0043 753 tpsaen: equ 4 ; 0 = not in TPS acceleration mode 1 = TPS acceleration mode 0043 754 tpsden: equ 5 ; 0 = not in deacceleration mode 1 = in deacceleration mode 0043 755 mapaen: equ 6 ; 0 = not in MAP acceleration mode 1 = MAP deaceeleration mode 0043 756 idleOn: equ 7 ; 757 0043 758 baro: ds 1 ; Barometer ADC Raw Reading - KPa (0 - 255) 0044 759 map: ds 1 ; Manifold Absolute Pressure ADC Raw Reading - KPa (0 - 255) 0045 760 mat: ds 1 ; Manifold Air Temp ADC Raw Reading - counts (0 - 255) 0046 761 clt: ds 1 ; Coolant Temperature ADC Raw Reading - counts (0 - 255) 0047 762 tps: ds 1 ; Throttle Position Sensor ADC Raw Reading - counts, represents 0 - 5 volts 0048 763 batt: ds 1 ; Battery Voltage ADC Raw Reading - counts 0049 764 ego: ds 1 ; Exhaust Gas Oxygen ADC Raw Reading - counts 004A 765 egocorr: ds 1 ; Oxygen Sensor Correction 004B 766 aircor: ds 1 ; Air Density Correction lookup - percent 004C 767 warmcor: ds 1 ; Total Warmup Correction - percent 004D 768 rpm: ds 1 ; Computed engine RPM - rpm/100 004E 769 pw1: ds 1 ; injector squirt time in 1/10 millesec (0 to 25.5 millisec) - applied 004F 770 tpsaccel: ds 1 ; Acceleration enrichment - percent 0050 771 barocor: ds 1 ; Barometer Lookup Correction - percent 0051 772 gammae: ds 1 ; Total Gamma Enrichments - percent 0052 773 vecurr: ds 1 ; Current VE value from lookup table - percent 0053 774 pw2: ds 1 0054 775 vecurr2: ds 1 0055 776 idleDC: ds 1 0056 777 ctimeCommH: ds 1 ; Cycle time H for communication 0057 778 ctimeCommL: ds 1 ; Cycle time L for communication 0058 779 SparkAngle: ds 1 ; Spark angle (256 = 90 deg) 0059 780 afrTarget: ds 1 ; AFR Target temp variable 005A 781 o2_fpadc: ds 1 ; Second O2 sensor or Fuel Pressure 005B 782 egtadc: ds 1 ; EGT Temperature 005C 783 CltIatAngle: ds 1 ; Coolant Iat Angle 005D 784 KnockAngle: ds 1 ; Knock Angle 005E 785 egoCorr2: ds 1 ; Second O2 sensor Ego Correction 786 787 ;------------------------- 788 005F 789 SparkBits: ds 1 ; Spark timing bits 0060 790 SparkTrigg equ 0 ; SparkBits(0) IRQ has triggered, but no spark yet 0060 791 SparkHSpeed equ 1 ; SparkBits(1) High speed spark (using highres timer) 0060 792 SparkLSpeed equ 2 ; SparkBits(2) Low speed spark (using low speed timer or trigger going low) 0060 793 dwellcd equ 3 ; used for rotary to tell calcdwellspk not to dwell trailing 0060 794 rise equ 4 ;} found a rising IRQ edge / 2nd multispark / coilcbit 0060 795 lc_fs equ 5 ; doing flat shift vs. launch 0060 796 trigret equ 6 ; falling edge at end of short pulses - sets crank timing 0060 797 Knocked equ 7 ; Knock system working 798 799 ;Rev limiter variables 0060 800 RevLimBits ds 1 ; Rev limiter status bits 0061 801 RevLimSoft equ 0 ; RevLimBits(0) Soft rev limiter in action 0061 802 RevLimHSoft equ 1 ; RevLimBits(1) Soft rev limiter hard mode 0061 803 RevLimHard equ 2 ; RevLimBits(2) Hard rev limiter in action 0061 804 sparkon equ 3 ; ran out of space in sparkbits 0061 805 coilerr equ 4 ; out of sequence coil detection 0061 806 sparkCut equ 5 ; Spark Cut in action 0061 807 LaunchOn equ 6 ; Soft Launch On 0061 808 Advancing equ 7 ; Advancing Knock system 809 0061 810 personality ds 1 ; code works from ram. loaded from flash at boot 0062 811 MSNS equ 0 ; Megasquirtnspark 0062 812 MSNEON equ 1 ; MS neon decoder 0062 813 WHEEL equ 2 ; generalised decoder 36-1, 60-2 etc 0062 814 WHEEL2 equ 3 ; 0 = -1 1 = -2 0062 815 EDIS equ 4 ; edis 0062 816 DUALEDIS equ 5 ; two edis modules (for edis4 on V8, edis6 on V12) 0062 817 TFI equ 6 ; Ford TFI system 0062 818 HEI7 equ 7 ; GM 7 pin HEI 819 820 ** output bits 821 ** spark output defaults to FIDLE (original MSnS) 822 ** Neon code always put coils on D19 and D17 0062 823 outputpins ds 1 ; 0 (B&G) | 1 (non B&G) 0063 824 REUSE_FIDLE equ 0 ; FIDLE for iasc | spark output 0063 825 REUSE_LED17 equ 1 ; LED17 for sled | coila output 0063 826 REUSE_LED18 equ 2 ; mismatch between .ini and .asm 0063 827 REUSE_LED18_2 equ 3 ; 828 ; LED18_2 LED18 function 829 ; 0 0 wled 830 ; 0 1 irq 831 ; 1 0 output4 832 ; 1 1 spark c 833 0063 834 REUSE_LED19 equ 4 ; LED19 for aled | coilb output 0063 835 X2_FAN equ 5 ; X2 water/n2o | fan control 0063 836 LED18_FAN equ 6 ; LED18 output4 | fan control 0063 837 TOY_DLI equ 7 ; toyota DLI ignition multiplex 838 0063 839 feature1 ds 1 ; some features taken from Dual Table 0064 840 wd_2trig equ 0 ; wheel decoder 2nd trigger i/p - new in 023c9 0064 841 egoIgnCount equ 1 0064 842 whlsim equ 2 ; enable wheel simulator for use on the stim ONLY 0064 843 taeIgnCount equ 3 0064 844 rotaryFDign equ 4 ; enable rotary FD ignition outputs 0064 845 hybridAlphaN equ 5 0064 846 CrankingPW2 equ 6 0064 847 Nitrous equ 7 0064 848 wd_2trigb equ 1 ; for use by BIT 849 0064 850 feature2 ds 1 ; more 0065 851 BoostControl equ 0 0065 852 ShiftLight equ 1 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 19 MC68HC908GP32 User Bootloader 0065 853 LaunchControl equ 2 0065 854 PWMidle equ 3 0065 855 out3sparkd equ 4 ; 1= use output for spark D 0065 856 min_dwell equ 5 0065 857 dwellduty50 equ 6 0065 858 config_error equ 7 ; set if non-sense combination of options - don't run. 859 860 ;feature3 ds 1 0065 861 KPaTpsOpenb equ 1 0065 862 VarLaunchb equ 2 0065 863 CltIatIgnitionb equ 4 0065 864 WaterInjb equ 8 0065 865 Fuel_SparkHardb equ $10 ; Fuel or Spark cut for Rev limiter 0065 866 FuelSparkCutb equ $20 ; Fuel or spark cut for Rev limiter 0065 867 KnockDetb equ $40 0065 868 TargetAFRb equ $80 869 870 ;feature4 ds 1 ; Enhanced stuff 0065 871 miss2ndb equ 1 ; Missing tooth AND 2nd trigger 0065 872 InvertOutOneb equ 2 0065 873 InvertOutTwob equ 4 874 ;;multispark equ 3 ; EDIS multi-spark } for use in brset/clr 0065 875 multisparkb equ 8 ; } for use in bit 0065 876 KPaDotBoostb equ $10 0065 877 DtNosb equ $20 ; If DT which Bank do we add NOS PW to (Bank1=0 Bank2=1) 0065 878 OverRunOnb equ $40 0065 879 KpaDotSetb equ $80 880 881 ;feature5 ds 1 ; More Enhanced stuff 0065 882 Fuel_SparkHLCb equ 1 ; Fuel or Spark cut for Launch 0065 883 FuelSparkLCb equ 2 ; Fuel or Spark cut for Launch 0065 884 stagedb: equ 4 ; Roger Enns Staged Mode xxxx00xx = Staged Off xxxx01xx = RPM Based 0065 885 stagedModeb: equ 8 ; Roger Enns Staged Mode xxxx10xx = MAP Based xxxx11xx = TPS Based 0065 886 stagedeither: equ $0c ; either staging 0065 887 BoostCutb: equ $10 ; Over boost Cut type, option2 or spark cut 0065 888 BoostCut2b: equ $20 ; Option2 for Over boost Cut type, fuel only or both fuel and spark 0065 889 NosLagSystemb: equ $40 ; Nos Anti-lag System used 0065 890 SparkTable2b: equ $80 ; Second Spark Table 891 892 ;feature6 ds 1 ; Enhanced stuff 0065 893 VETable3b equ 1 ; Use VE table 3 0065 894 TargetAFR3b equ 2 ; Use Target AFR for VE3 0065 895 hrd_disableb equ 4 ; 0=Enable hi-res dwell, 1=disable ; testing 0065 896 wheel_oldb equ 8 ; 0= new(025) wheel decoder or 1=old(024s9) style ; testing 0065 897 dualdizzyb equ $10 ; 0065 898 TractionCb equ $20 ; Traction control system on 0065 899 BoostDirb equ $40 ; Direction for boost control output 0065 900 NoDecelBoostb equ $80 ; No decelleration when in boost 901 0065 902 feature7 ds 1 ; Enhanced stuff 0066 903 TractionNos equ 0 ; Turn Nos off in Traction Loss? 0066 904 dwellcont equ 1 ; Real (crude) dwell control 0066 905 TCcycleSec equ 2 ; Hold traction settings for cycles or till rpm stable for 0.1S 0066 906 WheelSensor equ 3 ; TC wheel sensors fitted 0066 907 AlphaTarAFR equ 4 ; Alpha n or speed density for target afr 0066 908 TPSTargetAFR equ 5 ; TPS setpoint for target AFR's 0066 909 idle_warmup equ 6 ; pwm idle warmup open loop 0066 910 idle_cl equ 7 ; pwm idle closed loop 911 912 ;feature8 ds 1 ; More Enhanced stuff ; changed to bit modes, hence b suffix 0066 913 KPa300b: equ 1 ; 300 KPa sensor use 0066 914 KPa400b: equ 2 ; 400 KPa sensor use 0066 915 BoostTable3b: equ 4 ; Use boost table 3 when switch table input on 0066 916 spkeopb equ 8 ; Enable spark E output (instead of shiftlight) 0066 917 spkfopb equ $10 ; Enable spark F output (instead of knock in) 0066 918 DecelMAPb: equ $20 ; Use MAP for Decel 0066 919 InterpAcelb: equ $40 ; Interpole the accel enrichments down to a setpoint 0066 920 Out1_Out3b: equ $80 ; Output3 only if output1 is on. 921 922 ;feature9 0066 923 CrankPWTableb: equ 1 ; Use cranking PW Table 0066 924 ASETableb: equ 2 ; After start enrichment use table 0066 925 NoAccelASEb: equ 4 ; No Accel Enrich during After start enrichment 0066 926 BaroCorConstb: equ 8 ; If Alpha-n Mode then do we use MAP for Baro cor constantly. 0066 927 RpmAEBased: equ $10 ; RPM Based Accel Enrichment 0066 928 MassAirFlwb: equ $20 ; Using Mass AirFlow meter instead of a MAP sensor. 0066 929 NoAirFactorb: equ $40 ; If using MAF do we use Air Density in fueling cals? 0066 930 ConsBarCorb: equ $80 ; Constant Bar Cor using MAP on X7 931 932 ;feature10_f5 0066 933 aseIgnCountb equ 1 ; AFTER START Enrichment Seconds || Engine Cycles^ 0066 934 ASEHoldb: equ 2 ; Hold ASE from decaying for a period of time determined by TimFixASE_f 0066 935 MAPHoldb: equ 4 ; Fix MAP value during Fixed ASE timer 0066 936 cltMAPb: equ 8 ; Use Correction table in the Air Density factor 0066 937 CltMATCheck: equ $10 ; Correction table MAT or IAT based 938 ;feature11_f4 0066 939 AlwaysPrimeb: equ 1 ; Only fire pump if Prime pulse ON | Prime pump every time 0066 940 PrimeLateb equ 2 ; Fire prime pulse after 2 seconds 0066 941 PrimeTwiceb equ 4 ; Fire the Prime Pulses Twice 0066 942 NoPrimePb: equ 8 ; Use Priming Table or Use Prime Pulse 0066 943 cltcrankb: equ $10 ; use coolant temp for crank pulsewidth 0066 944 matcrankb: equ $20 ; use inlet air temp for crank pulsewidth. Both means average 0066 945 ExCrFuelb: equ $40 ; Look at TPS to see if we trigger extra fuel during cranking? 946 947 ;feature12_f2 0066 948 SecondO2b equ 1 949 0066 950 EnhancedBits: ds 1 ; Enhanced Stuff 0067 951 NosDcOk: equ 0 ; Nos System not causing Duty Cycle of >90% 0067 952 NosSysOn: equ 1 ; Nos System Running 0067 953 OverRun: equ 2 ; Over Run Fuel Cut 0067 954 REStaging: equ 3 ; Roger Enns Staging On 0067 955 NosAntiLag: equ 4 ; Nos Antilag running 0067 956 NosSysReady: equ 5 ; NOS Ready to go 0067 957 UseVE3: equ 6 ; Use VE table 3 0067 958 Primed: equ 7 ; Fuel System Primed 959 0067 960 EnhancedBits2: ds 1 ; A few more enhanced bits 0068 961 Traction: equ 0 ; Traction control running 0068 962 Output1On: equ 1 ; Bit for the output 1 on 0068 963 Output2On: equ 2 ; Bit for the output 2 on 0068 964 cant_crank equ 3 ; Flag that we can't enter crank mode 0068 965 cant_delay equ 4 ; delay bit for cant crank mode 0068 966 over_Run_Set: equ 5 ; Set over run active for timer 0068 967 mv_mode: equ 6 ; we are in Megaview mode, disable enhanced comms 0068 968 OneShotBArro: equ 7 ; One check for baro correction 969 0068 970 coilsel: ds 1 ; which coil are we working on 0069 971 coilabit equ 0 ; now a bit each to make life easier 0069 972 coilbbit equ 1 0069 973 coilcbit equ 2 0069 974 coildbit equ 3 0069 975 coilebit equ 4 ; can always hope 0069 976 coilfbit equ 5 ; can always hope 977 0069 978 EnhancedBits4: ds 1 006A 979 roll1 equ 0 ; bits to see if we missed a T2 overflow 006A 980 roll2 equ 1 006A 981 page2: equ 2 ; this was a whole byte 006A 982 wspk equ 3 ; set if we are running wasted spark type multiple outputs 006A 983 indwell equ 4 ; hi-res dwell is in process - may drop 006A 984 nextcyl equ 5 ; quick calc for next cyl mode 006A 985 invspk equ 6 ; quick calc for inverted / non-inverted spark 006A 986 FxdASEDone equ 7 ; Fixed ASE done now use normal ASE 987 006A 988 EnhancedBits5: ds 1 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 20 MC68HC908GP32 User Bootloader 006B 989 rotary2 equ 0 ; gets copied from flash var on boot and Burn 990 ; enable twin rotor leading/trailing split stuff 006B 991 checkbit equ 1 ; For testing the code. 006B 992 toothlog equ 2 ; log teeth in wheel decoder 006B 993 triglog equ 3 ; log ignition triggers (all ignition codes) 006B 994 rsh_s equ 4 ; rotary split hysteresis on split 006B 995 rsh_r equ 5 ; rotary split hysteresis on rpm 006B 996 cto equ 6 ; tach output armed 006B 997 ctodiv equ 7 ; tach output divider bit for half speed 006B 998 ctodivb equ $80 ; ctodiv for bit/eor ops 999 006B 1000 EnhancedBits6: ds 1 006C 1001 hrdwon equ 0 ; hi-res dwell hysteresis bit 006C 1002 wsync equ 1 ; wheel is synced 006C 1003 whold equ 2 ; wheel not in holdoff 006C 1004 trigger2 equ 3 ; used in conjunction with "rise" bit for 2nd trigger input 1005 1006 ; Calculation Variable 006C 1007 pwrun1 ds 1 ; Pulsewidth timing variable - from 0 to 25.5ms 006D 1008 pwrun2 ds 1 006E 1009 pwcalc1 ds 1 006F 1010 pwcalc2 ds 1 1011 1012 ; Engine RPM -> RPM = 12000/(ncyl * (rpmph - rpmpl)) 0070 1013 rpmph: ds 1 ; High part of RPM Period 0071 1014 rpmpl: ds 1 ; Low part of RPM Period 0072 1015 rpmch: ds 1 ; Counter for high part of RPM 0073 1016 rpmcl: ds 1 ; Counter for low part of RPM 0074 1017 idleph ds 1T 0075 1018 idlepl ds 1T 1019 0076 1020 flocker: ds 1 ; Flash locker semaphore 1021 1022 ; Previous ADC values for computing derivatives 0077 1023 lmap: ds 1 ; Manifold Absolute Pressure ADC last Reading 0078 1024 lmat: ds 1 ; Manifold Air Temp ADC last Reading 0079 1025 lclt: ds 1 ; Coolant Temperature ADC last Reading 007A 1026 ltps: ds 1 ; Throttle Position Sensor ADC last Reading 007B 1027 lbatt: ds 1 ; Battery Voltage ADC last Reading 007C 1028 lego: ds 1 ; Last EGO ADC reading 1029 1030 ;Global Time Clock 007D 1031 mms: ds 1 ; 0.0001 second update variable 007E 1032 ms: ds 1 ; 0.001 second increment 007F 1033 tenth: ds 1 ; 1/10th second 0080 1034 sech: ds 1 ; high seconds - rollover at 65536 secs (1110.933 minutes, 18.51 hours) 0081 1035 tpsaclk:ds 1 ; TPS enrichment timer clock in 0.1 second resolution 0082 1036 egocount:ds 1 ; Counter value for EGO step - incremented every ignition pulse 0083 1037 asecount:ds 1 ; Counter value for after-start enrichment counter - every ignition pulse 0084 1038 igncount1:ds 1 ; Ignition pulse counter 0085 1039 igncount2:ds 1 ; Ignition pulse counter 0086 1040 altcount1:ds 1 ; Alternate count selector 0087 1041 altcount2:ds 1 ; Alternate count selector 0088 1042 Decay_Accel:ds 1 ; Storage for Accel Value to decay from 0089 1043 tpsfuelcut: ds 1 ; TPS Fuel Cut (percent) 1044 1045 ;SCI parameters/variables 008A 1046 txcnt ds 1 ; SCI transmitter count (incremented) 008B 1047 txgoal ds 1 ; SCI number of bytes to transmit 008C 1048 txmode ds 1 ; Transmit mode flag 008D 1049 rxoffset ds 1 ; offset placeholder when receiving VE/constants vis. SCI 008E 1050 adsel: ds 1 ; ADC Selector Variable 1051 1052 ;Timer Equates for real-time clock function 008F 1053 T1Timerstop equ %00110010 ;TSC 008F 1054 T1Timergo equ %01010010 ;TSC 1055 ;T2SC0_No_PWM equ %00010000 ;TSC0 1056 1057 ; These control Injector PWM mode for T1SC0 and T1SC1 008F 1058 Timergo_NO_INT equ %00000010 ;TSC without interrupts 1059 ;T1SCX_PWM equ %00011010 ; Unbuffered PWM enabled 008F 1060 T1SCX_PWM equ %00011110 ; Unbuffered PWM enabled - set high on compare, toggle on overflow 1061 008F 1062 T1SCX_NO_PWM equ %00010000 ; No PWM 1063 008F 1064 burnSrc ds 2T 0091 1065 burnDst ds 2T 0093 1066 burnCount ds 1T 1067 1068 ; Temporary variables 0094 1069 tmp1 ds 1 0095 1070 tmp2 ds 1 0096 1071 tmp3 ds 1 0097 1072 tmp4 ds 1 0098 1073 tmp5 ds 1 0099 1074 tmp6 ds 1 009A 1075 tmp7 ds 1 009B 1076 tmp8 ds 1 009C 1077 tmp9 ds 1 009D 1078 tmp10 ds 1 009E 1079 tmp11 ds 1 009F 1080 tmp12 ds 1 00A0 1081 tmp13 ds 1 00A1 1082 tmp14 ds 1 00A2 1083 tmp15 ds 1 00A3 1084 tmp16 ds 1 00A4 1085 tmp17 ds 1 00A5 1086 tmp18 ds 1 00A6 1087 tmp19 ds 1 00A7 1088 tmp20 ds 1 00A8 1089 tmp21 ds 1 00A9 1090 tmp22 ds 1 1091 00AA 1092 T2CNTX ds 1 ; software 3rd byte of T2 1093 ;variables here don't need to be zero page 1094 ; Spark timing variables 00AB 1095 T2LastX: ds 1 ; T2 xhigh last 00AC 1096 T2LastH: ds 1 ; Timer 2 high last ; T2 at last decoded pulse. All spark codes. 00AD 1097 T2LastL: ds 1 ; Timer 2 low last 00AE 1098 itimeX: ds 1 ; Time between decoded triggers in us. X - calc in DOSQUIRT 00AF 1099 itimeH: ds 1 ; mid byte 00B0 1100 itimeL: ds 1 ; low byte 00B1 1101 SparkDelayH: ds 1 ; Spark delay high 00B2 1102 SparkDelayL: ds 1 ; Spark delay low 00B3 1103 SparkOnLeftah: ds 1 ; Time left for spark to be on (0.1ms) coil a high 00B4 1104 SparkOnLeftal: ds 1 ; Time left for spark to be on (0.1ms) coil a low 00B5 1105 SparkOnLeftbh: ds 1 ; Time left for spark to be on (0.1ms) coil b high 00B6 1106 SparkOnLeftbl: ds 1 ; Time left for spark to be on (0.1ms) coil b low 00B7 1107 SparkOnLeftch: ds 1 ; Time left for spark to be on (0.1ms) coil c high 00B8 1108 SparkOnLeftcl: ds 1 ; Time left for spark to be on (0.1ms) coil c low 00B9 1109 SparkOnLeftdh: ds 1 ; Time left for spark to be on (0.1ms) coil d high 00BA 1110 SparkOnLeftdl: ds 1 ; Time left for spark to be on (0.1ms) coil d low 00BB 1111 SparkOnLefteh: ds 1 ; Time left for spark to be on (0.1ms) coil e high 00BC 1112 SparkOnLeftel: ds 1 ; Time left for spark to be on (0.1ms) coil e low 00BD 1113 SparkOnLeftfh: ds 1 ; Time left for spark to be on (0.1ms) coil f high 00BE 1114 SparkOnLeftfl: ds 1 ; Time left for spark to be on (0.1ms) coil f low 00BF 1115 cTimeH: ds 1 ; Cycle time for spark delay calculation 00C0 1116 cTimeL: ds 1 ; Cycle time for spark delay calculation 00C1 1117 SparkTempH: ds 1 ; Temporary storage for spark delay calculation 00C2 1118 SparkTempL: ds 1 ; Temporary storage for spark delay calculation 00C3 1119 SparkCarry: ds 1 ; Temporary storage for spark delay calculation 00C4 1120 SRevLimTimeLeft ds 1 ; Soft rev limiter time left to hard mode 00C5 1121 T2PrevX: ds 1 ; top byte - only used for v.low rpm 00C6 1122 T2PrevH: ds 1 ; T2 at last IRQ/tooth - wheel decoder 00C7 1123 T2PrevL: ds 1 ; low byte 00C8 1124 acch: ds 1 ; engine accel/devel msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 21 MC68HC908GP32 User Bootloader 00C9 1125 accl: ds 1 ; " 00CA 1126 Pambient ds 1T 00CB 1127 kpa ds 1T 00CC 1128 coolant ds 1T 00CD 1129 idleLastDC ds 1T 00CE 1130 idleTarget ds 1T 00CF 1131 bcDC ds 1T 00D0 1132 KPAlast ds 1T 00D1 1133 TPSlast ds 1T 00D2 1134 idleCtlClock ds 1T 00D3 1135 idleActClock ds 1T 00D4 1136 bcActClock ds 1T 00D5 1137 bcCtlClock ds 1T ;DT 00D6 1138 TPSfuelCorr ds 1T 1139 1140 ; Enhanced stuff added 00D7 1141 OverRunTime: ds 1 ; Timer for over run to cut in 00D8 1142 SparkCutCnt: ds 1 00D9 1143 KnockTimLft: ds 1 00DA 1144 KnockAdv: ds 1 00DB 1145 kpa_n: ds 1 ; Kpa or TPs value for spark table lookup. 00DC 1146 GammaE2: ds 1 ; Second O2 sensor GammaE 00DD 1147 tmp31: ds 1 ; Tmp storage for anything thats only used in a jsr 00DE 1148 tmp32: ds 1 ; Tmp Storage for anything thats only used in a jsr 00DF 1149 ST2Timer: ds 1 ; Spark Table 2 delay timer 00E0 1150 VE3Timer: ds 1 ; VE Table 3 delay timer 00E1 1151 TCAccel: ds 1 ; Traction Control Enrichment 00E2 1152 TCAngle: ds 1 ; Traction Control Spark Retard 00E3 1153 TCSparkCut: ds 1 ; Traction Control Spark Cut number and prime pulse cnt 00E4 1154 mmsDiv: ds 1 ; 0.1mS counter for Boost Control 00E5 1155 TCCycles: ds 1 ; Engine hold cycles 00E6 1156 Out3Timer: ds 1 ; Output3 timer 1157 ;yet more ram variables for EDIS /wheel stuff 00E7 1158 wheelcount ds 1 ; wheel counter for decoder _and_ HoldSpark/toothsync/ignore_small 1159 ;note on wheelcount: 1160 ;In Neon mode this is used as a holdoff for syncing counting up to zero 1161 ; bit7 = !sync 1162 ; bit6 = holdspark 1163 ; Once synced it is used to count the teeth 1164 ; In non-Neon mode it is used as HoldSpark counting down to zero 1165 ;these two used by tooth decoders or EDIS 00E8 1166 dwelldelay1 ds 1 ; 2 bytes of dwell delay in 0.1ms 00E9 1167 ds 1 00EA 1168 dwelldelay2 ds 1 ; same for period +1 00EB 1169 ds 1 00EC 1170 dwelldelay3 ds 1 ; same for period +2 00ED 1171 ds 1 00EE 1172 dwelldelay4 ds 1 ; same for period +3 00EF 1173 ds 1 00F0 1174 dwelldelay5 ds 1 ; same for period +4 00F1 1175 ds 1 00F2 1176 dwelldelay6 ds 1 ; same for period +5 00F3 1177 ds 1 1178 sawh: ; EDIS SAW width 1179 stHp: 00F4 1180 avgtoothh: ds 1 ; OR.. gap between teeth previous in decoders 1181 sawl: 1182 stLp: 00F5 1183 avgtoothl: ds 1 ; low byte 00F6 1184 lowresH ds 1 ; low res counter. Added for Neon code. 00F7 1185 lowresL ds 1 ; 00F8 1186 dwelldms ds 1 ; target dwell in 0.1ms units 00F9 1187 dwellush ds 1 ; target dwell in us units 00FA 1188 dwellusl ds 1 ; low byte 00FB 1189 sparktargeth ds 1 ; H target t2 value for spark (used in hi-res dwell) 00FC 1190 sparktargetl ds 1 ; L 00FD 1191 iTimepX ds 1 00FE 1192 iTimepH ds 1 ; previous hi-res cycle time (for accel/decel) 00FF 1193 iTimepL ds 1 ; 0100 1194 splitdelH: ds 1 ; trailing split delay for rotary 0101 1195 splitdelL: ds 1 0102 1196 KnockBoost ds 1 ; Boost to remove from controller if Knock detected 0103 1197 KnockAngleRet: ds 1 ; Knock Angle storage 0104 1198 rpmlast: ds 1 ; RPM accel dot last value 0105 1199 VlaunchLimit: ds 1 ; Variable Launch RPM value 0106 1200 page ds 1 0107 1201 DelayAngle: ds 1 ; Angle to delay spark (TriggAngle - SparkAngle) 0108 1202 airTemp: ds 1 0109 1203 NitrousAngle: ds 1 ; Nitrous Angle of Retard 010A 1204 NosPW: ds 1 ; PW to add for NOS System 010B 1205 pw_staged: ds 1 010C 1206 n2olaunchdel: ds 1 ; launch to nitrous delay timer 010D 1207 n2ohold: ds 1 ; nitrous fuel and retard hold-on timer ; not yet used 1208 ; rename and use these place holders as needed 010E 1209 ramslot1: ds 1 ; oh shit, only 1 left! 1210 ;no more or ram copy of data will overrun stack 1211 ms_ram_end: 1212 ;************************************************** 1213 ; Flash Configuration Variables here - variables can be downloaded via serial link 1214 ; VETABLE and Constants 1215 ; "VE" is entry point, everything is offset from this point 1216 ; All of these variables point to RAM locations. Renamed to _r 1217 ; 1218 ms_rf_start: 010F 1219 VE_r rmb $90 ; 64 bytes for VE Table - Now 144 for 12x12 1220 ;CWU_r rmb 1 ; Crank Enrichment at -40 F 1221 ;CWH_r rmb 1 ; Crank Enrichment at 170 F 1222 ;AWEV_r rmb 1 ; After-start Warmup Percent enrichment add-on value 1223 ;AWC_r rmb 1 ; After-start number of cycles 1224 ;WWU_r rmb $0A ; Warmup bins(fn temp) 1225 ;TPSAQ_r rmb $04 ; TPS acceleration amount (fn TPSDOT) in 0.1 ms units 1226 ;tpsacold_r rmb 1 ; Cold acceleration amount (at -40 degrees) in 0.1 ms units 1227 ;tpsthresh_r rmb 1 ; Accel TPS DOT threshold 1228 ;TPSASYNC_r rmb 1 ; ***** TPS Acceleration clock value 1229 ;TPSDQ_r rmb 1 ; Deacceleration fuel cut 019F 1230 egotemp_r rmb 1 ; Coolant Temperature where EGO is active 01A0 1231 egocountcmp_r rmb 1 ; Counter value where EGO step is to occur 01A1 1232 egodelta_r rmb 1 ; EGO Percent step size for rich/lean 01A2 1233 egolimit_r rmb 1 ; Upper/Lower EGO rail limit (egocorr is inside 100 +/- Limit) 01A3 1234 REQ_FUEL_r rmb 1 ; Fuel Constant 01A4 1235 DIVIDER_r rmb 1 ; IRQ divide factor for pulse 01A5 1236 Alternate_r rmb 1 ; Alternate injector drivers 01A6 1237 InjOpen_r rmb 1 ; Injector Open Time 01A7 1238 InjOCFuel_r rmb 1 ; PW-correlated amount of fuel injected during injector open 01A8 1239 INJPWM_r rmb 1 ; Injector PWM duty cycle at current limit 01A9 1240 INJPWMT_r rmb 1 ; Injector PWM mmillisec time at which to activate. 01AA 1241 BATTFAC_r rmb 1 ; Battery Gamma Factor 01AB 1242 rpmk_r rmb 2 ; Constant for RPM = 12,000/ncyl - downloaded constant 01AD 1243 RPMRANGEVE_r rmb 12 ; VE table RPM Bins for 2-D interpolation 01BF 1244 KPARANGEVE_r rmb 12 ; VE Table MAP Pressure Bins for 2_D interp. 01D1 1245 CONFIG11_r rmb 1 ; Configuration for PC Configurator 1246 ; Bit 0-1 = MAP Type 1247 ; 00 = MPX4115AP 1248 ; 01 = MPX4250AP 1249 ; 10 = User-defined 1250 ; 11 = User-Defined 1251 ; Bit 2 = Engine Stroke 1252 ; 0 = Four Stroke 1253 ; 1 = Two Stroke 1254 ; Bit 3 = Injection Type 1255 ; 0 = Port Injection 1256 ; 1 = Throttle Body 1257 ; Bit 4-7 = Number of Cylinders 1258 ; 0000 = 1 cylinder 1259 ; 0001 = 2 cylinders 1260 ; 0010 = 3 cylinders msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 22 MC68HC908GP32 User Bootloader 1261 ; 0011 = 4 cylinders 1262 ; 0100 = 5 cylinder 1263 ; 0101 = 6 cylinders 1264 ; 0110 = 7 cylinders 1265 ; 0111 = 8 cylinders 1266 ; 1000 = 9 cylinders 1267 ; 1001 = 10 cylinders 1268 ; 1010 = 11 cylinders 1269 ; 1011 = 12 cylinders 01D2 1270 M_TwoStroke: equ 4 1271 01D2 1272 CONFIG12_r rmb 1 ; Configuration for PC Configurator 1273 ; Bit 0-1 = COOL Sensor Type 1274 ; 00 = GM 1275 ; 01 = User-defined 1276 ; 10 = User-defined 1277 ; 11 = User-Defined 1278 ; Bit 2-3 = MAT Sensor Type 1279 ; 00 = GM 1280 ; 01 = Undefined 1281 ; 10 = Undefined 1282 ; 11 = Undefined 1283 ; Bit 4-7 = Number of Injectors 1284 ; 0000 = 1 Injector 1285 ; 0001 = 2 Injectors 1286 ; 0010 = 3 Injectors 1287 ; 0011 = 4 Injectors 1288 ; 0100 = 5 Injectors 1289 ; 0101 = 6 Injectors 1290 ; 0110 = 7 Injectors 1291 ; 0111 = 8 Injectors 1292 ; 1000 = 9 Injectors 1293 ; 1001 = 10 Injectors 1294 ; 1010 = 11 Injectors 1295 ; 1011 = 12 Injectors 01D3 1296 CONFIG13_r rmb 1 ; Configuration for PC Configurator 1297 ; Bit 0 = Odd-fire averaging 1298 ; 0 = Normal 1299 ; 1 = Odd-Fire 1300 ; Bit 1 = O2 Sensor Type 1301 ; 0 = Narrow-band (single wire 14.7 stoch) 1302 ; 1 = DIY-WB (Stoch = 2.5V, reverse slope) 1303 ; Bit 2 = Control Stategy 1304 ; 0 = Speed-Density 1305 ; 1 = Alpha-N 1306 ; Bit 3 = Barometer Correction 1307 ; 0 = Enrichment Off (set to 100%) 1308 ; 1 = Enrichment On 1309 ;PRIMEP_r rmb 1 ; Priming pulses (0.1 millisec units) 01D4 1310 RPMOXLIMIT_r rmb 1 ; Minimum RPM where O2 Closed Loop is Active 01D5 1311 FASTIDLE_r rmb 1 ; Fast idle if enabled 01D6 1312 VOLTOXTARGET_r rmb 1 ; O2 sensor flip target value 1313 ;ACMULT_r rmb 1 ; Acceleration cold multiplication factor (percent/100) 1314 ;BLANK rmb 4 ; Extra Slots to make up 64 bytes total 1315 1316 ;Page 0 variables 1317 ;These are flash ONLY so no need to read them from RAM 1318 1319 ;Page 3 spark variables that get used from RAM 01D7 1320 ST_r equ ms_rf_start ; spark timing table 01D7 1321 RPMRANGEST_r equ {ms_rf_start + $90} ; Spark timing RPM bins for 2-D interpolation 01D7 1322 KPARANGEST_r equ {ms_rf_start + $9c} ; Spark timing MAP pressure bins for 2-D interpolation 1323 01D7 1324 TriggAngle_r equ {ms_rf_start + $a8} ; Trigger angle BTDC 01D7 1325 FixedAngle_r equ {ms_rf_start + $a9} ; Fixed angle, 0 = not in used 01D7 1326 TrimAngle_r equ {ms_rf_start + $aa} ; Trim angle, positive and negative 01D7 1327 CrankAngle_r equ {ms_rf_start + $ab} ; Cranking angle 1328 1329 ; Increased to 200 as according to the 'List' file thats the size of ms_fr since 12x12 ? 01D7 1330 org {ms_rf_start + 200T} ; reserve 200 bytes for paging use in RAM 1331 ms_rf_end: 1332 1333 ;------------------------------------------------------------------------------- 01D7 1334 ms_ram_size equ {ms_ram_end-ms_ram_start} 01D7 1335 ms_rf_size equ {ms_rf_end-ms_rf_start} 01D7 1336 ms_total_ram_size equ {ms_rf_end-ms_ram_start} 1337 ;------------------------------------------------------------------------------- 1338 ;new equates so burner ram_exec area can be used as temp storage WITHIN int handlers 01D7 1339 int_ram equ $01ED ; same as ram_exec, space used by burner 1340 01D7 1341 itmp00 equ {int_ram + $00 } 01D7 1342 itmp01 equ {int_ram + $01 } 01D7 1343 itmp02 equ {int_ram + $02 } 01D7 1344 itmp03 equ {int_ram + $03 } 01D7 1345 itmp04 equ {int_ram + $04 } 01D7 1346 itmp05 equ {int_ram + $05 } 01D7 1347 itmp06 equ {int_ram + $06 } 01D7 1348 itmp07 equ {int_ram + $07 } 01D7 1349 itmp08 equ {int_ram + $08 } 01D7 1350 itmp09 equ {int_ram + $09 } 01D7 1351 itmp0a equ {int_ram + $0a } 01D7 1352 itmp0b equ {int_ram + $0b } 01D7 1353 itmp0c equ {int_ram + $0c } 01D7 1354 itmp0d equ {int_ram + $0d } 01D7 1355 itmp0e equ {int_ram + $0e } 01D7 1356 itmp0f equ {int_ram + $0f } 1357 01D7 1358 itmp10 equ {int_ram + $10 } 01D7 1359 itmp11 equ {int_ram + $11 } 01D7 1360 itmp12 equ {int_ram + $12 } 01D7 1361 itmp13 equ {int_ram + $13 } 01D7 1362 itmp14 equ {int_ram + $14 } 01D7 1363 itmp15 equ {int_ram + $15 } 01D7 1364 itmp16 equ {int_ram + $16 } 01D7 1365 itmp17 equ {int_ram + $17 } 01D7 1366 itmp18 equ {int_ram + $18 } 01D7 1367 itmp19 equ {int_ram + $19 } 01D7 1368 itmp1a equ {int_ram + $1a } 01D7 1369 itmp1b equ {int_ram + $1b } 01D7 1370 itmp1c equ {int_ram + $1c } 01D7 1371 itmp1d equ {int_ram + $1d } 01D7 1372 itmp1e equ {int_ram + $1e } 01D7 1373 itmp1f equ {int_ram + $1f } 1374 01D7 1375 itmpcomm equ {int_ram + $20 } ; $32 (50) bytes for SCI comm data packet 1376 1377 *************************************************************************** 1378 ; Argument list for LinInterp, used throughout. 1379 ; 1380 ; If you move these down to LinInterp, the assembler can't use direct 1381 ; addressing for some arguments, so the code is bigger. 1382 01D7 1383 liX1 equ tmp1 01D7 1384 liX2 equ tmp2 01D7 1385 liY1 equ tmp3 01D7 1386 liY2 equ tmp4 01D7 1387 liX equ tmp5 01D7 1388 liY equ tmp6 ; Function output. 1389 1390 ;udvd32 uses some memory space, use tmp instead 01D7 1391 INTACC1 equ tmp1 ; and 2,3,4 01D7 1392 INTACC2 equ tmp5 ; and 6,7,8 1393 ; tmp9,10,11 used within udvd32 1394 ; udvd32 is only used within Calcrpm, ought to rewrite a simpler routine 1395 1396 ;misc_spark uses these msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 23 MC68HC908GP32 User Bootloader 01D7 1397 dwelltmpX equ tmp2 01D7 1398 dwelltmpH equ tmp3 01D7 1399 dwelltmpL equ tmp4 01D7 1400 dwelltmpXp equ tmp12 01D7 1401 dwelltmpHp equ tmp13 01D7 1402 dwelltmpLp equ tmp14 01D7 1403 dwelltmpXac equ tmp20 ; use these so they don't get trashed by lookup 01D7 1404 dwelltmpHac equ tmp21 01D7 1405 dwelltmpLac equ tmp22 01D7 1406 dwelltmpXop equ tmp5 ; these are the us result 01D7 1407 dwelltmpHop equ tmp6 01D7 1408 dwelltmpLop equ tmp7 01D7 1409 dwelltmpXms equ tmp8 ; these are the 0.1ms result before transferring to dwelldelay1,2,3,4 01D7 1410 dwelltmpHms equ tmp9 01D7 1411 dwelltmpLms equ tmp10 1412 01D7 1413 SparkdltX equ tmp2 ; not used at same time as dwelltmpX etc. 01D7 1414 SparkdltH equ tmp3 01D7 1415 SparkdltL equ tmp4 1416 *************************************************************************** 1417 ** 1418 ** Main Routine Here - Initialization and main loop 1419 ** 1420 ** Note: Org down 128 bytes below the "rom_start" point 1421 ** because of erase bug in bootloader routine 1422 ** All MS HC908 continue to be shipped with the bug to preserve backward 1423 ** compatability (BB posted on this on www.msefi.com) 1424 ** Do not mess with this offset or your chip won't boot! 1425 ** 1426 ** Note: Items commented out after the Start entry point are 1427 ** taken care of in the Boot_R12.asm code 1428 *************************************************************************** 8128 1429 org {rom_start + 128} 1430 Start: 8128 4501ED 1431 ldhx #init_stack+1 ; Set the stack Pointer 812B 94 1432 txs ; Move before burner to avoid conflict 1433 1434 ; Clock now 8MHz - DJLH 812C 1936 1435 bclr BCS,pctl ; Select external Clock Reference 812E 1B36 1436 bclr PLLON,pctl ; Turn Off PLL 8130 6E0236 1437 mov #$02,pctl ; Set P and E Bits 8133 6ED03A 1438 mov #$D0,pmrs ; Set L 8136 6E0338 1439 mov #$03,pmsh ; Set N (MSB) 8139 6ED139 1440 mov #$D1,pmsl ; Set N (LSB) 813C 1E37 1441 bset AUTO,pbwc 813E 1A36 1442 bset PLLON,pctl ; Turn back on PLL 1443 ;PLLwait: 8140 0D37FD 1444 brclr LOCK,pbwc,* 8143 1836 1445 bset BCS,pctl 1446 1447 1448 ; 1449 ; Set all RAM to known value - for code runaway protection. 1450 ; If there is ever a code runaway, and processor tries 1451 ; executing this as an opcode ($32) then a reset will occur. 1452 ; 8145 450040 1453 ldhx #ram_start ; Point to start of RAM 1454 ClearRAM: 8148 A632 1455 lda #$32 ; This is an illegal op-code - 1456 ; cause reset if executed 814A F7 1457 sta ,x ; Set RAM location 814B AF01 1458 aix #1 ; advance pointer 814D 650240 1459 cphx #ram_last+1 ; done ? 8150 26F6 1460 bne ClearRAM ; loop back if not 1461 1462 1463 ; Set up the port data-direction registers 1464 8152 A600 1465 lda #%00000000 8154 B705 1466 sta ddrb ; Set as inputs (ADC will select 1467 ; which channel later) 8156 A630 1468 lda #%00110000 ; Turn off injectors (inverted output) 8158 B703 1469 sta portd 815A 160F 1470 bset launch,ptdpue 815C 120F 1471 bset NosIn,ptdpue ; Set all the inputs internal 1472 ; pull ups On 1473 815E C6E074 1474 lda feature8_f ; using spark F ? 8161 A510 1475 bit #spkfopb 8163 2704 1476 beq no_spk_f 8165 A6F5 1477 lda #%11110101 ; make pin an output 8167 2004 1478 bra store_ddrd 1479 no_spk_f: 8169 140F 1480 bset KnockIn,ptdpue 816B A6F1 1481 lda #%11110001 ; Changed to 0 is an output 1482 store_ddrd: 816D B707 1483 sta ddrd ; Outputs for injector 1484 816F 3F00 1485 clr porta 8171 A6FF 1486 lda #%11111111 8173 B704 1487 sta ddra ; Outputs for Fp and Spark 8175 A600 1488 lda #$00 8177 B702 1489 sta portc 1490 ;is PTC4 an input? - see also 'B' code section 8179 C6E00B 1491 lda feature1_f 817C A501 1492 bit #wd_2trigb 817E 2704 1493 beq norm_op_ddrc 8180 A60F 1494 lda #%00001111 ; make PTC4 an input for second trigger 8182 2002 1495 bra op_ddrc 1496 norm_op_ddrc: 8184 A61F 1497 lda #%00011111 ; ** Was 11111111 1498 op_ddrc: 8186 B706 1499 sta ddrc ; Outputs for LED 8188 A601 1500 lda #%00000001 ; Serial Comm Port 818A B70C 1501 sta ddre 1502 1503 ; Set up the Real-time clock Timer (TIM2) 818C 6E332B 1504 MOV #%00110011,t2sc ; Stop Timer so it can be set up 1505 ; No overflow interrupt, stop, 1506 ; reset, div / 8 1507 818F 6EFF2E 1508 mov #$FF,T2MODH ; Free running timer 8192 6EFF2F 1509 mov #$FF,T2MODL 1510 8195 6E0031 1511 mov #0T,T2CH0H ; Channel 0 high, 0 1512 ; mov #92T,T2CH0L ; Channel 0 low, 92 = 0.1 ms 8198 6E6432 1513 mov #100T,T2CH0L ; Channel 0 low, 100 = 0.1 ms 1514 ; @ 8.0MHz - DJLH 819B 6E5430 1515 mov #%01010100,T2SC0 ; Output compare, interrupt enabled 1516 819E 6E0034 1517 mov #$00,T2CH1H ; Channel 1 high, to be used 1518 ; for spark control 81A1 6E0035 1519 mov #$00,T2CH1L ; Channel 1 low, 0 81A4 6E5433 1520 mov #%01010100,T2SC1 ; Channel 1 Output compare, 1521 ; interrupt enabled 1522 ; edis? mov #%01010000,T2SC1 ; Channel 1 Output compare, 1523 ; interrupt enabled 81A7 1F33 1524 bclr TOF,T2SC1 ; clear any pending interrupt 81A9 1D33 1525 bclr TOIE,T2SC1 ; Disable timer interrupt until 1526 ; we are ready 1527 1528 1529 ;; mov #%00010011,T2SC ; Start timer, no overflow int, div / 8 81AB 6E532B 1530 mov #%01010011,T2SC ; Start timer, overflow int, div / 8 1531 1532 ; Set up the PWM for the Injector (for current limit mode) msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 24 MC68HC908GP32 User Bootloader 81AE 6E3220 1533 MOV #T1Timerstop,t1sc ; Stop Timer so it can be set up 81B1 6E0023 1534 mov #$00,T1MODH 81B4 6E6424 1535 mov #$64,T1MODL ; set timer modulus register to 100 1536 ; decimal 1537 ; mov #T1SCX_NO_PWM,T1SC0 ; make this normal port output 1538 ; (PWM MODE is #$5E) 1539 ; mov #T1SCX_NO_PWM,T1SC1 ; make this normal port output 1540 ; (PWM MODE is #$5E) 81B7 6E0026 1541 mov #$00,T1CH0H 81BA C6E199 1542 lda INJPWM_f1 81BD B727 1543 sta T1CH0L 81BF 6E0029 1544 mov #$00,T1CH1H 81C2 C6E021 1545 lda dtmode_f 81C5 A510 1546 bit #alt_i2t2 81C7 2705 1547 beq setpwmsingle 81C9 C6E299 1548 lda INJPWM_f2 81CC 2003 1549 bra store_pwm 1550 setpwmsingle: 81CE C6E199 1551 lda INJPWM_f1 1552 store_pwm: 81D1 B72A 1553 sta T1CH1L 1554 ; MOV #Timergo_NO_INT,T1SC ; No interrupts for this 1555 1556 ; Set up SCI port 81D3 A630 1557 lda #$30 ; This is 9615 baud w/ the osc 1558 ; frequency 8.0M - DJLH 81D5 B719 1559 sta scbr 81D7 1C13 1560 bset ensci,scc1 ; Enable SCI 81D9 1414 1561 bset RE,SCC2 ; Enable receiver 81DB 1A14 1562 bset SCRIE,SCC2 ; Enable Receive interrupt 81DD B616 1563 lda SCS1 ; Clear SCI transmitter Empty Bit 81DF 3F8A 1564 clr txcnt 81E1 3F8B 1565 clr txgoal 1566 1567 ; Set up Interrupts 81E3 6E041D 1568 mov #%00000100,INTSCR ;Enable IRQ 1569 1570 ;clear water outputs 81E6 1B00 1571 bclr water,porta ;water injection 81E8 1900 1572 bclr water2,porta ;2nd water injection output 81EA 086402 1573 brset out3sparkd,feature2,w_no3 81ED 1103 1574 bclr Output3,portd 1575 w_no3: 1576 ; 1577 ; Load the constants (VE Table, etc) from Flash to RAM - the program 1578 ; uses the RAM values. 1579 ; Changed! 1580 ; For multi table work we always operate from flash unless directed to 1581 ; copy the data into RAM for tuning. Even then only the VE tables will 1582 ; use the RAM version. Extra coding could change this, but the initial 1583 ; release will use all other variables from flash ONLY - so be sure to 1584 ; "send" the data after changes. 1585 ; 81EF A6FF 1586 lda #$ff 81F1 C70106 1587 sta page ; select invalid page to make 1588 ;sure we run from flash 1589 ; Set up RAM Variable - also when burning page0 search for "burning page0" 81F4 C6E00B 1590 lda feature1_f 81F7 B763 1591 sta feature1 81F9 C6E00C 1592 lda feature2_f 81FC B764 1593 sta feature2 1594 ; lda feature3_f - flash only 1595 ; sta feature3 1596 ; lda feature4_f - flash only 1597 ; sta feature4 1598 ; lda feature5_f - flash only 1599 ; sta feature5 1600 ; lda feature6_f - flash only 1601 ; sta feature6 81FE C6E06D 1602 lda feature7_f 8201 B765 1603 sta feature7 1604 ; lda feature8_f - flash only 1605 ; sta feature8 8203 C6E001 1606 lda outputpins_f 8206 B762 1607 sta outputpins 8208 C6E000 1608 lda personality_f 820B B761 1609 sta personality ;move from flash to ram 1610 820D 3F7D 1611 clr mms 820F 3F7E 1612 clr ms 8211 3F7F 1613 clr tenth 8213 3F40 1614 clr secl 8215 3F80 1615 clr sech 8217 3F41 1616 clr squirt 8219 3F42 1617 clr engine 821B 3F70 1618 clr rpmph 821D 3F71 1619 clr rpmpl 821F 3F72 1620 clr rpmch 8221 3F73 1621 clr rpmcl 8223 3F4D 1622 clr rpm 8225 3F76 1623 clr flocker 8227 A600 1624 lda #$00 8229 C70100 1625 sta splitdelH ; initial value for rotary split 822C C70101 1626 sta splitdelL 822F B7FD 1627 sta iTimepX 8231 B7FE 1628 sta iTimepH 8233 B7FF 1629 sta iTimepL 8235 C70103 1630 sta KnockAngleRet 8238 B7DA 1631 sta KnockAdv 823A B7D9 1632 sta KnockTimLft 823C B75D 1633 sta KnockAngle 823E B7E2 1634 sta TCAngle 8240 C70102 1635 sta KnockBoost 8243 B75C 1636 sta CltIatAngle 8245 B7E1 1637 sta TCAccel 8247 B76E 1638 sta pwcalc1 8249 B76F 1639 sta pwcalc2 824B B74E 1640 sta pw1 824D B753 1641 sta pw2 824F 3F6C 1642 clr pwrun1 8251 3F6D 1643 clr pwrun2 8253 A6FF 1644 lda #$FF 8255 B7D1 1645 sta TPSlast 8257 C70104 1646 sta rpmlast 825A 3F82 1647 clr egocount 825C C7010C 1648 sta N2Olaunchdel 1649 825F 450000 1650 ldhx #0 8262 35E8 1651 sthx dwelldelay1 8264 35EA 1652 sthx dwelldelay2 8266 35EC 1653 sthx dwelldelay3 8268 35EE 1654 sthx dwelldelay4 826A 35F0 1655 sthx dwelldelay5 826C 35F2 1656 sthx dwelldelay6 1657 826E A6BB 1658 lda #$BB 8270 B743 1659 sta baro 8272 B744 1660 sta map 8274 B745 1661 sta mat 8276 B746 1662 sta clt 8278 B747 1663 sta tps 827A B748 1664 sta batt 1665 827C A664 1666 lda #$64 827E B74B 1667 sta aircor 8280 B752 1668 sta vecurr msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 25 MC68HC908GP32 User Bootloader 8282 B750 1669 sta barocor 8284 B74C 1670 sta warmcor 8286 B74A 1671 sta egocorr 8288 B75E 1672 sta EgoCorr2 828A B789 1673 sta tpsfuelcut 828C 3F51 1674 clr gammae 828E A646 1675 lda #$46 8290 B744 1676 sta map 8292 A665 1677 lda #$65 8294 B743 1678 sta baro 8296 3F4F 1679 clr tpsaccel 8298 3F88 1680 clr Decay_Accel 829A 3F84 1681 clr igncount1 829C 3F85 1682 clr igncount2 829E 3F55 1683 clr idleDC ; set fully closed 82A0 C6E057 1684 lda Spark2Delay_f 82A3 B7DF 1685 sta ST2Timer ; Set delay timer for ST2 82A5 C6E05D 1686 lda VE3Delay_f 82A8 B7E0 1687 sta VE3Timer ; Set Delay timer for VE 3 82AA A600 1688 lda #00T 82AC B7E3 1689 sta TCSparkCut 82AE B7C4 1690 sta SRevLimTimeLeft 82B0 C70109 1691 sta NitrousAngle ; Clear the NOS Angle 82B3 C7010A 1692 sta NosPW ; Clear the Nos PW 82B6 B7D8 1693 sta SparkCutCnt ; Spark Cut counter - Enhanced 82B8 C7010B 1694 sta pw_staged ; Reset the Staged PW 82BB 3F5F 1695 clr SparkBits 82BD 3FB3 1696 clr Sparkonleftah 82BF 3FB4 1697 clr Sparkonleftal 82C1 3FB5 1698 clr Sparkonleftbh 82C3 3FB6 1699 clr Sparkonleftbl 82C5 3FB7 1700 clr Sparkonleftch 82C7 3FB8 1701 clr Sparkonleftcl 82C9 3FB9 1702 clr Sparkonleftdh 82CB 3FBA 1703 clr Sparkonleftdl 82CD 3FBB 1704 clr Sparkonlefteh 82CF 3FBC 1705 clr Sparkonleftel 82D1 3FBD 1706 clr Sparkonleftfh 82D3 3FBE 1707 clr Sparkonleftfl 82D5 3FF6 1708 clr lowresH ; low res (0.1ms) timer 82D7 3FF7 1709 clr lowresL ; 82D9 C6E06E 1710 lda dwellcrank_f 82DC B7F8 1711 sta dwelldms ; initial dwell period 82DE 6E10F9 1712 mov #$10,dwellush ; } high speed dwell delay, 1713 ; default of 4.1ms 82E1 3FFA 1714 clr dwellusl ; } until calc in main loop 82E3 145F 1715 bset SparkLSpeed,SparkBits ; At boot turn on low speed ignition 82E5 3F60 1716 clr RevLimBits 82E7 3F66 1717 clr EnhancedBits 82E9 3F67 1718 clr EnhancedBits2 82EB 3F69 1719 clr EnhancedBits4 82ED 3F6A 1720 clr EnhancedBits5 82EF 3F6B 1721 clr EnhancedBits6 82F1 3F68 1722 clr coilsel 82F3 1068 1723 bset coilabit,coilsel 82F5 1860 1724 bset coilerr,RevLimBits ; set "error" bit so first coil found is used 1725 1726 ;possible that this calc could go wrong if a large "addition" was used but then a small 1727 ;real angle. Shouldn't happen if angles set correctly. 82F7 C6E3A8 1728 lda TriggAngle_f 82FA A139 1729 cmp #57T ; check for next cyl mode 82FC 2202 1730 bhi init_crang ; trigger angle > 20, continue 82FE 1A69 1731 bset nextcyl,EnhancedBits4 1732 init_crang: 8300 C6E3AB 1733 lda CrankAngle_f 8303 B758 1734 sta SparkAngle 8305 086110 1735 brset EDIS,personality,init_edis 1736 1737 ;this won't work for next-cyl but will be ignored at low rpm anyway 8308 C6E3A8 1738 lda TriggAngle_f 830B C0E3AB 1739 sub CrankAngle_f 830E AB1C 1740 add #28T ; - - 10deg 8310 C70107 1741 sta DelayAngle 8313 C6E3AC 1742 lda SparkHoldCyc_f 8316 200E 1743 bra init_cont 1744 1745 init_edis: 8318 C6E3A8 1746 lda TriggAngle_f 831B C70107 1747 sta DelayAngle 831E A605 1748 lda #$05 ; set initial SAW to 10 degrees 8320 B7F4 1749 sta sawh 8322 A600 1750 lda #$00 8324 B7F5 1751 sta sawl 1752 1753 init_cont: 8326 B7E7 1754 sta wheelcount ; (HoldSpark) 8328 026105 1755 brset MSNEON,personality,init_wheel 832B 046102 1756 brset WHEEL,personality,init_wheel 832E 200D 1757 bra init_no_hold 1758 init_wheel: 8330 6EC5E7 1759 mov #WHEELINIT,wheelcount ; set !sync,holdoff, 5 teeth 1760 ; holdoff for Neon/Wheel 8333 136B 1761 bclr wsync,EnhancedBits6 8335 146B 1762 bset whold,EnhancedBits6 8337 A600 1763 lda #0 8339 B7F4 1764 sta avgtoothh 833B B7F5 1765 sta avgtoothl 1766 1767 init_no_hold: 1768 833D A6FF 1769 lda #$FF 833F B7AF 1770 sta iTimeH 8341 B7B0 1771 sta iTimeL 8343 B7AE 1772 sta iTimeX 1773 1774 ;see if inverted or non-inv output and use a quick bit 8345 C6E3AD 1775 lda SparkConfig1_f ; check if noninv or inv spark 8348 A508 1776 bit #M_SC1InvSpark 834A 2604 1777 bne inspk_inv 834C 1D69 1778 bclr invspk,EnhancedBits4 ; set non-inverted 834E 2002 1779 bra inspk_done 1780 inspk_inv: 8350 1C69 1781 bset invspk,EnhancedBits4 ; set inverted 1782 inspk_done: 1783 8352 C6E7C0 1784 lda p7feat1_f 8355 A501 1785 bit #rotary2b 8357 2706 1786 beq not_init_rot 8359 106A 1787 bset rotary2,EnhancedBits5 ; set rotary quick bit 835B 1769 1788 bclr wspk,EnhancedBits4 ; set that we are NOT doing normal wasted spark 835D 2002 1789 bra done_rot 1790 not_init_rot: 835F 116A 1791 bclr rotary2,EnhancedBits5 ; clr rotary quick bit 1792 1793 done_rot: 1794 1795 ;decide if we are doing multiple wasted spark outputs 8361 026105 1796 brset MSNEON,personality,wsp_init 8364 046102 1797 brset WHEEL,personality,wsp_init 8367 2008 1798 bra mv_init ; not wasted spark so skip 1799 wsp_init: 8369 096205 1800 brclr REUSE_LED19,outputpins,mv_init 836C 006A02 1801 brset rotary2,EnhancedBits5,mv_init 836F 1669 1802 bset wspk,EnhancedBits4 ; set that we are doing wasted spark 1803 mv_init: 1804 ; set MegaView mode to block enhanced comms, S,P,R,X commands reset msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 26 MC68HC908GP32 User Bootloader 1805 ; it to allow normal ops 8371 1C67 1806 bset mv_mode,EnhancedBits2 1807 1808 ;If HEI set bypass to 0v 8373 0F6102 1809 brclr HEI7,personality,not_hei7_init 8376 1202 1810 bset aled,portc 1811 not_hei7_init: 1812 8378 0B6102 1813 brclr DUALEDIS,personality,chk_out 837B 1861 1814 bset EDIS,personality ; DUALEDIS implies EDIS 1815 1816 chk_out: 1817 **** add in some sanity checks for outputs vs. code base **** 837D B661 1818 lda personality 837F 260A 1819 bne check_out_config 1820 ; lda outputpins ; assumes if personality zero 1821 ; ; then any outputs are error 1822 ; beq b_dc ; no personality, no outputs 1823 ;wrong! This prevents "Fuel only", just check for conflicts 8381 202C 1824 bra check3 1825 1826 ;set_error: 8383 6E0197 1827 mov #1,tmp4 8386 1E64 1828 bset config_error,feature2 8388 CC8482 1829 jmp done_checks 1830 1831 check_out_config: 838B 036205 1832 brclr REUSE_LED17,outputpins,block_neon 838E 096202 1833 brclr REUSE_LED19,outputpins,block_neon 8391 200B 1834 bra check_msns 1835 block_neon: 8393 036108 1836 brclr MSNEON,personality,check_msns 8396 6E0297 1837 mov #2,tmp4 8399 1E64 1838 bset config_error,feature2 ; if MSNEON but haven't 1839 ; reused led17&19 then error 839B CC8482 1840 jmp done_checks 1841 1842 check_msns: 839E 01610E 1843 brclr MSNS,personality,check3 83A1 00620B 1844 brset REUSE_FIDLE,outputpins,check3 83A4 026208 1845 brset REUSE_LED17,outputpins,check3 83A7 6E0397 1846 mov #3,tmp4 83AA 1E64 1847 bset config_error,feature2 ; if MSNS and haven't reused 1848 ; FIDLE or LED17 then error 83AC CC8482 1849 jmp done_checks 1850 1851 check3: ; check for idle conflict 83AF 07640B 1852 brclr PWMidle,feature2,check4 83B2 016208 1853 brclr REUSE_FIDLE,outputpins,check4 83B5 6E0497 1854 mov #4,tmp4 83B8 1E64 1855 bset config_error,feature2 ; trying to use PWM idle and spark 1856 ; on FIDLE 83BA CC8482 1857 jmp done_checks 1858 1859 check4: ; check we don't have Water and Fan control as both use X2 83BD C6E02E 1860 lda feature3_f 83C0 A508 1861 bit #WaterInjb 83C2 270B 1862 beq check5 1863 ; brclr WaterInj,feature3,check5 83C4 0B6208 1864 brclr X2_FAN,outputpins,check5 83C7 6E0597 1865 mov #5,tmp4 83CA 1E64 1866 bset config_error,feature2 ; X2 in conflict 1867 b_dc: 83CC CC8482 1868 jmp done_checks 1869 check5: 83CF 0F630F 1870 brclr Nitrous,feature1,check6 83D2 C6E02E 1871 lda feature3_f 83D5 A508 1872 bit #WaterInjb 83D7 2708 1873 beq check6 1874 ; brclr WaterInj,feature3,check6 83D9 6E0697 1875 mov #6,tmp4 83DC 1E64 1876 bset config_error,feature2 ; X4 water/nitrous pin in conflict 83DE CC8482 1877 jmp done_checks 1878 1879 check6: ;7pin HEI must have spark output B (LED19) defined. For bypass output 83E1 0F610B 1880 brclr HEI7,personality,check7 83E4 086208 1881 brset REUSE_LED19,outputpins,check7 83E7 6E0797 1882 mov #7,tmp4 83EA 1E64 1883 bset config_error,feature2 83EC CC8482 1884 jmp done_checks 1885 1886 check7: ; do some checks on wasted spark outputs 83EF 006A60 1887 brset rotary2,EnhancedBits5,check8a 1888 ; coilc is the pain - set if LED18=1 and LED18_2=1 83F2 07695B 1889 brclr wspk,EnhancedBits4,check8 ; don't bother if we 1890 ; aren't doing multiple outputs 83F5 056158 1891 brclr WHEEL,personality,check8 83F8 086408 1892 brset out3sparkd,feature2,ck74 ; 4th output 83FB 056218 1893 brclr REUSE_LED18,outputpins,ck72 ; not 3rd output 83FE 076215 1894 brclr REUSE_LED18_2,outputpins,ck72 ; not 3rd output 8401 200B 1895 bra ck73 ; LED18=1 & LED18_2=1 1896 ck74: 8403 C6E01C 1897 lda trig4_f 8406 271D 1898 beq ck7err 8408 05621A 1899 brclr REUSE_LED18,outputpins,ck7err 840B 076217 1900 brclr REUSE_LED18_2,outputpins,ck7err 1901 ck73: 840E C6E01B 1902 lda trig3_f 8411 2712 1903 beq ck7err 8413 09620F 1904 brclr REUSE_LED19,outputpins,ck7err 1905 ck72: 8416 C6E01A 1906 lda trig2_f 8419 270A 1907 beq ck7err 1908 ck72b: 841B 036207 1909 brclr REUSE_LED17,outputpins,ck7err 1910 ck71: 841E C6E019 1911 lda trig1_f 8421 2702 1912 beq ck7err 8423 2007 1913 bra check7b ; passed all checks 1914 ck7err: 8425 6E0897 1915 mov #8,tmp4 8428 1E64 1916 bset config_error,feature2 842A 2056 1917 bra done_checks 1918 check7b: ; can't use FIDLE for spark if doing wasted spark 842C 016207 1919 brclr REUSE_FIDLE,outputpins,check7c 842F 6E0997 1920 mov #9,tmp4 8432 1E64 1921 bset config_error,feature2 8434 204C 1922 bra done_checks 1923 1924 check7c: 1925 ;now check other way around 1926 ;first check for dual dizzy feature 8436 C6E05C 1927 lda feature6_f 8439 A510 1928 bit #dualdizzyb 843B 2613 1929 bne check8 ; if dual dizzy then only 2 outputs anyway 1930 843D C6E01C 1931 lda trig4_f ; if trig4 pt set must have 1932 ; spark o/p d 8440 2703 1933 beq ck7c3 8442 0964E0 1934 brclr out3sparkd,feature2,ck7err ; 4th output 1935 ck7c3: 8445 C6E01B 1936 lda trig3_f ; if trig3 pt set must 1937 ; have spark o/p c 8448 2706 1938 beq check8 844A 0562D8 1939 brclr REUSE_LED18,outputpins,ck7err 844D 0762D5 1940 brclr REUSE_LED18_2,outputpins,ck7err msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 27 MC68HC908GP32 User Bootloader 1941 1942 check8: 8450 2030 1943 bra check9 1944 check8a: 1945 ; do rotary2 output checks, must have led17,18,19 set to spark and two 1946 ; wheel triggers 8452 056218 1947 brclr REUSE_LED18,outputpins,ck8aerr 8455 076215 1948 brclr REUSE_LED18_2,outputpins,ck8aerr 8458 096212 1949 brclr REUSE_LED19,outputpins,ck8aerr 845B 03620F 1950 brclr REUSE_LED17,outputpins,ck8aerr 1951 ;now check wheel decoder is setup 845E 05611A 1952 brclr WHEEL,personality,ck8cerr 1953 ;check for two triggers 8461 C6E01A 1954 lda trig2_f 8464 270E 1955 beq ck8berr 8466 C6E019 1956 lda trig1_f 8469 2709 1957 beq ck8berr 846B 2015 1958 bra check9 1959 1960 ck8aerr: 846D 6E1097 1961 mov #10,tmp4 8470 1E64 1962 bset config_error,feature2 8472 200E 1963 bra done_checks 1964 ck8berr: 8474 6E1197 1965 mov #11,tmp4 8477 1E64 1966 bset config_error,feature2 8479 2007 1967 bra done_checks 1968 ck8cerr: 847B 6E1297 1969 mov #12,tmp4 847E 1E64 1970 bset config_error,feature2 8480 2000 1971 bra done_checks 1972 1973 check9: 1974 done_checks: 1975 ;make sure all spark outputs are inactive as soon as poss 1976 8482 CD9FDC 1977 jsr turnallsparkoff ; subroutine 1978 1979 start_adc: 1980 ; Fire up the ADC, and perform three conversions to get the baro value, IAT 1981 ; and the clt temp 1982 8485 A670 1983 lda #%01110000 ; Set up divide 8 and internal bus clock source 8487 B73E 1984 sta adclk 8489 A600 1985 lda #%00000000 ; Select one conversion, no interrupt, AD0 848B B73C 1986 sta adscr 848D 0F3CFD 1987 brclr coco,adscr,* ; wait until conversion is finished 1988 8490 B63D 1989 lda adr 8492 B743 1990 sta baro ; Store value in Barometer 1991 8494 A602 1992 lda #%00000010 ; Select second conversion, no interrupt, AD2 8496 B73C 1993 sta adscr 8498 0F3CFD 1994 brclr coco,adscr,* ; wait until conversion is finished 1995 849B BE3D 1996 ldx adr 849D D6F500 1997 lda THERMFACTOR,x 84A0 B7CC 1998 sta coolant ; Coolant temperature in degrees F + 40 1999 84A2 A603 2000 lda #%00000011 ; Select third conversion, no interrupt, AD3 84A4 B73C 2001 sta adscr 84A6 0F3CFD 2002 brclr coco,adscr,* ; wait until conversion is finished 2003 84A9 BE3D 2004 ldx adr 84AB D6F700 2005 lda MATFACTOR,x 84AE C70108 2006 sta airTemp 84B1 3F8E 2007 clr adsel ; Clear the channel selector 2008 2009 TURN_ON_INTS: 84B3 9A 2010 cli ; Turn on all interrupts now 2011 2012 *************************************************************************** 2013 ** Check for config error 2014 *************************************************************************** 84B4 0E646C 2015 brset config_error,feature2,config_er1JMP 2016 2017 *************************************************************************** 2018 ** 2019 ** Prime Pulse - Shoot out one priming pulse of length PRIMEP now or 2020 ** after 2 seconds 2021 ** Also added the facility for 2 priming pulses P Ringwood 2022 ** 2023 *************************************************************************** 84B7 1F66 2024 bclr Primed,EnhancedBits ; Clear the primed bit 84B9 C6E4C1 2025 lda feature11_f4 84BC A504 2026 bit #PrimeTwiceb 84BE 2602 2027 bne Two_Primes 2028 ; brset PrimeTwice,feature6,Two_Primes ; Are we firing priming 2029 ; pulses twice? 84C0 3CE3 2030 inc TCSparkCut ; Add 1 to prime counter 2031 ; so it only does it once 2032 Two_Primes: ; using spark cut byte to 2033 ; cut down bytes 84C2 C6E4C1 2034 lda feature11_f4 84C5 A502 2035 bit #PrimeLateb 84C7 2639 2036 bne PrimeLater 2037 ; brset PrimeLate,feature6,PrimeLater ; Are we going to prime late? 2038 2039 PrimeNow: 84C9 3CE3 2040 inc TCSparkCut ; Increase Prime Pulse Counter 84CB B6E3 2041 lda TCSparkCut 2042 84CD A102 2043 cmp #02T ; Have we reached prime 2044 ; pulse count limit? 84CF 2506 2045 blo Prime_Not_Done 84D1 1E66 2046 bset Primed,EnhancedBits ; Set Primed bit high if 2047 ; we've done all pulses 84D3 A600 2048 lda #00T 84D5 B7E3 2049 sta TCSparkCut ; Clear this for use later 2050 2051 Prime_Not_Done: 84D7 C6E4C1 2052 lda feature11_f4 ; Priming pulse table or box? 84DA A508 2053 bit #NoPrimePb 84DC 2714 2054 beq PrimeTable_P ; Prime table 2055 84DE C6E4C4 2056 lda primePulse_f ; Prime pulse 84E1 2702 2057 beq Prime_NoPrime ; if zero are we priming pump? 84E3 2025 2058 bra prime ; Go do prime 2059 Prime_NoPrime: 84E5 C6E4C1 2060 lda feature11_f4 ; zero pulse so are we priming pump? 84E8 A501 2061 bit #AlwaysPrimeb 84EA 2740 2062 beq CalcRunJMP ; zero and not fing pump 84EC 1E66 2063 bset Primed,EnhancedBits ; We have primed now 84EE A600 2064 lda #00T ; firing pump, put 00 back in acc 84F0 2018 2065 bra prime 2066 2067 PrimeTable_P: 2068 ; Interpolate from CLT, same curve as cranking PW. 2069 84F2 CD9AA7 2070 jsr crankingModePrime 84F5 B699 2071 lda tmp6 84F7 2011 2072 bra prime 2073 2074 NotPrimed: ; If were here we must 2075 ; be priming late 84F9 B640 2076 lda secl msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 28 MC68HC908GP32 User Bootloader 84FB A102 2077 cmp #02T ; Have we been powered up 2078 ; for 2 secs? 84FD 24CA 2079 bhs PrimeNow ; Yes so fire prime pulse now 84FF CC9A36 2080 jmp Prime_Checked ; No so go back to main loop 2081 2082 PrimeLater: 8502 1042 2083 bset running,engine 8504 1242 2084 bset crank,engine 8506 1000 2085 bset fuelp,porta ; Start the pump running 8508 2073 2086 bra CalcRunningParameters ; Don't pulse the injectors yet 2087 2088 prime: 2089 850A 1042 2090 bset running,engine 850C 1000 2091 bset fuelp,porta 2092 850E B74E 2093 sta pw1 8510 3F6C 2094 clr pwrun1 8512 1441 2095 bset sched1,squirt 8514 1041 2096 bset inj1,squirt 2097 8516 0D6364 2098 brclr CrankingPW2,feature1,CalcRunningParameters; can skip prime 2099 ; on second channel 8519 B753 2100 sta pw2 851B 3F6D 2101 clr pwrun2 851D 1841 2102 bset sched2,squirt 851F 1241 2103 bset inj2,squirt 8521 205A 2104 bra CalcRunningParameters 2105 2106 config_er1JMP: 8523 CC852E 2107 jmp config_error1 ; Config Error jump 2108 2109 PumpPrime: 8526 1242 2110 bset crank,engine 8528 1042 2111 bset running,engine 852A 1000 2112 bset fuelp,porta ; prime the pump 2113 CalcRunJMP: 852C 204F 2114 bra CalcRunningParameters ; Go start the main loop 2115 2116 ******** Config error dead end ********** 2117 ** Toggle these ports as a visual and audible indicator 2118 *************************************************************************** 2119 config_error1: 852E 121D 2120 bset IMASK,INTSCR ; disable interrupts for 2121 ; IRQ (the ignition i/p) 8530 1142 2122 bclr running,engine 8532 1000 2123 bset fuelp,porta 2124 ; bclr wled,portc 2125 2126 dead_end: 8534 1000 2127 bset fuelp,porta 2128 8536 B697 2129 lda tmp4 8538 2719 2130 beq skip_err_msg ; if zero then don't try 2131 ; to send 2132 2133 ;find start address or error message 853A B697 2134 lda tmp4 853C 48 2135 asla 853D 97 2136 tax 853E 8C 2137 clrh 853F D6D490 2138 lda error_vector,x 8542 B798 2139 sta tmp5 8544 5C 2140 incx 8545 D6D490 2141 lda error_vector,x 8548 B799 2142 sta tmp6 2143 854A 6E0D8C 2144 mov #$0D,txmode 854D 1614 2145 bset TE,SCC2 ; Enable Transmit 854F 1E14 2146 bset SCTIE,SCC2 ; Enable transmit interrupt 8551 3F97 2147 clr tmp4 ; wipe error code so we 2148 ; only send it once 2149 ;if we keep sending it then it gets in the way of tuning software trying to 2150 ;read and write data to put the error right. e.g. you send 'R' but the code 2151 ;is in the middle of sending a message 2152 skip_err_msg: 2153 8553 6E1094 2154 mov #10,tmp1 2155 dead_loop1 8556 3F95 2156 clr tmp2 2157 dead_loop2: 8558 3F96 2158 clr tmp3 2159 dead_loop3: 855A 3A96 2160 dec tmp3 855C 26FC 2161 bne dead_loop3 855E 3A95 2162 dec tmp2 8560 26F6 2163 bne dead_loop2 8562 3A94 2164 dec tmp1 8564 26F0 2165 bne dead_loop1 2166 8566 1100 2167 bclr fuelp,porta 2168 8568 6E1094 2169 mov #10,tmp1 2170 dead_loop4 856B 3F95 2171 clr tmp2 2172 dead_loop5: 856D 3F96 2173 clr tmp3 2174 dead_loop6: 856F 3A96 2175 dec tmp3 8571 26FC 2176 bne dead_loop6 8573 3A95 2177 dec tmp2 8575 26F6 2178 bne dead_loop5 8577 3A94 2179 dec tmp1 8579 26F0 2180 bne dead_loop4 2181 857B 20B7 2182 bra dead_end 2183 2184 ***************************************************************************** 2185 ***************************************************************************** 2186 ** 2187 ** Correction Factor Lookup Table Access 2188 ** 2189 ** Perform table lookup for barometer and air density correction factors, 2190 ** and performs coolant temperature conversion from counts to degrees F. 2191 ** 2192 ** All tables are pre-computed for all 256 different values 2193 ** and stored in FLASH. 2194 ** 2195 ** Note: Coolant temperature is in degrees F plus 40 - this allows 2196 ** unsigned numbers for full temperature range of -40 to 215. 2197 ** 2198 *************************************************************************** 2199 2200 CalcRunningParameters: 2201 2202 ******************************* 857D 8C 2203 clrh 857E 0E671B 2204 brset OneShotBArro,EnhancedBits2,bEnd_of_Baro ; Only do this once 2205 ; as we may change 2206 ; the baro value 2207 8581 C6E0C7 2208 lda feature9_f 8584 A580 2209 bit #ConsBarCorb ; Are we doing constant Bar COr using map on X7 ?? 8586 2626 2210 bne ConsBar 2211 8588 C6E1B8 2212 lda config13_f1 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 29 MC68HC908GP32 User Bootloader 858B A504 2213 bit #c13_cs ; Are we doing Alpha_n? 858D 2710 2214 beq OneShot_Bar ; No so one shot baro only! 2215 858F C6E0C7 2216 lda feature9_f ; Are we doing constant baro correction using 8592 A508 2217 bit #BaroCorConstb ; the on board map in Alpha_n mode? 8594 2709 2218 beq OneShot_Bar 8596 B644 2219 lda map 8598 B743 2220 sta baro ; Store the map in the baro variable 859A 2016 2221 bra DoBaroCorr 2222 2223 bEnd_of_Baro: 859C CC8628 2224 jmp End_of_Baro ; extend branch above 2225 2226 OneShot_Bar: 859F 1E67 2227 bset OneShotBArro,EnhancedBits2 85A1 C6E1B8 2228 lda config13_f1 85A4 A508 2229 bit #c13_bc 85A6 260A 2230 bne DoBaroCorr 85A8 A664 2231 lda #100T 85AA B7CA 2232 sta Pambient 85AC 2078 2233 bra DoneBaroCorr 2234 ConsBar: ; MAP connected to X7, so using constant BARO COR 85AE B65A 2235 lda o2_fpadc 85B0 B743 2236 sta baro 2237 2238 DoBaroCorr: 85B2 BE43 2239 ldx baro 85B4 C6E1B6 2240 lda config11_f1 85B7 A501 2241 bit #$01 ; Are we using Turbo Map sensor? 85B9 2755 2242 beq do_bar4115 85BB B643 2243 lda baro 85BD C1E052 2244 cmp BarroHi_f ; Check if its above upper limit 85C0 2507 2245 blo Baro_Lo_Check ; If its lower than upper limit 2246 ; check lower limit 85C2 C6E052 2247 lda BarroHi_f ; Its higher than upper limit 2248 ; so reset it to max 85C5 B743 2249 sta baro 85C7 BE43 2250 ldx baro 2251 Baro_Lo_Check: 85C9 C1E053 2252 cmp BarroLow_f ; Lower setpoint for Baro Correction 85CC 2205 2253 bhi Do_BaroTurbo ; If its higher then do the baro factor 85CE C6E053 2254 lda BarroLow_f ; If not then fix it to lower limit 85D1 B743 2255 sta baro 2256 2257 Do_BaroTurbo: 2258 ; brclr KPa300,feature8,No_KPA_300 ; Are we using non standard 2259 ; MAP sensor? 85D3 C6E074 2260 lda feature8_f 85D6 A501 2261 bit #KPa300b 85D8 272A 2262 beq No_KPA_300 85DA 8C 2263 clrh 85DB B643 2264 lda baro 85DD B7DD 2265 sta tmp31 85DF 97 2266 tax 85E0 C6E083 2267 lda BarCorr300_f ; Multiply by differential factor 85E3 42 2268 mul 85E4 9F 2269 txa ; Transfer high byte to accumulator 85E5 2401 2270 bcc No_Carry_Barro ; Is the carry bit set? 85E7 4C 2271 inca 2272 No_Carry_Barro: 85E8 BBDD 2273 add tmp31 ; Add the original bar back in 2274 ; brset KPa400,feature8,KPa400_Set 85EA 97 2275 tax 85EB C6E074 2276 lda feature8_f 85EE A502 2277 bit #KPa400b 85F0 9F 2278 txa 85F1 2602 2279 bne KPa400_set 85F3 A002 2280 sub #$02 2281 KPa400_Set: 85F5 A00A 2282 sub #$0a ; Remove offset from original sensor 85F7 B743 2283 sta baro 85F9 97 2284 tax 85FA D6F400 2285 lda KPAFACTOR4250,x 85FD B7CA 2286 sta Pambient 85FF D6F200 2287 lda BAROFAC4250,x 8602 2022 2288 bra DoneBaroCorr 2289 2290 2291 2292 No_KPA_300: 8604 BE43 2293 ldx baro 2294 TurboConst: 8606 D6F400 2295 lda KPAFACTOR4250,x 8609 B7CA 2296 sta Pambient 860B D6F200 2297 lda BAROFAC4250,x 860E 2016 2298 bra DoneBaroCorr 2299 do_bar4115: 8610 B643 2300 lda baro 8612 C1E053 2301 cmp BarroLow_f ; Are we below the lower limit? 8615 2207 2302 bhi Do_NABaro ; If its higher than lower limit 2303 ; then do correction (No need to 2304 ; check hi limit) 8617 C6E053 2305 lda BarroLow_f ; Fix it to lower limit 861A B743 2306 sta baro 861C BE43 2307 ldx baro 2308 Do_NABaro: 861E D6F300 2309 lda KPAFACTOR4115,x 8621 B7CA 2310 sta Pambient 8623 D6F100 2311 lda BAROFAC4115,x 2312 DoneBaroCorr: 8626 B750 2313 sta barocor ; Barometer Correction Gamma 2314 End_of_Baro: 8628 BE44 2315 ldx map 862A C6E1B6 2316 lda config11_f1 862D A501 2317 bit #$01 862F 2710 2318 beq do_bar4115m 2319 2320 ; Add check here for 300KPa sensor, can only use it if 255 sensor selected 2321 2322 ; brclr KPa300,feature8,Normal_KPa ; Are we using 300KPa sensor? 8631 C6E074 2323 lda feature8_f 8634 A501 2324 bit #KPa300b 8636 2704 2325 beq Normal_Kpa 8638 B644 2326 lda map ; Use Raw ADC value if 300 KPa 2327 ; instead of KPAFACTOR 863A 2008 2328 bra DoneBaro 2329 2330 Normal_KPa: 863C D6F400 2331 lda KPAFACTOR4250,x 863F 2003 2332 bra DoneBaro 2333 2334 do_bar4115m: 8641 D6F300 2335 lda KPAFACTOR4115,x 2336 2337 DoneBaro: 8644 B7CB 2338 sta kpa 2339 8646 BE46 2340 ldx clt 8648 D6F500 2341 lda THERMFACTOR,x 864B B7CC 2342 sta coolant ; Coolant temperature in degrees F + 40 2343 864D BE45 2344 ldx mat 864F D6F700 2345 lda MATFACTOR,x 8652 C70108 2346 sta airTemp ; Added for enhanced stuff Air Temp in F + 40 2347 8655 C6E0C7 2348 lda feature9_f ; Are we using a MAF? msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 30 MC68HC908GP32 User Bootloader 8658 A520 2349 bit #MassAirFlwb 865A 270C 2350 beq Do_AirDens 865C C6E0C7 2351 lda feature9_f ; Using MAF, so do we still do Air Cor? 865F A540 2352 bit #NoAirFactorb 8661 2705 2353 beq Do_AirDens 8663 A664 2354 lda #100T ; No Air Cor so set it to 100% 8665 CC86EF 2355 jmp Store_AirCor 2356 2357 Do_AirDens: ; Not using a Air correction within a MAF 2358 2359 ;******** CHECK IF CORRECTING AIR DENSITY ***************** 8668 C6E5B3 2360 lda feature10_f5 866B A508 2361 bit #cltMAPb ; Are we correcting the air density factor? 866D 277B 2362 beq NormAirDen ; If no then do normal air density 2363 2364 ; If we get here we are doing correction to air density 2365 ; Air Density = IAT Air Density * (Correction * Reduction based on RPM %) 2366 866F 45E5C0 2367 ldhx #CltMATRange ; Temps for table 8672 3594 2368 sthx tmp1 8674 A609 2369 lda #$09 ; 10 bytes big 8676 B796 2370 sta tmp3 2371 8678 C6E5B3 2372 lda feature10_f5 867B A510 2373 bit #CltMATCheck 867D 2705 2374 beq CoolantRel ; Are we using Coolant or IAT for correction? 867F C60108 2375 lda airTemp ; MAT based correction 8682 2002 2376 bra MATRel 2377 2378 CoolantRel: 8684 B6CC 2379 lda coolant ; Coolant based correction 2380 MATRel: 8686 B797 2381 sta tmp4 8688 CDCF9B 2382 jsr tableLookup ; Find the lookup place for coolant 2383 ; corr in table 868B 8C 2384 clrh 868C BE98 2385 ldx tmp5 868E D6E5B7 2386 lda cltMATcorr_f,x ; From correction table to correct Density 8691 B797 2387 sta liY2 8693 5A 2388 decx 8694 D6E5B7 2389 lda cltMATcorr_f,x 8697 B796 2390 sta liY1 2391 8699 C6E5B3 2392 lda feature10_f5 869C A510 2393 bit #CltMATCheck 869E 2705 2394 beq CoolantTabl ; Are we using Coolant or IAT for correction? 86A0 C60108 2395 lda airTemp 86A3 2002 2396 bra StoreCoret 2397 2398 CoolantTabl: 86A5 B6CC 2399 lda coolant 2400 StoreCoret: 86A7 B798 2401 sta liX 86A9 CDCFB8 2402 jsr LinInterp 86AC 4E99DD 2403 mov tmp6,tmp31 ; Tmp31 now contains correction percentage 2404 2405 ; So now we have the correction for Air Den, now interpolate the RPM to reduce this if needed due to engine speed 2406 ; We do this by having 2 RPM set points, below Lowest is all of calculated coolant correction, above it is interpolated. 2407 86AF B64D 2408 lda rpm 86B1 C1E5BE 2409 cmp RPMReduLo_f ; Are we below the min reduction value? 86B4 251C 2410 blo Do_Cal_Red1 ; YES so no reduction on correction factor 86B6 B64D 2411 lda rpm 86B8 B798 2412 sta liX ; Store current value to see where we are 86BA C6E5BF 2413 lda RPMReduHi_f 86BD B795 2414 sta liX2 ; Highest point to stop all correction 86BF C6E5BE 2415 lda RPMReduLo_f 86C2 B794 2416 sta liX1 ; Lowest point to start to remove correction 86C4 B6DD 2417 lda tmp31 ; This is the coolant correction value 86C6 B796 2418 sta liY1 86C8 A664 2419 lda #100T 86CA B797 2420 sta liY2 ; 100% correction when at this setpoint (No correction) 86CC CDCFB8 2421 jsr LinInterp ; Find How much we want to reduce by. 86CF 4E99DD 2422 mov tmp6,tmp31 ; tmp31 now contains coolant correction * 0-100% reduction depending on RPM 2423 2424 Do_Cal_Red1: 86D2 8C 2425 clrh 86D3 BE45 2426 ldx mat 86D5 D6F600 2427 lda AIRDENFACTOR,x ; Find normal Air Density 86D8 B79D 2428 sta tmp10 86DA 3F9E 2429 clr tmp11 86DC B6DD 2430 lda tmp31 86DE B79F 2431 sta tmp12 86E0 3FA0 2432 clr tmp13 86E2 CDD170 2433 jsr Supernorm ; Multiply Norm AirDen with correction 86E5 4E9D4B 2434 mov tmp10,AirCor ; Now we have amount of correction based on correction * RPM reduction% 86E8 2007 2435 bra Do_Mat_Fact ; jump past normal Air Density 2436 2437 ;******** NORMAL AIR DENSITY ************************************** 2438 NormAirDen: 86EA BE45 2439 ldx mat 86EC D6F600 2440 lda AIRDENFACTOR,x 2441 Store_AirCor: 86EF B74B 2442 sta AirCor ; Air Density Correction Factor 2443 2444 Do_Mat_Fact: 2445 2446 *************************************************************************** 2447 ** 2448 ** Computation of RPM 2449 ** 2450 ** Result left in accumulator. 2451 ** 2452 ** rpmk:rpmk+1 2453 ** ----------- = rpm 2454 ** rpmph:rpmpl 2455 ** 2456 ** rpmk:rpmK+1 = RPM constant = (6,000 * (stroke/2))/ncyl 2457 ** rpmph:rpmpl = period count between IRQ pulsed lines, in 0.1 ms resolution 2458 ** 2459 **************************************************************************** 2460 2461 CalcRPM: 2462 ; 50% re-written in 026i with aim of better odd-fire averaging 2463 86F1 004207 2464 brset running,engine,dorpmCalc 86F4 5570 2465 ldhx rpmph 86F6 2603 2466 bne dorpmCalc ; If zero then jump over calculation 2467 ; - prevent divide by zero 86F8 CC878A 2468 jmp rpmCalcZero ; previous branches out of range 2469 2470 dorpmCalc: 2471 ;tmp12,13,14 used to hold average iTime or avg iTime 86FB 9B 2472 sei ; must block ints for this little period 86FC 4EAE9F 2473 mov iTimeX,tmp12 86FF 4EAFA0 2474 mov iTimeH,tmp13 8702 4EB0A1 2475 mov iTimeL,tmp14 2476 8705 4EFDA2 2477 mov iTimepX,tmp15 8708 4EFEA3 2478 mov iTimepH,tmp16 870B 4EFFA4 2479 mov iTimepL,tmp17 870E 9A 2480 cli 2481 2482 ; If odd-fire is set (bit zero of Config13), then average RPM values 870F C6E1B8 2483 lda config13_f1 8712 A401 2484 and #$01 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 31 MC68HC908GP32 User Bootloader 8714 2717 2485 beq NO_ODD_FIRE 2486 2487 YES_ODD_FIRE: 2488 ;average previous period with previous previous 8716 B6A4 2489 lda tmp17 ; add together 8718 BBA1 2490 add tmp14 871A B7A1 2491 sta tmp14 871C B6A3 2492 lda tmp16 871E B9A0 2493 adc tmp13 8720 B7A0 2494 sta tmp13 8722 B6A2 2495 lda tmp15 8724 B99F 2496 adc tmp12 8726 44 2497 lsra ; divide by 2 8727 B79F 2498 sta tmp12 8729 36A0 2499 ror tmp13 872B 36A1 2500 ror tmp14 2501 2502 NO_ODD_FIRE: 872D B69F 2503 lda tmp12 872F 2731 2504 beq rpmCalcFast ; If we have only 8-bit denominator, 2505 ; then use native divide 2506 2507 ;note, udvd32 re-written so that it uses 2508 ;tmp1,2,3,4 as intacc1 2509 ;tmp5,6,7,8 as intacc2 2510 ;tmp9,10,11 as temp storage instead of extra stack 2511 2512 rpmCalcSlow: 2513 ;need to divide period (tmp12,13,14) by 100 to obtain period time in 0.1ms 8731 AE64 2514 ldx #100T 8733 8C 2515 clrh 8734 B69F 2516 lda tmp12 8736 52 2517 div ; A rem H = (H:A) / X 8737 B79F 2518 sta tmp12 8739 B6A0 2519 lda tmp13 873B 52 2520 div ; A rem H = (H:A) / X 873C B7A0 2521 sta tmp13 873E B6A1 2522 lda tmp14 8740 52 2523 div ; A rem H = (H:A) / X 8741 B7A1 2524 sta tmp14 2525 8743 B69F 2526 lda tmp12 8745 2643 2527 bne rpmCalcZero ; if tmp12>0 then very slow indeed (<100rpm) 2528 2529 8747 3F94 2530 clr intacc1 8749 3F95 2531 clr intacc1+1 2532 874B 4EA098 2533 mov tmp13,intacc2 874E 4EA199 2534 mov tmp14,intacc2+1 2535 8751 C6E19C 2536 lda rpmk_f1 8754 B796 2537 sta intacc1+2 8756 C6E19D 2538 lda rpmk_f1+1 8759 B797 2539 sta intacc1+3 2540 875B CDD035 2541 jsr udvd32 ; 32 / 16 divide 2542 875E B697 2543 lda intacc1+3 ; get 8-bit RPM result 8760 2029 2544 bra rpmCalcDone 2545 2546 rpmCalcFast: 2547 ;This (new) slower code takes the time between IRQs in 1us accuracy to calc the rpm 2548 ;this should eliminate the jumpiness at high rpm where one 0.1ms step > 100rpm 2549 ; 2550 ;Multiply rpmk x 100 then do 32/16 divide using 1us time 8762 A664 2551 lda #100T 8764 CEE19D 2552 ldx rpmk_f1+1 ; LSB of multiplicand. 8767 42 2553 mul 8768 B797 2554 sta intacc1+3 ; LSB of result stored. 876A BF96 2555 stx intacc1+2 ; Carry on stack. 876C A664 2556 lda #100T 876E CEE19C 2557 ldx rpmk_f1 ; MSB of multiplicand. 8771 42 2558 mul 8772 BB96 2559 add intacc1+2 ; Add in carry from LSB. 8774 B796 2560 sta intacc1+2 ; MSB of result. 8776 2401 2561 bcc nox_of 8778 5C 2562 incx 2563 nox_of: 8779 BF95 2564 stx intacc1+1 877B 3F94 2565 clr intacc1 2566 ;rpmk x 100 now dividend 2567 ;make iTime the divisor 877D 4EA098 2568 mov tmp13,intacc2 8780 4EA199 2569 mov tmp14,intacc2+1 8783 CDD035 2570 jsr udvd32 ; 32/16 divide 2571 8786 B697 2572 lda intacc1+3 ; get 8-bit RPM result 8788 2001 2573 bra rpmCalcDone 2574 2575 rpmCalcZero: 878A 4F 2576 clra 2577 2578 rpmCalcDone: 878B B74D 2579 sta rpm 2580 2581 *************************************************************************** 2582 ** First, check RPM value to determine if we are cranking or running, 2583 ** then calculate the appropriate pulse width. 2584 *************************************************************************** 2585 CalcPWs: 878D B64D 2586 lda rpm 878F C1E4C2 2587 cmp crankRPM_f ; Check if we are cranking, 8792 2209 2588 bhi runIt 8794 066706 2589 brset cant_crank,EnhancedBits2,runIt ; don't allow reentry 2590 ; to crank mode while 2591 ; running 2592 crankIt: 8797 CD9AA4 2593 jsr crankingMode 879A CC8E9E 2594 jmp checkRPMsettings 2595 runIt: 2596 2597 ;-------------------------------------------------------------------------- 2598 ; Approximate ranges of the various terms of the equation: 2599 ; 2600 ; gammae 90-150, highest when cold, but really of no consequence. 2601 ; vecurr 10-200, biggest range with blown motors. 2602 ; kPa 20-250, biggest range with blown motors. 2603 ; reqFuel 50-150, lowest values with big injectors, blown motors again. 2604 ; battcorr ~100, assume it's constant. 2605 ; 2606 ; So calc VEcurr * reqFuel before * kPa to minimize overflow. 2607 2608 ; calc 'PW1' from table 1 879D 1569 2609 bclr page2,EnhancedBits4 ; set table 1 2610 879F 0C6605 2611 brset UseVE3,EnhancedBits,VE3_Table ; Jump if were using VE table 3 2612 Do_VE1_4_Now: 2613 87A2 CD9BC1 2614 jsr VE1_LOOKUP ; calcs vecurr 87A5 2007 2615 bra No_VE3 2616 2617 VE3_Table: 87A7 B6E0 2618 lda VE3Timer 87A9 26F7 2619 bne Do_VE1_4_Now 87AB CD9D18 2620 jsr VE3_LOOKUP ; Use VE Table 3, result in vecurr msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 32 MC68HC908GP32 User Bootloader 2621 No_VE3: 2622 2623 CalcGammaE: 2624 2625 ; Now we do all the WUE, TAE and EGO in sequence rather than subroutines 2626 ; (ram saving?) 2627 2628 *************************************************************************** 2629 ** PW Correction Factor subroutines. 2630 *************************************************************************** 2631 *************************************************************************** 2632 ** 2633 ** Warm-up and After-start Enrichment Section 2634 ** 2635 ** The Warm-up enrichment is a linear interpolated value from WWU (10 points) 2636 ** which are placed at different temperatures 2637 ** 2638 ** Method: 2639 ** 2640 ** 1) Perform ordered table search of WWU (using coolant variable) to determine 2641 ** which bin. 2642 ** 2) Perform linear interpolation to get interpolated warmup enrichment 2643 ** 2644 ** Also, the after-start enrichment value is calculated and applied here - it 2645 ** is an added percent value on top of the warmup enrichment, and it is applied 2646 ** for the number of ignition cycles specified in AWC. This enrichment starts 2647 ** at a value of AWEV at first, then it linearly interpolates down to zero 2648 ** after AWC cycles. 2649 ** 2650 ** 3) If (startw, engine is set) then: 2651 ** 4) compare if (awc < ASEcount) then: 2652 ** 5) x1=0, x2=AWC, y1=AWEV, y2=0, x=ASEcount, y=ASEenrichment 2653 ** 6) else clear startw bit in engine 2654 ** 2655 *************************************************************************** 2656 WUE_CALC: 87AE 03420C 2657 brclr crank,engine,WUE1 87B1 1342 2658 bclr crank,engine 87B3 3FE5 2659 clr TCCycles 87B5 3FE1 2660 clr TCAccel 87B7 1442 2661 bset startw,engine 87B9 1642 2662 bset warmup,engine 87BB 3F83 2663 clr ASEcount 2664 WUE1: 87BD B6CC 2665 lda coolant 87BF A1CD 2666 cmp #205T 87C1 2506 2667 blo Warm_NotDone ; If coolant is >165F (greater than the max setting) 87C3 B64C 2668 lda warmcor 87C5 A164 2669 cmp #100T ; And if Warm corr = 100? 87C7 272E 2670 beq Warm_Done_Now ; then dont do all the table stuff as this is over 2671 2672 Warm_NotDone: 87C9 45D808 2673 ldhx #WWURANGE 87CC 3594 2674 sthx tmp1 87CE A609 2675 lda #$09 87D0 B796 2676 sta tmp3 87D2 B6CC 2677 lda coolant 87D4 B797 2678 sta tmp4 87D6 CDCF9B 2679 jsr tableLookup 2680 87D9 8C 2681 clrh 87DA BE98 2682 ldx tmp5 87DC D6E4AC 2683 lda WWU_f1,x 87DF B797 2684 sta liY2 87E1 5A 2685 decx 87E2 D6E4AC 2686 lda WWU_f1,x 87E5 B796 2687 sta liY1 87E7 B6CC 2688 lda coolant 87E9 B798 2689 sta liX 87EB CDCFB8 2690 jsr LinInterp 87EE 4E994C 2691 mov tmp6,warmcor 87F1 B64C 2692 lda warmcor 87F3 A164 2693 cmp #100T 87F5 2615 2694 bne WUE2 2695 2696 ; Outside of warmup range - clear warmup enrichment mode 2697 Warm_Done_Now: 87F7 A664 2698 lda #100T 87F9 B74C 2699 sta warmcor 87FB 1E69 2700 bset FxdASEDone,EnhancedBits4 87FD 1542 2701 bclr startw,engine 87FF 1742 2702 bclr warmup,engine 8801 04623E 2703 brset REUSE_LED18,outputpins,WUE_DONEJMP 8804 06623B 2704 brset REUSE_LED18_2,outputpins,WUE_DONEJMP ; Using led as output 4 8807 1502 2705 bclr wled,portc ; not when crank sim or if 2706 ; LED re-used as IRQ indicator 8809 CC888F 2707 jmp WUE_DONE 2708 WUE2: 880C 046205 2709 brset REUSE_LED18,outputpins,WUE2_ledskip 880F 066202 2710 brset REUSE_LED18_2,outputpins,WUE2_ledskip ; Using led as output 4 8812 1402 2711 bset wled,portc 2712 WUE2_ledskip: 8814 05422B 2713 brclr startw,engine,WUE_DONEJMP 2714 2715 ; Added a fixed period of ASE rather than a decaying ASE, after fixed period it 2716 ; goes to the normal ASE decay type of ASE 2717 8817 C6E5B3 2718 lda feature10_f5 881A A502 2719 bit #ASEHoldb ; Are we holding the ASE at a fixed percentage? 881C 271B 2720 beq NormASE_Count 881E 0E6918 2721 brset FxdASEDone,EnhancedBits4,NormASE_Count ; If Fixed ASE done 2722 8821 B6CC 2723 lda coolant ; We are in fixed Accel mode 8823 C1E5B5 2724 cmp CltFixASE_f ; so are we below the temperature setpoint? 8826 2504 2725 blo Cont_FixASE 8828 1E69 2726 bset FxdASEDone,EnhancedBits4 882A 200D 2727 bra NormASE_Count 2728 Cont_FixASE: 882C B683 2729 lda ASEcount 882E C1E5B4 2730 cmp TimFixASE_f 8831 2511 2731 blo Table_ASEStuff ; Have we passed the Fixed timer yet? 2732 8833 A600 2733 lda #00T 8835 B783 2734 sta ASEcount ; Reset ASE count so we do the norm ASE now 8837 1E69 2735 bset FxdASEDone,EnhancedBits4 2736 NormASE_Count: 8839 B683 2737 lda ASEcount 883B C1E5B2 2738 cmp awc_f1 ; Check if ASE period has expired. 883E 244D 2739 bhs WUE3 8840 2002 2740 bra Table_ASEStuff 2741 WUE_DONEJMP: 8842 204B 2742 bra WUE_DONE 2743 ; Table ASE stuff based on coolant temp - PR 2744 Table_ASEStuff: 8844 4ECC97 2745 mov coolant,tmp4 8847 45D808 2746 ldhx #WWURANGE 884A 3594 2747 sthx tmp1 884C 6E0996 2748 mov #$09,tmp3 ; 10 bits wide 884F CDCF9B 2749 jsr tableLookup ; This finds the bins when the 2750 ; temperatures are set 8852 8C 2751 clrh 8853 BE98 2752 ldx tmp5 2753 8855 D6E5A8 2754 lda ASEVTbl_f,x 8858 B797 2755 sta liY2 885A 5A 2756 decx msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 33 MC68HC908GP32 User Bootloader 885B D6E5A8 2757 lda ASEVTbl_f,x ; This finds the values for the 2758 ; ase percentage for the temperature 885E B796 2759 sta liY1 8860 4ECC98 2760 mov coolant,liX 8863 CDCFB8 2761 jsr LinInterp ; tmp6 contains amount of ase 2762 ; enrichment in percent for this 2763 ; temperature 2764 8866 3F94 2765 clr liX1 8868 C6E5B2 2766 lda AWC_f1 886B B795 2767 sta liX2 2768 886D B699 2769 lda tmp6 ; Use the value from the interpolated 2770 ; table rather than the normal value 886F B796 2771 sta liY1 8871 3F97 2772 clr liY2 8873 3F98 2773 clr liX 8875 C6E5B3 2774 lda feature10_f5 8878 A502 2775 bit #ASEHoldb 887A 2703 2776 beq NormASE_Interp 887C 0F6903 2777 brclr FxdASEDone,EnhancedBits4,All_ASECount 2778 NormASE_Interp: 887F 4E8398 2779 mov ASEcount,liX 2780 All_ASECount: 8882 CDCFB8 2781 jsr LinInterp 8885 B699 2782 lda tmp6 8887 BB4C 2783 add warmcor 8889 B74C 2784 sta warmcor 888B 2002 2785 bra WUE_DONE 2786 2787 WUE3: 888D 1542 2788 bclr startw,engine ; ASE period terminated, turn off bit. 2789 2790 WUE_DONE: 2791 2792 *************************************************************************** 2793 ** 2794 ** Throttle Position Acceleration Enrichment 2795 ** 2796 ** Method is the following: 2797 ** 2798 ** 2799 ** ACCELERATION ENRICHMENT: 2800 ** If (TPS < TPSlast) goto DECELERATION ENLEANMENT 2801 ** If (TPS - TPSlast) > TPSthresh and TPSAEN == 0 { 2802 ** Turn on acceleration enrichment. 2803 ** 1) Set acceleration mode. 2804 ** 2) Continuously determine rate-of-change of throttle, and 2805 ** perform interpolation of TPSAQ values to determine 2806 ** acceleration enrichment amount to apply. 2807 ** } 2808 ** If (TPSACLK > TPSACLKCMP) and TPSAEN is set { 2809 ** 1) Clear TPSAEN engine bit. 2810 ** 2) Set TPSACCEL to 0 ms. 2811 ** 3) Go to EGO Delta Step Check Section. 2812 ** } 2813 ** 2814 ** 2815 ** DECELERATION ENLEANMENT: 2816 ** If (TPSlast - TPS) > TPSthresh { 2817 ** If TPSAEN == 1 { 2818 ** 1) TPSACCEL = 0 ms (terminate AE early) 2819 ** 2) Clear TPSAEN bit in ENGINE 2820 ** 3) Go to EGO Delta Step 2821 ** } 2822 ** If RPM > 15 { 2823 ** Turn on deceleration fuel cut. 2824 ** 1) Set TPSACCEL value to TPSDQ 2825 ** 2) Set TPSDEN bit in ENGINE 2826 ** 3) Go to EGO Delta Step Check Section 2827 ** } 2828 ** } 2829 ** else { 2830 ** If TPSDEN == 1 { 2831 ** 1) Clear TPSDEN bit in ENGINE 2832 ** 2) TPSACCEL = 0 ms 2833 ** 3) Go to EGO Delta Step Check Section 2834 ** } 2835 ** } 2836 ** 2837 *************************************************************************** 2838 TAE_CALC: 888F C6E042 2839 lda feature4_f 8892 A580 2840 bit #KpaDotSetb 8894 2726 2841 beq tps_dotty 2842 ; brclr KpaDotSet,feature4,tps_dotty ; If not in KPA dot mode 2843 ; jump past KPa settings 8896 A510 2844 bit #KpaDotBoostb 8898 2706 2845 beq No_Boost_Chk 2846 ; brclr KpaDotBoost,feature4,No_Boost_Chk; Are we going to stop 2847 ; accel in boost? 889A B6CB 2848 lda kpa 889C A164 2849 cmp #100T 889E 227D 2850 bhi TAE_CHK_JMP ; If KPa above 100 then no 2851 ; accel deccel enrichment 2852 No_Boost_Chk: 88A0 C6E0C7 2853 lda feature9_f 88A3 A504 2854 bit #NoAccelASEb ; Are we Acceling during ASE? 88A5 2703 2855 beq NoASE_Check_Accel 88A7 044273 2856 brset startw,engine,TAE_CHK_JMP ; Is After Start Enrichment running? 2857 2858 NoASE_Check_Accel: 88AA 9B 2859 sei 88AB 4ECB94 2860 mov kpa,tmp1 ; Load kpa into temp1 88AE B6D1 2861 lda TPSlast 88B0 B795 2862 sta tmp2 88B2 9A 2863 cli 88B3 B694 2864 lda tmp1 88B5 B195 2865 cmp tmp2 88B7 2415 2866 bhs AE_CHK 88B9 CC8A70 2867 jmp TDE 2868 2869 tps_dotty: 88BC 9B 2870 sei 88BD 4E4794 2871 mov tps,tmp1 88C0 B6D1 2872 lda TPSlast 88C2 B795 2873 sta tmp2 88C4 9A 2874 cli 88C5 B694 2875 lda tmp1 88C7 B195 2876 cmp tmp2 88C9 2403 2877 bhs AE_CHK 88CB CC8A70 2878 jmp TDE 2879 2880 AE_CHK: 88CE B095 2881 sub tmp2 88D0 B7DD 2882 sta tmp31 88D2 C6E042 2883 lda feature4_f ; Are we in TPS or KPA mode? 88D5 A580 2884 bit #KpaDotSetb 88D7 270A 2885 beq tps_ThreshCheck 88D9 B6DD 2886 lda tmp31 88DB C1E05B 2887 cmp MAPthresh_f ; Are we above the Accel 2888 ; threshold for MAP? 88DE 240D 2889 bhs AE_SET 88E0 CC89EE 2890 jmp TAE_CHK_TIME 2891 2892 tps_ThreshCheck: msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 34 MC68HC908GP32 User Bootloader 88E3 B6DD 2893 lda tmp31 88E5 C1E0C1 2894 cmp TPSthresh_f1 ; Are we above the Accel 2895 ; threshold for TPS? 88E8 2403 2896 bhs AE_SET 88EA CC89EE 2897 jmp TAE_CHK_TIME 2898 AE_SET: 88ED 084230 2899 brset TPSAEN,ENGINE,AE_COMP_SHOOT_AMT 2900 2901 ; Add in accel enrichment 88F0 C6E0C7 2902 lda feature9_f 88F3 A510 2903 bit #RpmAEBased ; This is a basic AE system that uses 88F5 2705 2904 beq NormalBased_AE ; RPM rather than dot 88F7 C6E0AB 2905 lda RPMAQL_f2 88FA 200F 2906 bra Store_TEA1 2907 2908 NormalBased_AE: 88FC C6E042 2909 lda feature4_f 88FF A580 2910 bit #KpaDotSetb 8901 2705 2911 beq tps_FirstElem 8903 C6E0B8 2912 lda MAPAQ_f ; start out using first element 2913 ; - will determine actual next 2914 ; time around 8906 2003 2915 bra Store_TEA1 2916 2917 tps_FirstElem: 8908 C6E0BC 2918 lda TPSAQ_f1 ; start out using first element 2919 ; - will determine actual next 2920 ; time around 2921 2922 Store_TEA1: 890B B74F 2923 sta TPSACCEL ; Acceleration percent amount 2924 ; - used in later calculations 890D B788 2925 sta Decay_Accel 890F 3F81 2926 clr TPSACLK 8911 1842 2927 bset TPSAEN,ENGINE 8913 1B42 2928 bclr TPSDEN,ENGINE 8915 086202 2929 brset REUSE_LED19,outputpins,acc_done_led ; LED already used 2930 ; in NEON as coilb 8918 1202 2931 bset aled,portc 2932 acc_done_led: 891A CC8AD5 2933 jmp TAE_DONE 2934 TAE_CHK_JMP: 891D CC89EE 2935 jmp TAE_CHK_TIME 2936 2937 ; First, calculate cold temperature add-on enrichment value from coolant value, 2938 ; from -40 degrees to 165 degrees. 2939 ; 2940 ; Then determine cold temperature multiplier value ACCELMULT (in percent), 2941 ; from -40 degrees to 165 degrees. 2942 ; 2943 ; Next, calculate squirt amount (quantity) for acceleration enrichment 2944 ; Find bins (between) for corresponding TPSdot, and linear interpolate 2945 ; to find enrichment amount (from TPSAQ). This is continuously 2946 ; checked every time thru main loop while in acceleration mode, 2947 ; and the highest value is latched and used. 2948 ; 2949 ; The final acceleration applied is: 2950 ; AE = Alookup(TPSdot) * (ACCELMULT/100) + TPSACOLD 2951 2952 AE_COMP_SHOOT_AMT: 2953 ; First, the amount based on cold temperatures 8920 B64C 2954 lda warmcor 8922 A164 2955 cmp #100T ; And if Warm corr = 100? 8924 2731 2956 beq Warmup_OverAE 8926 3F94 2957 clr liX1 ; 0 -> - 40 degrees 8928 6ECD95 2958 mov #205T,liX2 ; 165 + 40 degrees (because of 2959 ; offset in lookup table) 892B C6E0C0 2960 lda TPSACOLD_f1 892E B796 2961 sta liY1 ; This is the amount at coldest 8930 3F97 2962 clr liY2 ; no enrichment addon at warm 2963 ; temperature 8932 B6CC 2964 lda coolant 8934 B798 2965 sta liX 8936 CDCFB8 2966 jsr LinInterp 8939 4E99A0 2967 mov liY,tmp13 ; result - save here temporarily 2968 2969 ; Second, find the multiplier (ACCELMULT) amount based on cold temperatures 893C 3F94 2970 clr liX1 ; 0 -> - 40 degrees 893E 6ECD95 2971 mov #205T,liX2 ; 165 + 40 degrees 8941 3F95 2972 clr tmp2 8943 C6E0C4 2973 lda ACMULT_f1 8946 B796 2974 sta liY1 ; This is the amount at coldest 8948 6E6497 2975 mov #100T,liY2 ; 1.00 multiplier at 165 degrees 894B B6CC 2976 lda coolant 894D B798 2977 sta liX 894F CDCFB8 2978 jsr lininterp 8952 4E99A1 2979 mov liY,tmp14 ; result - save here temporarily 8955 2008 2980 bra AECarry_OnAE 2981 2982 Warmup_OverAE: 8957 A600 2983 lda #00T ; If we get here then the warmup = 100 so no need to 8959 B7A0 2984 sta tmp13 ; Add any cold stuff so bypass it 895B A664 2985 lda #100T 895D B7A1 2986 sta tmp14 2987 AECarry_OnAE: 895F C6E0C7 2988 lda feature9_f 8962 A510 2989 bit #RpmAEBased ; This is a basic AE system that uses 8964 271F 2990 beq NotRPMBased ; engine rpm instead of rate of change of tps 8966 45E0A4 2991 ldhx #RPMbasedrate_f ; or map. Amount added is rpm based. 8969 3594 2992 sthx tmp1 896B 6E0396 2993 mov #$03,tmp3 896E B64D 2994 lda rpm 8970 B797 2995 sta tmp4 8972 B79D 2996 sta tmp10 8974 CDCF9B 2997 jsr tableLookup ; Find the rpm bins we are going to use 8977 8C 2998 clrh 8978 BE98 2999 ldx tmp5 897A D6E0A8 3000 lda RPMAQ_f2,x 897D B797 3001 sta liY2 897F 5A 3002 decx 8980 D6E0A8 3003 lda RPMAQ_f2,x 8983 204D 3004 bra Carry_On_TEA 3005 3006 NotRPMBased: 8985 C6E042 3007 lda feature4_f 8988 A580 3008 bit #KpaDotSetb 898A 2715 3009 beq tps_doty 3010 3011 ; Now the amount based on MAPdot 898C 45E0B4 3012 ldhx #MAPdotrate_f 898F 3594 3013 sthx tmp1 8991 6E0396 3014 mov #$03,tmp3 8994 B6CB 3015 lda kpa ; If not store KPa into last_tps 8996 B0D1 3016 sub TPSlast ; 8998 B797 3017 sta tmp4 ; TPSDOT 899A B79D 3018 sta tmp10 ; Save away for later use below 899C CDCF9B 3019 jsr tableLookup 899F 2013 3020 bra miss_tps ; Jump past the tps checks 3021 3022 ; Now the amount based on TPSdot 3023 tps_doty: 89A1 45E0B0 3024 ldhx #TPSdotrate 89A4 3594 3025 sthx tmp1 89A6 6E0396 3026 mov #$03,tmp3 89A9 B647 3027 lda tps 89AB B0D1 3028 sub TPSlast msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 35 MC68HC908GP32 User Bootloader 89AD B797 3029 sta tmp4 ; TPSdot 89AF B79D 3030 sta tmp10 ; Save away for later use below 89B1 CDCF9B 3031 jsr tableLookup 3032 miss_tps: 89B4 8C 3033 clrh 89B5 BE98 3034 ldx tmp5 3035 89B7 C6E042 3036 lda feature4_f 89BA A580 3037 bit #KpaDotSetb 89BC 270B 3038 beq TPS_Accel_AE 3039 89BE D6E0B8 3040 lda MAPAQ_f,x ;MAP Based DOT 89C1 B797 3041 sta liY2 89C3 5A 3042 decx 89C4 D6E0B8 3043 lda MAPAQ_f,x 89C7 2009 3044 bra Carry_On_TEA 3045 3046 TPS_Accel_AE: 89C9 D6E0BC 3047 lda TPSAQ_f1,x ; TPS Based dot 89CC B797 3048 sta liY2 89CE 5A 3049 decx 89CF D6E0BC 3050 lda TPSAQ_f1,x 3051 3052 Carry_On_TEA: 89D2 B796 3053 sta liY1 89D4 4E9D98 3054 mov tmp10,liX 89D7 CDCFB8 3055 jsr LinInterp 3056 3057 ; Apply the cold multiplier 89DA 4E999E 3058 mov tmp6,tmp11 89DD 3F9F 3059 clr tmp12 89DF B6A1 3060 lda tmp14 89E1 CDD00A 3061 jsr uMulAndDiv 89E4 B69E 3062 lda tmp11 89E6 BBA0 3063 add tmp13 ; Add on the amount computed in 3064 ; cold temperature enrich above 89E8 B799 3065 sta tmp6 89EA B14F 3066 cmp TPSACCEL 89EC 2268 3067 bhi Higher_Accel 3068 3069 ; Check if acceleration done 3070 TAE_CHK_TIME: 89EE 0A426D 3071 brset TPSDEN,ENGINE,RST_ACCEL 89F1 B681 3072 lda TPSaclk 89F3 C1E0C2 3073 cmp TPSASYNC_f1 89F6 2466 3074 bhs RST_ACCEL 3075 3076 ; MAP or TPS rate stable now so have we selected to interpolate the 3077 ; accel enrichments? 89F8 C6E074 3078 lda feature8_f 89FB A540 3079 bit #InterpAcelb 89FD 2755 3080 beq TAE_DONEJMP 3081 3082 ; Decay the Accel enrichment away to a setpoint in the time period set - Phil 3083 89FF C6E0C6 3084 lda AccelDecay_f 8A02 B14F 3085 cmp TPSACCEL ; Only do interpolated Decay if 3086 ; Accel is higher than target point 8A04 244E 3087 bhs TAE_DONEJMP 8A06 B797 3088 sta liY2 ; Load in the Decay PW value in mS 3089 ; at the end of the timer 8A08 3F94 3090 clr lix1 ; Acceltimer Start point for 3091 ; linear interpolater. 8A0A C6E0C2 3092 lda TPSASYNC_f1 8A0D B795 3093 sta lix2 ; Stick the max time in lix2 for 3094 ; linear interpolater. 8A0F B688 3095 lda Decay_Accel 8A11 B796 3096 sta liY1 ; Load in the actual maximum PW we 3097 ; calculated fo the Accel to 3098 ; interpolate from 8A13 B681 3099 lda TPSaclk 8A15 B798 3100 sta lix ; Actual timer point 8A17 CDCFB8 3101 jsr lininterp ; Go and work out the value 8A1A B699 3102 lda tmp6 8A1C B7DD 3103 sta tmp31 ; Save true result for a moment 3104 8A1E C6E0C7 3105 lda feature9_f 8A21 A510 3106 bit #RpmAEBased ; If we are in rpm AE mode then check 8A23 272B 3107 beq NormAEMode ; rpm AE value as it may be lower than the 8A25 45E0A4 3108 ldhx #RPMbasedrate_f ; Decay value. 8A28 3594 3109 sthx tmp1 8A2A 6E0396 3110 mov #$03,tmp3 8A2D B64D 3111 lda rpm 8A2F B797 3112 sta tmp4 8A31 B79D 3113 sta tmp10 8A33 CDCF9B 3114 jsr tableLookup ; Find the rpm bins we are going to use 8A36 8C 3115 clrh 8A37 BE98 3116 ldx tmp5 8A39 D6E0A8 3117 lda RPMAQ_f2,x 8A3C B797 3118 sta liY2 8A3E 5A 3119 decx 8A3F D6E0A8 3120 lda RPMAQ_f2,x 8A42 B796 3121 sta liY1 8A44 4E9D98 3122 mov tmp10,liX 8A47 CDCFB8 3123 jsr LinInterp 8A4A B699 3124 lda tmp6 8A4C B1DD 3125 cmp tmp31 ; Is the RPM value lower than the 8A4E 2502 3126 blo StoreTPSACCEL ; AE value? tmp6 < tmp31 ? 3127 3128 NormAEMode: 8A50 B6DD 3129 lda tmp31 3130 3131 StoreTPSACCEL: 8A52 B74F 3132 sta TPSACCEL ; Save decaying accel value 3133 TAE_DONEJMP: 8A54 207F 3134 bra TAE_DONE 3135 3136 Higher_Accel: 8A56 B699 3137 lda tmp6 ; Replace with this higher value 8A58 B74F 3138 sta TPSACCEL 8A5A B788 3139 sta Decay_Accel ; Decaying Accel value 8A5C 2077 3140 bra TAE_DONE 3141 3142 RST_ACCEL: 8A5E 6E64D6 3143 mov #100T,TPSfuelCorr 8A61 3F4F 3144 clr TPSACCEL 8A63 3F88 3145 clr Decay_Accel 8A65 1942 3146 bclr TPSAEN,ENGINE 8A67 1B42 3147 bclr TPSDEN,ENGINE 8A69 086269 3148 brset REUSE_LED19,outputpins,TAE_DONE 8A6C 1302 3149 bclr aled,portc ; not in Neon 8A6E 2065 3150 bra TAE_DONE 3151 3152 ; deaccel 3153 TDE: 8A70 C6E05C 3154 lda feature6_f 8A73 A580 3155 bit #NoDecelBoostb ; Have we selected to use Decel 3156 ; all the time? 8A75 2707 3157 beq NormDecel 8A77 B6CB 3158 lda kpa 8A79 C1E081 3159 cmp DecelKpa_f 8A7C 2257 3160 bhi TAE_DONE ; If KPa above user defined amount 3161 ; then no decel enrichment 3162 3163 NormDecel: 8A7E B695 3164 lda tmp2 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 36 MC68HC908GP32 User Bootloader 8A80 B094 3165 sub tmp1 8A82 B7DD 3166 sta tmp31 8A84 C6E074 3167 lda feature8_f ; Are we in MAP or TPS mode for Decel? 8A87 A520 3168 bit #DecelMAPb 8A89 270C 3169 beq tps_Decell 8A8B B6DD 3170 lda tmp31 8A8D C1E05B 3171 cmp MAPthresh_f 8A90 2537 3172 blo TDE_CHK_DONE 8A92 09421E 3173 brclr TPSAEN,ENGINE,TDE_CHK_FUEL_CUT 8A95 200A 3174 bra Clear_Decel 3175 3176 tps_Decell: 8A97 B6DD 3177 lda tmp31 8A99 C1E0C1 3178 cmp TPSthresh_f1 8A9C 252B 3179 blo TDE_CHK_DONE 8A9E 094212 3180 brclr TPSAEN,ENGINE,TDE_CHK_FUEL_CUT 3181 3182 Clear_Decel: 8AA1 6E64D6 3183 mov #100T,TPSfuelCorr 8AA4 3F4F 3184 clr TPSACCEL 8AA6 3F88 3185 clr Decay_Accel 8AA8 1942 3186 bclr TPSAEN,ENGINE 8AAA 1B42 3187 bclr TPSDEN,ENGINE 8AAC 086226 3188 brset REUSE_LED19,outputpins,TAE_DONE 8AAF 1302 3189 bclr aled,portc ; not in Neon 8AB1 2022 3190 bra TAE_DONE 3191 3192 TDE_CHK_FUEL_CUT: 8AB3 B64D 3193 lda rpm 8AB5 A10F 3194 cmp #15T ; Only active above 1500 8AB7 251C 3195 blo TAE_DONE 8AB9 C6E0C3 3196 lda TPSDQ_f1 8ABC B7D6 3197 sta TPSfuelCorr 8ABE 1A42 3198 bset TPSDEN,ENGINE 8AC0 1942 3199 bclr TPSAEN,ENGINE 8AC2 086210 3200 brset REUSE_LED19,outputpins,TAE_DONE 8AC5 1302 3201 bclr aled,portc ; not in Neon 8AC7 200C 3202 bra TAE_DONE 3203 3204 TDE_CHK_DONE: 8AC9 0B4209 3205 brclr TPSDEN,ENGINE,TAE_DONE 8ACC 1B42 3206 bclr TPSDEN,ENGINE 8ACE 6E64D6 3207 mov #100T,TPSfuelCorr 8AD1 3F4F 3208 clr TPSACCEL 8AD3 3F88 3209 clr Decay_Accel 3210 3211 TAE_DONE: 3212 3213 *************************************************************************** 3214 ** 3215 ** Exhaust Gas Oxygen Sensor Measurement Section 3216 ** 3217 ** Steps are the following: 3218 ** 3219 ** If EGOdelta = 0 then skipo2 3220 ** If KPA > 100 then skipo2 3221 ** If RPM < ego_rpm then skipo2 3222 ** If TPSAEN in ENGINE or TPSDEN in ENGINE are set then skipo2 3223 ** If coolant < EGOtemp then skipo2 3224 ** If sech = 0 and secl < 30 seconds then skipo2 3225 ** (skip first 30 seconds) 3226 ** If TPS > 3.5 volts then skipo2 3227 ** 3228 ** If EGOcount > EGOcountcmp { 3229 ** EGOcount = 0 3230 ** If EGO > 26 (counts, or 0.5 Volts) then (rich) { 3231 ** tpm = EGOcurr - EGOdelta 3232 ** if tpm >= EGOlimit then EGOcorr = tpm 3233 ** return 3234 ** } 3235 ** else (lean) { 3236 ** tpm = EGOcorr + EGOdelta 3237 ** if tpm > EGOlimit then EGOcorr = tpm 3238 ** return 3239 ** } 3240 ** } 3241 ** 3242 ** skipo2: 3243 ** EGOcorr = 100% 3244 ** 3245 *************************************************************************** 3246 3247 EGO_CALC: 8AD5 C6E02E 3248 lda feature3_f 8AD8 A508 3249 bit #WaterInjb 8ADA 2703 3250 beq no_ego_w_chk 3251 ; brclr WaterInj,feature3,no_ego_w_chk 8ADC 0A002A 3252 brset water,porta,SKIP_ALL_O2 ; if water injection on 3253 ; skip both O2 checks 3254 no_ego_w_chk: 8ADF 026627 3255 brset NosSysOn,EnhancedBits,SKIP_ALL_O2; If NOS running then no 3256 ;O2 checks 8AE2 046624 3257 brset OverRun,EnhancedBits,SKIP_ALL_O2; Skip O2 if in Overrun mode 8AE5 C6E192 3258 lda EGOdelta_f ; No delta means open loop. 8AE8 271D 3259 beq SkipO2JMP 3260 8AEA C6E02E 3261 lda feature3_f 8AED A501 3262 bit #KPaTpsOpenb 8AEF 270B 3263 beq throttle_check 3264 ; brclr KPaTpsOpen,feature3,throttle_check ; 0 = throttle do 3265 ; throttle check 1 = KPa 8AF1 C6E040 3266 lda kpaO2_f ; In KPa mode so is it higher 3267 ; than setpoint? 8AF4 271C 3268 beq SETAFR_UP ; If its zero dont check it as 3269 ; no open loop 8AF6 B1CB 3270 cmp kpa 8AF8 250F 3271 blo SKIP_ALL_O2 ; If it is dont check O2 3272 No_KPA_Check: 8AFA 2016 3273 bra SETAFR_UP 3274 3275 throttle_check: 8AFC C6E041 3276 lda tpsO2_f ; Throttle position setpoint 3277 ; check for open loop 8AFF 2711 3278 beq SETAFR_UP ; If its zero dont check it 3279 ; as no open loop 8B01 B147 3280 cmp tps ; Load in TPS 8B03 2504 3281 blo SKIP_ALL_O2 8B05 200B 3282 bra SETAFR_UP 3283 3284 SkipO2JMP: 8B07 207B 3285 bra SKIPO2A 3286 3287 SKIP_ALL_O2: ; Skip both O2 checks 8B09 A664 3288 lda #100T 8B0B B74A 3289 sta EGOCorr 8B0D B75E 3290 sta EgoCorr2 8B0F CC8BD0 3291 jmp EGOALL_DONE 3292 3293 SETAFR_UP: 8B12 C6E02E 3294 lda feature3_f 8B15 A580 3295 bit #TargetAFRb 8B17 260A 3296 bne CheckVE1 3297 ; brset TargetAFR,feature3,CheckVE1 ; Target AFR? 3298 3299 Re_CheckTarg: 8B19 C6E05C 3300 lda feature6_f msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 37 MC68HC908GP32 User Bootloader 8B1C A502 3301 bit #TargetAFR3b 8B1E 2608 3302 bne CheckVE3 3303 ; brset TargetAFR3,feature6,CheckVE3 8B20 CC8B2B 3304 jmp SETAFRNORMAL 3305 3306 CheckVE1: 8B23 0C66F3 3307 brset useVE3,EnhancedBits,Re_CheckTarg; Are we are using VE3 3308 ; at present if so check 3309 ; if targets needed? 8B26 2008 3310 bra SETAFRTABLE 3311 3312 CheckVE3: 8B28 0C6605 3313 brset useVE3,EnhancedBits,SETAFRTABLE ; If were not running in 3314 ; VE3 then no targets 3315 3316 SETAFRNORMAL: ; Normal setting for AFR 8B2B C6E1BB 3317 lda O2targetV_f 8B2E B759 3318 sta afrTarget 3319 3320 SETAFRTABLE: ; AFR Table value is already in 3321 ; afrTarget 8B30 B649 3322 lda ego 8B32 B7DE 3323 sta tmp32 ; Make tmp32 = the ego raw adc 3324 ; in narrow band or non AFR target mode 3325 3326 AFTERAFRSET: 8B34 0842D2 3327 brset TPSAEN,ENGINE,Skip_ALL_O2 8B37 0A42CF 3328 brset TPSDEN,ENGINE,Skip_ALL_O2 8B3A 0067CC 3329 brset Traction,EnhancedBits2,Skip_ALL_O2 3330 8B3D B680 3331 lda sech 8B3F 2606 3332 bne chk_o2_lag ; if high seconds set then we 3333 ; can check o2 8B41 B640 3334 lda secl 8B43 A11E 3335 cmp #30T ; 30 seconds threshold 8B45 25C2 3336 blo Skip_ALL_O2 3337 3338 CHK_O2_LAG: 3339 ; Check if exceeded lag time - if so then we can modify EGOcorr 8B47 B682 3340 lda EGOcount 8B49 C1E191 3341 cmp EGOcountcmp_f 8B4C 2509 3342 blo EGOALL_DONEJMP 3343 ; Check if we are over the O2 operating temp 8B4E B6CC 3344 lda coolant 8B50 C1E190 3345 cmp EGOtemp_f 8B53 252F 3346 blo SkipO2A 8B55 2002 3347 bra Do_The_Ego 3348 3349 EGOALL_DONEJMP: 8B57 2077 3350 bra EGOALL_DONE 3351 3352 Do_The_Ego: 8B59 B64D 3353 lda rpm ; Over EGOrpm we go closed loop. 8B5B C1E1B9 3354 cmp EGOrpm_f 8B5E 2524 3355 blo SkipO2A 3356 3357 ; Check if rich/lean 8B60 3F82 3358 clr EGOcount 8B62 B6CB 3359 lda kpa ; See if we need to load in a 3360 ; new Ego Limit 8B64 C1E027 3361 cmp EgoLimitKPa_f 8B67 2207 3362 bhi New_EgoLim 8B69 C6E193 3363 lda EGOlimit_f ; Original Ego Limit 8B6C B7DD 3364 sta tmp31 8B6E 2005 3365 bra EgoLim_Done 3366 New_EgoLim: 8B70 C6E028 3367 lda EgoLim2_f ; New Ego Limit 8B73 B7DD 3368 sta tmp31 3369 EgoLim_Done: 3370 8B75 C6E1B8 3371 lda config13_f1 ; Check if Narrow-band (bit=0) 3372 ; or DIY-WB (bit=1) 8B78 A502 3373 bit #c13_o2 ; Use BIT instead of brset 3374 ; because outside of zero-page 8B7A 260A 3375 bne WBO2TYPE ; Branch if the bit is set 3376 NBO2TYPE: 8B7C B6DE 3377 lda tmp32 ; EGO 8B7E B159 3378 cmp afrTarget 8B80 2521 3379 blo O2_IS_LEAN 8B82 2008 3380 bra O2_IS_RICH 3381 3382 SkipO2A: ; Jmp for Skip O2 8B84 2034 3383 bra SkipO2 3384 3385 WBO2TYPE: 8B86 B6DE 3386 lda tmp32 8B88 B159 3387 cmp afrTarget 8B8A 2217 3388 bhi O2_IS_LEAN 3389 3390 ; rich o2 - lean out EGOcorr 3391 O2_IS_RICH: 8B8C A664 3392 lda #100T 8B8E B0DD 3393 sub tmp31 ; Generate the lower limit rail point 8B90 B795 3394 sta tmp2 8B92 B64A 3395 lda EGOcorr 8B94 C0E192 3396 sub EGOdelta_f ; remove the amount required per step. 8B97 B794 3397 sta tmp1 8B99 B195 3398 cmp tmp2 8B9B 2521 3399 blo EGO_DONE ; railed at EGOlimit value 8B9D B694 3400 lda tmp1 8B9F B74A 3401 sta EGOcorr 8BA1 201B 3402 bra EGO_DONE 3403 3404 ; lean o2 - richen EGOcorr 3405 O2_IS_LEAN: 8BA3 A664 3406 lda #100T 8BA5 BBDD 3407 add tmp31 ; Generate the upper limit rail point 8BA7 B795 3408 sta tmp2 3409 8BA9 B64A 3410 lda EGOcorr 8BAB CBE192 3411 add EGOdelta_f 8BAE B794 3412 sta tmp1 8BB0 B195 3413 cmp tmp2 8BB2 220A 3414 bhi EGO_DONE ; railed at EGOlimit value 8BB4 B694 3415 lda tmp1 8BB6 B74A 3416 sta EGOcorr 8BB8 2004 3417 bra EGO_DONE 3418 3419 ; reset EGOcorr to 100% 3420 SkipO2: 8BBA A664 3421 lda #100T 8BBC B74A 3422 sta EGOcorr 3423 EGO_DONE: 8BBE C6E021 3424 lda DTmode_f ; check if DT in use 8BC1 A510 3425 bit #alt_i2t2 8BC3 2707 3426 beq No_DT_SecondO2 8BC5 C6E2BF 3427 lda feature12_f2 8BC8 A501 3428 bit #SecondO2b 8BCA 2607 3429 bne DO_Second_Ego 3430 ; brset SecondO2,feature4,DO_Second_Ego ; Do we have a second 3431 ; O2 sensor? 3432 No_DT_SecondO2: 8BCC B64A 3433 lda Egocorr 8BCE B75E 3434 sta Egocorr2 3435 EGOALL_DONE: 8BD0 CC8C5F 3436 jmp EGO_2Done msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 38 MC68HC908GP32 User Bootloader 3437 3438 ;Second O2 Sensor runs from Page2 Enrichments 3439 3440 DO_Second_Ego: 8BD3 3F82 3441 clr EGOcount 3442 8BD5 B64D 3443 lda rpm ; Over EGOrpm we go closed loop. 8BD7 C1E2B9 3444 cmp EGOrpm_f2 8BDA 2568 3445 blo SkipO22 8BDC B6CC 3446 lda coolant 8BDE C1E290 3447 cmp EGOtemp_f2 8BE1 2561 3448 blo SkipO22 3449 8BE3 C6E02E 3450 lda feature3_f 8BE6 A580 3451 bit #TargetAFRb 8BE8 260A 3452 bne Check2VE1 3453 ; brset TargetAFR,feature3,Check2VE1 ; Target AFR? 3454 3455 Re_Check2Targ: 8BEA C6E05C 3456 lda feature6_f 8BED A502 3457 bit #TargetAFR3b 8BEF 2608 3458 bne Check2VE3 3459 ; brset TargetAFR3,feature6,Check2VE3 8BF1 CC8BFC 3460 jmp SETAFRNORMAL2 3461 3462 Check2VE1: 8BF4 0C66F3 3463 brset useVE3,EnhancedBits,Re_Check2Targ ; Are we are using 3464 ; VE3 at present if 3465 ; so check if targets 3466 ; needed? 8BF7 2008 3467 bra SETAFRTABLE2 3468 3469 Check2VE3: 8BF9 0C6605 3470 brset useVE3,EnhancedBits,SETAFRTABLE2 ; If were not running 3471 ; in VE3 then no 3472 ; targets 3473 3474 SETAFRNORMAL2: ; Normal setting for AFR 8BFC C6E2BB 3475 lda O2targetV_f2 8BFF B759 3476 sta afrTarget 3477 3478 SETAFRTABLE2: 8C01 B65A 3479 lda o2_fpadc 8C03 B7DE 3480 sta tmp32 3481 3482 AFTERAFRSET2: 8C05 B6CB 3483 lda kpa ; See if we need to load in a 3484 ; new Ego Limit 8C07 C1E027 3485 cmp EgoLimitKPa_f 8C0A 2207 3486 bhi EgoLim2_New 8C0C C6E293 3487 lda EGOlimit_f2 ; Original Ego Limit from page 2 8C0F B7DD 3488 sta tmp31 ; We can re-use this as its 3489 ; reset every time 8C11 2005 3490 bra EgoLim2_Done 3491 3492 EgoLim2_New: 8C13 C6E028 3493 lda EgoLim2_f ; New Ego Limit 8C16 B7DD 3494 sta tmp31 3495 3496 EgoLim2_Done: 3497 8C18 C6E2B8 3498 lda config13_f2 ; Check if Narrow-band (bit=0) 3499 ; or DIY-WB (bit=1) 8C1B A502 3500 bit #c13_o2 ; Use BIT instead of brset because 3501 ; outside of zero-page 8C1D 2608 3502 bne WBO2TYPE2 ; Branch if the bit is set 3503 NBO2TYPE2: 8C1F B6DE 3504 lda tmp32 ; ADC from Second O2 8C21 B159 3505 cmp afrTarget 8C23 2525 3506 blo O2_IS_LEANER 8C25 2006 3507 bra O2_IS_RICHER 3508 3509 WBO2TYPE2: 8C27 B6DE 3510 lda tmp32 8C29 B159 3511 cmp afrTarget 8C2B 221D 3512 bhi O2_IS_LEANER 3513 3514 ; rich o2 - lean out EGOcorr2 3515 O2_IS_RICHER: 8C2D A664 3516 lda #100T 8C2F B0DD 3517 sub tmp31 ; Generate the lower limit rail point 8C31 B795 3518 sta tmp2 8C33 B65E 3519 lda EgoCorr2 8C35 C0E292 3520 sub EGOdelta_f2 8C38 B794 3521 sta tmp1 8C3A B195 3522 cmp tmp2 8C3C 2521 3523 blo EGO_2Done ; railed at EGOlimit value 8C3E B694 3524 lda tmp1 8C40 B75E 3525 sta EgoCorr2 3526 EGO_2DoneJMP: 8C42 201B 3527 bra EGO_2Done 3528 3529 SkipO22: 8C44 A664 3530 lda #100T 8C46 B75E 3531 sta EgoCorr2 8C48 2015 3532 bra EGO_2Done 3533 3534 ; lean o2 - richen EGOcorr2 3535 O2_IS_LEANER: 8C4A A664 3536 lda #100T 8C4C BBDD 3537 add tmp31 ; Generate the upper limit rail point 8C4E B795 3538 sta tmp2 8C50 B65E 3539 lda EgoCorr2 8C52 CBE292 3540 add EGOdelta_f2 8C55 B794 3541 sta tmp1 8C57 B195 3542 cmp tmp2 8C59 2204 3543 bhi EGO_2Done ; railed at EGOlimit value 8C5B B694 3544 lda tmp1 8C5D B75E 3545 sta EgoCorr2 3546 EGO_2Done: 3547 3548 *************************************************************************** 3549 *************************************************************************** 3550 *************************************************************************** 3551 ** 3552 ** Computation of Fuel Parameters 3553 ** 3554 ** Remainders are maintained for hi-resolution calculations - results 3555 ** converted back to 100 microsecond resolution at end. 3556 ** 3557 ** (Warm * Tpsfuelcut)/100 = R1 + rem1/100 3558 ** (Barcor * Aircor)/100 = R2 + rem2/100 3559 ** ((R1 + rem1/100) * (R2 + rem2/100)) / 100 = R3 + rem3/100 3560 ** (EGO * MAP)/100 = R4 + rem4/100 3561 ** ((R3 + rem3/100) * (R4 + rem4/100)) /100 = R5 + rem5/100 3562 ** (VE * REQ_FUEL)/100 = R6 + rem6/100 3563 ** ((R5 + rem5/100) * (R6 + rem6/100)) = R7 3564 ** 3565 ** 3566 ** 3567 ** Note: that GAMMAE only includes Warm, Tpsfuelcut, Barocor, and Aircor 3568 ** (EGO no longer included) 3569 ** 3570 ** Rationle on ordering: to prevent calculation overflow for boosted 3571 ** operations, the variables have been ordered in specific "pairs" in 3572 ** the calculation: msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 39 MC68HC908GP32 User Bootloader 3573 ** EGO * MAP - when at WOT, EGO is set to 100%, 3574 ** so MAP can run up to 255% without overflow 3575 ** VE * REQ_FUEL - for boosted applications, 3576 ** REQ_FUEL tends to be low (below 10 ms) due to the added fuel 3577 ** requirements (i.e. large injectors), so VE entries can be well 3578 ** above 100%. 3579 ** 3580 *************************************************************************** 3581 3582 3583 3584 WARMACCEL_COMP: 3585 8C5F 4E4C9D 3586 mov warmcor,tmp10 ; Warmup Correction in tmp10 8C62 3F9E 3587 clr tmp11 ; tmp11 is zero 8C64 4ED69F 3588 mov TPSfuelcorr,tmp12 ; tpsfuelcut in tmp12 8C67 3FA0 3589 clr tmp13 ; tmp13 is zero 8C69 CDD170 3590 jsr Supernorm ; do the multiply and normalization 8C6C 4E9DDD 3591 mov tmp10,tmp31 ; save whole result in tmp31 8C6F 4E9EDE 3592 mov tmp11,tmp32 ; save remainder in tmp32 3593 8C72 4E509D 3594 mov barocor,tmp10 ; tmp10 is barometer percent 8C75 3F9E 3595 clr tmp11 ; zero to tmp11 8C77 4E4B9F 3596 mov AirCor,tmp12 ; air temp correction % in tmp12 8C7A 3FA0 3597 clr tmp13 ; tmp13 is zero 8C7C CDD170 3598 jsr Supernorm ; multiply and divide by 100 3599 ; result in tmp10:tmp11 8C7F 4EDD9F 3600 mov tmp31,tmp12 ; move saved tmp31 into tmp12 8C82 4EDEA0 3601 mov tmp32,tmp13 ; move saved tmp32 into tmp13 8C85 CDD170 3602 jsr Supernorm ; multiply/divide 8C88 4E9D98 3603 mov tmp10,tmp5 ; save whole result into tmp5 8C8B 4E9E99 3604 mov tmp11,tmp6 ; save remainder into tmp6 3605 8C8E C6E021 3606 lda DTmode_f ; Must check the INJ1 GammaE bit, 8C91 A520 3607 bit #alt_i1ge ; if 0 then set it to 100T to 3608 ; remove GammaE. 8C93 2605 3609 bne ld_ve_1 8C95 6E6451 3610 mov #100T,GammaE 8C98 2003 3611 bra ld_ve_1Done 3612 ld_ve_1: 8C9A 4E9D51 3613 mov tmp10,GammaE 3614 ld_ve_1Done: 3615 8C9D 4E4A9D 3616 mov EGOcorr,tmp10 ; closed-loop correction percent 3617 ; into tmp10 8CA0 3F9E 3618 clr tmp11 ; remainder is zero 3619 8CA2 0A6310 3620 brset hybridAlphaN,feature1,skip_loadcontcomp ; if hybrid then 3621 ; skip AN bypass 3622 8CA5 C6E1B8 3623 lda config13_f1 3624 3625 LoadContribcomp: 8CA8 A504 3626 bit #c13_cs 8CAA 2702 3627 beq MAFCheck ; No Alpha but are we using MAF? 8CAC 2049 3628 bra LoadContribDone 3629 3630 MAFCheck: 8CAE C6E0C7 3631 lda feature9_f 8CB1 A520 3632 bit #MassAirFlwb 8CB3 2700 3633 beq skip_loadcontcomp ; Are we using a MAF on pin X7? 3634 3635 skip_loadcontcomp: 8CB5 4ECB9F 3636 mov kpa,tmp12 ; MAP into tmp12 8CB8 3FA0 3637 clr tmp13 ; no remainder 8CBA CDD170 3638 jsr Supernorm ; do the multiply and divide 3639 8CBD C6E1B6 3640 lda config11_f1 8CC0 A501 3641 bit #$01 ; Are we using Turbo Map sensor? 8CC2 2733 3642 beq LoadContribDone 3643 3644 ; Are we using non 3645 ; standard MAP sensor? 8CC4 C6E074 3646 lda feature8_f 8CC7 A501 3647 bit #KPa300b 8CC9 272C 3648 beq LoadContribDone 3649 3650 ; If we get here we are using non-standard map sensor 3651 ; so do kpa * compensation factor to work out larger kpa 3652 ; value then add it back to the normal kpa cals later 3653 8CCB 8C 3654 clrh 8CCC B69D 3655 lda tmp10 8CCE B7DD 3656 sta tmp31 8CD0 B69E 3657 lda tmp11 8CD2 B7DE 3658 sta tmp32 3659 8CD4 B698 3660 lda tmp5 ; Load the result from above 8CD6 B79D 3661 sta tmp10 8CD8 3F9E 3662 clr tmp11 8CDA C6E0AF 3663 lda KPaCorr300_f ; Multiply by differential factor 8CDD B79F 3664 sta tmp12 8CDF 3FA0 3665 clr tmp13 8CE1 CDD170 3666 jsr Supernorm 8CE4 98 3667 clc 8CE5 B69D 3668 lda tmp10 8CE7 BB98 3669 add tmp5 8CE9 2402 3670 bcc Store_Mod_KPa1 8CEB A6FF 3671 lda #255T ; Limit 3672 Store_Mod_KPa1: 8CED B798 3673 sta tmp5 8CEF B6DD 3674 lda tmp31 8CF1 B79D 3675 sta tmp10 8CF3 B6DE 3676 lda tmp32 8CF5 B79E 3677 sta tmp11 3678 3679 ; NORMAL KPA stuff now 3680 LoadContribDone: 3681 8CF7 4E989F 3682 mov tmp5,tmp12 ; take saved result in tmp5 and put into tmp12 8CFA 4E99A0 3683 mov tmp6,tmp13 ; tmp6 into tmp13 8CFD CDD170 3684 jsr Supernorm ; mult/div 8D00 4E9D96 3685 mov tmp10,tmp3 ; result (whole) save in tmp3 8D03 4E9E97 3686 mov tmp11,tmp4 ; remainder result save in tmp4 3687 8D06 4E529D 3688 mov vecurr,tmp10 ; VE into tmp10 8D09 3F9E 3689 clr tmp11 ; no remainder value for VE 3690 8D0B C60106 3691 lda page 8D0E A101 3692 cmp #01T 8D10 2705 3693 beq rqfr1 8D12 C6E194 3694 lda REQ_FUEL_f1 8D15 2003 3695 bra rqfe1 3696 rqfr1: 8D17 C601A3 3697 lda REQ_FUEL_r 3698 rqfe1: 8D1A B79F 3699 sta tmp12 ; req-fuel into tmp12 8D1C 3FA0 3700 clr tmp13 ; no remainder 8D1E CDD170 3701 jsr Supernorm ; mult/div 3702 8D21 4E969F 3703 mov tmp3,tmp12 ; take previous result and put in tmp12 8D24 4E97A0 3704 mov tmp4,tmp13 ; again for remainder 8D27 CDD170 3705 jsr Supernorm ; multiply/divide 8D2A 4E9D9E 3706 mov tmp10,tmp11 3707 3708 ; jsr BATT_CORR_CALC ; result in tmp6 <- f(Vbatt) msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 40 MC68HC908GP32 User Bootloader 3709 3710 3711 *************************************************************************** 3712 ** For V E T A B L E 1 and 3 3713 ** Calculation of Battery Voltage Correction for Injector Opening Time 3714 ** 3715 ** Leaves result in liY == tmp6. 3716 ** Mangles tmp1-tmp5. 3717 ** 3718 ** Injector open time is implemented as a linear function of 3719 ** battery voltage, from 7.2 volts (61 ADC counts) to 19.2 volts (164 counts), 3720 ** with 13.2 volts (113 counts) being the nominal operating voltage 3721 ** 3722 ** INJOPEN = injector open time at 13.2 volts in mms 3723 ** BATTFAC = injector open adjustment factor 6 volts from 13.2V in mms 3724 ** 3725 ** 3726 ** + (INJOPEN + BATTFAC) 3727 ** + * 3728 ** + (INJOPEN) 3729 ** + * 3730 ** + (INJOPEN - BATTFAC) 3731 ** + * 3732 ** + 3733 ** ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3734 ** 7.2v 13.2v 19.2v 3735 ** 3736 *************************************************************************** 3737 3738 BATT_CORR_CALC: 8D2D 8C 3739 clrh 3740 BATT_CORR_PW: 8D2E 6E3D94 3741 mov #061T,liX1 ; x1 8D31 6EA495 3742 mov #164T,liX2 ; x2 8D34 C6E197 3743 lda InjOpen_f1 8D37 CBE19B 3744 add battfac_f1 8D3A B796 3745 sta liY1 ; y1 8D3C C6E197 3746 lda injopen_f1 8D3F C0E19B 3747 sub battfac_f1 8D42 B797 3748 sta liY2 ; y2 8D44 2A02 3749 bpl MBFF ; y2 < 0, underflow 8D46 3F97 3750 clr liY2 ; Screws up slope, but gives 3751 ; reasonable result. 3752 MBFF: 8D48 4E4898 3753 mov batt,liX ; xInterp 8D4B CDCFB8 3754 jsr LinInterp ; injector open time in tmp6 3755 3756 ; jsr CALC_FINAL ; result saved in: 3757 ; tmp20 <- tmp6+tmp11+ae+oc 3758 3759 3760 3761 *************************************************************************** 3762 ** F O R V E T A B L E 1 and 3 3763 ** Calculation of Final Pulse Width 3764 ** 3765 ** The following equation is evaluated here: 3766 ** 3767 ** tmp20 = tmp6 + TMP11 + TPSACCEL - INJOCFUEL 3768 ** 3769 ** Note that InjOCFuel (injected fuel during injector open and 3770 ** close) is currently a constant - eventually it will be a function 3771 ** of battery voltage. 3772 ** 3773 *************************************************************************** 3774 CALC_FINAL: 3775 8D4E B69E 3776 lda tmp11 ; From required fuel, above. 8D50 270C 3777 beq PW_Done ; If no calculated pulse, then 3778 ; don't open at all. 8D52 BB99 3779 add tmp6 ; from batt correction 8D54 2506 3780 bcs MaxPulse 8D56 BB4F 3781 add TPSACCEL 8D58 2502 3782 bcs MaxPulse 8D5A 2002 3783 bra PW_Done 3784 3785 MaxPulse: 8D5C A6FF 3786 lda #$FF 3787 PW_Done: 3788 8D5E B7A7 3789 sta tmp20 8D60 C6E04C 3790 lda feature5_f 8D63 A50C 3791 bit #stagedeither 8D65 2703 3792 beq Calc_Final1Done 8D67 CD9B5F 3793 jsr CALC_STAGED_PW ; Do the Staged PW calculations if set 3794 Calc_Final1Done: 3795 **************************************************************************** 3796 3797 8D6A 4EA794 3798 mov tmp20,tmp1 ; store PW from table 1 8D6D C6E021 3799 lda DTmode_f 8D70 A510 3800 bit #alt_i2t2 8D72 275E 3801 beq both_table1JMP ; if (inj2=t2) =0 then single table 3802 3803 ; calc 'PW2' from table 2 8D74 4EA7A9 3804 mov tmp20,tmp22 ; storage for PW1 whilst doing DT 8D77 1469 3805 bset page2,EnhancedBits4 ; set page2 8D79 CD9C72 3806 jsr VE2_LOOKUP ; calcs vecurr2 3807 3808 ; jsr CalcGammaE2 ; Results in tmp1 3809 ; No longer used Now do this below - PR 3810 ;*********** Dual Table CALCULATIONS*********************************** 3811 ; I think theres only need to do this bit as the rest would have been done in VE1? 3812 8D7C 4E4C9D 3813 mov warmcor,tmp10 ; Warmup Correction in tmp10 8D7F 3F9E 3814 clr tmp11 ; tmp11 is zero 8D81 4ED69F 3815 mov tpsfuelcorr,tmp12 ; tpsfuelcut in tmp12 8D84 3FA0 3816 clr tmp13 ; tmp13 is zero 8D86 CDD170 3817 jsr Supernorm ; do the multiply and normalization 8D89 4E9DDD 3818 mov tmp10,tmp31 ; save whole result in tmp31 8D8C 4E9EDE 3819 mov tmp11,tmp32 ; save remainder in tmp32 3820 8D8F 4E509D 3821 mov barocor,tmp10 ; tmp10 is barometer percent 8D92 3F9E 3822 clr tmp11 ; zero to tmp11 8D94 4E4B9F 3823 mov AirCor,tmp12 ; air temp correction % in tmp12 8D97 3FA0 3824 clr tmp13 ; tmp13 is zero 8D99 CDD170 3825 jsr Supernorm ; multiply and divide by 100 3826 3827 ; result in tmp10:tmp11 3828 8D9C 4EDD9F 3829 mov tmp31,tmp12 ; move saved tmp31 into tmp12 8D9F 4EDEA0 3830 mov tmp32,tmp13 ; move saved tmp32 into tmp13 8DA2 CDD170 3831 jsr Supernorm ; multiply/divide 8DA5 4E9D98 3832 mov tmp10,tmp5 ; save whole result into tmp5 8DA8 4E9E99 3833 mov tmp11,tmp6 ; save remainder into tmp6 3834 8DAB C6E021 3835 lda DTmode_f 8DAE A540 3836 bit #alt_i2ge 8DB0 2605 3837 bne ld_ve_2 ; Are we using gammae in Second PW? 8DB2 6E6451 3838 mov #100T,GammaE 8DB5 2003 3839 bra ld_ve2_Done 3840 3841 ld_ve_2: 8DB7 4E9D51 3842 mov tmp10,GammaE 3843 ld_ve2_Done: 8DBA 4E5E9D 3844 mov EGOcorr2,tmp10 ; closed-loop correction percent msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 41 MC68HC908GP32 User Bootloader 3845 ; into tmp10 8DBD 3F9E 3846 clr tmp11 ; remainder is zero 3847 8DBF 0A6313 3848 brset hybridAlphaN,feature1,skip_loadccomp2 ; if hybrid then 3849 ; skip AN bypass 3850 8DC2 C6E2B8 3851 lda config13_f2 8DC5 A504 3852 bit #c13_cs 8DC7 270C 3853 beq skip_loadccomp2 ; Ignore if not alpha-N 3854 8DC9 C6E0C7 3855 lda feature9_f ; Using Alhpa-n so 8DCC A508 3856 bit #BaroCorConstb ; are we adding the KPa factor? 8DCE 2747 3857 beq LoadContribDn2 3858 8DD0 2003 3859 bra skip_loadccomp2 3860 3861 both_table1JMP: 8DD2 CC8E98 3862 jmp both_table1 3863 3864 skip_loadccomp2: 3865 8DD5 4ECB9F 3866 mov kpa,tmp12 ; MAP into tmp12 8DD8 3FA0 3867 clr tmp13 ; no remainder 8DDA CDD170 3868 jsr Supernorm ; do the multiply and divide 3869 8DDD C6E1B6 3870 lda config11_f1 8DE0 A501 3871 bit #$01 ; Are we using Turbo Map sensor? 8DE2 2733 3872 beq LoadContribDn2 3873 3874 ; Are we using non 3875 ; standard MAP sensor? 8DE4 C6E074 3876 lda feature8_f 8DE7 A501 3877 bit #KPa300b 8DE9 272C 3878 beq LoadContribDn2 3879 3880 ; If we get here we are using non-standard map sensor 3881 ; so do kpa * compensation factor to work out larger kpa 3882 ; value then add it back to the normal kpa cals later 3883 8DEB 8C 3884 clrh 8DEC B69D 3885 lda tmp10 8DEE B7DD 3886 sta tmp31 8DF0 B69E 3887 lda tmp11 8DF2 B7DE 3888 sta tmp32 3889 8DF4 B698 3890 lda tmp5 ; Load the result from above 8DF6 B79D 3891 sta tmp10 8DF8 3F9E 3892 clr tmp11 8DFA C6E0AF 3893 lda KPaCorr300_f ; Multiply by differential factor 8DFD B79F 3894 sta tmp12 8DFF 3FA0 3895 clr tmp13 8E01 CDD170 3896 jsr Supernorm 8E04 98 3897 clc 8E05 B69D 3898 lda tmp10 8E07 BB98 3899 add tmp5 8E09 2402 3900 bcc Store_Mod_KPa2 8E0B A6FF 3901 lda #255T ; Limit 3902 Store_Mod_KPa2: 8E0D B798 3903 sta tmp5 8E0F B6DD 3904 lda tmp31 8E11 B79D 3905 sta tmp10 8E13 B6DE 3906 lda tmp32 8E15 B79E 3907 sta tmp11 3908 3909 ; NORMAL KPA stuff now 3910 LoadContribDn2: 8E17 4E989F 3911 mov tmp5,tmp12 ; take saved result in tmp5 and put into tmp12 8E1A 4E99A0 3912 mov tmp6,tmp13 ; tmp6 into tmp13 8E1D CDD170 3913 jsr Supernorm ; mult/div 8E20 4E9D96 3914 mov tmp10,tmp3 ; result (whole) save in tmp3 8E23 4E9E97 3915 mov tmp11,tmp4 ; remainder result save in tmp4 3916 8E26 4E549D 3917 mov vecurr2,tmp10 ; VE into tmp10 8E29 3F9E 3918 clr tmp11 ; no remainder value for VE 8E2B C60106 3919 lda page 8E2E A102 3920 cmp #02T 8E30 2705 3921 beq rqfr2 8E32 C6E294 3922 lda REQ_FUEL_f2 8E35 2003 3923 bra rqfe2 3924 rqfr2: 8E37 C601A3 3925 lda REQ_FUEL_r 3926 3927 rqfe2: 3928 8E3A B79F 3929 sta tmp12 ; req-fuel into tmp12 8E3C 3FA0 3930 clr tmp13 ; no remainder 8E3E CDD170 3931 jsr Supernorm ; mult/div 3932 8E41 4E969F 3933 mov tmp3,tmp12 ; take previous result and put in tmp12 8E44 4E97A0 3934 mov tmp4,tmp13 ; again for remainder 8E47 CDD170 3935 jsr Supernorm ; multiply/divide 3936 8E4A 4E9D9E 3937 mov tmp10,tmp11 3938 3939 End_DTCalcs: 3940 3941 ; jsr BATT_CORR_CALC ; result in tmp6 3942 8E4D 2000 3943 bra BATT_CORR_CALC2 3944 3945 3946 *************************************************************************** 3947 ** For V E T A B L E 2 3948 ** Calculation of Battery Voltage Correction for Injector Opening Time 3949 ** 3950 ** Leaves result in liY == tmp6. 3951 ** Mangles tmp1-tmp5. 3952 ** 3953 ** Injector open time is implemented as a linear function of 3954 ** battery voltage, from 7.2 volts (61 ADC counts) to 19.2 volts (164 counts), 3955 ** with 13.2 volts (113 counts) being the nominal operating voltage 3956 ** 3957 ** INJOPEN = injector open time at 13.2 volts in mms 3958 ** BATTFAC = injector open adjustment factor 6 volts from 13.2V in mms 3959 ** 3960 ** 3961 ** + (INJOPEN + BATTFAC) 3962 ** + * 3963 ** + (INJOPEN) 3964 ** + * 3965 ** + (INJOPEN - BATTFAC) 3966 ** + * 3967 ** + 3968 ** ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3969 ** 7.2v 13.2v 19.2v 3970 ** 3971 *************************************************************************** 3972 3973 BATT_CORR_CALC2: 8E4F 8C 3974 clrh 8E50 6E3D94 3975 mov #061T,liX1 ; x1 8E53 6EA495 3976 mov #164T,liX2 ; x2 8E56 C6E297 3977 lda injopen_f2 8E59 CBE29B 3978 add battfac_f2 8E5C B796 3979 sta liY1 ; y1 8E5E C6E297 3980 lda injopen_f2 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 42 MC68HC908GP32 User Bootloader 8E61 C0E29B 3981 sub battfac_f2 8E64 B797 3982 sta liY2 ; y2 8E66 2A02 3983 bpl MBFF2 ; y2 < 0, underflow 8E68 3F97 3984 clr liY2 ; Screws up slope, but gives 3985 ; reasonable result. 3986 MBFF2: 8E6A 4E4898 3987 mov batt,liX ; xInterp 8E6D CDCFB8 3988 jsr LinInterp ; injector open time in tmp6 3989 3990 ; jsr CALC_FINAL ; result saved in tmp21 3991 3992 *************************************************************************** 3993 ** F O R V E T A B L E 2 3994 ** Calculation of Final Pulse Width 3995 ** 3996 ** The following equation is evaluated here: 3997 ** 3998 ** tmp20 = tmp6 + TMP11 + TPSACCEL - INJOCFUEL 3999 ** 4000 ** Note that InjOCFuel (injected fuel during injector open and 4001 ** close) is currently a constant - eventually it will be a function 4002 ** of battery voltage. 4003 ** 4004 *************************************************************************** 4005 CALC_FINAL2: 4006 8E70 B69E 4007 lda tmp11 ; From required fuel, above. 8E72 270C 4008 beq PW2_Done ; If no calculated pulse, then 4009 ; don't open at all. 8E74 BB99 4010 add tmp6 ; from batt correction 8E76 2506 4011 bcs MaxPulse2 8E78 BB4F 4012 add TPSACCEL 8E7A 2502 4013 bcs MaxPulse2 8E7C 2002 4014 bra PW2_Done 4015 4016 MaxPulse2: 8E7E A6FF 4017 lda #$FF 4018 PW2_Done: 8E80 B7A8 4019 sta tmp21 ; PW2 temp 4020 4021 Calc_Final2Done: 4022 **************************************************************************** 4023 8E82 4EA994 4024 mov tmp22,tmp1 ; When DT done put PW1 back into tmp1 4025 4026 PW2_calc: 8E85 3F95 4027 clr tmp2 8E87 C6E021 4028 lda DTmode_f 8E8A A510 4029 bit #alt_i2t2 ; if inj2 is not driven from 4030 ; table1 then skip 8E8C 2605 4031 bne pw2_table2 8E8E 4EA795 4032 mov tmp20,tmp2 ; 'PW' from table 1 8E91 200B 4033 bra checkRPMsettings 4034 pw2_table2: 8E93 4EA895 4035 mov tmp21,tmp2 ; 'PW' from table 2 8E96 2006 4036 bra checkRPMsettings 4037 4038 both_table1: 8E98 B6A7 4039 lda tmp20 8E9A B794 4040 sta tmp1 8E9C B795 4041 sta tmp2 4042 4043 checkRPMsettings: 4044 ; Do all the rpm related stuff here. 4045 8E9E 03643C 4046 brclr ShiftLight,feature2,ShiftLightDone 8EA1 C6E074 4047 lda feature8_f ; if spark output E then no shift lights 8EA4 A508 4048 bit #spkeopb 8EA6 2635 4049 bne ShiftLightDone 4050 ; if rpm < shiftLo bclr p3_3, bclr p3_4 4051 ; shiftMd = (shiftLo+shiftHi)/2 4052 ; if rpm < shiftMd bset p3_3, bclr p3_4 4053 ; if rpm < shiftHi bclr p3_3, bset p3_4 4054 ; otherwise bset p3_3, bset p3_4 4055 ;if wheel decoder second input is enabled then lower limit only functions 4056 8EA8 C6E012 4057 lda shiftLo_f 8EAB B14D 4058 cmp rpm 8EAD 2309 4059 bls shiftLight1 8EAF 1702 4060 bclr 3,portc 8EB1 006329 4061 brset wd_2trig,feature1,shiftLightDone 8EB4 1902 4062 bclr 4,portc 8EB6 2025 4063 bra shiftLightDone 4064 shiftLight1: 8EB8 CBE013 4065 add shiftHi_f 8EBB 46 4066 rora 8EBC B14D 4067 cmp rpm 8EBE 2309 4068 bls shiftLight2 8EC0 1602 4069 bset 3,portc 8EC2 006318 4070 brset wd_2trig,feature1,shiftLightDone 8EC5 1902 4071 bclr 4,portc 8EC7 2014 4072 bra shiftLightDone 4073 shiftLight2: 8EC9 C6E013 4074 lda shiftHi_f 8ECC B14D 4075 cmp rpm 8ECE 2306 4076 bls shiftLight3 8ED0 1702 4077 bclr 3,portc 8ED2 1802 4078 bset 4,portc 8ED4 2007 4079 bra shiftLightDone 4080 shiftLight3: 8ED6 1602 4081 bset 3,portc 8ED8 006302 4082 brset wd_2trig,feature1,shiftLightDone 8EDB 1802 4083 bset 4,portc 4084 shiftLightDone: 4085 4086 ;Hard Cut Rev and Launch checks 8EDD 1B60 4087 bclr sparkCut,RevLimBits ; Reset spark cut bit 8EDF 05644A 4088 brclr LaunchControl,feature2,LaunchDone; Is Launch selected? 4089 ;Changes to launch system for 025y - JSM 8EE2 060331 4090 brset Launch,portd,Reset_VL ; Button not pressed so 4091 ; reset variable bit 8EE5 C60105 4092 lda VlaunchLimit 8EE8 A108 4093 cmp #08T ; If launch limit higher 8EEA 2232 4094 bhi chk_launch_lim ; than 800 then it has been set 4095 4096 ;if it is currently zero then we are arming the system. 4097 ;If in Vlaunch mode we grab current rpm and save that as the limit 4098 ;Else, if rpm > LC_flatsel then use flat shift limit 4099 ;else use fixed launch limit 8EEC C6E02E 4100 lda feature3_f 8EEF A502 4101 bit #VarLaunchb ; Is variable launch wanted, 8EF1 2704 4102 beq No_V_Launch_On ; if not go to fixed section 4103 8EF3 B64D 4104 lda rpm ; load rpm and set this as limit 8EF5 2022 4105 bra str_launch ; 4106 4107 No_V_Launch_On: 8EF7 B64D 4108 lda rpm ; higher or lower than launch/flat limit 8EF9 C1E07C 4109 cmp LC_flatsel_f 8EFC 250D 4110 blo set_launch ; lower, so launch 8EFE C6E0AD 4111 lda N2Odel_flat_f ; load flat shift delay 8F01 C7010C 4112 sta N2Olaunchdel ; store into launch/nitrous delay timer 8F04 1A5F 4113 bset lc_fs,SparkBits ; set flatshift mode on 8F06 C6E080 4114 lda LC_flatlim ; higher so use flat shift limit 8F09 200E 4115 bra str_launch 4116 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 43 MC68HC908GP32 User Bootloader 4117 set_launch: 8F0B C6E0AC 4118 lda N2Odel_launch_f ; load launch delay 8F0E C7010C 4119 sta N2Olaunchdel ; store into launch/nitrous delay timer 8F11 C6E014 4120 lda Launchlimit_f ; use launch limit 8F14 2003 4121 bra str_launch 4122 4123 Reset_VL: 8F16 4F 4124 clra 8F17 1B5F 4125 bclr lc_fs,SparkBits ; make sure flatshift mode off 4126 4127 str_launch: 8F19 C70105 4128 sta VlaunchLimit ; Reset Launch Limit var 8F1C 200E 4129 bra LaunchDone ; Not in Launch mode so 4130 4131 chk_Launch_lim: 8F1E B647 4132 lda tps ; Is throttle in right place? 8F20 C1E029 4133 cmp LC_Throttle_f 8F23 2507 4134 blo LaunchDone ; No then no LC 4135 8F25 C60105 4136 lda Vlaunchlimit ; load up limit 8F28 B14D 4137 cmp rpm 8F2A 2549 4138 blo Chk_Cuts ; We've hit the limiter... 4139 LaunchDone: 4140 4141 ; ***Over Boost Protection********************************** 8F2C C6E02C 4142 lda Over_B_P_f ; load in Over boost KPa value 8F2F A165 4143 cmp #101T 8F31 251D 4144 blo BoostP_Done ; If set to less than 100KPa 4145 ; then no boost protection 8F33 B1CB 4146 cmp kpa ; Is the kpa higher than the 4147 ; boost safety high limit? 8F35 2219 4148 bhi BoostP_Done 8F37 C6E04C 4149 lda feature5_f 8F3A A510 4150 bit #BoostCutb 8F3C 2709 4151 beq B_SparkFuel ; Spark Cut Mode? 4152 8F3E B6D8 4153 lda SparkCutCnt 8F40 C1E054 4154 cmp SparkCutBNum_f ; Have we sparked more than 4155 ; the user defined number? 8F43 2202 4156 bhi B_SparkFuel ; Yes so dont cut any more 4157 ; sparks 8F45 1A60 4158 bset sparkCut,RevLimBits ; No so cut next spark 4159 4160 B_SparkFuel: 8F47 C6E04C 4161 lda feature5_f 8F4A A520 4162 bit #BoostCut2b 8F4C 2640 4163 bne cutChannels 8F4E 204D 4164 bra checkRevsOk 4165 BoostP_Done: 4166 4167 ;implement fuel cut from rev limiter soft limiter 8F50 026009 4168 brset RevLimHSoft,RevLimBits,Chk_Rev_Cuts 4169 4170 ; Hard-cut rev limiter, done here during pulse 4171 ; calcs to avoid timing issues if we set pw and 4172 ; then reset it a few instructions later. I was 4173 ; seeing "ghost" pulses when this was the case. 4174 checkHighLimit: 8F53 C6E006 4175 lda revLimit_f 8F56 2745 4176 beq checkRevsOk ; Zero means no limit 8F58 B14D 4177 cmp rpm 8F5A 2441 4178 bhs checkRevsOk ; We have not hit any 4179 ; Rev limits 4180 4181 ; IF we get here we are in rev limit hard cut mode so check for 4182 ; fuel or and spark cut 4183 Chk_Rev_Cuts: 8F5C C6E02E 4184 lda feature3_f 8F5F A510 4185 bit #Fuel_SparkHardb ; Spark cut mode? 8F61 2709 4186 beq FuelCut_C 8F63 B6D8 4187 lda SparkCutCnt ; We are in spark cut only 4188 ; mode so how many sparks 4189 ; are we at? 8F65 C1E02D 4190 cmp SparkCutNum_f ; User defined spark number 8F68 2202 4191 bhi Fuelcut_C ; If spark count higher than 4192 ; number dont set spark cut bit 8F6A 1A60 4193 bset sparkCut,RevLimBits ; Set sparkcut bit 4194 4195 ; HARD REV LIMITER FUEL CUT 4196 Fuelcut_C: 8F6C C6E02E 4197 lda feature3_f 8F6F A520 4198 bit #FuelSparkCutb ; Are we cutting fuel? 8F71 261B 4199 bne cutChannels 8F73 2028 4200 bra checkRevsOk 4201 4202 ;If we get here we are in Launch control 4203 ;so check whether spark and or fuel cuts 4204 Chk_Cuts: 8F75 C6E04C 4205 lda feature5_f 8F78 A501 4206 bit #Fuel_SparkHLCb 8F7A 2709 4207 beq SparkFuel_LC ; Spark cut? 4208 8F7C B6D8 4209 lda SparkCutCnt ; We are in spark cut 4210 ; mode so how many sparks 4211 ; are we at? 8F7E C1E04D 4212 cmp SparkCutNLC_f ; User defined spark number 4213 ; for Launch 8F81 2202 4214 bhi SparkFuel_LC ; If spark count higher than 4215 ; number dont set spark cut bit 8F83 1A60 4216 bset sparkCut,RevLimBits ; Set sparkcut bit 4217 4218 SparkFuel_LC: 8F85 C6E04C 4219 lda feature5_f ; Launch fuel cut? 8F88 A502 4220 bit #FuelSparkLCb 8F8A 2602 4221 bne cutChannels 8F8C 200F 4222 bra checkRevsOk 4223 4224 cutChannels: 8F8E 3F94 4225 clr tmp1 8F90 3F95 4226 clr tmp2 8F92 1566 4227 bclr OverRun,EnhancedBits ; Reset Over Run Fuel Cut 8F94 4E946E 4228 mov tmp1,pwcalc1 8F97 4E956F 4229 mov tmp2,pwcalc2 8F9A CC902F 4230 jmp spark_lookup ; In fuel cut mode so return 4231 ; with zeros 4232 checkRevsOk: 8F9D 01670A 4233 brclr Traction,EnhancedBits2,No_Traction_On 8FA0 B6E3 4234 lda TCSparkCut 8FA2 2706 4235 beq No_Traction_On ; If zero then no spark cut 8FA4 B1D8 4236 cmp SparkCutCnt ; In traction mode do we 4237 ; cut sparks 8FA6 2302 4238 bls No_Traction_On 8FA8 1A60 4239 bset sparkCut,RevLimBits ; Set sparkcut bit 4240 4241 No_Traction_On: 8FAA 0466E1 4242 brset OverRun,EnhancedBits,cutChannels; If Over run fuel cut on 4243 ; cut fuel 4244 4245 ; Add in the NOS and Staged PW's here 8FAD C6E04C 4246 lda feature5_f 8FB0 A50C 4247 bit #stagedeither 8FB2 261B 4248 bne Add_to_PWCALC 4249 ; brset staged,feature5,Add_to_PWCALC ; If in Staged mode Add 4250 ; to PW1+2 4251 ; brset stagedMode,feature5,Add_to_PWCALC; If in Staged mode 4252 ; Add to PW1+2 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 44 MC68HC908GP32 User Bootloader 8FB4 0E6318 4253 brset Nitrous,feature1,Add_to_PWCALC; If NOS System selected 4254 ; add to PW1+2 4255 8FB7 02420C 4256 brset crank,engine,No_TCAccel 4257 8FBA B694 4258 lda tmp1 8FBC BBE1 4259 add TCAccel 8FBE B794 4260 sta tmp1 8FC0 B695 4261 lda tmp2 8FC2 BBE1 4262 add TCAccel ; Add in the traction 4263 ; control enrichments 8FC4 B795 4264 sta tmp2 4265 No_TCAccel: 8FC6 4E946E 4266 mov tmp1,pwcalc1 8FC9 4E956F 4267 mov tmp2,pwcalc2 8FCC CC902F 4268 jmp spark_lookup 4269 Add_to_PWCALC: 8FCF C6E021 4270 lda DTmode_f ; check if DT in use 8FD2 A510 4271 bit #alt_i2t2 8FD4 2707 4272 beq Do_Nos_PW1 ; i2t2=1 4273 8FD6 C6E042 4274 lda feature4_f 8FD9 A520 4275 bit #DtNosb 8FDB 2607 4276 bne Dont_Nos_PW1 4277 ; brset DtNos,feature4,Dont_Nos_PW1 4278 Do_Nos_PW1: 8FDD B694 4279 lda tmp1 8FDF CB010A 4280 add NosPW ; Add Nos PW to pw1 8FE2 B794 4281 sta tmp1 4282 Dont_Nos_PW1: 8FE4 076605 4283 brclr REStaging,EnhancedBits,No_Staging; Staging not running 4284 ; so dont add PW Staging 8FE7 C6010B 4285 lda pw_staged 8FEA B794 4286 sta tmp1 4287 No_Staging: ; Staging not running 8FEC C6E04C 4288 lda feature5_f 8FEF A50C 4289 bit #stagedeither 8FF1 2602 4290 bne Staging_2_PW 4291 ; brset staged,feature5,Staging_2_PW ; If in Staged mode Go to 4292 ; NOS PW2 4293 ; brset stagedMode,feature5,Staging_2_PW; If in Staged mode Go 4294 ; to NOS PW2 8FF3 200E 4295 bra Staging_Done_PW 4296 Staging_2_PW: 8FF5 076607 4297 brclr REStaging,EnhancedBits,No_PW2_Staging ; Staging Mode not 4298 ; running so no PW2 8FF8 C6010B 4299 lda pw_staged 8FFB B795 4300 sta tmp2 8FFD 2004 4301 bra Staging_Done_PW 4302 No_PW2_Staging: 8FFF A600 4303 lda #00T ; In Staging Mode but not 4304 ; running so PW2 = 0 9001 B795 4305 sta tmp2 4306 Staging_Done_PW: 9003 C6E021 4307 lda DTmode_f ; check if DT in use 9006 A510 4308 bit #alt_i2t2 9008 2707 4309 beq Nos_PWCal2 ; i2t2=1 900A C6E042 4310 lda feature4_f 900D A520 4311 bit #DtNosb 900F 2707 4312 beq Calc_PWs_DONE 4313 ; brclr DtNos,feature4,Calc_PWs_DONE ; In DT mode so do we add 4314 ; NosPW to PW2? 4315 Nos_PWCal2: 9011 B695 4316 lda tmp2 9013 CB010A 4317 add NosPW ; Add Nos PW to pwcalc2 9016 B795 4318 sta tmp2 4319 Calc_PWs_DONE: 9018 02420C 4320 brset crank,engine,No_TCAccel2 901B B694 4321 lda tmp1 901D BBE1 4322 add TCAccel 901F B794 4323 sta tmp1 9021 B695 4324 lda tmp2 9023 BBE1 4325 add TCAccel ; Add in the traction 4326 ; control enrichments 9025 B795 4327 sta tmp2 4328 No_TCAccel2: 9027 4E946E 4329 mov tmp1,pwcalc1 902A 4E956F 4330 mov tmp2,pwcalc2 902D 2000 4331 bra spark_lookup 4332 *************************************************************************** 4333 *some paging macros. (Were subroutines but consume yet more stack) 4334 *************************************************************************** 4335 ; NOTE! page stores which table is paged into RAM. 4336 4337 ; VE TABLE 1 902F 4338 $MACRO ve1x ; gets a VE byte from page1 or RAM. 4339 ; On entry X contains index. 4340 ; Returns byte in A 4341 lda page 4342 cmp #01T 4343 bne ve1xf 4344 lda VE_r,x 4345 bra ve1xc 4346 ve1xf: lda VE_f1,x 4347 ve1xc: 902F 4348 $MACROEND 4349 4350 ; VE TABLE 2 902F 4351 $MACRO ve2x ; gets a VE byte from page2 or RAM. 4352 ; On entry X contains index. 4353 ; Returns byte in A 4354 lda page 4355 cmp #02T 4356 bne ve2xf 4357 lda VE_r,x 4358 bra ve2xc 4359 ve2xf: lda VE_f2,x 4360 ve2xc: 902F 4361 $MACROEND 4362 4363 ; SPARK TABLE 1 902F 4364 $MACRO ve3x ; gets a ST byte from page3 or RAM. 4365 ; On entry X contains index. 4366 ; Returns byte in A 4367 lda page 4368 cmp #03T 4369 bne ve3xf 4370 lda VE_r,x 4371 bra ve3xc 4372 ve3xf: lda ST_f1,x 4373 ve3xc: 902F 4374 $MACROEND 4375 4376 ; SPARK TABLE 2 902F 4377 $MACRO ve4x ; gets a ST byte from page4 or RAM. 4378 ; On entry X contains index. 4379 ; Returns byte in A 4380 lda page 4381 cmp #04T 4382 bne ve4xf 4383 lda VE_r,x 4384 bra ve4xc 4385 ve4xf: lda ST_f2,x 4386 ve4xc: 902F 4387 $MACROEND 4388 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 45 MC68HC908GP32 User Bootloader 4389 ; VE TABLE 3 902F 4390 $MACRO ve5x ; gets a VE byte from page5 or RAM. 4391 ; On entry X contains index. 4392 ; Returns byte in A 4393 lda page 4394 cmp #05T 4395 bne ve5xf 4396 lda VE_r,x 4397 bra ve5xc 4398 ve5xf: lda VE_f3,x 4399 ve5xc: 902F 4400 $MACROEND 4401 4402 ; AFR TABLE 1 for VE1 902F 4403 $MACRO AFR1X ; gets an AFR byte from page6 or RAM. 4404 ; On entry X contains index. 4405 ; Returns byte in A 4406 lda page 4407 cmp #06T 4408 bne ve6xf 4409 lda VE_r,x 4410 bra ve6xc 4411 ve6xf: lda AFR_f1,x 4412 ve6xc: 902F 4413 $MACROEND 4414 4415 ; AFR TABLE 2 for VE3 902F 4416 $MACRO AFR2X ; gets an AFR byte from page7 or RAM. 4417 ; On entry X contains index. 4418 ; Returns byte in A 4419 lda page 4420 cmp #07T 4421 bne ve7xf 4422 lda VE_r,x 4423 bra ve7xc 4424 ve7xf: lda AFR_f2,x 4425 ve7xc: 902F 4426 $MACROEND 4427 4428 *************************************************************************** 4429 ** 4430 ** Check if fixed spark angle - only works if we are tuning this page 4431 ** 4432 *************************************************************************** 4433 spark_lookup: 902F C6E000 4434 lda personality_f ; Are we using a spark mode? 9032 270C 4435 beq No_Personality 4436 9034 C60106 4437 lda page 9037 A103 4438 cmp #3 9039 2608 4439 bne fixed_fl 903B C601B8 4440 lda FixedAngle_r 903E 2006 4441 bra fxr_c 4442 No_Personality: 9040 CC9321 4443 jmp CheckSoftLimit ; No spark Stuff set, so only fuel 4444 9043 C6E3A9 4445 fixed_fl: lda FixedAngle_f 4446 fxr_c: 9046 A103 4447 cmp #$03 9048 2503 4448 blo NOT_FIXED ; Added this as earlier MT didnt 4449 ; send a perfect 00T for -10 (use map) 4450 ;; sta SparkAngle ; else use this fixed advance 904A CC92C2 4451 jmp CALC_DELAY 4452 NOT_FIXED: 904D 0D600F 4453 brclr LaunchOn,RevLimBits,Not_LC_in 9050 0A5F06 4454 brset lc_fs,SparkBits,nf_flat 9053 C6E02A 4455 lda LC_LimAngle_f ; Launch Retard spark Angle 4456 ;; sta SparkAngle 9056 CC92C2 4457 jmp CALC_DELAY 4458 nf_flat: 9059 C6E08D 4459 lda LC_f_limangle_f 4460 ;; sta SparkAngle 905C CC92C2 4461 jmp CALC_DELAY 4462 Not_LC_in: 905F C6E3AE 4463 lda IdleAdvance_f 9062 A103 4464 cmp #$03 9064 2518 4465 blo use_spark_table 4466 ; check if set too high. Users loading old MSQ will have $FF in this byte 9066 A1F0 4467 cmp #$F0 9068 2214 4468 bhi use_spark_table 4469 ; if there's an idle advance set, see if we want to use it 906A B647 4470 lda tps 906C C1E3AF 4471 cmp IdleTPSThresh_f 906F 220D 4472 bhi use_spark_table 4473 ; ok, tps is where it needs to be, what about rpm? 9071 B64D 4474 lda rpm 9073 C1E3B0 4475 cmp IdleRPMThresh_f 9076 2206 4476 bhi use_spark_table 4477 ; ok, rpm is also where it should be, so use IdleAdvance_f 9078 C6E3AE 4478 lda IdleAdvance_f 4479 ;; sta SparkAngle 907B CC92C2 4480 jmp CALC_DELAY 4481 use_spark_table: 907E 016006 4482 brclr RevLimSoft,RevLimBits,STTABLELOOKUP 9081 C6E003 4483 lda SRevLimAngle ; Retard spark 4484 ;; sta SparkAngle 9084 CC92C2 4485 jmp CALC_DELAY 4486 *************************************************************************** 4487 ** 4488 ** ST 3-D Table Lookup 4489 ** 4490 ** This is used to determine value of SparkAngle ST based on RPM and MAP 4491 ** The table looks like: 4492 ** 4493 ** 105 +....+....+....+....+....+....+....+ 4494 ** .................................... 4495 ** 100 +....+....+....+....+....+....+....+ 4496 ** ... 4497 ** KPA ... 4498 ** ... 4499 ** 35 +....+....+....+....+....+....+....+ 4500 ** 5 15 25 35 45 55 65 75 RPM/100 4501 ** 4502 ** 4503 ** Steps: 4504 ** 1) Find the bracketing KPA positions via ORD_TABLE_FIND, 4505 ** put index in tmp8 and bounding values in tmp9(kpa1) and tmp10(kpa2) 4506 ** 2) Find the bracketing RPM positions via ORD_TABLE_FIND, store 4507 ** index in tmp11 and bounding values in tmp13(rpm1) and tmp14(rpm2) 4508 ** 3) Using the ST table, find the table ST values for tmp15=ST(kpa1,rpm1), 4509 ** tmp16=ST(kpa1,rpm2), tmp17 = ST(kpa2,rpm1), and tmp18 = ST(kpa2,rpm2) 4510 ** 4) Find the interpolated ST value at the lower KPA range : 4511 ** x1=rpm1, x2=rpm2, y1=ST(kpa1,rpm1), y2=ST(kpa1,rpm2) - put in tmp19 4512 ** 5) Find the interpolated ST value at the upper KPA range : 4513 ** x1=rpm1, x2=rpm2, y1=ST(kpa2,rpm1), y2=ST(kpa2,rpm2) - put in tmp11 4514 ** 6) Find the final ST value using the two interpolated ST values: 4515 ** x1=kpa1, x2=kpa2, y1=ST_FROM_STEP_4, y2=ST_FROM_STEP_5 4516 ** 4517 *************************************************************************** 4518 STTABLELOOKUP: 4519 4520 ; First, determine if in Speed-density or Alpha-N mode. If in Alpha-N 4521 ; mode, then replace the variable "kpa" with the contents of "tps". 4522 ; This will not break anything, since this check is performed again when 4523 ; multiplying MAP against the enrichments, and the SCI version of the 4524 ; variable is MAP, not kpa msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 46 MC68HC908GP32 User Bootloader 4525 9087 C6E1B8 4526 lda config13_f1 ; Check if in speed-density or 4527 ; Aplha-N mode 908A A504 4528 bit #$04 ; Use BIT instead of brset because 4529 ; outside of zero-page 908C 2706 4530 beq Kpa_n_Kpa ; Branch if the bit is clear 4531 908E B647 4532 lda tps 9090 B7DB 4533 sta kpa_n ; Added so as KPa can be used 4534 ; elsewhere in code 9092 200F 4535 bra ST_STEP_1 4536 Kpa_n_Kpa: 9094 C6E0C7 4537 lda feature9_f 9097 A520 4538 bit #MassAirFlwb 9099 2704 4539 beq ST1_SD ; Are we using a MAF on pin X7? 4540 909B B65A 4541 lda o2_fpadc ; Using MAF thats on pin X7 909D 2004 4542 bra ST_STEP_1 4543 ST1_SD: 909F B6CB 4544 lda kpa 90A1 B7DB 4545 sta kpa_n ; Added so as KPa can be used 4546 ; else where in code 4547 ST_STEP_1: 90A3 45E39C 4548 ldhx #KPARANGEST_f1 90A6 3594 4549 sthx tmp1 90A8 A60B 4550 lda #$0b ;(12-1) 90AA B796 4551 sta tmp3 90AC B6DB 4552 lda kpa_n 90AE B797 4553 sta tmp4 90B0 CDCF9B 4554 jsr ORD_TABLE_FIND 90B3 B694 4555 lda tmp1 90B5 B695 4556 lda tmp2 90B7 4E989B 4557 mov tmp5,tmp8 ;Index 90BA 4E949C 4558 mov tmp1,tmp9 ;X1 90BD 4E959D 4559 mov tmp2,tmp10 ;X2 4560 ST_STEP_2: 90C0 45E390 4561 ldhx #RPMRANGEST_f1 90C3 3594 4562 sthx tmp1 90C5 A60B 4563 lda #$0b ;(12-1) 90C7 B796 4564 sta tmp3 90C9 B64D 4565 lda rpm 90CB B797 4566 sta tmp4 90CD CDCF9B 4567 jsr ORD_TABLE_FIND 90D0 4E989E 4568 mov tmp5,tmp11 ;Index 90D3 4E94A0 4569 mov tmp1,tmp13 ;X1 90D6 4E95A1 4570 mov tmp2,tmp14 ;X2 4571 ST_STEP_3: 4572 ;TABLEWALK: 90D9 8C 4573 clrh 90DA A60C 4574 lda #$0c ;(12) 90DC 87 4575 psha 90DD 88 4576 pulx 90DE B69B 4577 lda tmp8 90E0 4A 4578 deca 90E1 42 4579 mul 90E2 BB9E 4580 add tmp11 90E4 4A 4581 deca 90E5 97 4582 tax 90E6 macro 4583 VE3X 90E6 C60106 4584 LDA PAGE 90E9 A103 4585 CMP #03T 90EB 2605 4586 BNE VE3XF 90ED D6010F 4587 LDA VE_R,X 90F0 2003 4588 BRA VE3XC 90F2 D6E300 4589 VE3XF: LDA ST_F1,X 4590 VE3XC: 90F5 B7A2 4591 sta tmp15 90F7 5C 4592 incx 90F8 macro 4593 VE3X 90F8 C60106 4594 LDA PAGE 90FB A103 4595 CMP #03T 90FD 2605 4596 BNE VE3XF 90FF D6010F 4597 LDA VE_R,X 9102 2003 4598 BRA VE3XC 9104 D6E300 4599 VE3XF: LDA ST_F1,X 4600 VE3XC: 9107 B7A3 4601 sta tmp16 9109 A60C 4602 lda #$0c ;(12) 910B 87 4603 psha 910C 88 4604 pulx 910D B69B 4605 lda tmp8 910F 42 4606 mul 9110 BB9E 4607 add tmp11 9112 4A 4608 deca 9113 97 4609 tax 9114 macro 4610 VE3X 9114 C60106 4611 LDA PAGE 9117 A103 4612 CMP #03T 9119 2605 4613 BNE VE3XF 911B D6010F 4614 LDA VE_R,X 911E 2003 4615 BRA VE3XC 9120 D6E300 4616 VE3XF: LDA ST_F1,X 4617 VE3XC: 9123 B7A4 4618 sta tmp17 9125 5C 4619 incx 9126 macro 4620 VE3X 9126 C60106 4621 LDA PAGE 9129 A103 4622 CMP #03T 912B 2605 4623 BNE VE3XF 912D D6010F 4624 LDA VE_R,X 9130 2003 4625 BRA VE3XC 9132 D6E300 4626 VE3XF: LDA ST_F1,X 4627 VE3XC: 9135 B7A5 4628 sta tmp18 9137 CC913A 4629 jmp ST_STEP_4 4630 4631 ST_STEP_4: 913A 4EA094 4632 mov tmp13,tmp1 913D 4EA195 4633 mov tmp14,tmp2 9140 4EA296 4634 mov tmp15,tmp3 9143 4EA397 4635 mov tmp16,tmp4 9146 4E4D98 4636 mov rpm,tmp5 9149 CDCFB8 4637 jsr lininterp 914C 4E99A6 4638 mov tmp6,tmp19 4639 4640 ST_STEP_5: 914F 4EA094 4641 mov tmp13,tmp1 9152 4EA195 4642 mov tmp14,tmp2 9155 4EA496 4643 mov tmp17,tmp3 9158 4EA597 4644 mov tmp18,tmp4 915B 4E4D98 4645 mov rpm,tmp5 915E CDCFB8 4646 jsr lininterp 9161 4E999E 4647 mov tmp6,tmp11 4648 4649 ST_STEP_6: 9164 4E9C94 4650 mov tmp9,tmp1 9167 4E9D95 4651 mov tmp10,tmp2 916A 4EA696 4652 mov tmp19,tmp3 916D 4E9E97 4653 mov tmp11,tmp4 9170 4EDB98 4654 mov kpa_n,tmp5 9173 B6DB 4655 lda kpa_n 9175 CDCFB8 4656 jsr lininterp 9178 B699 4657 lda tmp6 917A B7DD 4658 sta tmp31 ; Store the result away 4659 4660 ; Spark Table 2 Lookup msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 47 MC68HC908GP32 User Bootloader 4661 ST2_STEP_1: 917C C6E04C 4662 lda feature5_f 917F A580 4663 bit #SparkTable2b 9181 272A 4664 beq LookUp_Done 4665 ; brclr SparkTable2,feature5,LookUp_Done ; Are we using 4666 ; SparkTable2? 9183 0F6303 4667 brclr Nitrous,feature1,No_NOS_STable2 ; Are we using NOS? 9186 036624 4668 brclr NosSysOn,EnhancedBits,LookUp_Done ; NOS Mode not ready. 4669 No_NOS_STable2: 9189 B6DF 4670 lda ST2Timer ; Spark table 2 delay timer 918B 2620 4671 bne LookUp_Done ; If its not zero no ST2 918D 45E49C 4672 ldhx #KPARANGEST_f2 9190 3594 4673 sthx tmp1 9192 A60B 4674 lda #$0b ;(12-1) 9194 B796 4675 sta tmp3 9196 B6DB 4676 lda kpa_n 9198 B797 4677 sta tmp4 919A CDCF9B 4678 jsr ORD_TABLE_FIND 919D B694 4679 lda tmp1 919F B695 4680 lda tmp2 91A1 4E989B 4681 mov tmp5,tmp8 ;Index 91A4 4E949C 4682 mov tmp1,tmp9 ;X1 91A7 4E959D 4683 mov tmp2,tmp10 ;X2 91AA CC91B0 4684 jmp ST2_STEP_2 4685 4686 LookUp_Done: 91AD CC926B 4687 jmp LookUp_Finished 4688 4689 ST2_STEP_2: 91B0 45E490 4690 ldhx #RPMRANGEST_f2 91B3 3594 4691 sthx tmp1 91B5 A60B 4692 lda #$0b ;(12-1) 91B7 B796 4693 sta tmp3 91B9 B64D 4694 lda rpm 91BB B797 4695 sta tmp4 91BD CDCF9B 4696 jsr ORD_TABLE_FIND 91C0 4E989E 4697 mov tmp5,tmp11 ;Index 91C3 4E94A0 4698 mov tmp1,tmp13 ;X1 91C6 4E95A1 4699 mov tmp2,tmp14 ;X2 4700 ST2_STEP_3: 4701 ;TABLEWALK: 91C9 8C 4702 clrh 91CA A60C 4703 lda #$0c ;(12) 91CC 87 4704 psha 91CD 88 4705 pulx 91CE B69B 4706 lda tmp8 91D0 4A 4707 deca 91D1 42 4708 mul 91D2 BB9E 4709 add tmp11 91D4 4A 4710 deca 91D5 97 4711 tax 91D6 macro 4712 VE4X 91D6 C60106 4713 LDA PAGE 91D9 A104 4714 CMP #04T 91DB 2605 4715 BNE VE4XF 91DD D6010F 4716 LDA VE_R,X 91E0 2003 4717 BRA VE4XC 91E2 D6E400 4718 VE4XF: LDA ST_F2,X 4719 VE4XC: 91E5 B7A2 4720 sta tmp15 91E7 5C 4721 incx 91E8 macro 4722 VE4X 91E8 C60106 4723 LDA PAGE 91EB A104 4724 CMP #04T 91ED 2605 4725 BNE VE4XF 91EF D6010F 4726 LDA VE_R,X 91F2 2003 4727 BRA VE4XC 91F4 D6E400 4728 VE4XF: LDA ST_F2,X 4729 VE4XC: 91F7 B7A3 4730 sta tmp16 91F9 A60C 4731 lda #$0c ;(12) 91FB 87 4732 psha 91FC 88 4733 pulx 91FD B69B 4734 lda tmp8 91FF 42 4735 mul 9200 BB9E 4736 add tmp11 9202 4A 4737 deca 9203 97 4738 tax 9204 macro 4739 VE4X 9204 C60106 4740 LDA PAGE 9207 A104 4741 CMP #04T 9209 2605 4742 BNE VE4XF 920B D6010F 4743 LDA VE_R,X 920E 2003 4744 BRA VE4XC 9210 D6E400 4745 VE4XF: LDA ST_F2,X 4746 VE4XC: 9213 B7A4 4747 sta tmp17 9215 5C 4748 incx 9216 macro 4749 VE4X 9216 C60106 4750 LDA PAGE 9219 A104 4751 CMP #04T 921B 2605 4752 BNE VE4XF 921D D6010F 4753 LDA VE_R,X 9220 2003 4754 BRA VE4XC 9222 D6E400 4755 VE4XF: LDA ST_F2,X 4756 VE4XC: 9225 B7A5 4757 sta tmp18 9227 CC922A 4758 jmp ST2_STEP_4 4759 4760 ST2_STEP_4: 922A 4EA094 4761 mov tmp13,tmp1 922D 4EA195 4762 mov tmp14,tmp2 9230 4EA296 4763 mov tmp15,tmp3 9233 4EA397 4764 mov tmp16,tmp4 9236 4E4D98 4765 mov rpm,tmp5 9239 CDCFB8 4766 jsr lininterp 923C 4E99A6 4767 mov tmp6,tmp19 4768 4769 ST2_STEP_5: 923F 4EA094 4770 mov tmp13,tmp1 9242 4EA195 4771 mov tmp14,tmp2 9245 4EA496 4772 mov tmp17,tmp3 9248 4EA597 4773 mov tmp18,tmp4 924B 4E4D98 4774 mov rpm,tmp5 924E CDCFB8 4775 jsr lininterp 9251 4E999E 4776 mov tmp6,tmp11 4777 4778 ST2_STEP_6: 9254 4E9C94 4779 mov tmp9,tmp1 9257 4E9D95 4780 mov tmp10,tmp2 925A 4EA696 4781 mov tmp19,tmp3 925D 4E9E97 4782 mov tmp11,tmp4 9260 4EDB98 4783 mov kpa_n,tmp5 9263 B6DB 4784 lda kpa_n 9265 CDCFB8 4785 jsr lininterp ; Spark Table 2 result in tmp6 9268 030304 4786 brclr NosIn,portd,Not_ST1 ; If input low then use ST2 4787 4788 LookUp_Finished: 926B B6DD 4789 lda tmp31 ; Reload the look up angle for ST1 926D B799 4790 sta tmp6 4791 Not_ST1: 926F C60106 4792 lda page 9272 A103 4793 cmp #3 9274 2605 4794 bne trim_fl 9276 C601B9 4795 lda TrimAngle_r 9279 2003 4796 bra trim_c msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 48 MC68HC908GP32 User Bootloader 927B C6E3AA 4797 trim_fl: lda TrimAngle_f 927E 2A0A 4798 trim_c: bpl CHECK_SP_ADD ; check adding of trim 9280 BB99 4799 add tmp6 ; add lookup angle 9282 250E 4800 bcs TRIM_DONE ; if carry, all is done = high advance 9284 2A0C 4801 bpl TRIM_DONE ; if result is positive 9286 A600 4802 lda #$00 ; Negative trim over to high advance, 4803 ; clamp to 0 9288 2008 4804 bra TRIM_DONE 4805 4806 CHECK_SP_ADD: 928A BB99 4807 add tmp6 ; add lookup angle 928C 2404 4808 bcc TRIM_DONE ; Check if add over into low advance 928E 2B02 4809 bmi TRIM_DONE ; Check if result negative 9290 A6FF 4810 lda #$FF ; Clamp to maximum 4811 4812 TRIM_DONE: 9292 03420D 4813 brclr crank,engine,TRIM_DONE2 9295 0A6905 4814 brset nextcyl,EnhancedBits4,td_nc 9298 C6E3AB 4815 lda CrankAngle_f ; Update spark angle for User Interface 929B 2005 4816 bra TRIM_DONE2 4817 td_nc: 929D C6E3A8 4818 lda TriggAngle_f ; if next cyl cranking then use trigger angle 92A0 AB1C 4819 add #28T ; add on 10 deg offset 4820 4821 TRIM_DONE2: 4822 ; bmi store_spark ; Check if result negative 4823 ; (i.e. > 10ATDC) 4824 ; lda #0 ; Clamp to minimum (surely safer?) 4825 store_spark: 92A2 02421D 4826 brset crank,engine,store_spark2 ; if we are cranking skip 4827 ;to the save 4828 92A5 BB5C 4829 add CltIatAngle 92A7 CB0103 4830 add KnockAngleRet 92AA CB0109 4831 add NitrousAngle 92AD 98 4832 clc ; Clear carry bit ** 92AE BBE2 4833 add TCAngle 92B0 2402 4834 bcc Store_Spark_Ang ; Did we over flow with the 4835 ; traction angle? ** 92B2 A61C 4836 lda #28T ; Yes so limit angle to 0 deg ** 4837 Store_Spark_Ang: 92B4 0D600B 4838 brclr LaunchOn,RevLimBits,store_spark2 92B7 0A5F05 4839 brset lc_fs,SparkBits,nf_flat2 92BA C6E02A 4840 lda LC_LimAngle_f ; Launch Retard spark Angle 92BD 2003 4841 bra store_spark2 4842 nf_flat2: 92BF C6E08D 4843 lda LC_f_limangle_f 4844 4845 store_spark2: 4846 CALC_DELAY: 92C2 97 4847 tax ; take a copy in x, but don't save to SparkAngle yet 4848 92C3 08612C 4849 brset EDIS,personality,edis_calc 4850 92C6 0B691B 4851 brclr nextcyl,EnhancedBits4,this_cyl 92C9 A01C 4852 sub #28T ; subtract 10 deg offset 92CB 2505 4853 bcs next_cyl_rail ; just in case map has -ves in it. 92CD C1E3A8 4854 cmp TriggAngle_f 92D0 2208 4855 bhi next_cyl_calc ; if spark angle > trigger we're ok 4856 next_cyl_rail: 92D2 C6E3A8 4857 lda TriggAngle_f 92D5 AB1F 4858 add #31T ; add on 10deg offset + 1 degree safety margin 92D7 97 4859 tax ; save copy in x 92D8 A01C 4860 sub #28T ; remove that 10deg offset again 4861 ***************************************************************************** 4862 ** next Cyl mode works like this... 4863 ** DelayAngle = SparkAngle-Trigger 4864 ***************************************************************************** 4865 next_cyl_calc: 92DA BF58 4866 stx SparkAngle 92DC C0E3A8 4867 sub TriggAngle_f 4868 ;can't go negative because we checked just above 92DF C70107 4869 sta DelayAngle 92E2 203D 4870 bra CheckSoftLimit 4871 4872 this_cyl: 92E4 BF58 4873 stx SparkAngle 92E6 C6E3A8 4874 lda TriggAngle_f 92E9 B058 4875 sub SparkAngle 92EB AB1C 4876 add #28T 92ED C70107 4877 sta DelayAngle 92F0 202F 4878 bra CheckSoftLimit 4879 4880 edis_calc: 4881 ***************************************************************************** 4882 ** Delay angle not used, but code left as-is for simplicity 4883 ** now convert to SAW width. SAW = 1536 - (25.6 * adv) 4884 ** SparkAngle = adv / 45 * 128 by definition in MSS 4885 ** adv = SparkAngle * 45 / 128 re-arrange for adv 4886 ** (256 * 45 * SparkAngle) 4887 ** SAW = 1536 - (---------------------) 4888 ** (128 * 10 ) 4889 ** 4890 ** SAW (us) = 1536 - (SparkAngle * 9) 4891 ** BUT we will use baseline timing of 10ATDC so formula becomes 4892 ** SAW (us) = 1792 - (SparkAngle * 9) 4893 ** 4894 ** JSM - physical tests show some skewing, pulse is 2-3% longer and at 4895 ** least 15us too long 4896 ** make it 1777 ($6f1) 4897 ***************************************************************************** 4898 92F2 BF58 4899 stx SparkAngle 92F4 9F 4900 txa 92F5 AE09 4901 ldx #9 92F7 42 4902 mul ; stores result in x:a 92F8 BF94 4903 stx tmp1 ; save them 92FA B795 4904 sta tmp2 92FC 98 4905 clc 92FD A6F1 4906 lda #$f1 ; do 1792-... (1792 = $700) (1777 = $6f1) 92FF B295 4907 sbc tmp2 9301 B795 4908 sta tmp2 9303 A606 4909 lda #$6 9305 B294 4910 sbc tmp1 9307 B794 4911 sta tmp1 4912 ; if rpm < 1100 & multi-mode enabled 4913 ; brclr multispark,feature4,NOT_MULTI 9309 C6E042 4914 lda feature4_f ; this allow multi spark on/off 4915 ; while running 930C A508 4916 bit #multisparkb 930E 270D 4917 beq NOT_MULTI 9310 B64D 4918 lda rpm 9312 C1E015 4919 cmp edisms_f 9315 2406 4920 bhs NOT_MULTI 4921 ; add on 2048us (@8MHz) 4922 ; the initial 2048us command may correct the 2% error as the EDIS 4923 ; module uses it to 4924 ; calibrate its own timer 9317 B694 4925 lda tmp1 9319 AB08 4926 add #$08 931B B794 4927 sta tmp1 4928 NOT_MULTI: 931D 5594 4929 ldhx tmp1 931F 35F4 4930 sthx sawh ; save 16-bits in one instruction 4931 ; to avoid interruption 4932 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 49 MC68HC908GP32 User Bootloader 4933 *************************************************************************** 4934 ** 4935 ** Check rev limiters 4936 ** 4937 *************************************************************************** 4938 CheckSoftLimit: 9321 1D60 4939 bclr LaunchOn,RevLimBits ; Clear the Soft Launch 4940 ; Rev Limit bit 9323 056426 4941 brclr LaunchControl,feature2,Magnus_revlimiters; Is Launch 4942 ; selected? 9326 060323 4943 brset Launch,portd,Magnus_revlimiters ; Button not pressed 4944 ; so reset variable bit 9329 B647 4945 lda tps ; Is throttle in right place? 932B C1E029 4946 cmp LC_Throttle_f 932E 251C 4947 blo Magnus_revlimiters ; No then no LC 9330 0A5F05 4948 brset lc_fs,SparkBits,csl_flat 9333 C6E02B 4949 lda LC_Soft_Rpm_f ; Load in Launch soft limiter 9336 2003 4950 bra csl_comp 4951 csl_flat: 9338 C6E08C 4952 lda LC_f_slim_f 4953 csl_comp: 933B 270F 4954 beq Magnus_revlimiters ; If Zero no soft limit 933D B14D 4955 cmp rpm ; Is rpm higher than limit? 933F 220B 4956 bhi Magnus_revlimiters ; No so no soft limit 9341 B647 4957 lda tps ; Is tps higher than setting? 9343 C1E029 4958 cmp LC_Throttle_f 9346 2504 4959 blo Magnus_revlimiters ; No so no soft limit 9348 1C60 4960 bset LaunchOn,RevLimBits ; Set soft Launch bit on 934A 2022 4961 bra SRevLimOnDone ; Jump past rpm limit checks 4962 4963 Magnus_revlimiters: 934C C6E002 4964 lda SRevLimRPM 934F 271D 4965 beq SRevLimOnDone ; skip if zero 9351 B14D 4966 cmp rpm 9353 250B 4967 blo SRevLimOn ; rpm higher than limit 9355 2203 4968 bhi SRevLimOff ; rpm lower than limit 9357 006006 4969 brset RevLimSoft,RevLimBits,SRevLimOn ; at limit check 4970 ; current status 4971 SRevLimOff: 935A 1160 4972 bclr RevLimSoft,RevLimBits ; Clear soft limit bit 935C 1360 4973 bclr RevLimHSoft,RevLimBits ; Clear soft limit fuel cut bit 935E 200E 4974 bra SRevLimDone 4975 4976 SRevLimOn: 9360 1060 4977 bset RevLimSoft,RevLimBits ; Set soft limit bit 4978 ; lda SRevLimCTime ; Set Cool down period 4979 ; sta SRevLimCoolLeft 9362 B6C4 4980 lda SRevLimTimeLeft ; Check if time left = 4981 ; counting down 9364 2608 4982 bne SRevLimOnDone 9366 026005 4983 brset RevLimHSoft,RevLimBits,SRevLimOnDone ; Check if 4984 ; soft limit has cut fuel 9369 C6E004 4985 lda SRevLimHTime ; Set delay time for soft 4986 ; limit to cut fuel 936C B7C4 4987 sta SRevLimTimeLeft 4988 SRevLimOnDone: 4989 SRevLimDone: 4990 4991 *************************************************************************** 4992 ** 4993 ** Check outputs 4994 ** 4995 *************************************************************************** 4996 CheckOutputs: 936E 8C 4997 clrh 936F 006446 4998 brset BoostControl,feature2,Out1DoneJMP; If Boost control 4999 ; used then no output1 9372 C6E008 5000 lda Out1Source 9375 A11F 5001 cmp #31T 9377 2769 5002 beq TractOut1 9379 A105 5003 cmp #05T ; Are we using temperature? 937B 2706 5004 beq IAT1Source 937D A106 5005 cmp #06T 937F 2710 5006 beq CLT1Source 9381 2037 5007 bra Not_Temps1 5008 IAT1Source: 9383 C60108 5009 lda AirTemp 9386 B7DD 5010 sta tmp31 9388 C1E007 5011 cmp Out1Lim ; Check limit 938B 225A 5012 bhi Out1On ; Above limit, set output 938D 2777 5013 beq Out1Done ; Equal to limit skip out 938F 2039 5014 bra Hyster1 5015 CLT1Source: 9391 B6CC 5016 lda coolant 9393 B7DD 5017 sta tmp31 9395 C1E007 5018 cmp Out1Lim ; Check limit 9398 224D 5019 bhi Out1On ; Above limit, set output 939A 276A 5020 beq Out1Done ; Equal to limit skip out 939C 202C 5021 bra Hyster1 5022 5023 ADCX6_In1: ; ADC Input on X6 939E B65A 5024 lda o2_fpadc 93A0 B7DD 5025 sta tmp31 93A2 C1E007 5026 cmp Out1Lim 93A5 2240 5027 bhi Out1On 93A7 275D 5028 beq Out1Done 93A9 201F 5029 bra Hyster1 5030 5031 ADCX7_In1: ; ADC Input on X7 93AB B65B 5032 lda egtadc 93AD B7DD 5033 sta tmp31 93AF C1E007 5034 cmp Out1Lim 93B2 2233 5035 bhi Out1On 93B4 2750 5036 beq Out1Done 93B6 2012 5037 bra Hyster1 5038 5039 Out1DoneJMP: 93B8 204C 5040 bra Out1Done 5041 Not_Temps1: 93BA CEE008 5042 ldx Out1Source ; Get source 93BD 2747 5043 beq Out1Done ; No source = no check 93BF E640 5044 lda secl,x ; Get data 93C1 B7DD 5045 sta tmp31 93C3 C1E007 5046 cmp Out1Lim ; Check limit 93C6 221F 5047 bhi Out1On ; Above limit, set output 93C8 273C 5048 beq Out1Done ; Equal to limit skip out 5049 ; Hysterisis check 5050 Hyster1: 93CA 03670A 5051 brclr Output1On,Enhancedbits2,Out1Off ; Is output 1 off? 5052 ; If so carry on as normal 93CD C6E007 5053 lda Out1Lim 93D0 C0E07E 5054 sub Out1Hys_f ; Subtract Hysterisis for output1 5055 ; from Out1 limit 93D3 B1DD 5056 cmp tmp31 ; Actual value 93D5 232F 5057 bls Out1Done ; If actual value higher than 5058 ; Limit-Hysterisis then dont clear 5059 ; output 5060 5061 Out1Off: 93D7 1367 5062 bclr Output1On,Enhancedbits2 ; Turn the output bit check off 93D9 C6E042 5063 lda feature4_f 93DC A502 5064 bit #InvertOutOneb 93DE 2624 5065 bne out1_set 93E0 2015 5066 bra out1_clr ; Below limit, clear output 5067 5068 ;Added for traction bit set output msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 50 MC68HC908GP32 User Bootloader 5069 TractOut1: 93E2 006716 5070 brset Traction,EnhancedBits2,No_Upper_Lim1 ; If traction 5071 ; Running set output 93E5 20F0 5072 bra Out1Off 5073 5074 5075 Out1On: 93E7 C6E058 5076 lda Out1UpLim_f ; Upper limit. Creates a window 5077 ; for output to work in 93EA 270F 5078 beq No_Upper_Lim1 ; If zero no limit 93EC E140 5079 cmp secl,x 93EE 220B 5080 bhi No_Upper_Lim1 ; If higher than setpoint dont 5081 ; clear output 93F0 C6E042 5082 lda feature4_f 93F3 A502 5083 bit #InvertOutOneb 93F5 260D 5084 bne out1_set 5085 out1_clr: 93F7 1700 5086 bclr Output1,porta 93F9 200B 5087 bra Out1Done 5088 5089 No_Upper_Lim1: 93FB 1267 5090 bset Output1On,Enhancedbits2 ; Output on so set bit 93FD C6E042 5091 lda feature4_f 9400 A502 5092 bit #InvertOutOneb 9402 26F3 5093 bne out1_clr 5094 out1_set: 9404 1600 5095 bset Output1,porta ; Below limit, set output (Inverted) 5096 5097 Out1Done: 5098 9406 C6E00A 5099 lda Out2Source 5100 9409 A11F 5101 cmp #31T 940B 276D 5102 beq TractOut2 5103 940D A105 5104 cmp #05T ; Are we using temperature? 940F 2706 5105 beq IAT2Source 9411 A106 5106 cmp #06T 9413 2710 5107 beq CLT2Source 9415 2035 5108 bra Not_Temps2 5109 IAT2Source: 9417 C60108 5110 lda AirTemp 941A B7DD 5111 sta tmp31 941C C1E009 5112 cmp Out2Lim ; Check limit 941F 225E 5113 bhi Out2On ; Above limit, set output 9421 277B 5114 beq Out2Done ; Equal to limit skip out 9423 2037 5115 bra Hyster2 5116 CLT2Source: 9425 B6CC 5117 lda coolant 9427 B7DD 5118 sta tmp31 9429 C1E009 5119 cmp Out2Lim ; Check limit 942C 2251 5120 bhi Out2On ; Above limit, set output 942E 276E 5121 beq Out2Done ; Equal to limit skip out 9430 202A 5122 bra Hyster2 5123 5124 ADCX6_In2: ; ADC Input on X6 9432 B65A 5125 lda o2_fpadc 9434 B7DD 5126 sta tmp31 9436 C1E009 5127 cmp Out2Lim 9439 2244 5128 bhi Out2On 943B 2761 5129 beq Out2Done 943D 201D 5130 bra Hyster2 5131 5132 ADCX7_In2: 943F B65B 5133 lda egtadc 9441 B7DD 5134 sta tmp31 9443 C1E009 5135 cmp Out2Lim 9446 2237 5136 bhi Out2On 9448 2754 5137 beq Out2Done 944A 2010 5138 bra Hyster2 5139 5140 Not_Temps2: 944C CEE00A 5141 ldx Out2Source ; Get source 944F 274D 5142 beq Out2Done ; No source = no check 9451 E640 5143 lda secl,x ; Get data 9453 B7DD 5144 sta tmp31 9455 C1E009 5145 cmp Out2Lim ; Check limit 9458 2225 5146 bhi Out2On ; Above limit, set output 945A 2742 5147 beq Out2Done ; Equal to limit skip out 5148 ; Hysterisis check 5149 Hyster2: 945C 05670A 5150 brclr Output2On,Enhancedbits2,Out2Off ; Is output 1 off? 5151 ; If so carry on as normal 945F C6E009 5152 lda Out2Lim 9462 C0E07F 5153 sub Out2Hys_f ; Subtract Hysterisis for output1 5154 ; from Out1 limit 9465 B1DD 5155 cmp tmp31 ; Actual value 9467 2335 5156 bls Out2Done ; If actual value higher than 5157 ; Limit-Hysterisis then dont 5158 ; clear output 5159 5160 Out2Off: 9469 1567 5161 bclr Output2On,Enhancedbits2 ; Turn the output bit check off 946B C6E042 5162 lda feature4_f 946E A504 5163 bit #InvertOutTwob 9470 2604 5164 bne Inv_Out2 ; Are we inverting output2? 9472 1500 5165 bclr Output2,porta ; Below limit, clear output 9474 2028 5166 bra Out2Done 5167 Inv_Out2: 9476 1400 5168 bset Output2,porta ; Inverting output 9478 2024 5169 bra Out2Done 5170 5171 TractOut2: 947A 006716 5172 brset Traction,EnhancedBits2,No_Upper_Lim2 ; If traction 5173 ; Running set output 947D 20EA 5174 bra Out2Off 5175 5176 Out2On: 947F C6E059 5177 lda Out2UpLim_f ; Upper limit. Creates a window 5178 ; for output to work in 9482 270F 5179 beq No_Upper_Lim2 ; If zero no limit 9484 E140 5180 cmp secl,x 9486 220B 5181 bhi No_Upper_Lim2 ; If higher than setpoint dont 5182 ; clear output 9488 C6E042 5183 lda feature4_f 948B A504 5184 bit #InvertOutTwob 948D 260D 5185 bne out2_set 5186 out2_clr: 948F 1500 5187 bclr Output2,porta ; Inverting output 9491 200B 5188 bra Out2Done 5189 5190 No_Upper_Lim2: 9493 1467 5191 bset Output2On,Enhancedbits2 ; Output on so set bit 9495 C6E042 5192 lda feature4_f 9498 A504 5193 bit #InvertOutTwob 949A 26F3 5194 bne out2_clr 5195 out2_set: 949C 1400 5196 bset Output2,porta ; Below limit, set output (Inverted) 5197 Out2Done: 5198 5199 ******************************************************************************* 5200 ** OUTPUT 3 Port D 0 (pin 15 top of R14) with delay off timer 5201 ******************************************************************************* 5202 949E 086474 5203 brset out3sparkd,feature2,out3done 94A1 8C 5204 clrh msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 51 MC68HC908GP32 User Bootloader 94A2 C6E074 5205 lda feature8_f 94A5 A580 5206 bit #Out1_Out3b ; Are we in Out1+ mode? 94A7 2703 5207 beq Norm_Out3_check 94A9 07002F 5208 brclr Output1,porta,Out3Off ; If Output1 is off then 5209 ; don't do any checks for Out3 5210 5211 Norm_Out3_check: 94AC C6E084 5212 lda Out3Source_f 94AF A50F 5213 bit #$0f ; Only use 5 bits of this byte 94B1 2762 5214 beq Out3Done ; No source = no check 5215 ; cmp #01T 5216 ; beq Tract_Output3 ; If source = 1 then traction to 5217 ; activate output 94B3 A11F 5218 cmp #31T 94B5 274D 5219 beq Tract_Output3 ; If source = 31 then traction to 5220 ; activate output 94B7 A102 5221 cmp #02 94B9 274E 5222 beq DEC_Output3 ; If source = 2 then we are using 5223 ; decel to activate output 94BB A103 5224 cmp #03T 94BD 274F 5225 beq ACEL_Output3 ; If source = 3 then we are using 5226 ; accel to activate output 94BF A105 5227 cmp #05T ; Are we using temperature? 94C1 2725 5228 beq IAT3Source 94C3 A106 5229 cmp #06T 94C5 272D 5230 beq CLT3Source 94C7 A10A 5231 cmp #10T ; Are we looking at Out2? 94C9 2734 5232 beq Out2_Out3 94CB A120 5233 cmp #32T 94CD 2730 5234 beq Out2_Out3 94CF CEE084 5235 ldx Out3Source_f ; Get source 94D2 E640 5236 lda secl,x ; Get data 94D4 C1E085 5237 cmp Out3Lim_f ; Check limit 94D7 2238 5238 bhi Out3On ; Above limit, set output 94D9 273A 5239 beq Out3Done ; Equal to limit skip out 5240 Out3Off: 94DB C6E086 5241 lda TimerOut3_f ; What time delay is set? 94DE 2704 5242 beq No_Out3_Timer 94E0 B1E6 5243 cmp Out3Timer 94E2 2231 5244 bhi Out3Done 5245 5246 No_Out3_Timer: 94E4 1103 5247 bclr Output3,portd ; Below limit, clear output 94E6 202D 5248 bra Out3Done 5249 5250 IAT3Source: 94E8 C60108 5251 lda AirTemp 94EB C1E085 5252 cmp Out3Lim_f ; Check limit 94EE 2221 5253 bhi Out3On ; Above limit, set output 94F0 2723 5254 beq Out3Done ; Equal to limit skip out 94F2 20E7 5255 bra Out3Off 5256 CLT3Source: 94F4 B6CC 5257 lda coolant 94F6 C1E085 5258 cmp Out3Lim_f ; Check limit 94F9 2216 5259 bhi Out3On ; Above limit, set output 94FB 2718 5260 beq Out3Done ; Equal to limit skip out 94FD 20DC 5261 bra Out3Off 5262 5263 Out2_Out3: 94FF 0500D9 5264 brclr Output2,porta,Out3Off ; If Output2 on then turn 5265 ; output3 on 9502 200D 5266 bra Out3On 5267 5268 Tract_Output3: 9504 0167D4 5269 brclr Traction,EnhancedBits2,Out3Off ; If traction Running 5270 ; set output 9507 2008 5271 bra Out3On 5272 5273 DEC_Output3: 9509 0B42CF 5274 brclr TPSDEN,ENGINE,Out3Off ; If Decel output off 950C 2003 5275 bra Out3On 5276 5277 ACEL_Output3: 950E 0942CA 5278 brclr TPSAEN,ENGINE,Out3Off ; If Accel output off 5279 5280 Out3On: 9511 3FE6 5281 clr Out3Timer 9513 1003 5282 bset Output3,portd ; Set output 5283 5284 Out3Done: 5285 5286 5287 ***************************************************************************** 5288 ** OUTPUT 4 5289 ******************************************************************************* 5290 ; OUTPUT 4 LED 18 can be used as a standard output or as a fan control 5291 ; for those using WATER INJECTION on X2 5292 9515 046258 5293 brset REUSE_LED18,outputpins,Out4Done ; being used as IRQ 5294 ; or COIL C 9518 076255 5295 brclr REUSE_LED18_2,outputpins,Out4Done ; Are we re 5296 ; using LED18 as output4? 951B 0C6252 5297 brset LED18_FAN,outputpins,Out4Done ; Are we using it 5298 ;as fan control? 951E 8C 5299 clrh 951F C6E08A 5300 lda Out4Source_f 9522 A50F 5301 bit #$0f ; Only use 5 bits of this byte 9524 274A 5302 beq Out4Done ; No source = no check 5303 ; cmp #01T 5304 ; beq Tract_Output4 ; If source = 1 then traction to 5305 ; activate output 9526 A11F 5306 cmp #31T 9528 2737 5307 beq Tract_Output4 ; If source = 31 then traction to 5308 ; activate output 952A A102 5309 cmp #02T 952C 2738 5310 beq DEC_Output4 ; If source = 2 then we are using 5311 ; decel to activate output 952E A103 5312 cmp #03T 9530 2739 5313 beq ACEL_Output4 ; If source = 3 then we are using 5314 ; accel to activate output 9532 A105 5315 cmp #05T ; Are we using temperature? 9534 2714 5316 beq IAT4Source 9536 A106 5317 cmp #06T 9538 271C 5318 beq CLT4Source 953A CEE08A 5319 ldx Out4Source_f ; Get source 953D E640 5320 lda secl,x ; Get data 953F C1E08B 5321 cmp Out4Lim_f ; Check limit 9542 222A 5322 bhi Out4On ; Above limit, set output 9544 272A 5323 beq Out4Done ; Equal to limit skip out 5324 Out4Off: 9546 1502 5325 bclr wled,portc ; Below limit, clear output 9548 2026 5326 bra Out4Done 5327 5328 IAT4Source: 954A C60108 5329 lda AirTemp 954D C1E08B 5330 cmp Out4Lim_f ; Check limit 9550 221C 5331 bhi Out4On ; Above limit, set output 9552 271C 5332 beq Out4Done ; Equal to limit skip out 9554 20F0 5333 bra Out4Off 5334 CLT4Source: 9556 B6CC 5335 lda coolant 9558 C1E08B 5336 cmp Out4Lim_f ; Check limit 955B 2211 5337 bhi Out4On ; Above limit, set output 955D 2711 5338 beq Out4Done ; Equal to limit skip out 955F 20E5 5339 bra Out4Off 5340 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 52 MC68HC908GP32 User Bootloader 5341 Tract_Output4: 9561 0167E2 5342 brclr Traction,EnhancedBits2,Out4Off ; If traction Running 5343 ; set output 9564 2008 5344 bra Out4On 5345 5346 DEC_Output4: 9566 0B42DD 5347 brclr TPSDEN,ENGINE,Out4Off ; If Decel output off 9569 2003 5348 bra Out4On 5349 5350 ACEL_Output4: 956B 0942D8 5351 brclr TPSAEN,ENGINE,Out4Off ; If Accel output off 5352 5353 Out4On: 956E 1402 5354 bset wled,portc ; Set output 5355 5356 Out4Done: 5357 5358 *************************************************************************** 5359 ** 5360 ** Fan Control - added separate off-temp - from RPE 5361 ** Can use X2 and or LED18 5362 ** 5363 *************************************************************************** 9570 0A620B 5364 brset X2_FAN,outputpins,DO_FAN_Check ; Are we using X2 as fan 5365 ; control? 9573 046206 5366 brset REUSE_LED18,outputpins,fan_exit 9576 076203 5367 brclr REUSE_LED18_2,outputpins,fan_exit 9579 0C6202 5368 brset LED18_FAN,outputpins,DO_FAN_Check ; Are we using LED18 5369 ; as fan control? 5370 fan_exit: 957C 2027 5371 bra FAN_DONE ; Nope, so return 5372 5373 DO_FAN_Check: 957E 02420E 5374 brset crank,engine,FAN_OFF 9581 B6CC 5375 lda coolant 9583 C1E04A 5376 cmp EfanOnTemp_f 9586 2213 5377 bhi FAN_ON 9588 C1E04B 5378 cmp EfanOffTemp_f 958B 2502 5379 blo FAN_OFF 958D 2016 5380 bra FAN_DONE 5381 5382 FAN_OFF: 958F 0B6202 5383 brclr X2_FAN,outputpins,No_FAN_Porta ; Are we using X2? 9592 1B00 5384 bclr water,porta ; sharing X2 with water inj output 5385 No_FAN_Porta: 9594 0D620E 5386 brclr LED18_FAN,outputpins,FAN_DONE ; Are we using LED18? 9597 1502 5387 bclr wled,portc 9599 200A 5388 bra FAN_DONE 5389 FAN_ON: 959B 0B6202 5390 brclr X2_FAN,outputpins,No_FANOn_Porta ; Are we using X2? 959E 1A00 5391 bset water,porta ; sharing X2 with water inj output 5392 No_FANOn_Porta: 95A0 0D6202 5393 brclr LED18_FAN,outputpins,FAN_DONE ; Are we using LED18? 95A3 1402 5394 bset wled,portc 5395 5396 FAN_DONE: 5397 5398 5399 ******************************************************************************* 5400 ** 5401 ** Over run fuel cut system (P Ringwood) 5402 ** 5403 ******************************************************************************* 5404 Over_Run: 95A5 C6E042 5405 lda feature4_f 95A8 A540 5406 bit #OverRunOnb 95AA 2736 5407 beq Over_Run_Done 5408 5409 No_Over_Run: 95AC B6CB 5410 lda kpa 95AE C1E048 5411 cmp ORunKpa_f ; Is the KPa lower than the set point? 95B1 222B 5412 bhi No_OverRun ; No so no over run 95B3 B64D 5413 lda rpm 95B5 C1E047 5414 cmp ORunRpm_f ; Is the rpm higher than the setpoint? 95B8 2524 5415 blo No_OverRun ; No so no Over run 95BA B647 5416 lda tps 95BC C1E049 5417 cmp ORunTPS_f ; Is the TPS below the setpoint? 95BF 221D 5418 bhi No_OverRun ; No so no over run 95C1 B6CC 5419 lda coolant 95C3 C1E0C5 5420 cmp OverRunClt_f1 ; Is the coolant temp high enough? 95C6 2516 5421 blo No_OverRun 95C8 0A6706 5422 brset over_Run_Set,EnhancedBits2,No_OverRun_Reset 95CB 1A67 5423 bset over_Run_Set,EnhancedBits2 95CD A600 5424 lda #00T 95CF B7D7 5425 sta OverRunTime ; Reset the over run timer once 5426 ; per over run 5427 5428 No_OverRun_Reset: 95D1 B6D7 5429 lda OverRunTime 95D3 C1E082 5430 cmp OverRunT_f 95D6 2402 5431 bhs Do_OverRun 95D8 2006 5432 bra Over_Run_T 5433 5434 Do_OverRun: 95DA 1466 5435 bset OverRun,EnhancedBits ; Set Over Run Fuel Cut 95DC 2004 5436 bra Over_Run_Done 5437 No_OverRun: 95DE 1B67 5438 bclr over_Run_Set,EnhancedBits2 ; Clear the over run timer clear bit 5439 Over_Run_T: 95E0 1566 5440 bclr OverRun,EnhancedBits ; Clear the over run fuel cut 5441 5442 Over_Run_Done: 5443 5444 ***************************************************************************** 5445 ** Water Injection section 5446 ** 5447 ** Turn 1st water output (X2) on if MAP and RPM and IAT higher than 5448 ** Water set point 5449 ** 5450 ** Pulse water2 output (X3) at same rate as Fuel Injector #2. 5451 ** 5452 *************************************************************************** 95E2 C6E02E 5453 lda feature3_f 95E5 A508 5454 bit #WaterInjb 95E7 2728 5455 beq Water_Inj_Done 5456 5457 Water_Injection: ; we only get here if water 5458 ; inj is enabled 95E9 0A0008 5459 brset water,porta,ignore_iat;If water on then dont check 5460 ; IAT again 5461 95EC C6E03D 5462 lda iatpoint_f ; Load Inlet air temp setpoint 95EF C10108 5463 cmp airTemp ; Is it higher than actual iat? 95F2 221B 5464 bhi definatlyno_water 5465 5466 5467 ignore_iat: 95F4 C6E03E 5468 lda wateripoint_f ; Load water injection point 95F7 B1CB 5469 cmp kpa ; Is it lower than the actual kpa? 95F9 2509 5470 blo water_on ; If so turn water pump on 95FB 2012 5471 bra definatlyno_water ; If not then no water 5472 95FD B64D 5473 lda rpm 95FF C1E03F 5474 cmp wateriRpm_f ; Is the engine above the min rpm? 9602 250B 5475 blo definatlyno_water 5476 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 53 MC68HC908GP32 User Bootloader 5477 water_on: 9604 B64D 5478 lda rpm 9606 C1E03F 5479 cmp wateriRpm_f ; Are we actually above the rpm Minimum? 9609 2504 5480 blo definatlyno_water 960B 1A00 5481 bset water,porta ;Turn water pump on 960D 2002 5482 bra Water_Inj_Done 5483 5484 definatlyno_water: 5485 960F 1B00 5486 bclr water,porta ;Turn off water pump 5487 Water_Inj_Done: 5488 5489 ***************************************************************************** 5490 ** 5491 ** Coolant Related Ignition Advance (P Ringwood) 5492 ** Add Advance of 1 deg per user defined amount of coolant temp below setpoint 5493 ** 5494 ***************************************************************************** 5495 *************************************************************************** 5496 ** DeadBand: If we are within 5 degrees above of coolant setpoint then 5497 ** ensure we turn advance setting to zero. This is incase temp jumps up 5498 ** for some reason and leaves advance set. 5499 ** 5500 ** I have no idea if this could happen but I put it in just incase. 5501 ***************************************************************************** 9611 C6E02E 5502 lda feature3_f 9614 A504 5503 bit #CltIatIgnitionb 9616 274A 5504 beq retard_endJmp 5505 5506 IatClt_Related: 5507 9618 8C 5508 clrh 9619 C6E02F 5509 lda cltAdvance_f ; Load Coolant temperature setpoint 961C 2747 5510 beq Advance_end ; If zero no Advance 961E AB05 5511 add #05T ; Add 5 to the clt temp 9620 B1CC 5512 cmp coolant ; Are we within 5 degrees F of 5513 ; setpoint for clt advance? 9622 2541 5514 blo Advance_end ; 9624 B6CC 5515 lda coolant ; 9626 C1E02F 5516 cmp cltAdvance_f ; Is the clt under the setpoint? 9629 2507 5517 blo carryOn_Advance ; If so carry on with advance 962B A600 5518 lda #$00 962D B75C 5519 sta CltIatAngle ; If not then it's in dead band 5520 ; so clear trimAngle 962F CC96A7 5521 jmp retard_end ; Don't do any Advance / Retard 5522 ; till out of deadband 5523 5524 * End of dead band 5525 ********************************************************************** 5526 5527 carryOn_Advance: 5528 9632 C6E030 5529 lda cltDeg_f ; load the temp per 1 deg of Advance. 9635 272E 5530 beq Advance_end ; If zero no Advance 9637 44 5531 lsra ; Shift bit pattern to the right 5532 ; (Divide by 2) 9638 2401 5533 bcc nota_carry ; Check if carry bit clear, skip 5534 ; increment 963A 4C 5535 inca ; otherwise, increment accumulator 5536 nota_carry: 963B B7DD 5537 sta tmp31 ; Stores half the cltDeg (used for 5538 ; checking division) 963D C6E02F 5539 lda cltAdvance_f ; Load into the accumulator the top 5540 ; temperature limit 9640 B0CC 5541 sub coolant ; How much cooler are we? 9642 8C 5542 clrh ; Zero out high 8 bits of 16-bit 5543 ; H:X register 5544 ; Accumulator contains low 8 bits 9643 CEE030 5545 ldx cltDeg_f ; Set divisor 9646 52 5546 div ; (H:A) /X -> A, with rem in H 5547 9647 97 5548 tax ; Move quotient to index register 9648 8B 5549 pshh ; Transfer remainder to accumulator 9649 86 5550 pula 964A B1DD 5551 cmp tmp31 ; See if the remainder is more than 5552 ; half of divisor 964C 2501 5553 blo roundedAdvance 964E 5C 5554 incx ; It was a big remainder, round up. 5555 5556 roundedAdvance: 964F A603 5557 lda #3T ; 1 degree 9651 42 5558 mul ; X * A -> (X:A) 9652 A300 5559 cpx #0T ; See if we overflowed, i.e., X != 0 9654 2702 5560 beq maxAdvanceTrim ; No, so see if we are at max angle 9656 A6FF 5561 lda #255T ; Overflow value 5562 5563 maxAdvanceTrim: 9658 C1E031 5564 cmp maxAdvAng_f ; Is it above the max allowed advance? 965B 2503 5565 blo store_Advance ; No, store the advance 965D C6E031 5566 lda maxAdvAng_f ; Yes, load the max Advance allowed 5567 5568 store_Advance: 9660 B75C 5569 sta CltIatAngle ; Store the advance 5570 5571 retard_endJmp: 5572 9662 CC96A7 5573 jmp retard_end ; If Coolant advance running dont 5574 ; check IAT retard 5575 5576 Advance_end: 5577 5578 ***************************************************************************** 5579 ** 5580 ** Add Retard of 1 deg per user defined amount of IAT when IAT and 5581 ** boost above setpoints 5582 ** 5583 ***************************************************************************** 5584 9665 C6E032 5585 lda iatDeg_f ; load the temp per 1 deg of retard. 9668 273D 5586 beq noRetard ; If zero then no Retard 966A 44 5587 lsra ; Shift bit pattern to the right 5588 ; (Divide by 2) 966B 2401 5589 bcc no_carry ; Check if carry bit clear, skip 5590 ; increment 966D 4C 5591 inca ; otherwise, increment accumulator 5592 5593 no_carry: 966E B7DE 5594 sta tmp32 ; Stores half the iatDeg 5595 9670 B6CB 5596 lda kpa 9672 C1E033 5597 cmp kpaRetard_f ; Setpoint of KPa for retard 9675 252C 5598 blo clr_Retard ; If not reached make sure we 5599 ; clear the retard angle 5600 9677 C60108 5601 lda airTemp ; Actual IAT Temp 967A C1E034 5602 cmp iatDanger_f ; Setpoint for start of retard 967D 2524 5603 blo clr_Retard ; If not reached make sure we 5604 ; clear the retard angle 5605 967F C0E034 5606 sub iatDanger_f ; How much higher are we? Leaves 5607 ; difference in accumulator 9682 8C 5608 clrh ; Zero out high 8 bits of 16-bit 5609 ; H:X register 5610 ; Accumulator contains low 8 bits 9683 CEE032 5611 ldx iatDeg_f ; Set divisor 9686 52 5612 div ; (H:A) /X -> A, with rem in H msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 54 MC68HC908GP32 User Bootloader 5613 9687 97 5614 tax ; Move quotient to index register 9688 8B 5615 pshh ; Transfer remainder to accumulator 9689 86 5616 pula 968A B1DE 5617 cmp tmp32 ; See if the remainder is more than 5618 ; half of divisor 968C 2501 5619 blo roundedRetard 968E 5C 5620 incx ; It was a big remainder, round up. 5621 5622 roundedRetard: 968F A603 5623 lda #3T ; 1 degree 9691 42 5624 mul ; X * A -> (X:A) 5625 9692 B7DD 5626 sta tmp31 ; Store angle to retard, its an 5627 ; advance angle at the moment 9694 A6FF 5628 lda #255T ; 9696 B0DD 5629 sub tmp31 ; (255-angle to retard) turns it 5630 ; into a retard angle 5631 9698 A300 5632 cpx #0T ; See if we overflowed, i.e., X != 0 969A 2702 5633 beq storeRetardedTrim 969C A6FF 5634 lda #255T ; Overflow value 5635 5636 storeRetardedTrim: 969E B75C 5637 sta CltIatAngle ; 96A0 CC96A7 5638 jmp retard_end ; finished retard 5639 5640 clr_Retard: 96A3 A600 5641 lda #$00 96A5 B75C 5642 sta CltIatAngle ; Sets trim angle back to zero when 5643 ; no setpoints met 5644 noRetard: 5645 retard_end: 5646 5647 5648 *************************************************************************** 5649 ** 5650 ** Idle Speed Adjustment 5651 ** 5652 ** Brian Fielding's PWM algorithm for single-coil valves. 5653 ** 5654 ** idleOn = adjustment algorithm is running. If it is not, then 5655 ** idleLastDC will not be changed. 5656 ** 5657 ** if cranking 5658 ** idleDC = 100% 5659 ** idleLastDC = 100% 5660 ** idleOn off 5661 ** 5662 ** if in ASE 5663 ** leave things the way they are, presumably 100% open 5664 ** 5665 ** if in TPS Decel 5666 ** clock = 0 5667 ** idleDC = idleLastDC 5668 ** 5669 ** JSM added warmup PWM setting. Can choose open loop or closed loop. 5670 ** This is designed to work like a variable version of B&G 5671 ** Can set duty cycle at lower temp. Interpolates to zero at upper temp, where 5672 ** rpm targets take over. 5673 ** If rpm targets are set to zero then valve shut about upper temp. 5674 *************************************************************************** 96A7 006268 5675 brset REUSE_FIDLE,outputpins,idle_DoneJMP 5676 5677 IdleAdjust: 96AA 066412 5678 brset PWMidle,feature2,idlePWM 5679 5680 ;-- Toggle Mode ---------------------------------------------------------------- 5681 5682 idleToggle: 96AD B6CC 5683 lda coolant 96AF C1E1BA 5684 cmp fastIdleBG_f ; use original B&G on/off temp 96B2 2305 5685 bls idleFast ; Shouldn't there be some hysteresis 5686 ; here? On the other hand, the 5687 ; temp should never hover around 5688 ; here, so why bother? 5689 idleSlow: 96B4 3F55 5690 clr idleDC ; Fully closed. 96B6 CC97FC 5691 jmp idleDone 5692 5693 idleFast: 96B9 6EFF55 5694 mov #255T,idleDC ; Wide open. 96BC CC97FC 5695 jmp idleDone 5696 5697 ;-- PWM Mode ------------------------------------------------------------------- 5698 5699 idlePWM: 96BF 02427D 5700 brset crank,engine,eskipAdjust ; Don't adjust idle during cranking 96C2 0D652A 5701 brclr idle_warmup,feature7,idle_closedloop 5702 5703 ; Warmup PWM 5704 idle_openloop: 96C5 B6CC 5705 lda coolant 96C7 C1E023 5706 cmp slowIdleTemp_f 96CA 2505 5707 blo idle_loopcold 96CC 0F653B 5708 brclr idle_cl,feature7,clrNskip ; If we are not using closed loop then clear DC 96CF 201E 5709 bra idle_closedloop 5710 5711 idle_loopcold: 5712 ; determine duty cycle by linear interpolation 96D1 C6E022 5713 lda fastIdletemp_f 96D4 B794 5714 sta liX1 96D6 C6E023 5715 lda slowIdleTemp_f 96D9 B795 5716 sta liX2 96DB C6E07A 5717 lda idle_dc_lo 96DE B796 5718 sta liY1 96E0 C6E095 5719 lda idle_dc_hi 96E3 B797 5720 sta liy2 ; rmd upper duty limit 96E5 B6CC 5721 lda coolant 96E7 B798 5722 sta liX 96E9 CDCFB8 5723 jsr lininterp 96EC 4E9955 5724 mov liY,idleDC 5725 5726 idle_closedloop: 96EF 0F6520 5727 brclr idle_cl,feature7,idle_DoneJMP 96F2 04425C 5728 brset startw,engine,skipAdjust ; skip if in after-start period 96F5 0A4252 5729 brset tpsden,engine,idleDashpot ; Reset idle duty cycle 5730 ; on decel active 5731 5732 idleTest: 96F8 B64D 5733 lda rpm ; rmd see if idle above 5734 ; 700RPM, if below kick up 5735 ; idleDC 96FA C1E091 5736 cmp idlekickrpm_f ; rmd/jsm 96FD 2337 5737 bls eidleRestore ; rmd 96FF B647 5738 lda tps ; See if we are supposed to be idling 9701 C1E026 5739 cmp IdleThresh_f 9704 230E 5740 bls IDLE_COUNT 9706 1F42 5741 bclr idleOn,engine ; Throttle above idle, so 5742 ; disable adjustment 9708 200D 5743 bra idleDelay ; Postpone idle duty cycle decay 5744 5745 clrNskip: 970A C6E095 5746 lda idle_dc_hi ; Store hot DC in Idle DC 970D B755 5747 sta idleDC ; Added for setting idle DC as if ignition turned 970F CC97FC 5748 jmp idleDone ; on when engine hot msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 55 MC68HC908GP32 User Bootloader 5749 5750 idle_DoneJMP: 9712 203D 5751 bra skipAdjust 5752 5753 IDLE_COUNT: 9714 0F422A 5754 brclr idleOn,engine,idleRestore ; Reset idle duty cycle 5755 ; on returning to idle 5756 5757 idleDelay: 9717 B64D 5758 lda rpm 9719 C1E09B 5759 cmp delay2rpm_f 971C 220C 5760 bhi idleDelay2 971E B6D2 5761 lda idleCtlClock ; Postpone idle adjust for idle 5762 ; response time 9720 C1E090 5763 cmp idlePeriod_f ; so we don't slam solenoid shut 5764 ; at slightest 9723 251A 5765 blo eskipAdjust ; hint of throttle opening. 9725 0F422B 5766 brclr idleOn,engine,shutIdle ; rmd Close idle solenoid when 5767 ; throttle is pressed 9728 203E 5768 bra idleSpeed ; for long enough. 5769 5770 idleDelay2: 972A B6D2 5771 lda idleCtlClock ; Postpone idle adjust for idle 5772 ; response time 972C C1E09C 5773 cmp idlePeriod2_f ; so we don't slam solenoid shut 5774 ; at slightest 972F 250E 5775 blo eskipAdjust ; hint of throttle opening. 9731 0F421F 5776 brclr idleOn,engine,shutIdle ; rmd Close idle solenoid when 5777 ; throttle is pressed 9734 2032 5778 bra idleSpeed ; for long enough. 5779 5780 eidleRestore: 9736 1E42 5781 bset idleOn,engine ; Idle control is active 5782 eidleDashpot: 9738 3FD2 5783 clr idleCtlClock 973A C6E092 5784 lda idlekickdc_f ; rmd was idlelastDC. changed to 973D B755 5785 sta idleDC ; correct idle plumet 5786 eskipAdjust: 973F 2010 5787 bra skipAdjust 5788 5789 idleRestore: 9741 B64D 5790 lda rpm ; rmd stop idle from 9743 C1E09D 5791 cmp irestorerpm_f ; returning when in overrun 9746 220B 5792 bhi shutIdle ; 5793 9748 1E42 5794 bset idleOn,engine ; Idle control is active 5795 idleDashpot: 974A 3FD2 5796 clr idleCtlClock 974C C6E093 5797 lda idledashdc_f ; rmd was idlelastDC. changed to 974F B755 5798 sta idleDC ; correct idle plumet 5799 skipAdjust: 9751 207B 5800 bra idleDoneJMP2 5801 5802 shutIdle: 9753 B655 5803 lda idleDC 9755 C1E09E 5804 cmp idleclosedc_f 9758 2507 5805 blo shutIdle2 975A 2772 5806 beq idleDoneJMP2 975C 4A 5807 deca 975D B755 5808 sta idleDC 975F 206D 5809 bra idleDoneJMP2 5810 5811 shutIdle2: 9761 C6E09E 5812 lda idleclosedc_f 9764 B755 5813 sta idleDC 9766 2066 5814 bra idleDoneJMP2 5815 5816 idleSpeed: 5817 ; Compute RPM set point based on coolant temperature. 9768 C6E022 5818 lda fastIdletemp_f 976B B794 5819 sta liX1 976D C6E023 5820 lda slowIdleTemp_f 9770 B795 5821 sta liX2 9772 C6E024 5822 lda fastIdle_f 9775 B796 5823 sta liY1 9777 C6E025 5824 lda slowIdle_f 977A B797 5825 sta liY2 977C B6CC 5826 lda coolant 977E B798 5827 sta liX 9780 CDCFB8 5828 jsr lininterp 9783 B699 5829 lda liY 9785 B7CE 5830 sta idleTarget 9787 97 5831 tax 5832 5833 ; Calculate target ignition count base upon set point. 9788 C6E19C 5834 lda rpmk_f1 ; Idle RPM is +/-10 revs. 978B 87 5835 psha 978C 8A 5836 pulh 978D C6E19D 5837 lda rpmk_f1+1 9790 52 5838 div ; A = (H:A) / X 9791 AE0A 5839 ldx #10T 9793 42 5840 mul 9794 BF74 5841 stx idleph 9796 B775 5842 sta idlepl 9798 8B 5843 pshh 9799 86 5844 pula ; Remainder 979A AE0A 5845 ldx #10T 979C 42 5846 mul 979D 89 5847 pshx 979E 8A 5848 pulh 979F BECE 5849 ldx idleTarget 97A1 52 5850 div 97A2 BB75 5851 add idlepl 97A4 2402 5852 bcc idleSpeedCheck 97A6 3C74 5853 inc idleph 5854 5855 idleSpeedCheck: 97A8 B775 5856 sta idlepl 97AA 5570 5857 ldhx rpmph 97AC 7574 5858 cphx idleph ; Compare 16-bit rpm counter 5859 ; with target RPM. 97AE 274C 5860 beq idleDone 97B0 223A 5861 bhi idleTooLow 5862 5863 idleTooHigh: 97B2 B6CB 5864 lda kpa 97B4 C1E096 5865 cmp idlekpa1_f 97B7 2217 5866 bhi idlekpacorr1 97B9 B6CB 5867 lda kpa 97BB C1E097 5868 cmp idlekpa2_f 97BE 221E 5869 bhi idlekpacorr2 97C0 B655 5870 lda idleDC ; Crank DC down by one, if possible. 97C2 C1E094 5871 cmp idlemindc_f ; rmd was #0T, changed to provide 5872 ; lower idleDC limit 97C5 2525 5873 blo idleTooLow 97C7 2733 5874 beq idleDone 97C9 4A 5875 deca 97CA B755 5876 sta idleDC 97CC 2027 5877 bra idleSaveDC 5878 5879 idleDoneJMP2: 97CE 202C 5880 bra idleDone 5881 5882 idlekpacorr1: 97D0 B655 5883 lda idleDC 97D2 C1E098 5884 cmp ikpamin1_f msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 56 MC68HC908GP32 User Bootloader 97D5 2515 5885 blo idleTooLow 97D7 2723 5886 beq idleDone 97D9 4A 5887 deca 97DA B755 5888 sta idleDC 97DC 2017 5889 bra idleSaveDC 5890 5891 idlekpacorr2: 97DE B655 5892 lda idleDC 97E0 C1E099 5893 cmp ikpamin2_f 97E3 2507 5894 blo idleTooLow 97E5 2715 5895 beq idleDone 97E7 4A 5896 deca 97E8 B755 5897 sta idleDC 97EA 2009 5898 bra idleSaveDC 5899 5900 idleTooLow: 97EC B655 5901 lda idleDC ; Jack DC up by one, if possible. 97EE A164 5902 cmp #100T 97F0 270A 5903 beq idleDone 97F2 4C 5904 inca 97F3 B755 5905 sta idleDC 5906 5907 idleSaveDC: 97F5 3FD2 5908 clr idleCtlClock ; Reset the clock. 97F7 0F4202 5909 brclr idleOn,engine,idleDone 97FA B7CD 5910 sta idleLastDC ; Save the last active idle dutycycle 5911 5912 idleDone: 5913 5914 ****************************************************************************** 5915 ** K n o c k D e t e c t i o n S y s t e m P Ringwood ** 5916 ** 5917 ** This receives an input in from the JP1 header, if its low it sees 5918 ** it as a knock. 5919 ** Basic functionality: 5920 ** Are we below the max rpm allowed? 5921 ** Yes- carry on with detection, 5922 ** No- reset all and end knock detection. 5923 ** Knock on input, retard ignition by the 1st retard value 5924 ** (KnockRetard1), start timer 5925 ** wait for timer to time out (KnockTimLft) 5926 ** Is it still knocking? 5927 ** Yes- then add knockretard2 value to total retard. 5928 ** No- then advance by KnockAdv amount. 5929 ** Is the total retard less than 1 degree? 5930 ** Yes- reset all knock settings, goto start. 5931 ** No- so carry on with timer 5932 ** Check for knock. If knocking add retard2 restart timer - if not 5933 ** Wait for timer to time out before adding advance. 5934 ** Is it still knocking? 5935 ** Yes- then add knockretard2 value to total retard, restart timer. 5936 ** No- then advance by KnockAdv amount, restart timer. 5937 ** Is the total retard less than 1 degree? 5938 ** Yes- reset all knock settings, goto start. 5939 ** No- so carry on with timer 5940 ** When timer timed out check for knock? If knocking add knockRetard2, 5941 ** if not advance 5942 ** etc, etc, 5943 ** 5944 **************************************************************************** 5945 **************************************************************************** 5946 Knock_Detection: 5947 97FC C6E02E 5948 lda feature3_f 97FF A540 5949 bit #KnockDetb 9801 277B 5950 beq End_KnockJmp ; knock not enabled 5951 9803 C6E074 5952 lda feature8_f 9806 A510 5953 bit #spkfopb 9808 2674 5954 bne End_KnockJmp ; Spark output F enabled, incompatible 5955 980A 8C 5956 clrh 980B B64D 5957 lda rpm 980D C1E035 5958 cmp KnockRpmL_f ; Is the engine rpm too high for 5959 ; the knock sensor? 9810 2269 5960 bhi Clr_KnockJmp ; If it is clear values, no more retard 9812 C1E036 5961 cmp KnockRpmLL_f ; Is it running lower than the 5962 ; low rpm setpoint? 9815 2564 5963 blo Clr_KnockJmp ; If so clear all values, no 5964 ; more retard 9817 B6CB 5965 lda kpa 9819 C1E037 5966 cmp KnockKpaL_f ; Is the boost above the limit 5967 ; for knock system? 981C 225D 5968 bhi Clr_KnockJmp ; If it is clear knock values, 5969 ; no more retard. 981E 0E5F16 5970 brset Knocked,SparkBits,KnockTLeft ; If knock has been 5971 ; previously detected do timer 9821 0E601E 5972 brset Advancing,RevLimBits,KnockALeft ; If we are advancing back 9824 040357 5973 brset KnockIn,portd,End_KnockJmp ; If no knock on input 5974 ; then no knock 9827 1E5F 5975 bset Knocked,SparkBits ; 1st Knock on input so set knocked bit 9829 C6E038 5976 lda KnockRet1_f 982C B75D 5977 sta KnockAngle ; Load in first retard amount 982E C6E06B 5978 lda BoostKnock_f ; Value to remove from Boost controller 9831 C70102 5979 sta KnockBoost ; target 9834 CC98B8 5980 jmp Start_KnockTime ; Start the knock timer 5981 5982 KnockTLeft: 9837 1F60 5983 bclr Advancing,RevLimBits ; Clear advance bit as we are retarding 9839 B6D9 5984 lda KnockTimLft 983B A100 5985 cmp #00T 983D 2711 5986 beq NoTimeLeft ; If timer counted down then add 5987 ; some advance 983F CC987E 5988 jmp End_KnockJmp ; End of Knock 5989 5990 KnockALeft: 9842 1F5F 5991 bclr Knocked,SparkBits ; Clear Retard set bit as we 5992 ; are advancing 9844 05034D 5993 brclr KnockIn,portd,Knocking_Still ; Do we have any knocking? 9847 B6D9 5994 lda KnockTimLft 9849 A100 5995 cmp #00T 984B 2703 5996 beq NoTimeLeft ; If timer counted down then add 5997 ; some advance 984D CC987E 5998 jmp End_KnockJmp ; End of Knock 5999 6000 NoTimeLeft: 9850 050341 6001 brclr KnockIn,portd,Knocking_Still ; Still knocking? 9853 1F5F 6002 bclr Knocked,SparkBits ; No Knocking so clear knock bit 9855 1E5F 6003 bset Advancing,SparkBits ; Set advancing bit 9857 C6E06B 6004 lda Boostknock_f 985A 270D 6005 beq No_BoostKnock ; if no Boost Knock value then 6006 ; jump past checks 985C C60102 6007 lda KnockBoost ; Value to add to Boost controller 985F C0E06B 6008 sub BoostKnock_f ; target 9862 C70102 6009 sta KnockBoost 9865 A103 6010 cmp #03T 9867 2518 6011 blo ClearTime ; If target boost less than 6012 ; 0.5psi then clear all 6013 No_BoostKnock: 9869 B65D 6014 lda KnockAngle ; No Knock detected and time 6015 ; period over 986B C0E03A 6016 sub KnockAdv_f ; so remove some retard 6017 6018 StoreKnock: 986E A103 6019 cmp #03T 9870 250F 6020 blo ClearTime ; If retard is less than 1deg msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 57 MC68HC908GP32 User Bootloader 6021 ; clear timer, we have finished 9872 A155 6022 cmp #85T 9874 220B 6023 bhi ClearTime ; If we are above 30 Degrees 6024 ; then somethings wrong so clear retard 9876 B75D 6025 sta KnockAngle 9878 CC98B8 6026 jmp Start_KnockTime 6027 6028 Clr_KnockJmp: 987B CC98CA 6029 jmp Clr_Knock 6030 End_KnockJmp: 987E CC98D8 6031 jmp End_Knock 6032 6033 ClearTime: ; No Knocks and retard back to start 6034 ; so clear everything. 9881 A600 6035 lda #00T 9883 B75D 6036 sta KnockAngle ; Clear the knock angle 9885 B7D9 6037 sta KnockTimLft ; Clear the time left value 9887 C70103 6038 sta KnockAngleRet ; Clears actual knock angle 988A C70102 6039 sta KnockBoost ; Clear the boost value to remove 988D 1F5F 6040 bclr Knocked,SparkBits ; Clear the Knocked bit 988F 1F60 6041 bclr Advancing,RevLimBits ; Clear advance bit 9891 CC98D8 6042 jmp End_Knock ; Go to end of knock system 6043 6044 Knocking_Still: 9894 1E5F 6045 bset Knocked,SparkBits ; Set Knocking bit 9896 1F60 6046 bclr Advancing,RevLimBits ; Clear the advance bit as we are 6047 ; in knock retard 9898 C60102 6048 lda KnockBoost 989B CBE06B 6049 add BoostKnock_f ; Increase the amount of boost to remove 989E C1E06C 6050 cmp BoostKnMax_f ; Are we at max? 98A1 2503 6051 blo Store_Boost_Remove ; No so store boost to remove 98A3 C6E06C 6052 lda BoostKnMax_f ; Yes so store the max 6053 Store_Boost_Remove: 98A6 C70102 6054 sta KnockBoost 98A9 C6E039 6055 lda KnockRet2_f ; 98AC BB5D 6056 add KnockAngle ; add the knock retard angle2 to 6057 ; knock angle 98AE C1E03B 6058 cmp KnockMax_f ; Are we at the max retard? 98B1 2503 6059 blo Not_atMax ; If not at max store new angle 98B3 C6E03B 6060 lda KnockMax_f ; If above max load the max allowed. 6061 6062 Not_atMax: 98B6 B75D 6063 sta KnockAngle ; Store new knock angle 6064 6065 Start_KnockTime: 98B8 C6E03C 6066 lda KnockTim_f ; Start/Restart the knock timer 98BB B7D9 6067 sta KnockTimLft 98BD A6FF 6068 lda #255T 98BF B05D 6069 sub KnockAngle ; (255-Knock Angle) turns it into a retard angle 98C1 A1AA 6070 cmp #$aa ; Limit the retard to 30 degrees 98C3 2210 6071 bhi StoreAngle 98C5 A6AA 6072 lda #$aa 98C7 CC98D5 6073 jmp StoreAngle 6074 6075 Clr_Knock: 98CA 1F5F 6076 bclr Knocked,SparkBits ; Clear the Knocked bit 98CC 1F60 6077 bclr Advancing,RevLimBits ; Clear advancing bit 98CE A600 6078 lda #$00 ; Clear the knock angle value 98D0 C70102 6079 sta KnockBoost ; Clear the boost value to remove 98D3 B75D 6080 sta KnockAngle 6081 6082 StoreAngle: 98D5 C70103 6083 sta KnockAngleRet ; Actual retard value for MSnS 6084 6085 End_Knock: 6086 ****************************************************************************** 6087 ****************************************************************************** 6088 ** Anti-Rev System P Ringwood 6089 ** System based on rate of change of rpm or input signals from 6090 ** 2 x Vehicle Speed Sensors 6091 ** Fuel enrichment, to bog down the engine and retard angle are 6092 ** interpolated from the 4 bins of each setting. Spark Cut isn't 6093 ** interpolated as it's not worth the effort as it's such a low 6094 ** figure (1 or 2 cuts) 6095 ** Now added cycle counter so it can hold settings for an interpolated amount 6096 ** of engine cycles. Uses ASEcount, so can only work after start warm up over. 6097 ** Using this saves making h file bigger and adding yet another counter 6098 ** to the interupt. 6099 ** 6100 ******************************************************************************** 6101 ******************************************************************************** 6102 98D8 C6E05C 6103 lda feature6_f 98DB A520 6104 bit #TractionCb 98DD 2776 6105 beq Traction_DoneJMP 6106 6107 TractionSystem: 98DF 01421F 6108 brclr running,engine,No_TC_Yet; Only use it if engine running 98E2 02421C 6109 brset crank,engine,No_TC_Yet ; Dont use it during cranking as we use some 6110 ; traction bytes 98E5 044219 6111 brset startw,engine,No_TC_Yet ; only use Anti-Rev when after 6112 ; start enrichment over 98E8 066519 6113 brset WheelSensor,feature7,No_RPM_Thresh ; If using wheel 6114 ; sensors then no need to look at rpm 6115 Do_RPM_TC: 98EB B64D 6116 lda rpm 98ED C10104 6117 cmp rpmlast 98F0 246B 6118 bhs RPM_Thresh ; Has the rpm increased? 6119 NO_TC_Loss: 98F2 006763 6120 brset Traction,EnhancedBits2,reset_TC_Yet ; Have we selected 6121 ; to wait till cycle counter timed out? 6122 Reset_TC_Now: 98F5 1167 6123 bclr Traction,EnhancedBits2 ; Clear the traction control bit 98F7 A600 6124 lda #00T 98F9 B7E5 6125 sta TCCycles 98FB B7E2 6126 sta TCAngle 98FD B7E1 6127 sta TCAccel 98FF B783 6128 sta ASEcount 6129 No_TC_Yet: 9901 CC9A30 6130 jmp Traction_Done ; No so return 6131 6132 No_RPM_Thresh: 6133 6134 ; Driven input = egtadc Non-Driven input = o2_fpadc 6135 ; If under max speed and over min speed, multiply driven speed sensor 6136 ; input by the scale factor to find the speed the un-driven sensor should be at. 6137 ; Then find the allowable slip amount based on calculated estimate speed 6138 ; than actual then we have lost traction. I think:-) 6139 9904 B65A 6140 lda o2_fpadc ; Non-driven speed sensor input 9906 C1E076 6141 cmp UDSpeedLim_f ; Have we reached the speed limit? 9909 22EA 6142 bhi Reset_TC_Now ; Yes so reset TC 990B C1E075 6143 cmp UDSpeedLo_f ; Are we above the minimum speed? 990E 25E5 6144 blo Reset_TC_Now ; Yes so reset TC 9910 8C 6145 clrh 9911 BE5B 6146 ldx egtadc ; Put Driven input into x reg 9913 C6E077 6147 lda TCScaleFac_f ; Multiply by the differential factor 9916 42 6148 mul 9917 9F 6149 txa ; Transfer high byte to accumulator 9918 2401 6150 bcc Carry_LC ; Is the carry bit set? 991A 4C 6151 inca 6152 Carry_LC: ; Acc contains result 991B B7DE 6153 sta tmp32 991D B05A 6154 sub o2_fpadc ; subtract undriven wheel speed 991F 2BD1 6155 bmi NO_TC_Loss ; Drive wheels slower than undriven, 6156 ; no TC msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 58 MC68HC908GP32 User Bootloader 6157 6158 ; Interpolate to find allowable slip depending on vehicle speed 6159 ; (store allowed slip in tmp31) 9921 3F94 6160 clr liX1 ; Set minimum speed to 00 9923 A67F 6161 lda #127T ; Set maximum speed for 6162 ; interpolater to half speed 9925 B795 6163 sta liX2 9927 C6E078 6164 lda TCSlipFac_f ; Slip allowed at minimum speed 6165 ; (00 liX1) 992A B796 6166 sta liY1 992C C6E07B 6167 lda TCSlipFacH_f ; Slip allowed at half speed 992F B797 6168 sta liY2 9931 B65A 6169 lda o2_fpadc ; Actual speed were running at 9933 B798 6170 sta liX 9935 CDCFB8 6171 jsr LinInterp ; Go and find out what slip is 6172 ; allowed at current speed 9938 B7DD 6173 sta tmp31 6174 6175 ; Find out if we are slipping over the amount allowed 993A BEDE 6176 ldx tmp32 ; Load x reg with speed undriven 6177 ; wheels should be (calculated 6178 ; from driven wheel) 993C B6DD 6179 lda tmp31 ; Multiply by the allowable 6180 ; difference factor (slip allowed) 993E 42 6181 mul 993F 9F 6182 txa ; Transfer high byte to acc 9940 2401 6183 bcc Carry_Slip 9942 4C 6184 inca 6185 Carry_Slip: 9943 BB5A 6186 add o2_fpadc ; Acc = speed of undriven wheel 6187 ; + slip allowed 9945 25AB 6188 bcs NO_TC_Loss ; If we go over 255 then no traction 9947 B1DE 6189 cmp tmp32 ; Compare to calculated speed of 6190 ; undriven wheel 9949 22A7 6191 bhi NO_TC_Loss ; Were not over limit so no TC 994B B7DD 6192 sta tmp31 ; Store speed of undriven wheel 6193 ; + slip allowed 994D B6DE 6194 lda tmp32 ; Load calculated value of 6195 ; undriven wheel 994F B0DD 6196 sub tmp31 9951 B7DE 6197 sta tmp32 ; Store amount of traction loss 9953 2049 6198 bra VSSThresh_RJMP 6199 6200 Traction_DoneJMP: 9955 CC9A30 6201 jmp Traction_Done 6202 6203 ; If were here weve had Anti-Rev working and rpm is stable so do we 6204 ; reset it yet or later? 6205 reset_TC_Yet: 9958 05659A 6206 brclr TCcycleSec,feature7,Reset_TC_Now ; Reset it now if 6207 ; stable rpm selected 995B 200A 6208 bra Check_TC_Counter ; Not reseting on stable rpm 6209 ; so check cycle counter 6210 6211 RPM_Thresh: 995D B64D 6212 lda rpm 995F C00104 6213 sub rpmlast 9962 C1E062 6214 cmp RPMthresh_f ; Have we increased rpm above 6215 ; the threshold? 9965 2413 6216 bhs Thresh_Reach 6217 6218 Check_TC_Counter: 9967 B683 6219 lda ASEcount ; Use after start warmup counter 6220 ; as its only used for a few 6221 ; seconds on start up. 9969 B1E5 6222 cmp TCCycles 996B 250A 6223 blo Dont_Reset_Tract ; Only reset angle and accel 6224 ; enrich after nn cycles 996D 1167 6225 bclr Traction,EnhancedBits2 ; Clear the traction control bit 996F A600 6226 lda #00T 9971 B7E2 6227 sta TCAngle 9973 B7E1 6228 sta TCAccel 9975 B783 6229 sta ASEcount 6230 Dont_Reset_Tract: 9977 CC9A30 6231 jmp Traction_Done 6232 6233 ; For RPM Based Anti-Rev 6234 Thresh_Reach: 997A 1067 6235 bset Traction,EnhancedBits2 ; Set the traction control bit 997C A600 6236 lda #00T 997E B783 6237 sta ASEcount ; Reset the cycle counter 9980 3F95 6238 clr tmp2 6239 6240 ; Find the rate of change from the table lookup, store it in tmp31 for 6241 ; the rest of the interpolaters 9982 45D853 6242 ldhx #rpmdotrate ; Store address for finding 6243 ; rate of change 9985 3594 6244 sthx tmp1 9987 6E0396 6245 mov #$03,tmp3 ; Table size 4 (3+1) 998A B64D 6246 lda rpm 998C C00104 6247 sub rpmlast 998F B797 6248 sta tmp4 9991 B79D 6249 sta tmp10 9993 CDCF9B 6250 jsr tablelookup ; Go find the address 9996 8C 6251 clrh 9997 B698 6252 lda tmp5 ; Put Address value from lookup 6253 ; into x reg 9999 97 6254 tax 999A B7DD 6255 sta tmp31 ; Save tmp5 for next lin inter 999C 2002 6256 bra TC_Interpoler 6257 6258 VSSThresh_RJMP: 999E 2050 6259 bra VSSThresh_Reach 6260 6261 TC_Interpoler: 6262 ; Enrichment interpole 99A0 D6E05E 6263 lda RPMrate_f,x ; Load the enrich value 99A3 B797 6264 sta liY2 99A5 5A 6265 decx 99A6 D6E05E 6266 lda RPMrate_f,x ; Load the enrich value - 1 99A9 B796 6267 sta liY1 99AB 4E9D98 6268 mov tmp10,liX 99AE CDCFB8 6269 jsr LinInterp 99B1 B699 6270 lda tmp6 ; result from Lin Inter 99B3 B7E1 6271 sta TCAccel ; Store enrichment 6272 6273 ; Retard angle interpole 99B5 BEDD 6274 ldx tmp31 ; Address from lookup table 99B7 D6E063 6275 lda TractDeg_f,x 99BA B797 6276 sta liY2 99BC 5A 6277 decx 99BD D6E063 6278 lda TractDeg_f,x ; Load the angle value - 1 99C0 B796 6279 sta liY1 99C2 4E9D98 6280 mov tmp10,liX 99C5 CDCFB8 6281 jsr LinInterp 99C8 A6FF 6282 lda #255T ; 255 - result = retard angle 99CA B099 6283 sub tmp6 ; result from Lin Inter 99CC B7E2 6284 sta TCAngle ; Store retard angle 6285 6286 ; Engine cycles to hold interpole 99CE BEDD 6287 ldx tmp31 ; Address from lookup table 99D0 D6E070 6288 lda TractCycle_f,x ; 99D3 B797 6289 sta liY2 99D5 5A 6290 decx 99D6 D6E070 6291 lda TractCycle_f,x ; Load the cycle hold value - 1 99D9 B796 6292 sta liY1 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 59 MC68HC908GP32 User Bootloader 99DB 4E9D98 6293 mov tmp10,liX 99DE CDCFB8 6294 jsr LinInterp 99E1 B699 6295 lda tmp6 99E3 B7E5 6296 sta TCCycles 6297 6298 ; Spark Cut finder 99E5 BEDD 6299 ldx tmp31 99E7 D6E067 6300 lda TractSpark_f,x 99EA B7E3 6301 sta TCSparkCut ; No need to lin interpolate as 6302 99EC 2042 6303 bra Traction_Done 6304 6305 TC_InterpJMP: 99EE 20B0 6306 bra TC_Interpoler 6307 6308 ; For speed sensor Anti-Rev system, find table value. Tmp32 contains loss 6309 VSSThresh_Reach: 99F0 1067 6310 bset Traction,EnhancedBits2 ; Set the traction control bit 99F2 A600 6311 lda #00T 99F4 B783 6312 sta ASEcount ; Reset the cycle counter 99F6 3F95 6313 clr tmp2 6314 ; Find percentage of loss: Undriven wheel/100 * loss of traction (tmp32) 99F8 B65A 6315 lda o2_fpadc 99FA 8C 6316 clrh 99FB AE64 6317 ldx #100T 99FD 52 6318 div ; (H:A) / X ->A, rem in H 99FE 97 6319 tax 99FF 8B 6320 pshh 9A00 86 6321 pula 9A01 A132 6322 cmp #50T ; Is remainder higher than half 6323 ; divisor? 9A03 2501 6324 blo Round_Slip_Per 9A05 5C 6325 incx 6326 Round_Slip_Per: 9A06 B6DE 6327 lda tmp32 9A08 42 6328 mul ; X*A -> (X:A) 9A09 A300 6329 cpx #0T ; Did we overflow? 9A0B 2702 6330 beq No_OF_Slip 9A0D A664 6331 lda #100T ; 100% max 6332 No_OF_Slip: 9A0F A164 6333 cmp #100T 9A11 2502 6334 blo Slip_Percentage 9A13 A664 6335 lda #100T 6336 Slip_Percentage: 9A15 B7DE 6337 sta tmp32 ; Store percentage slip 6338 6339 ; Find the percent slip from the table lookup, store it in tmp31 for 6340 ; the rest of the interpolaters 9A17 45D857 6341 ldhx #sliprate ; Store address for finding slipage 9A1A 3594 6342 sthx tmp1 9A1C 6E0396 6343 mov #$03,tmp3 ; Table size 4 (3+1) 9A1F B6DE 6344 lda tmp32 ; Percentage of loss 9A21 B797 6345 sta tmp4 9A23 B79D 6346 sta tmp10 9A25 CDCF9B 6347 jsr tablelookup ; Go find the address 9A28 8C 6348 clrh 9A29 B698 6349 lda tmp5 ; Put Address value from lookup 6350 ; into x reg 9A2B 97 6351 tax 9A2C B7DD 6352 sta tmp31 ; Save tmp5 for next lin inter 9A2E 20BE 6353 bra TC_InterpJMP ; Now go and work out the 6354 ; enrichments, etc 6355 6356 Traction_Done: 6357 6358 *************************************************************************** 6359 ******************** S U B S E C T I O N L O O P ************** 6360 *************************************************************************** 6361 6362 SubSectionLoop: 9A30 0E6603 6363 brset Primed,EnhancedBits,Prime_Checked ; Have we primed? 9A33 CC84F9 6364 jmp NotPrimed 6365 6366 Prime_Checked: 9A36 016403 6367 brclr BoostControl,feature2,no_boost 9A39 CD9E0B 6368 jsr CalcBoostDC 6369 6370 no_boost: 9A3C 0F6303 6371 brclr Nitrous,feature1,no_nitrous 9A3F CDD1C6 6372 jsr EnableN2O 6373 6374 no_nitrous: 9A42 C6E05C 6375 lda feature6_f 9A45 A501 6376 bit #VETable3b 9A47 2703 6377 beq No_VE_Table_3 9A49 CDD301 6378 jsr Check_VE3_Table 6379 6380 No_VE_Table_3: 9A4C C6E02E 6381 lda feature3_f 9A4F A580 6382 bit #TargetAFRb 9A51 2703 6383 beq No_AFRTar_VE1 6384 ; Are we using the 6385 ; target afrs for 6386 ; table 1? 9A53 CDD316 6387 jsr AFR1_Targets; Get Target AFR 6388 ; from table 1 for VE 1 6389 NO_AfrTar_VE1: 9A56 C6E05C 6390 lda feature6_f 9A59 A502 6391 bit #TargetAFR3b 9A5B 2703 6392 beq No_AfrTar_VE3 9A5D CDD3D3 6393 jsr AFR2_Targets; Are we using the 6394 ; target afrs for 6395 ; table 3? 6396 ; Get Target AFR 6397 ; from table 2 for VE 3 6398 No_AfrTar_VE3: 9A60 004203 6399 brset running,engine,nospkoff ; skip next check 6400 ;if not running then make sure all spark outputs are OFF 6401 ;this is a bandaid, but better safe than sorry 9A63 CD9FDC 6402 jsr turnallsparkoff ; subroutine to stop them all 6403 nospkoff: 9A66 C6E000 6404 lda personality_f 9A69 2703 6405 beq No_misc_Spark 9A6B CDA052 6406 jsr misc_spark ; dwell and other bits 6407 6408 No_misc_Spark: 6409 ;This section checks for imminent T2 rollover. Trying to avoid a race condition where 6410 ;the timer overflows but we try to read software byte before the overflow handler 6411 ; gets there. This would give an incorrect 24bit "current" value 9A6E 9B 6412 sei 9A6F 006904 6413 brset roll1,EnhancedBits4,roll1set 9A72 1369 6414 bclr roll2,EnhancedBits4 9A74 2002 6415 bra chk_roll 6416 roll1set: 9A76 1269 6417 bset roll2,EnhancedBits4 6418 chk_roll: 9A78 B62D 6419 lda T2CNTL ; unlatch any previous read 9A7A B62C 6420 lda T2CNTH 9A7C A1FF 6421 cmp #$FF 9A7E 2604 6422 bne roll_not_high 9A80 1069 6423 bset roll1,EnhancedBits4 9A82 2002 6424 bra chkroll_end 6425 roll_not_high: 9A84 1169 6426 bclr roll1,EnhancedBits4 6427 chkroll_end: 9A86 9A 6428 cli msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 60 MC68HC908GP32 User Bootloader 6429 6430 ;test code 6431 ;check if 0.1ms code has executed since we got here last. Major problem if it 6432 ;hasn't. 9A87 036A15 6433 brclr checkbit,EnhancedBits5,troll_ck_done ; ok 6434 ;oh dear, we've missed it 6435 9A8A B62D 6436 lda T2CNTL ; unlatch any previous read 9A8C B62C 6437 lda T2CNTH 9A8E B794 6438 sta tmp1 9A90 B62D 6439 lda T2CNTL 9A92 AB0A 6440 add #10T ; interrupt will occur in 10us 9A94 97 6441 tax 9A95 B694 6442 lda tmp1 9A97 A900 6443 adc #0T 9A99 B731 6444 sta T2CH0H 9A9B BF32 6445 stx T2CH0L 9A9D 1C30 6446 bset TOIE,T2SC0 ; re-enable 0.1ms interrupt 6447 6448 troll_ck_done: 9A9F 126A 6449 bset checkbit,EnhancedBits5 ;set it here, 0.1ms will clear it 6450 6451 9AA1 CC857D 6452 jmp CalcRunningParameters ; Start main loop again 6453 6454 *************************************************************************** 6455 ** 6456 ** Cranking Mode 6457 ** 6458 ** Pulsewidth is directly set by the coolant temperature value of 6459 ** 021p added facility to use Inlet Manifold air temp instead / as well 6460 ** CWU (at -40 degrees) and CWH (at 165 degrees) - value is interpolated 6461 ** 6462 ** Leaves result in tmp1, clears tmp2. 6463 ** 6464 *************************************************************************** 6465 6466 crankingMode: ; Normal cranking: no pulse on no rpm. 6467 ; lda rpm 6468 ; beq floodClear 6469 ;why do the above? Prevents starting if rpm < 100! 6470 ; brclr running,engine,floodClear ; only skip if not running 9AA4 014213 6471 brclr running,engine,ExtraFuelCrank ; We are stopped so do we add 6472 ; extra fuel whilst cranking? 6473 6474 crankingModePrime: 9AA7 1242 6475 bset crank,engine ; Turn on cranking mode. 9AA9 1542 6476 bclr startw,engine ; Turn off ASE mode. 9AAB 1742 6477 bclr warmup,engine ; Turn off WUE mode. 6478 9AAD B647 6479 lda tps ; ~70% comparison value for throttle 6480 ; - flood clear trigger 6481 ; cmp #$B2 ; 3.5 v, should be a user setting. 9AAF C1E4C3 6482 cmp tpsflood_f 9AB2 252F 6483 blo crankingPW 9AB4 3FE1 6484 clr TCAccel 6485 6486 floodClear: 9AB6 4F 6487 clra ; Turn off pulses altogether. 9AB7 CC9B54 6488 jmp crankingDone 6489 6490 ; Extra Fueling for Cranking! This is triggered if the TPS goes above the floodclear 6491 ; value 3 times before starting. Were using the NosDcOk Bit as its not used at cranking. 6492 ; Were also using various Traction Bytes too. All this to save RAM. 6493 6494 ExtraFuelCrank: 9ABA C6E4C1 6495 lda feature11_f4 9ABD A540 6496 bit #ExCrFuelb 9ABF 27F5 6497 beq floodClear ; If Extra Cranking Fuel not selected then 6498 ; carry on as normal 6499 9AC1 B647 6500 lda tps 9AC3 C1E4C3 6501 cmp tpsflood_f 9AC6 2414 6502 bhs HighTPS ; Is the TPS higher than the floodclear value? 9AC8 0166EB 6503 brclr NosDcOk,EnhancedBits,floodClear ; No so go back to clearing PW 9ACB 1166 6504 bclr NosDcOk,EnhancedBits 9ACD 3CE5 6505 inc TCCycles ; Temp storage of TPS counter 9ACF B6E5 6506 lda TCCycles 9AD1 A103 6507 cmp #03T 9AD3 25E1 6508 blo floodClear ; If we havent done it 3 times then clear PW 9AD5 C6E4C5 6509 lda ExtraCrFu_f 9AD8 B7E1 6510 sta TCAccel 9ADA 20DA 6511 bra floodClear 6512 6513 HighTPS: 6514 9ADC 0066D7 6515 brset NosDcOk,EnhancedBits,floodClear ; Have we done this? 9ADF 1066 6516 bset NosDcOk,EnhancedBits ; Set bit so we dont do this again 9AE1 20D3 6517 bra floodClear 6518 6519 6520 6521 crankingPW: 9AE3 3F94 6522 clr liX1 ; -40 + 40 9AE5 A6CD 6523 lda #205T ; 165 + 40 degrees (because of 6524 ; offset in lookup table) 9AE7 B795 6525 sta liX2 9AE9 C6E4A8 6526 lda cwu_f1 9AEC B796 6527 sta liY1 9AEE C6E4A9 6528 lda cwh_f1 9AF1 B797 6529 sta liY2 6530 ; choose coolant, airtemp or average 6531 ; brset matcrank,feature11_f4,crpwmat 9AF3 C6E4C1 6532 lda feature11_f4 9AF6 A520 6533 bit #matcrankb 9AF8 2604 6534 bne crpwmat 6535 crpwclt: ; if cltcrank bit is 1 or 0 9AFA B6CC 6536 lda coolant 9AFC 2016 6537 bra crpwint 6538 6539 crpwmat: 6540 6541 ; brclr cltcrank,feature11_f4,crpwint ; if just mat then done 9AFE C6E4C1 6542 lda feature11_f4 9B01 A510 6543 bit #cltcrankb 9B03 270C 6544 beq CltOnlyPulse 9B05 C60108 6545 lda airtemp 9B08 BBCC 6546 add coolant 9B0A 2402 6547 bcc Clt_IAT_NOFlow 9B0C A6FF 6548 lda #255T 6549 Clt_IAT_NOFlow: 9B0E 46 6550 rora ; ( airtemp + coolant ) /2 9B0F 2003 6551 bra crpwint 6552 6553 CltOnlyPulse: 9B11 C60108 6554 lda airtemp ; Air Temp only 6555 crpwint: 9B14 B798 6556 sta liX 6557 6558 ; If we are here and we havent primed then we are in table mode 6559 ; for priming pulse 6560 ; brclr Primed,EnhancedBits,Table_Crank_PWs ; Have we primed? 6561 6562 ;Table_Crank_PWs: 6563 ; bset Primed,EnhancedBits 6564 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 61 MC68HC908GP32 User Bootloader 6565 ; Table look up for Cranking PW, liX already contains temperature to look for - PR 9B16 4E9897 6566 mov liX,tmp4 ; tmp4 holds the variable to look 6567 ; for in the lookup table 9B19 4E989D 6568 mov liX,tmp10 ; Save away for later use below 9B1C 45D808 6569 ldhx #WWURANGE 9B1F 3594 6570 sthx tmp1 9B21 6E0996 6571 mov #$09,tmp3 ; 10 bits wide 9B24 CDCF9B 6572 jsr tableLookup ; This finds the bins when the 6573 ; temperatures are set 6574 9B27 8C 6575 clrh 9B28 BE98 6576 ldx tmp5 6577 9B2A D6E4B7 6578 lda CrankPWs_f,x 9B2D B797 6579 sta liY2 9B2F 5A 6580 decx 9B30 D6E4B7 6581 lda CrankPWs_f,x ; This finds the values for the 6582 ; PW at the above temperatures 9B33 B796 6583 sta liY1 9B35 4E9D98 6584 mov tmp10,liX 6585 9B38 CDCFB8 6586 jsr LinInterp 6587 6588 ; If TCAccel > 0 then we are multiplying the Crank PW by it 6589 9B3B B6E1 6590 lda TCAccel 9B3D 2713 6591 beq MultiFacCrank ; Do we have a value to use? 9B3F B79D 6592 sta tmp10 9B41 3F9E 6593 clr tmp11 9B43 B699 6594 lda tmp6 9B45 B79F 6595 sta tmp12 9B47 3FA0 6596 clr tmp13 9B49 CDD170 6597 jsr Supernorm 9B4C B69D 6598 lda tmp10 9B4E BB99 6599 add tmp6 ; Add original PW back 9B50 2002 6600 bra crankingDone 6601 6602 MultiFacCrank: 9B52 B699 6603 lda tmp6 ; Leave it where expected. 6604 6605 crankingDone: 6606 ; sta egtadc 9B54 B794 6607 sta tmp1 9B56 0D6303 6608 brclr CrankingPW2,feature1,no_crankpw2 9B59 B795 6609 sta tmp2 ; Pulse bank 2 just like bank 1. 9B5B 81 6610 rts 6611 no_crankpw2: 9B5C 3F95 6612 clr tmp2 ; Zero out bank 2 while cranking. 9B5E 81 6613 rts 6614 6615 6616 *************************************************************************** 6617 ** Roger Enns' Staged Injection System 6618 ** (Modded for MSnS-Extra by P Ringwood) 6619 ** Calculate staged mode pulse width: 6620 ** 6621 ** PW_STAGED = ((TMP11 + TPSACCEL) * ScaleFac / 512) - INJOCFUEL + TMP6 6622 ** 6623 ** ScaleFac = Primary inj size /(Prim + Sec inj size) * 512, should always 6624 ** be <=255. If identically sized injectors, use 255. 6625 *************************************************************************** 6626 CALC_STAGED_PW: 9B5F B69E 6627 lda tmp11 9B61 BB4F 6628 add TPSACCEL 9B63 2513 6629 bcs MAX_PWM_ALLOWED2 9B65 97 6630 tax ; move calc'd pw to x-register 9B66 C6E04F 6631 lda SCALEFAC_f ; load SCALEFAC constant into 6632 ; accumulator 9B69 42 6633 mul ; multipy the two together, 6634 ; 16-bit result in x:a 9B6A 9F 6635 txa ; transfer high byte of 6636 ; pw*ScaleFac to accumlator, 6637 ; overwriting existing lower byte. 9B6B 44 6638 lsra ; Shift bit pattern to the right 9B6C 2401 6639 bcc NO_INC ; if carry bit clear, skip increment 9B6E 4C 6640 inca ; otherwise, increment accumulator 6641 NO_INC: 9B6F BB99 6642 add tmp6 ; then add open time 9B71 2505 6643 bcs MAX_PWM_ALLOWED2 6644 ; sub InjOCFuel_f1 ; Removed 9B73 C7010B 6645 sta pw_staged 9B76 2005 6646 BRA FINISHED_PW_COMP 6647 MAX_PWM_ALLOWED2: ; THIS SHOULD NEVER HAPPEN 9B78 A6FE 6648 lda #$FE 9B7A C7010B 6649 sta pw_staged 6650 FINISHED_PW_COMP: 6651 6652 *************************************************************************** 6653 ** 6654 ** Check for injector staging - RPE 6655 ** 6656 ** Staged based on kpa, rpm, or map - selectable via config13 bits 6,7 6657 ** 6658 ** If >= STGTRANS, staged mode on 6659 ** If <= (STGTRANS - STGDELTA), staged mode off 6660 ** STGDELTA provides user-definable hysteresis to prevent 'chattering' during 6661 ** transition phase. 6662 ** 6663 *************************************************************************** 9B7D C6E04C 6664 lda feature5_f 9B80 A508 6665 bit #stagedModeb 9B82 260F 6666 bne LastCheck 6667 ; brset stagedMode,feature5,LastCheck ; If this bit is set then 6668 ; not RPM 9B84 C6E050 6669 lda STGTRANS_f ; RPM-based staging 9B87 B14D 6670 cmp rpm 9B89 2330 6671 bls STAGED_ON 9B8B C0E051 6672 sub STGDELTA_f 9B8E B14D 6673 cmp rpm 9B90 242C 6674 bhs STAGED_OFF 9B92 81 6675 rts 6676 6677 LastCheck: 9B93 C6E04C 6678 lda feature5_f 9B96 A504 6679 bit #stagedb 9B98 2712 6680 beq MAPSTAGED 6681 ; brclr staged,feature5,MAPSTAGED ; If this bit is set then 6682 ; not TPS 9B9A B647 6683 lda tps ; TPS-based staging 9B9C C1E050 6684 cmp STGTRANS_f 9B9F 241A 6685 bhs STAGED_ON 9BA1 C6E050 6686 lda STGTRANS_f 9BA4 C0E051 6687 sub STGDELTA_f 9BA7 B147 6688 cmp tps 9BA9 2413 6689 bhs STAGED_OFF 9BAB 81 6690 rts 6691 6692 MAPSTAGED: ; Must be MAP Based staging 9BAC C6E050 6693 lda STGTRANS_f 9BAF B1CB 6694 cmp kpa 9BB1 2308 6695 bls STAGED_ON 9BB3 C0E051 6696 sub STGDELTA_f 9BB6 B1CB 6697 cmp kpa 9BB8 2404 6698 bhs STAGED_OFF 9BBA 81 6699 rts 6700 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 62 MC68HC908GP32 User Bootloader 6701 STAGED_ON: ; set staged bit to 1 9BBB 1666 6702 bset REStaging,EnhancedBits 9BBD 81 6703 rts 6704 6705 STAGED_OFF: ; clear bit 9BBE 1766 6706 bclr REStaging,EnhancedBits 9BC0 81 6707 rts 6708 6709 6710 6711 *************************************************************************** 6712 *************************************************************************** 6713 ** 6714 ** VE 3-D Table Lookup 6715 ** 6716 ** This is used to determine value of VE based on RPM and MAP 6717 ** The table looks like: 6718 ** 6719 ** 105 +....+....+....+....+....+....+....+ 6720 ** .................................... 6721 ** 100 +....+....+....+....+....+....+....+ 6722 ** ... 6723 ** KPA ... 6724 ** ... 6725 ** 35 +....+....+....+....+....+....+....+ 6726 ** 5 15 25 35 45 55 65 75 RPM/100 6727 ** 6728 ** 6729 ** Steps: 6730 ** 1) Find the bracketing KPA positions via tableLookup, put index in 6731 ** tmp8 and bounding values in tmp9(kpa1) and tmp10(kpa2) 6732 ** 2) Find the bracketing RPM positions via tableLookup, store index 6733 ** in tmp11 and bounding values in tmp13(rpm1) and tmp14(rpm2) 6734 ** 3) Using the VE table, find the table VE values for tmp15=VE(kpa1,rpm1), 6735 ** tmp16=VE(kpa1,rpm2), tmp17 = VE(kpa2,rpm1), and tmp18 = VE(kpa2,rpm2) 6736 ** 4) Find the interpolated VE value at the lower KPA range : 6737 ** x1=rpm1, x2=rpm2, y1=VE(kpa1,rpm1), y2=VE(kpa1,rpm2) - put in tmp19 6738 ** 5) Find the interpolated VE value at the upper KPA range : 6739 ** x1=rpm1, x2=rpm2, y1=VE(kpa2,rpm1), y2=VE(kpa2,rpm2) - put in tmp11 6740 ** 6) Find the final VE value using the two interpolated VE values: 6741 ** x1=kpa1, x2=kpa2, y1=VE_FROM_STEP_4, y2=VE_FROM_STEP_5 6742 ** 6743 *************************************************************************** 6744 6745 *************************************************************************** 6746 ** JSM changed it to just be one routine per page. Maybe Eric will kill 6747 ** me, but we've plenty of flash and I'm obviously a bit lazy. 6748 *************************************************************************** 6749 6750 VE1_LOOKUP: ; ALWAYS page 1 9BC1 8C 6751 clrh 9BC2 5F 6752 clrx 9BC3 C6E1B8 6753 lda config13_f1 6754 VE1_LOOKUP_PW1: 6755 9BC6 A504 6756 bit #c13_cs 9BC8 260F 6757 bne VE1_AN ; if alpha-N 6758 9BCA C6E0C7 6759 lda feature9_f 9BCD A520 6760 bit #MassAirFlwb 9BCF 2704 6761 beq VE1_SD ; Are we using a MAF on pin X7? 6762 9BD1 B65A 6763 lda o2_fpadc ; Using MAF thats on pin X7 9BD3 2006 6764 bra VE1_STEP_1 6765 VE1_SD: 6766 9BD5 B6CB 6767 lda kpa ; SD, so use kpa for load 9BD7 2002 6768 bra VE1_STEP_1 6769 VE1_AN: 9BD9 B647 6770 lda tps 6771 6772 VE1_STEP_1: 9BDB B7DB 6773 sta kpa_n 9BDD 45E1AA 6774 ldhx #KPARANGEVE_f1 9BE0 3594 6775 sthx tmp1 9BE2 A60B 6776 lda #$0b ; 12x12 9BE4 B796 6777 sta tmp3 9BE6 B6DB 6778 lda kpa_n 9BE8 B797 6779 sta tmp4 9BEA CDCF9B 6780 jsr tableLookup 9BED B694 6781 lda tmp1 9BEF B695 6782 lda tmp2 9BF1 4E989B 6783 mov tmp5,tmp8 ; Index 9BF4 4E949C 6784 mov tmp1,tmp9 ; X1 9BF7 4E959D 6785 mov tmp2,tmp10 ; X2 6786 6787 VE1_STEP_2: 9BFA 45E19E 6788 ldhx #RPMRANGEVE_f1 9BFD 3594 6789 sthx tmp1 9BFF 6E0B96 6790 mov #$0b,tmp3 ; 12x12 9C02 4E4D97 6791 mov rpm,tmp4 9C05 CDCF9B 6792 jsr tableLookup 9C08 4E989E 6793 mov tmp5,tmp11 ; Index 9C0B 4E94A0 6794 mov tmp1,tmp13 ; X1 9C0E 4E95A1 6795 mov tmp2,tmp14 ; X2 6796 6797 VE1_STEP_3: 6798 9C11 8C 6799 clrh 9C12 AE0C 6800 ldx #$0c ; 12x12 9C14 B69B 6801 lda tmp8 9C16 4A 6802 deca 9C17 42 6803 mul 9C18 BB9E 6804 add tmp11 9C1A 4A 6805 deca 9C1B 97 6806 tax 9C1C macro 6807 VE1X 9C1C C60106 6808 LDA PAGE 9C1F A101 6809 CMP #01T 9C21 2605 6810 BNE VE1XF 9C23 D6010F 6811 LDA VE_R,X 9C26 2003 6812 BRA VE1XC 9C28 D6E100 6813 VE1XF: LDA VE_F1,X 6814 VE1XC: 9C2B B7A2 6815 sta tmp15 9C2D 5C 6816 incx 9C2E macro 6817 VE1X 9C2E C60106 6818 LDA PAGE 9C31 A101 6819 CMP #01T 9C33 2605 6820 BNE VE1XF 9C35 D6010F 6821 LDA VE_R,X 9C38 2003 6822 BRA VE1XC 9C3A D6E100 6823 VE1XF: LDA VE_F1,X 6824 VE1XC: 9C3D B7A3 6825 sta tmp16 9C3F AE0C 6826 ldx #$0c ; 12x12 9C41 B69B 6827 lda tmp8 9C43 42 6828 mul 9C44 BB9E 6829 add tmp11 9C46 4A 6830 deca 9C47 97 6831 tax 9C48 macro 6832 VE1X 9C48 C60106 6833 LDA PAGE 9C4B A101 6834 CMP #01T 9C4D 2605 6835 BNE VE1XF 9C4F D6010F 6836 LDA VE_R,X msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 63 MC68HC908GP32 User Bootloader 9C52 2003 6837 BRA VE1XC 9C54 D6E100 6838 VE1XF: LDA VE_F1,X 6839 VE1XC: 9C57 B7A4 6840 sta tmp17 9C59 5C 6841 incx 9C5A macro 6842 VE1X 9C5A C60106 6843 LDA PAGE 9C5D A101 6844 CMP #01T 9C5F 2605 6845 BNE VE1XF 9C61 D6010F 6846 LDA VE_R,X 9C64 2003 6847 BRA VE1XC 9C66 D6E100 6848 VE1XF: LDA VE_F1,X 6849 VE1XC: 9C69 B7A5 6850 sta tmp18 6851 9C6B CD9DC9 6852 jsr VE_STEP_4 9C6E 4E9952 6853 mov tmp6,vecurr 9C71 81 6854 rts 6855 6856 *************************************************************************** 6857 ** Maybe lazy, but we have lots of flash, so quicker to have one 6858 ** routine per page 6859 *************************************************************************** 6860 VE2_LOOKUP: ; ALWAYS page 2 9C72 8C 6861 clrh 9C73 5F 6862 clrx 9C74 C6E2B8 6863 lda config13_f2 6864 VE2_LOOKUP_PW1: 6865 9C77 A504 6866 bit #c13_cs 9C79 2604 6867 bne VE2_AN ; if alpha-N 9C7B B6CB 6868 lda kpa ; SD, so use kpa for load 9C7D 2002 6869 bra VE2_STEP_1 6870 VE2_AN: 9C7F B647 6871 lda tps 6872 6873 VE2_STEP_1: 9C81 B7DB 6874 sta kpa_n 9C83 45E2AA 6875 ldhx #KPARANGEVE_f2 9C86 3594 6876 sthx tmp1 9C88 A60B 6877 lda #$0b 9C8A B796 6878 sta tmp3 9C8C B6DB 6879 lda kpa_n 9C8E B797 6880 sta tmp4 9C90 CDCF9B 6881 jsr tableLookup 9C93 B694 6882 lda tmp1 9C95 B695 6883 lda tmp2 9C97 4E989B 6884 mov tmp5,tmp8 ; Index 9C9A 4E949C 6885 mov tmp1,tmp9 ; X1 9C9D 4E959D 6886 mov tmp2,tmp10 ; X2 6887 6888 VE2_STEP_2: 9CA0 45E29E 6889 ldhx #RPMRANGEVE_f2 9CA3 3594 6890 sthx tmp1 9CA5 6E0B96 6891 mov #$0b,tmp3 ; 12x12 9CA8 4E4D97 6892 mov rpm,tmp4 9CAB CDCF9B 6893 jsr tableLookup 9CAE 4E989E 6894 mov tmp5,tmp11 ; Index 9CB1 4E94A0 6895 mov tmp1,tmp13 ; X1 9CB4 4E95A1 6896 mov tmp2,tmp14 ; X2 6897 6898 VE2_STEP_3: 6899 9CB7 8C 6900 clrh 9CB8 AE0C 6901 ldx #$0c ; 12x12 9CBA B69B 6902 lda tmp8 9CBC 4A 6903 deca 9CBD 42 6904 mul 9CBE BB9E 6905 add tmp11 9CC0 4A 6906 deca 9CC1 97 6907 tax 9CC2 macro 6908 VE2X 9CC2 C60106 6909 LDA PAGE 9CC5 A102 6910 CMP #02T 9CC7 2605 6911 BNE VE2XF 9CC9 D6010F 6912 LDA VE_R,X 9CCC 2003 6913 BRA VE2XC 9CCE D6E200 6914 VE2XF: LDA VE_F2,X 6915 VE2XC: 9CD1 B7A2 6916 sta tmp15 9CD3 5C 6917 incx 9CD4 macro 6918 VE2X 9CD4 C60106 6919 LDA PAGE 9CD7 A102 6920 CMP #02T 9CD9 2605 6921 BNE VE2XF 9CDB D6010F 6922 LDA VE_R,X 9CDE 2003 6923 BRA VE2XC 9CE0 D6E200 6924 VE2XF: LDA VE_F2,X 6925 VE2XC: 9CE3 B7A3 6926 sta tmp16 9CE5 AE0C 6927 ldx #$0c ; 12x12 9CE7 B69B 6928 lda tmp8 9CE9 42 6929 mul 9CEA BB9E 6930 add tmp11 9CEC 4A 6931 deca 9CED 97 6932 tax 9CEE macro 6933 VE2X 9CEE C60106 6934 LDA PAGE 9CF1 A102 6935 CMP #02T 9CF3 2605 6936 BNE VE2XF 9CF5 D6010F 6937 LDA VE_R,X 9CF8 2003 6938 BRA VE2XC 9CFA D6E200 6939 VE2XF: LDA VE_F2,X 6940 VE2XC: 9CFD B7A4 6941 sta tmp17 9CFF 5C 6942 incx 9D00 macro 6943 VE2X 9D00 C60106 6944 LDA PAGE 9D03 A102 6945 CMP #02T 9D05 2605 6946 BNE VE2XF 9D07 D6010F 6947 LDA VE_R,X 9D0A 2003 6948 BRA VE2XC 9D0C D6E200 6949 VE2XF: LDA VE_F2,X 6950 VE2XC: 9D0F B7A5 6951 sta tmp18 6952 9D11 CD9DC9 6953 jsr VE_STEP_4 9D14 4E9954 6954 mov tmp6,vecurr2 9D17 81 6955 rts 6956 *************************************************************************** 6957 *** VE Table 3 Look up 6958 *************************************************************************** 6959 6960 VE3_LOOKUP: ; ALWAYS page 3 9D18 8C 6961 clrh 9D19 5F 6962 clrx 9D1A C6E1B8 6963 lda config13_f1 6964 VE3_LOOKUP_PW1: 6965 9D1D A504 6966 bit #c13_cs 9D1F 260F 6967 bne VE3_AN ; if alpha-N 6968 9D21 C6E0C7 6969 lda feature9_f 9D24 A520 6970 bit #MassAirFlwb 9D26 2704 6971 beq VE3_SD ; Are we using a MAF on pin X7? 6972 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 64 MC68HC908GP32 User Bootloader 9D28 B65A 6973 lda o2_fpadc ; Using MAF thats on pin X7 9D2A 2006 6974 bra VE3_STEP_1 6975 VE3_SD: 9D2C B6CB 6976 lda kpa ; SD, so use kpa for load 9D2E 2002 6977 bra VE3_STEP_1 6978 VE3_AN: 9D30 B647 6979 lda tps 6980 6981 VE3_STEP_1: 9D32 B7DB 6982 sta kpa_n 9D34 45E59C 6983 ldhx #KPARANGEVE_f3 9D37 3594 6984 sthx tmp1 9D39 A60B 6985 lda #$0b ; 12x12 9D3B B796 6986 sta tmp3 9D3D B6DB 6987 lda kpa_n 9D3F B797 6988 sta tmp4 9D41 CDCF9B 6989 jsr tableLookup 9D44 B694 6990 lda tmp1 9D46 B695 6991 lda tmp2 9D48 4E989B 6992 mov tmp5,tmp8 ; Index 9D4B 4E949C 6993 mov tmp1,tmp9 ; X1 9D4E 4E959D 6994 mov tmp2,tmp10 ; X2 6995 6996 VE3_STEP_2: 9D51 45E590 6997 ldhx #RPMRANGEVE_f3 9D54 3594 6998 sthx tmp1 9D56 6E0B96 6999 mov #$0b,tmp3 ; 12x12 9D59 4E4D97 7000 mov rpm,tmp4 9D5C CDCF9B 7001 jsr tableLookup 9D5F 4E989E 7002 mov tmp5,tmp11 ; Index 9D62 4E94A0 7003 mov tmp1,tmp13 ; X1 9D65 4E95A1 7004 mov tmp2,tmp14 ; X2 7005 7006 VE3_STEP_3: 7007 9D68 8C 7008 clrh 9D69 AE0C 7009 ldx #$0c ; 12x12 9D6B B69B 7010 lda tmp8 9D6D 4A 7011 deca 9D6E 42 7012 mul 9D6F BB9E 7013 add tmp11 9D71 4A 7014 deca 9D72 97 7015 tax 9D73 macro 7016 VE5X 9D73 C60106 7017 LDA PAGE 9D76 A105 7018 CMP #05T 9D78 2605 7019 BNE VE5XF 9D7A D6010F 7020 LDA VE_R,X 9D7D 2003 7021 BRA VE5XC 9D7F D6E500 7022 VE5XF: LDA VE_F3,X 7023 VE5XC: 9D82 B7A2 7024 sta tmp15 9D84 5C 7025 incx 9D85 macro 7026 VE5X 9D85 C60106 7027 LDA PAGE 9D88 A105 7028 CMP #05T 9D8A 2605 7029 BNE VE5XF 9D8C D6010F 7030 LDA VE_R,X 9D8F 2003 7031 BRA VE5XC 9D91 D6E500 7032 VE5XF: LDA VE_F3,X 7033 VE5XC: 9D94 B7A3 7034 sta tmp16 9D96 AE0C 7035 ldx #$0c ; 12x12 9D98 B69B 7036 lda tmp8 9D9A 42 7037 mul 9D9B BB9E 7038 add tmp11 9D9D 4A 7039 deca 9D9E 97 7040 tax 9D9F macro 7041 VE5X 9D9F C60106 7042 LDA PAGE 9DA2 A105 7043 CMP #05T 9DA4 2605 7044 BNE VE5XF 9DA6 D6010F 7045 LDA VE_R,X 9DA9 2003 7046 BRA VE5XC 9DAB D6E500 7047 VE5XF: LDA VE_F3,X 7048 VE5XC: 9DAE B7A4 7049 sta tmp17 9DB0 5C 7050 incx 9DB1 macro 7051 VE5X 9DB1 C60106 7052 LDA PAGE 9DB4 A105 7053 CMP #05T 9DB6 2605 7054 BNE VE5XF 9DB8 D6010F 7055 LDA VE_R,X 9DBB 2003 7056 BRA VE5XC 9DBD D6E500 7057 VE5XF: LDA VE_F3,X 7058 VE5XC: 9DC0 B7A5 7059 sta tmp18 7060 9DC2 CD9DC9 7061 jsr VE_STEP_4 9DC5 4E9952 7062 mov tmp6,vecurr 9DC8 81 7063 rts 7064 7065 **************************************************************** 7066 7067 VE_STEP_4: 9DC9 4EA094 7068 mov tmp13,liX1 ; rpm low 9DCC 4EA195 7069 mov tmp14,liX2 ; rpm high 9DCF 4EA296 7070 mov tmp15,liY1 ; ve low 9DD2 4EA397 7071 mov tmp16,liY2 ; ve high 9DD5 4E4D98 7072 mov rpm,liX 9DD8 CDCFB8 7073 jsr LinInterp 9DDB 4E99A6 7074 mov tmp6,tmp19 ; ve at lower kPa/alpha bound 7075 7076 VE_STEP_5: 9DDE 4EA094 7077 mov tmp13,liX1 ; rpm low 9DE1 4EA195 7078 mov tmp14,liX2 ; rpm high 9DE4 4EA496 7079 mov tmp17,liY1 ; ve low 9DE7 4EA597 7080 mov tmp18,liY2 ; ve high 9DEA 4E4D98 7081 mov rpm,liX 9DED CDCFB8 7082 jsr LinInterp 9DF0 4E999E 7083 mov tmp6,tmp11 ; ve at upper kPa/alpha bound 7084 7085 VE_STEP_6: 9DF3 4E9C94 7086 mov tmp9,liX1 ; kPa/alpha low 9DF6 4E9D95 7087 mov tmp10,liX2 ; kPa/alpha high 9DF9 4EA696 7088 mov tmp19,liY1 ; ve low 9DFC 4E9E97 7089 mov tmp11,liY2 ; ve high 9DFF B6DB 7090 lda kpa_n 9E01 B798 7091 sta liX 9E03 CDCFB8 7092 jsr LinInterp 9E06 81 7093 rts 7094 7095 ****************************************************** 7096 ** Boost Controller table lookup macros 7097 ;these lookup macros are messed up because they refer to the 7098 ;wrong page and the ram lookup is from the wrong place 7099 ; because that will return the wrong data 7100 ; 022i - commented out until they get fixed 7101 7102 ; boost control TABLE 1 9E07 7103 $MACRO bc1X ; gets a byte from page8 or RAM. 7104 ; On entry X contains index. 7105 ; Returns byte in A 7106 ; lda page 7107 ; cmp #08T ; it isn't in page !!!! 7108 ; bne ve7xf msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 65 MC68HC908GP32 User Bootloader 7109 ; lda VE_r,x 7110 ; bra ve7xc 7111 ve7xf: lda bc_kpa_f,x 7112 ve7xc: 9E07 7113 $MACROEND 7114 7115 ; boost control TABLE 2 9E07 7116 $MACRO bc2X ; gets a byte from page8 or RAM. 7117 ; On entry X contains index. 7118 ; Returns byte in A 7119 ; lda page 7120 ; cmp #08T 7121 ; bne ve8xf 7122 ; lda VE_r,x 7123 ; bra ve8xc 7124 ve8xf: lda bc_dc_f,x 7125 ve8xc: 9E07 7126 $MACROEND 7127 7128 ; boost control TABLE 3 for 7129 ; switching boost table on the run 9E07 7130 $MACRO bc3X ; gets a byte from page8 or RAM. 7131 ; On entry X contains index. 7132 ; Returns byte in A 7133 ; lda page 7134 ; cmp #08T 7135 ; bne ve9xf 7136 ; lda VE_r,x 7137 ; bra ve9xc 7138 ve9xf: lda bc3_kpa_f,x 7139 ve9xc: 9E07 7140 $MACROEND 7141 7142 ; rotary trailing split ; switching boost table on the run 9E07 7143 $MACRO rs1X ; gets a byte from flash or RAM. 7144 ; On entry X contains index. 7145 ; Returns byte in A 7146 ;just work from flash for now 7147 lda page 7148 cmp #07T 7149 bne rs1xf 7150 lda {VE_r+split_f-flash_table7},x ; offset into ram copy 7151 bra rs1xc 7152 rs1xf: lda split_f,x 7153 rs1xc: 9E07 7154 $MACROEND 7155 7156 *************** 7157 ; a few boost bits up here to be relative 7158 boostZero: 9E07 4F 7159 clra 9E08 B7CF 7160 sta bcDC 7161 boostDone_dupe: 9E0A 81 7162 rts 7163 7164 *************************************************************************** 7165 ** Boost Controller 7166 ** 7167 ** Sets bcDC to current pwm duty cycle for boost control. Current 7168 ** implementation assumes Audi-style solenoid plumbing, such that 7169 ** zero DC reduces boost as much as possible, while 100% DC 7170 ** increases boost as much as possible. Added change to direction option 7171 ** for 100%DC = decrease boost. 7172 ** 7173 ** The closed loop calc is 7174 ** output = output + (kpaTarget-kpa)*pGain - (kpa-kpaLast)*dGain 7175 ** 7176 ** kpaTarget is the target boost looked up on 6x6 (rpm,tps) map 7177 ** 7178 ** if kpaTarget-kpa > diff max then output is lookup up on open loop 6x6 (rpm,tps) map 7179 ** 7180 *************************************************************************** 7181 9E0B 7182 bcSetPoint equ tmp6 9E0B 7183 bcDelta equ tmp7 9E0B 7184 bcP equ tmp8 7185 7186 CalcBoostDC: 7187 9E0B B6CB 7188 lda kpa 9E0D B1CA 7189 cmp Pambient 9E0F 25F6 7190 blo boostZero ; If no boost sensed, don't burn 7191 ; up the solenoid. 7192 ; is this good or bad?? 7193 9E11 B6D5 7194 lda bcCtlClock ; RTC-based updates. 7195 ; Would it be better to use engine revs 9E13 C1E00F 7196 cmp bcUpdate_f ; See if our clock has expired 9E16 25F2 7197 blo boostDone_dupe 9E18 3FD5 7198 clr bcCtlClock 7199 7200 ************************************************************************** 7201 ** Compute the target boost value based upon TPS and RPM 6x6 table 7202 ************************************************************************** 7203 7204 ; boost control ALWAYS page 8 9E1A 4E47DB 7205 mov tps,kpa_n ; (kpa_n also used in VE_STEP4) 7206 7207 ; brclr BoostTable3,feature8,BoostT1 9E1D C6E074 7208 lda feature8_f 9E20 A504 7209 bit #BoostTable3b 9E22 2703 7210 beq BoostT1 7211 9E24 030330 7212 brclr NosIn,portd,Table3_Boost; If using Boost Table 3 and input 7213 ; low then its time to use it 7214 7215 ;bc1_STEP_1: 7216 BoostT1: 9E27 45E72A 7217 ldhx #TPSRANGEbc_f 9E2A 3594 7218 sthx tmp1 9E2C 6E0596 7219 mov #$05,tmp3 ; 6x6 9E2F 4EDB97 7220 mov kpa_n,tmp4 9E32 CDCF9B 7221 jsr tableLookup 9E35 4E989B 7222 mov tmp5,tmp8 ; Index 9E38 4E949C 7223 mov tmp1,tmp9 ; X1 9E3B 4E959D 7224 mov tmp2,tmp10 ; X2 7225 7226 bc1_STEP_2: 9E3E 45E724 7227 ldhx #RPMRANGEbc_f 9E41 3594 7228 sthx tmp1 9E43 6E0596 7229 mov #$05,tmp3 ; 6x6 9E46 4E4D97 7230 mov rpm,tmp4 9E49 CDCF9B 7231 jsr tableLookup 9E4C 4E989E 7232 mov tmp5,tmp11 ; Index 9E4F 4E94A0 7233 mov tmp1,tmp13 ; X1 9E52 4E95A1 7234 mov tmp2,tmp14 ; X2 9E55 2002 7235 bra bc1_STEP_3 7236 7237 Table3_Boost: 9E57 202F 7238 bra Table3_Boost_J ; Jump 7239 7240 bc1_STEP_3: 9E59 8C 7241 clrh 9E5A AE06 7242 ldx #$06 ; 6x6 9E5C B69B 7243 lda tmp8 9E5E 4A 7244 deca msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 66 MC68HC908GP32 User Bootloader 9E5F 42 7245 mul 9E60 BB9E 7246 add tmp11 9E62 4A 7247 deca 9E63 97 7248 tax 9E64 macro 7249 bc1X 9E64 D6E700 7250 VE7XF: LDA BC_KPA_F,X 7251 VE7XC: 9E67 B7A2 7252 sta tmp15 9E69 5C 7253 incx 9E6A macro 7254 bc1X 9E6A D6E700 7255 VE7XF: LDA BC_KPA_F,X 7256 VE7XC: 9E6D B7A3 7257 sta tmp16 9E6F AE06 7258 ldx #$06 ; 6x6 9E71 B69B 7259 lda tmp8 9E73 42 7260 mul 9E74 BB9E 7261 add tmp11 9E76 4A 7262 deca 9E77 97 7263 tax 9E78 macro 7264 bc1X 9E78 D6E700 7265 VE7XF: LDA BC_KPA_F,X 7266 VE7XC: 9E7B B7A4 7267 sta tmp17 9E7D 5C 7268 incx 9E7E macro 7269 bc1X 9E7E D6E700 7270 VE7XF: LDA BC_KPA_F,X 7271 VE7XC: 9E81 B7A5 7272 sta tmp18 7273 9E83 CD9DC9 7274 jsr VE_STEP_4 9E86 2030 7275 bra No_BTable_3_J 7276 ; result in tmp6, equ'd above to be bcSetPoint 7277 7278 ***************************************************************************** 7279 ** Extra Boost Target Table put in for switching over on the run 7280 ***************************************************************************** 7281 ; bc3_STEP_1: 7282 Table3_Boost_J: 9E88 45E78A 7283 ldhx #TPSRANGE3bc_f 9E8B 3594 7284 sthx tmp1 9E8D 6E0596 7285 mov #$05,tmp3 ; 6x6 9E90 4EDB97 7286 mov kpa_n,tmp4 9E93 CDCF9B 7287 jsr tableLookup 9E96 4E989B 7288 mov tmp5,tmp8 ; Index 9E99 4E949C 7289 mov tmp1,tmp9 ; X1 9E9C 4E959D 7290 mov tmp2,tmp10 ; X2 7291 7292 bc3_STEP_2: 9E9F 45E784 7293 ldhx #RPMRANGE3bc_f 9EA2 3594 7294 sthx tmp1 9EA4 6E0596 7295 mov #$05,tmp3 ; 6x6 9EA7 4E4D97 7296 mov rpm,tmp4 9EAA CDCF9B 7297 jsr tableLookup 9EAD 4E989E 7298 mov tmp5,tmp11 ; Index 9EB0 4E94A0 7299 mov tmp1,tmp13 ; X1 9EB3 4E95A1 7300 mov tmp2,tmp14 ; X2 9EB6 2002 7301 bra bc3_STEP_3 7302 7303 No_BTable_3_J: 9EB8 202D 7304 bra No_BTable_3 ; Jump 7305 7306 bc3_STEP_3: 9EBA 8C 7307 clrh 9EBB AE06 7308 ldx #$06 ; 6x6 9EBD B69B 7309 lda tmp8 9EBF 4A 7310 deca 9EC0 42 7311 mul 9EC1 BB9E 7312 add tmp11 9EC3 4A 7313 deca 9EC4 97 7314 tax 9EC5 macro 7315 bc3X 9EC5 D6E760 7316 VE9XF: LDA BC3_KPA_F,X 7317 VE9XC: 9EC8 B7A2 7318 sta tmp15 9ECA 5C 7319 incx 9ECB macro 7320 bc3X 9ECB D6E760 7321 VE9XF: LDA BC3_KPA_F,X 7322 VE9XC: 9ECE B7A3 7323 sta tmp16 9ED0 AE06 7324 ldx #$06 ; 6x6 9ED2 B69B 7325 lda tmp8 9ED4 42 7326 mul 9ED5 BB9E 7327 add tmp11 9ED7 4A 7328 deca 9ED8 97 7329 tax 9ED9 macro 7330 bc3X 9ED9 D6E760 7331 VE9XF: LDA BC3_KPA_F,X 7332 VE9XC: 9EDC B7A4 7333 sta tmp17 9EDE 5C 7334 incx 9EDF macro 7335 bc3X 9EDF D6E760 7336 VE9XF: LDA BC3_KPA_F,X 7337 VE9XC: 9EE2 B7A5 7338 sta tmp18 9EE4 CD9DC9 7339 jsr VE_STEP_4 7340 7341 No_BTable_3: 7342 ; result in tmp6, equ'd above to 7343 ; be bcSetPoint 7344 ***************************************************************************** 7345 ** Compute a delta for the current duty cycle. 7346 ***************************************************************************** 7347 ; The real boost controller, 7348 ; compute delta. 9EE7 B699 7349 lda bcSetPoint 9EE9 C00102 7350 sub KnockBoost ; Subtract boost target with knock 7351 ; detection boost value 9EEC B799 7352 sta bcSetPoint 7353 7354 ***************************************************************************** 7355 ** 7356 ** Remove 1 psi of boost per user defined amount of IAT when IAT 7357 ** above setpoint 7358 ** 7359 ***************************************************************************** 9EEE 3FDD 7360 clr tmp31 9EF0 C6E087 7361 lda iatBoostSt_f 9EF3 2735 7362 beq noBoostIAT ; If zero then dont go any further. 9EF5 C6E088 7363 lda iatBoost_f ; load the temp per 1 psi to remove. 9EF8 2730 7364 beq noBoostIAT ; If zero then dont go any further. 9EFA 44 7365 lsra ; Shift bit pattern to the right 7366 ; (Divide by 2) 9EFB 2401 7367 bcc no_carry_B ; Check if carry bit clear, 7368 ; skip increment 7369 9EFD 4C 7370 inca ; otherwise, increment accumulator 7371 7372 no_carry_B: 9EFE B7DE 7373 sta tmp32 ; Stores half the iatDeg 7374 9F00 B647 7375 lda tps 9F02 C1E089 7376 cmp tpsBooIAT_f ; Setpoint of tps for boost reduction 9F05 2523 7377 blo noBoostIAT 7378 9F07 C60108 7379 lda airTemp ; Actual IAT Temp 9F0A C1E087 7380 cmp iatBoostSt_f ; Setpoint for start of Boost removal msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 67 MC68HC908GP32 User Bootloader 9F0D 251B 7381 blo noBoostIAT 7382 9F0F C0E087 7383 sub iatBoostSt_f ; How much higher are we? 7384 ; Leaves difference in accumulator 9F12 8C 7385 clrh ; Zero out high 8 bits of 16-bit 7386 ; H:X register 7387 ; Accumulator contains low 8 bits 9F13 CEE088 7388 ldx iatBoost_f ; Set divisor 9F16 52 7389 div ; (H:A) /X -> A, with rem in H 7390 9F17 97 7391 tax ; Move quotient to index register 9F18 8B 7392 pshh ; Transfer remainder to accumulator 9F19 86 7393 pula 9F1A B1DE 7394 cmp tmp32 ; See if the remainder is more 7395 ; than half of divisor 9F1C 2501 7396 blo FinishBIAT 9F1E 5C 7397 incx ; It was a big remainder, round up. 7398 FinishBIAT: 9F1F A607 7399 lda #07T ; Multiply by 7 KPa (1PSI) 9F21 42 7400 mul 9F22 B7DD 7401 sta tmp31 ; Boost to remove 9F24 B699 7402 lda bcSetPoint 9F26 B0DD 7403 sub tmp31 9F28 B799 7404 sta bcSetPoint ; New boost target 7405 noBoostIAT: 7406 7407 ***************************************************************************** 7408 ** Matt Dupuis idea 7409 ** if abs(target pressure - curr pressure ) > bc_max_diff 7410 ** then use bc_default duty cycle 7411 ** This can now make the controller open loop only by setting the 7412 ** max diff to zero 7413 ***************************************************************************** 7414 9F2A B6CB 7415 lda kpa ; Calc P for our PD controller. 9F2C B099 7416 sub bcSetPoint ; result from interpolate tmp6 9F2E 2401 7417 bcc mboostPos 9F30 40 7418 nega 7419 mboostPos: 9F31 C1E07D 7420 cmp bc_max_diff 9F34 2241 7421 bhi boost_fixed 7422 7423 bc_eric: 7424 ;Originated Eric Fahlgren, closed loop method 9F36 B6CB 7425 lda kpa ; Calc P for our PD controller. 9F38 B099 7426 sub bcSetPoint ; result from interpolate tmp6 9F3A 2401 7427 bcc boostPos 9F3C 40 7428 nega 7429 boostPos: 9F3D CEE010 7430 ldx bcPgain_f ; Proportional Gain in percent, 7431 ; 255=100%. 9F40 42 7432 mul ; returns in x:a 9F41 BF9B 7433 stx bcP ; just high byte 7434 ; bcP = abs(kpa-bcSetpoint) * (Pgain / 256) 7435 9F43 B6CB 7436 lda kpa ; now calc 'kpadot' in here at 7437 ; same rate 9F45 B0D0 7438 sub kpalast 9F47 2401 7439 bcc kpadotPos 9F49 40 7440 nega 7441 kpadotPos: 9F4A CEE011 7442 ldx bcDgain_f ; Differential Gain 9F4D 42 7443 mul 9F4E 9F 7444 txa 9F4F 40 7445 nega ; = - abs(kpa-kpalast) * (dGain/255) 7446 9F50 BB9B 7447 add bcP 9F52 B79A 7448 sta bcDelta ; p term - d term 7449 7450 ***************************************************************************** 7451 ** We now have a setpoint and a delta, so adjust the duty cycle. 7452 ***************************************************************************** 7453 9F54 B6CB 7454 lda kpa 9F56 B199 7455 cmp bcSetPoint 9F58 250A 7456 blo boostInc ; going up 9F5A 2000 7457 bra boostDec ; coming down 7458 7459 boostDec: 9F5C B6CF 7460 lda bcDC 9F5E B09A 7461 sub bcDelta 9F60 250E 7462 bcs boostZero2 9F62 200D 7463 bra boostSet 7464 7465 boostInc: 9F64 B6CF 7466 lda bcDC 9F66 BB9A 7467 add bcDelta 9F68 2502 7468 bcs boostRail 9F6A 2005 7469 bra boostSet 7470 7471 boostRail: 9F6C A6FF 7472 lda #255T 9F6E 2001 7473 bra boostSet 7474 7475 boostZero2: 9F70 4F 7476 clra 7477 7478 boostSet: 9F71 B7CF 7479 sta bcDC 7480 boostDone: 9F73 4ECBD0 7481 mov kpa,kpalast 9F76 81 7482 rts 7483 7484 boost_fixed: 7485 ;lookup fixed duty cycle from table. 'out of range' open loop duty 7486 7487 ;boost control ALWAYS page 8 9F77 4E47DB 7488 mov tps,kpa_n ; (kpa_n also used in VE_STEP4) 7489 ;bc2_STEP_1: 9F7A 45E75A 7490 ldhx #TPSRANGEbc_f2 9F7D 3594 7491 sthx tmp1 9F7F 6E0596 7492 mov #$05,tmp3 ; 6x6 9F82 4EDB97 7493 mov kpa_n,tmp4 9F85 CDCF9B 7494 jsr tableLookup 9F88 4E989B 7495 mov tmp5,tmp8 ; Index 9F8B 4E949C 7496 mov tmp1,tmp9 ; Y1 9F8E 4E959D 7497 mov tmp2,tmp10 ; Y2 7498 7499 bc2_STEP_2: 9F91 45E754 7500 ldhx #RPMRANGEbc_f2 9F94 3594 7501 sthx tmp1 9F96 6E0596 7502 mov #$05,tmp3 ; 6x6 9F99 4E4D97 7503 mov rpm,tmp4 9F9C CDCF9B 7504 jsr tableLookup 9F9F 4E989E 7505 mov tmp5,tmp11 ; Index 9FA2 4E94A0 7506 mov tmp1,tmp13 ; X1 9FA5 4E95A1 7507 mov tmp2,tmp14 ; X2 7508 7509 bc2_STEP_3: 7510 9FA8 8C 7511 clrh 9FA9 AE06 7512 ldx #$06 ; 6x6 9FAB B69B 7513 lda tmp8 9FAD 4A 7514 deca 9FAE 42 7515 mul 9FAF BB9E 7516 add tmp11 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 68 MC68HC908GP32 User Bootloader 9FB1 4A 7517 deca 9FB2 97 7518 tax 9FB3 macro 7519 bc2X 9FB3 D6E730 7520 VE8XF: LDA BC_DC_F,X 7521 VE8XC: 9FB6 B7A2 7522 sta tmp15 9FB8 5C 7523 incx 9FB9 macro 7524 bc2X 9FB9 D6E730 7525 VE8XF: LDA BC_DC_F,X 7526 VE8XC: 9FBC B7A3 7527 sta tmp16 9FBE AE06 7528 ldx #$06 ; 6x6 9FC0 B69B 7529 lda tmp8 9FC2 42 7530 mul 9FC3 BB9E 7531 add tmp11 9FC5 4A 7532 deca 9FC6 97 7533 tax 9FC7 macro 7534 bc2X 9FC7 D6E730 7535 VE8XF: LDA BC_DC_F,X 7536 VE8XC: 9FCA B7A4 7537 sta tmp17 9FCC 5C 7538 incx 9FCD macro 7539 bc2X 9FCD D6E730 7540 VE8XF: LDA BC_DC_F,X 7541 VE8XC: 9FD0 B7A5 7542 sta tmp18 7543 9FD2 CD9DC9 7544 jsr VE_STEP_4 9FD5 4E99CF 7545 mov tmp6,bcDC 9FD8 4ECBD0 7546 mov kpa,kpalast 9FDB 81 7547 rts 7548 *************************************************************************** 7549 9FDC 7550 $MACRO TurnAllSpkOff ; gets called in stall or on 7551 ; entering bootloader mode 7552 ;turn spark outputs to inactive 7553 brclr invspk,EnhancedBits4,soin 7554 ; inverting easy, just put all to zero 7555 bclr iasc,porta 7556 bclr sled,portc 7557 bclr wled,portc 7558 bclr aled,portc 7559 bclr Output3,portd 7560 bclr pin10,portc 7561 bclr KnockIn,portd 7562 bra soin_done 7563 soin: ; non inv 7564 brset REUSE_FIDLE,outputpins,soin1 7565 bclr iasc,porta 7566 bra soin2 7567 soin1: bset iasc,porta 7568 soin2: brset REUSE_LED17,outputpins,soin3 7569 bclr sled,portc 7570 bra soin4 7571 soin3: bset sled,portc 7572 soin4: brset REUSE_LED19,outputpins,soin5 7573 bclr aled,portc 7574 bra soin6 7575 soin5: bset aled,portc 7576 soin6: brclr REUSE_LED18,outputpins,soin7 7577 brclr REUSE_LED18_2,outputpins,soin7 7578 bset wled,portc 7579 bra soin8 7580 soin7: bclr wled,portc 7581 soin8: 7582 brclr out3sparkd,feature2,soin9 7583 bset Output3,portd 7584 soin9: 7585 lda feature8_f 7586 bit #spkeopb 7587 beq soin10 7588 bset pin10,portc 7589 soin10: 7590 lda feature8_f 7591 bit #spkfopb 7592 beq soin11 7593 bset KnockIn,portd 7594 soin11: 7595 soin_done: 7596 7597 ;kill the dwell timers too just in case 7598 clr SparkOnLeftah 7599 clr SparkOnLeftal 7600 clr SparkOnLeftbh 7601 clr SparkOnLeftbl 7602 clr SparkOnLeftch 7603 clr SparkOnLeftcl 7604 clr SparkOnLeftdh 7605 clr SparkOnLeftdl 7606 clr SparkOnLefteh 7607 clr SparkOnLeftel 7608 clr SparkOnLeftfh 7609 clr SparkOnLeftfl 7610 9FDC 7611 $MACROEND 7612 7613 *************************************************************************** 7614 9FDC 7615 $MACRO SubDwell 7616 lda dwelltmpLop 7617 sub dwellusl ; dwell target calc'd just earlier 7618 sta dwelltmpLop ; temp result 7619 lda dwelltmpHop 7620 sbc dwellush 7621 sta dwelltmpHop 7622 lda dwelltmpXop 7623 sbc #0 7624 sta dwelltmpXop 9FDC 7625 $MACROEND 9FDC 7626 $MACRO DwellRail 7627 ; check if we've gone too low 7628 lda dwelltmpXop 7629 beq dwlnwchk 7630 bit #$80 7631 bne dwlnwrail ; gone negative. Rail. 7632 bra dwlnwok ; X byte>0 so dwell long enough 7633 dwlnwchk: 7634 lda dwelltmpHop 7635 bne dwlnwok ; H byte>0 so dwell long enough 7636 lda dwelltmpLop 7637 cmp mindischg_f 7638 bhs dwlnwok 7639 dwlnwrail: 7640 clr dwelltmpXop ; rail dwell delay at min discharge 7641 clr dwelltmpHop 7642 lda mindischg_f 7643 sta dwelltmpLop 7644 dwlnwok: 9FDC 7645 $MACROEND 7646 9FDC 7647 $MACRO DwellDiv 7648 ;store result. Convert us to 0.1ms 7649 ; don't use udvd32 - wasteful, only need 24/8bit divide 7650 clrh 7651 ldx #100T 7652 lda dwelltmpXop msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 69 MC68HC908GP32 User Bootloader 7653 div ;A rem H = (H:A) / X 7654 sta dwelltmpXms 7655 lda dwelltmpHop 7656 div 7657 sta dwelltmpHms 7658 lda dwelltmpLop 7659 div 7660 sta dwelltmpLms 7661 7662 lda dwelltmpXms 7663 beq dwlldend ; too long, rail to max 7664 lda #255T 7665 sta dwelltmpHms 7666 sta dwelltmpLms 7667 7668 dwlldend: 7669 7670 ;check for high speed when dwell and period may be close 7671 lda dwelltmpHms 7672 bne save_dwell 7673 7674 lda dwelltmpLms 7675 cmp mindischg_f ; check if less than minimum period 7676 bhi save_dwell 7677 dwell_lim: ; target dwell period>available period 7678 clr dwelltmpHms 7679 lda mindischg_f 7680 sta dwelltmpLms ; minimum X x 0.1ms non-dwell time 7681 7682 save_dwell: 7683 ;move calculation variable into variable used by CalcDwellspk 7684 ldhx dwelltmpHms 9FDC 7685 $MACROEND 7686 7687 *************************************************************************** 7688 7689 turnallsparkoff: 9FDC macro 7690 TurnAllSpkOff 9FDC 0D6910 7691 BRCLR INVSPK,ENHANCEDBITS4,SOIN 9FDF 1300 7692 BCLR IASC,PORTA 9FE1 1102 7693 BCLR SLED,PORTC 9FE3 1502 7694 BCLR WLED,PORTC 9FE5 1302 7695 BCLR ALED,PORTC 9FE7 1103 7696 BCLR OUTPUT3,PORTD 9FE9 1702 7697 BCLR PIN10,PORTC 9FEB 1503 7698 BCLR KNOCKIN,PORTD 9FED 203E 7699 BRA SOIN_DONE 7700 SOIN: 9FEF 006204 7701 BRSET REUSE_FIDLE,OUTPUTPINS,SOIN1 9FF2 1300 7702 BCLR IASC,PORTA 9FF4 2002 7703 BRA SOIN2 9FF6 1200 7704 SOIN1: BSET IASC,PORTA 9FF8 026204 7705 SOIN2: BRSET REUSE_LED17,OUTPUTPINS,SOIN3 9FFB 1102 7706 BCLR SLED,PORTC 9FFD 2002 7707 BRA SOIN4 9FFF 1002 7708 SOIN3: BSET SLED,PORTC A001 086204 7709 SOIN4: BRSET REUSE_LED19,OUTPUTPINS,SOIN5 A004 1302 7710 BCLR ALED,PORTC A006 2002 7711 BRA SOIN6 A008 1202 7712 SOIN5: BSET ALED,PORTC A00A 056207 7713 SOIN6: BRCLR REUSE_LED18,OUTPUTPINS,SOIN7 A00D 076204 7714 BRCLR REUSE_LED18_2,OUTPUTPINS,SOIN7 A010 1402 7715 BSET WLED,PORTC A012 2002 7716 BRA SOIN8 A014 1502 7717 SOIN7: BCLR WLED,PORTC 7718 SOIN8: A016 096402 7719 BRCLR OUT3SPARKD,FEATURE2,SOIN9 A019 1003 7720 BSET OUTPUT3,PORTD 7721 SOIN9: A01B C6E074 7722 LDA FEATURE8_F A01E A508 7723 BIT #SPKEOPB A020 2702 7724 BEQ SOIN10 A022 1602 7725 BSET PIN10,PORTC 7726 SOIN10: A024 C6E074 7727 LDA FEATURE8_F A027 A510 7728 BIT #SPKFOPB A029 2702 7729 BEQ SOIN11 A02B 1403 7730 BSET KNOCKIN,PORTD 7731 SOIN11: 7732 SOIN_DONE: A02D 3FB3 7733 CLR SPARKONLEFTAH A02F 3FB4 7734 CLR SPARKONLEFTAL A031 3FB5 7735 CLR SPARKONLEFTBH A033 3FB6 7736 CLR SPARKONLEFTBL A035 3FB7 7737 CLR SPARKONLEFTCH A037 3FB8 7738 CLR SPARKONLEFTCL A039 3FB9 7739 CLR SPARKONLEFTDH A03B 3FBA 7740 CLR SPARKONLEFTDL A03D 3FBB 7741 CLR SPARKONLEFTEH A03F 3FBC 7742 CLR SPARKONLEFTEL A041 3FBD 7743 CLR SPARKONLEFTFH A043 3FBE 7744 CLR SPARKONLEFTFL A045 81 7745 rts 7746 *************************************************************************** 7747 * Spark and Dwell stuff 7748 * Some bits moved out of interrupt routines to save a few ticks 7749 *************************************************************************** 7750 * The following table is a dwell period vs battery voltage correction table 7751 * derived from 7752 * T = -L/R * ln(1- RI/V) 7753 *************************************************************************** 7754 A046 33445566 7755 dwelltv: db 51T,68T,85T,102T,119T,136T ; 6v,8v,10v,12v,14v,16v 7788 A04C FA7C5440 7756 dwelltf: db 250T,124T,84T,64T,51T,44T 332C 7757 ;Values in table are /4 (i.e. 250 = 250/256*4 = x 3.9) 7758 7759 misc_spark: A052 004200 7760 brset running,engine,hei7_spd ; skip next check 7761 ;if not running then make sure all spark outputs are OFF 7762 ;this is a bandaid, but better safe than sorry 7763 ; TurnAllSpkOff ; macro to stop them all - moved to mainloop 7764 ; 7765 hei7_spd: 7766 ;moved from Sparktime - set/clr HEI7 output A055 0F6112 7767 brclr HEI7,personality,dwellornot 7768 ;024a changed the logic, now transitions when fully out of crank (+1 second) 7769 ; and over 400rpm A058 02420D 7770 brset crank,engine,hei7zero 7771 ;cant_crank only gets set when above cranking rpm for over a second A05B 07670A 7772 brclr cant_crank,EnhancedBits2,hei7zero A05E B64D 7773 lda rpm A060 A104 7774 cmp #4T ; hardcoded 400rpm transisition A062 2504 7775 blo hei7zero 7776 hei7five: A064 1302 7777 bclr aled,portc A066 2002 7778 bra dwellornot 7779 hei7zero: 7780 ;If HEI and low speed set bypass to 0v A068 1202 7781 bset aled,portc 7782 7783 dwellornot: A06A 036546 7784 brclr dwellcont,feature7,ms_dwell ; skip if not doing real dwell 7785 7786 ;first lookup battery correction factor from above table msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 70 MC68HC908GP32 User Bootloader A06D 45A046 7787 ldhx #dwelltv A070 3594 7788 sthx tmp1 A072 6E0596 7789 mov #5,tmp3 ; 6 elements A075 4E4897 7790 mov batt,tmp4 A078 CDCF9B 7791 jsr tableLookup 7792 A07B 8C 7793 clrh A07C BE98 7794 ldx tmp5 A07E D6A04C 7795 lda dwelltf,x A081 B797 7796 sta liY2 A083 5A 7797 decx A084 D6A04C 7798 lda dwelltf,x A087 B796 7799 sta liY1 A089 B648 7800 lda batt A08B B798 7801 sta liX A08D CDCFB8 7802 jsr LinInterp 7803 ;result in tmp6 7804 A090 024205 7805 brset crank,engine,crankdwell 7806 A093 C6E06F 7807 lda dwellrun_f A096 2003 7808 bra dwell_corr 7809 crankdwell: A098 C6E06E 7810 lda dwellcrank_f 7811 dwell_corr: A09B BE99 7812 ldx tmp6 A09D 42 7813 mul ; result in x:a 7814 ;now multiply by 4 as factor table is /4 and dwell in 0.1ms units 7815 A09E 48 7816 lsla A09F 59 7817 rolx A0A0 2504 7818 bcs max_dwell 7819 A0A2 48 7820 lsla A0A3 59 7821 rolx A0A4 2402 7822 bcc do_dwell_us 7823 7824 max_dwell: A0A6 AEFF 7825 ldx #255T ; max dwell 25.5ms 7826 do_dwell_us: A0A8 BFF8 7827 stx dwelldms ; save corrected target dwell 7828 ; (in 0.1ms units) 7829 7830 ;calculate this in us A0AA A664 7831 lda #100T A0AC 42 7832 mul 7833 A0AD 9B 7834 sei ; no ints while we save these A0AE BFF9 7835 stx dwellush ; this is the microsecond duration of coil-on A0B0 B7FA 7836 sta dwellusl A0B2 9A 7837 cli 7838 7839 ; we've now calculated target dwell period 7840 7841 ;used by dwell and duty cycle 7842 ms_dwell: A0B3 9B 7843 sei ; avoid interruption between high/low bytes A0B4 4EAE95 7844 mov iTimeX,dwelltmpX ; dt-1 A0B7 4EAF96 7845 mov iTimeH,dwelltmpH A0BA 4EB097 7846 mov iTimeL,dwelltmpL A0BD 4EFD9F 7847 mov iTimepX,dwelltmpXp ; dt-2 A0C0 4EFEA0 7848 mov iTimepH,dwelltmpHp A0C3 4EFFA1 7849 mov iTimepL,dwelltmpLp A0C6 9A 7850 cli 7851 7852 ;For a single period, can.. 7853 ;predict this period iTime[this] = itime[last]) + (itime[last] - itime[previous]) 7854 ;calculate acceleration factor (itime[last] - itime[previous]) and store in dwelltmp?ac 7855 ;024n sense changed now +ve is accel, -ve is decel. Unlikely to make any difference, but 7856 ;worth a try 7857 7858 ;025n7, try reversing sense as it was doing more harm than good 7859 ;somehow I'd got the sense wrong. 7860 A0C7 B6A1 7861 lda dwelltmpLp A0C9 B097 7862 sub dwelltmpL A0CB B7A9 7863 sta dwelltmpLac ; ddt A0CD B6A0 7864 lda dwelltmpHp A0CF B296 7865 sbc dwelltmpH A0D1 B7A8 7866 sta dwelltmpHac A0D3 B69F 7867 lda dwelltmpXp A0D5 B295 7868 sbc dwelltmpX A0D7 B7A7 7869 sta dwelltmpXac 7870 7871 7872 7873 ;when in accel double the correction factor to compensate for increasing 7874 ; advance etc. and to err on the side of a bit more dwell 7875 ; brclr 7,dwelltmpXac,not_dwell_accel ; if positive i.e. decel 7876 ; lsl dwelltmpLac 7877 ; rol dwelltmpHac 7878 ; rol dwelltmpXac 7879 7880 not_dwell_accel: 7881 ;dwelltmp?ac now contains the acceleration factor (-ddt) 7882 ;re-write of this whole next section (025i) 7883 ; instead of doing some calcs and then branching, have one big section of code for each 7884 ; option. Code space isn't a problem. Brain space is! 7885 ; Various code options. 7886 ; "dwell" duty cycle for 1,2,3,4 outputs - this is pretty much the earlier 7887 ; dwell control for 1,2,3,4, rotary2 outputs 7888 7889 A0D9 036503 7890 brclr dwellcont,feature7,dwell_duty_calc A0DC CCA29C 7891 jmp true_dwell_calc 7892 dwell_duty_calc: A0DF 066903 7893 brset wspk,EnhancedBits4,wasted_dwell ; wasted spark/multi-outputs 7894 ;just add on (-ddt) A0E2 CCA1F4 7895 jmp dwlprdcalc 7896 7897 wasted_dwell: 7898 7899 ;see how many periods we want to dwell across 7900 ;Here we'll predict period between sparks on a channel 7901 ; we wait 360 degrees (could be 720 actually if someone does 4cyl COP) 7902 ;Would be desireable to go "back" only enough periods to give greater accuracy 7903 7904 ;for waste spark outputs need to add lots more correction factor 7905 ; 2 outputs = 3x 7906 ; 3 outputs = 6x 7907 ; 4 outputs = 10x 7908 ; all assumes uniform acceleration 7909 ;residue of old code, checks how many outputs 7910 ;for now always calc all periods 7911 7912 ;5th and 6th A0E5 C6E074 7913 lda feature8_f A0E8 A510 7914 bit #spkfopb A0EA 264F 7915 bne jcd_6dd A0EC A508 7916 bit #spkeopb A0EE 2648 7917 bne jcd_5dd 7918 ;check if 4th spark output in use A0F0 086442 7919 brset out3sparkd,feature2,jcd_4dd ; if 4 ops 7920 ;check if 3rd spark output in use 7921 ;don't check for 2nd output, wouldn't have got here otherwise A0F3 056248 7922 brclr REUSE_LED18,outputpins,cd_2dd ; want 1 } spark c msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 71 MC68HC908GP32 User Bootloader A0F6 076245 7923 brclr REUSE_LED18_2,outputpins,cd_2dd ; want 1 } 7924 cd_3dd: 7925 ;3 periods = 3dt-1 + 3ddt 7926 ;3x dt-1 7927 ;save a copy in dwelltmp?p A0F9 4E97A1 7928 mov dwelltmpL,dwelltmpLp A0FC 4E96A0 7929 mov dwelltmpH,dwelltmpHp A0FF 4E959F 7930 mov dwelltmpX,dwelltmpXp 7931 A102 3897 7932 lsl dwelltmpL A104 3996 7933 rol dwelltmpH A106 3995 7934 rol dwelltmpX 7935 A108 B697 7936 lda dwelltmpL A10A BBA1 7937 add dwelltmpLp A10C B797 7938 sta dwelltmpL A10E B696 7939 lda dwelltmpH A110 B9A0 7940 adc dwelltmpHp A112 B796 7941 sta dwelltmpH A114 B695 7942 lda dwelltmpX A116 B99F 7943 adc dwelltmpXp A118 B795 7944 sta dwelltmpX 7945 7946 ;2x ddt A11A 38A9 7947 lsl dwelltmpLac A11C 39A8 7948 rol dwelltmpHac A11E 39A7 7949 rol dwelltmpXac 7950 ;+ ddt A120 B697 7951 lda dwelltmpL A122 BBA9 7952 add dwelltmpLac A124 B797 7953 sta dwelltmpL A126 B696 7954 lda dwelltmpH A128 B9A8 7955 adc dwelltmpHac A12A B796 7956 sta dwelltmpH A12C B695 7957 lda dwelltmpX A12E B9A7 7958 adc dwelltmpXac A130 B795 7959 sta dwelltmpX 7960 A132 CCA1F4 7961 jmp dwlprdcalc 7962 A135 CCA14D 7963 jcd_4dd: jmp cd_4dd A138 CCA168 7964 jcd_5dd: jmp cd_5dd A13B CCA1AF 7965 jcd_6dd: jmp cd_6dd 7966 7967 cd_2dd: 7968 ;2 periods = 2dt-1 + 2ddt 7969 ;2x dt-1 A13E 3897 7970 lsl dwelltmpL A140 3996 7971 rol dwelltmpH A142 3995 7972 rol dwelltmpX 7973 ;2x ddt A144 38A9 7974 lsl dwelltmpLac A146 39A8 7975 rol dwelltmpHac A148 39A7 7976 rol dwelltmpXac 7977 A14A CCA1F4 7978 jmp dwlprdcalc 7979 7980 cd_4dd: 7981 ;4 periods = 4dt-1 + 4ddt 7982 ;4x dt-1 A14D 3897 7983 lsl dwelltmpL A14F 3996 7984 rol dwelltmpH A151 3995 7985 rol dwelltmpX 7986 A153 3897 7987 lsl dwelltmpL A155 3996 7988 rol dwelltmpH A157 3995 7989 rol dwelltmpX 7990 ;4x ddt A159 38A9 7991 lsl dwelltmpLac A15B 39A8 7992 rol dwelltmpHac A15D 39A7 7993 rol dwelltmpXac 7994 A15F 38A9 7995 lsl dwelltmpLac A161 39A8 7996 rol dwelltmpHac A163 39A7 7997 rol dwelltmpXac 7998 7999 A165 CCA1F4 8000 jmp dwlprdcalc 8001 8002 cd_5dd: 8003 ;5 periods = 5dt-1 + 5ddt 8004 ;3x dt-1 8005 ;save a copy in dwelltmp?p A168 4E97A1 8006 mov dwelltmpL,dwelltmpLp A16B 4E96A0 8007 mov dwelltmpH,dwelltmpHp A16E 4E959F 8008 mov dwelltmpX,dwelltmpXp 8009 A171 3897 8010 lsl dwelltmpL A173 3996 8011 rol dwelltmpH A175 3995 8012 rol dwelltmpX 8013 A177 3897 8014 lsl dwelltmpL A179 3996 8015 rol dwelltmpH A17B 3995 8016 rol dwelltmpX 8017 A17D B697 8018 lda dwelltmpL A17F BBA1 8019 add dwelltmpLp A181 B797 8020 sta dwelltmpL A183 B696 8021 lda dwelltmpH A185 B9A0 8022 adc dwelltmpHp A187 B796 8023 sta dwelltmpH A189 B695 8024 lda dwelltmpX A18B B99F 8025 adc dwelltmpXp A18D B795 8026 sta dwelltmpX 8027 8028 ;2x ddt A18F 38A9 8029 lsl dwelltmpLac A191 39A8 8030 rol dwelltmpHac A193 39A7 8031 rol dwelltmpXac 8032 ;2x ddt A195 38A9 8033 lsl dwelltmpLac A197 39A8 8034 rol dwelltmpHac A199 39A7 8035 rol dwelltmpXac 8036 8037 ;+ ddt A19B B697 8038 lda dwelltmpL A19D BBA9 8039 add dwelltmpLac A19F B797 8040 sta dwelltmpL A1A1 B696 8041 lda dwelltmpH A1A3 B9A8 8042 adc dwelltmpHac A1A5 B796 8043 sta dwelltmpH A1A7 B695 8044 lda dwelltmpX A1A9 B9A7 8045 adc dwelltmpXac A1AB B795 8046 sta dwelltmpX 8047 A1AD 2045 8048 bra dwlprdcalc 8049 8050 cd_6dd: 8051 ;same as 3dd x 2 8052 ;3 periods = 3dt-1 + 3ddt 8053 ;3x dt-1 8054 ;save a copy in dwelltmp?p A1AF 4E97A1 8055 mov dwelltmpL,dwelltmpLp A1B2 4E96A0 8056 mov dwelltmpH,dwelltmpHp A1B5 4E959F 8057 mov dwelltmpX,dwelltmpXp 8058 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 72 MC68HC908GP32 User Bootloader A1B8 3897 8059 lsl dwelltmpL A1BA 3996 8060 rol dwelltmpH A1BC 3995 8061 rol dwelltmpX 8062 A1BE B697 8063 lda dwelltmpL A1C0 BBA1 8064 add dwelltmpLp A1C2 B797 8065 sta dwelltmpL A1C4 B696 8066 lda dwelltmpH A1C6 B9A0 8067 adc dwelltmpHp A1C8 B796 8068 sta dwelltmpH A1CA B695 8069 lda dwelltmpX A1CC B99F 8070 adc dwelltmpXp A1CE B795 8071 sta dwelltmpX 8072 8073 ;2x ddt A1D0 38A9 8074 lsl dwelltmpLac A1D2 39A8 8075 rol dwelltmpHac A1D4 39A7 8076 rol dwelltmpXac 8077 ;+ ddt A1D6 B697 8078 lda dwelltmpL A1D8 BBA9 8079 add dwelltmpLac A1DA B797 8080 sta dwelltmpL A1DC B696 8081 lda dwelltmpH A1DE B9A8 8082 adc dwelltmpHac A1E0 B796 8083 sta dwelltmpH A1E2 B695 8084 lda dwelltmpX A1E4 B9A7 8085 adc dwelltmpXac A1E6 B795 8086 sta dwelltmpX 8087 8088 ;double it A1E8 3897 8089 lsl dwelltmpL ; high byte A1EA 3996 8090 rol dwelltmpH ; Divide by 2 to get 50% dwell A1EC 3995 8091 rol dwelltmpX 8092 ;double it A1EE 38A9 8093 lsl dwelltmpLac A1F0 39A8 8094 rol dwelltmpHac A1F2 39A7 8095 rol dwelltmpXac 8096 8097 ; bra dwlprdcalc 8098 8099 8100 dwlprdcalc: 8101 ;add off the accel factor (-ve) A1F4 B697 8102 lda dwelltmpL A1F6 BBA9 8103 add dwelltmpLac A1F8 B797 8104 sta dwelltmpL A1FA B696 8105 lda dwelltmpH A1FC B9A8 8106 adc dwelltmpHac A1FE B796 8107 sta dwelltmpH A200 B695 8108 lda dwelltmpX A202 B9A7 8109 adc dwelltmpXac A204 B795 8110 sta dwelltmpX 8111 8112 ;dwelltmp? now contains the predicted period between sparks on one ignition channel 8113 ;for single coil this is an ignition event, for wasted spark this is 360 or even 720 8114 ;we've now calculated the full period to dwell over so decide what to do with it 8115 8116 ;save an un-mutilated copy for rotary A206 4E95A7 8117 mov dwelltmpX,dwelltmpXac A209 4E96A8 8118 mov dwelltmpH,dwelltmpHac A20C 4E97A9 8119 mov dwelltmpL,dwelltmpLac 8120 A20F 3495 8121 lsr dwelltmpX ; high byte A211 3696 8122 ror dwelltmpH ; Divide by 2 to get 50% dwell A213 3697 8123 ror dwelltmpL 8124 ; 8125 ; original MSnS code uses 75%, but there was discussion that 50% might be 8126 ; more suitable for some ignition setups, so I changed it. Now made a 8127 ; config option. 8128 ; A215 0C6406 8129 brset dwellduty50,feature2,end_dwell A218 3495 8130 lsr dwelltmpX A21A 3696 8131 ror dwelltmpH A21C 3697 8132 ror dwelltmpL ; divide by 2 again to get 75% dwell 8133 8134 end_dwell: 8135 ;now convert the precision calculation into a raw 0.1ms value 8136 ;use by both dwell and duty cylce outputs 8137 8138 ; don't use udvd32 - wasteful, only need 24/8bit divide A21E 8C 8139 clrh A21F AE64 8140 ldx #100T A221 B695 8141 lda dwelltmpX A223 52 8142 div ;A rem H = (H:A) / X A224 B795 8143 sta dwelltmpX A226 B696 8144 lda dwelltmpH A228 52 8145 div A229 B796 8146 sta dwelltmpH A22B B697 8147 lda dwelltmpL A22D 52 8148 div A22E B797 8149 sta dwelltmpL 8150 A230 B695 8151 lda dwelltmpX A232 2706 8152 beq dwelldiv_end ; too long, rail to max A234 A6FF 8153 lda #255T A236 B796 8154 sta dwelltmpH A238 B797 8155 sta dwelltmpL 8156 8157 dwelldiv_end: 8158 8159 ; decide where to save it given new scheme A23A 5596 8160 ldhx dwelltmpH A23C 006A22 8161 brset rotary2,EnhancedBits5,sd_1 ; are we doing rotary split A23F 07691F 8162 brclr wspk,EnhancedBits4,sd_1 ; or non-wasted, then single output A242 C6E074 8163 lda feature8_f A245 A510 8164 bit #spkfopb A247 2641 8165 bne sd_6 A249 A508 8166 bit #spkeopb A24B 262E 8167 bne sd_5 8168 ;check if 4th spark output in use A24D 08641E 8169 brset out3sparkd,feature2,sd_4 ; if 4 ops 8170 ;check if 3rd spark output in use 8171 ;don't check for 2nd output, wouldn't have got here otherwise A250 056212 8172 brclr REUSE_LED18,outputpins,sd_2 ; want 1 } spark c A253 07620F 8173 brclr REUSE_LED18_2,outputpins,sd_2 ; want 1 } 8174 sd_3: A256 35EC 8175 sthx dwelldelay3 A258 450000 8176 ldhx #0 A25B 35E8 8177 sthx dwelldelay1 A25D 35EA 8178 sthx dwelldelay2 A25F 2038 8179 bra sd_done 8180 sd_1: A261 35E8 8181 sthx dwelldelay1 A263 2034 8182 bra sd_done 8183 8184 sd_2: A265 35EA 8185 sthx dwelldelay2 A267 450000 8186 ldhx #0 A26A 35E8 8187 sthx dwelldelay1 A26C 202B 8188 bra sd_done 8189 8190 sd_4: A26E 35EE 8191 sthx dwelldelay4 A270 450000 8192 ldhx #0 A273 35E8 8193 sthx dwelldelay1 A275 35EA 8194 sthx dwelldelay2 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 73 MC68HC908GP32 User Bootloader A277 35EC 8195 sthx dwelldelay3 A279 201E 8196 bra sd_done 8197 sd_5: A27B 35F0 8198 sthx dwelldelay5 A27D 450000 8199 ldhx #0 A280 35E8 8200 sthx dwelldelay1 A282 35EA 8201 sthx dwelldelay2 A284 35EC 8202 sthx dwelldelay3 A286 35EE 8203 sthx dwelldelay4 A288 200F 8204 bra sd_done 8205 sd_6: A28A 35F2 8206 sthx dwelldelay6 A28C 450000 8207 ldhx #0 A28F 35E8 8208 sthx dwelldelay1 A291 35EA 8209 sthx dwelldelay2 A293 35EC 8210 sthx dwelldelay3 A295 35EE 8211 sthx dwelldelay4 A297 35F0 8212 sthx dwelldelay5 8213 ; bra sd_done 8214 sd_done: A299 CCA727 8215 jmp really_done_dwell 8216 8217 8218 8219 true_dwell_calc: 8220 ; One section of code depending on number of spark outputs now 8221 ; so code can apply delay of 1,2,3,4 periods back depending on rpm/advance 8222 ; this is supposed to improve dwell stability at medium speeds when engine conditions 8223 ; could have changed a lot between setting the dwell timer and the dwell starting. 8224 8225 ; Fixed duty cycle doesn't really need this lot as we always "dwell" across the whole time 8226 ; between sparks on one channel. 8227 ; Most of the comments in here are related to real dwell control. 8228 8229 ;dwellduty1 = dt-1 + acc factor - dwell dt-1 + ddt 8230 ;dwellduty2 = dwellduty1 + dt-1 + ac + ac 2dt-1 + 3ddt 8231 ;dwellduty3 = dwellduty2 + dt-1 + ac + 2ac 3dt-1 + 6ddt 8232 ;dwellduty4 = dwellduty3 + dt-1 + 4ac 4dt-1 + 10ddt 8233 8234 ;But the massive loads of correction factor seemed to do more harm than good, 8235 ;dwellduty1 = dt-1 + acc factor - dwell dt-1 + ddt 8236 ;dwellduty2 = dwellduty1 + dt-1 + ac + ac 2dt-1 + 2ddt 8237 ;dwellduty3 = dwellduty2 + dt-1 + ac + 2ac 3dt-1 + 3ddt 8238 ;dwellduty4 = dwellduty3 + dt-1 + 4ac 4dt-1 + 4ddt 8239 8240 ;add off the accel factor (-ve) dt = dt-1 + (-ddt) (predicted next period) A29C B697 8241 lda dwelltmpL ; dt-1 A29E BBA9 8242 add dwelltmpLac ; ac A2A0 B7A1 8243 sta dwelltmpLp ; used if wspk A2A2 B79A 8244 sta dwelltmpLop ; output value A2A4 B696 8245 lda dwelltmpH A2A6 B9A8 8246 adc dwelltmpHac A2A8 B7A0 8247 sta dwelltmpHp A2AA B799 8248 sta dwelltmpHop A2AC B695 8249 lda dwelltmpX A2AE B9A7 8250 adc dwelltmpXac A2B0 B79F 8251 sta dwelltmpXp A2B2 B798 8252 sta dwelltmpXop 8253 A2B4 macro 8254 SubDwell ; subtract dwell A2B4 B69A 8255 LDA DWELLTMPLOP A2B6 B0FA 8256 SUB DWELLUSL A2B8 B79A 8257 STA DWELLTMPLOP A2BA B699 8258 LDA DWELLTMPHOP A2BC B2F9 8259 SBC DWELLUSH A2BE B799 8260 STA DWELLTMPHOP A2C0 B698 8261 LDA DWELLTMPXOP A2C2 A200 8262 SBC #0 A2C4 B798 8263 STA DWELLTMPXOP 8264 A2C6 006A03 8265 brset rotary2,EnhancedBits5,cd0 A2C9 066953 8266 brset wspk,EnhancedBits4,cd1_start 8267 8268 cd0: 8269 ;we are either have one spark output or rotary. We dwell across a single period only. A2CC macro 8270 DwellRail ; check if negative or less than mindischarge A2CC B698 8271 LDA DWELLTMPXOP A2CE 2706 8272 BEQ DWLNWCHK A2D0 A580 8273 BIT #$80 A2D2 260D 8274 BNE DWLNWRAIL A2D4 2014 8275 BRA DWLNWOK 8276 DWLNWCHK: A2D6 B699 8277 LDA DWELLTMPHOP A2D8 2610 8278 BNE DWLNWOK A2DA B69A 8279 LDA DWELLTMPLOP A2DC C1E08F 8280 CMP MINDISCHG_F A2DF 2409 8281 BHS DWLNWOK 8282 DWLNWRAIL: A2E1 3F98 8283 CLR DWELLTMPXOP A2E3 3F99 8284 CLR DWELLTMPHOP A2E5 C6E08F 8285 LDA MINDISCHG_F A2E8 B79A 8286 STA DWELLTMPLOP 8287 DWLNWOK: A2EA macro 8288 DwellDiv ; convert microseconds to 0.1ms units A2EA 8C 8289 CLRH A2EB AE64 8290 LDX #100T A2ED B698 8291 LDA DWELLTMPXOP A2EF 52 8292 DIV A2F0 B79B 8293 STA DWELLTMPXMS A2F2 B699 8294 LDA DWELLTMPHOP A2F4 52 8295 DIV A2F5 B79C 8296 STA DWELLTMPHMS A2F7 B69A 8297 LDA DWELLTMPLOP A2F9 52 8298 DIV A2FA B79D 8299 STA DWELLTMPLMS A2FC B69B 8300 LDA DWELLTMPXMS A2FE 2706 8301 BEQ DWLLDEND A300 A6FF 8302 LDA #255T A302 B79C 8303 STA DWELLTMPHMS A304 B79D 8304 STA DWELLTMPLMS 8305 DWLLDEND: A306 B69C 8306 LDA DWELLTMPHMS A308 260E 8307 BNE SAVE_DWELL A30A B69D 8308 LDA DWELLTMPLMS A30C C1E08F 8309 CMP MINDISCHG_F A30F 2207 8310 BHI SAVE_DWELL 8311 DWELL_LIM: A311 3F9C 8312 CLR DWELLTMPHMS A313 C6E08F 8313 LDA MINDISCHG_F A316 B79D 8314 STA DWELLTMPLMS 8315 SAVE_DWELL: A318 559C 8316 LDHX DWELLTMPHMS A31A 35E8 8317 sthx dwelldelay1 A31C CCA727 8318 jmp really_done_dwell 8319 8320 cd1_start: 8321 ;check to see if value we _would_ store in dwelldelay1 is negative 8322 ; ie. top bit set A31F B698 8323 lda dwelltmpXop A321 2B32 8324 bmi cd_1rail ; if pos ok, else set to zero ?? is BMI correct? A323 macro 8325 DwellDiv A323 8C 8326 CLRH A324 AE64 8327 LDX #100T A326 B698 8328 LDA DWELLTMPXOP A328 52 8329 DIV A329 B79B 8330 STA DWELLTMPXMS msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 74 MC68HC908GP32 User Bootloader A32B B699 8331 LDA DWELLTMPHOP A32D 52 8332 DIV A32E B79C 8333 STA DWELLTMPHMS A330 B69A 8334 LDA DWELLTMPLOP A332 52 8335 DIV A333 B79D 8336 STA DWELLTMPLMS A335 B69B 8337 LDA DWELLTMPXMS A337 2706 8338 BEQ DWLLDEND A339 A6FF 8339 LDA #255T A33B B79C 8340 STA DWELLTMPHMS A33D B79D 8341 STA DWELLTMPLMS 8342 DWLLDEND: A33F B69C 8343 LDA DWELLTMPHMS A341 260E 8344 BNE SAVE_DWELL A343 B69D 8345 LDA DWELLTMPLMS A345 C1E08F 8346 CMP MINDISCHG_F A348 2207 8347 BHI SAVE_DWELL 8348 DWELL_LIM: A34A 3F9C 8349 CLR DWELLTMPHMS A34C C6E08F 8350 LDA MINDISCHG_F A34F B79D 8351 STA DWELLTMPLMS 8352 SAVE_DWELL: A351 559C 8353 LDHX DWELLTMPHMS A353 2003 8354 bra cd_1store 8355 cd_1rail: A355 450000 8356 ldhx #0 8357 cd_1store: A358 35E8 8358 sthx dwelldelay1 8359 cd_2: 8360 ;dd2 = dd1 +dt-1 + ac + ac A35A B6A1 8361 lda dwelltmpLp ; period without dwell removed A35C BB97 8362 add dwelltmpL A35E B7A1 8363 sta dwelltmpLp ; now 2 periods ready for next calc A360 B79A 8364 sta dwelltmpLop A362 B6A0 8365 lda dwelltmpHp A364 B996 8366 adc dwelltmpH A366 B7A0 8367 sta dwelltmpHp A368 B799 8368 sta dwelltmpHop A36A B69F 8369 lda dwelltmpXp A36C B995 8370 adc dwelltmpX A36E B79F 8371 sta dwelltmpXp A370 B798 8372 sta dwelltmpXop 8373 A372 B69A 8374 lda dwelltmpLop A374 BBA9 8375 add dwelltmpLac A376 B79A 8376 sta dwelltmpLop A378 B699 8377 lda dwelltmpHop A37A B9A8 8378 adc dwelltmpHac A37C B799 8379 sta dwelltmpHop A37E B698 8380 lda dwelltmpXop A380 B9A7 8381 adc dwelltmpXac A382 B798 8382 sta dwelltmpXop 8383 A384 macro 8384 SubDwell ; subtract dwell A384 B69A 8385 LDA DWELLTMPLOP A386 B0FA 8386 SUB DWELLUSL A388 B79A 8387 STA DWELLTMPLOP A38A B699 8388 LDA DWELLTMPHOP A38C B2F9 8389 SBC DWELLUSH A38E B799 8390 STA DWELLTMPHOP A390 B698 8391 LDA DWELLTMPXOP A392 A200 8392 SBC #0 A394 B798 8393 STA DWELLTMPXOP 8394 A396 056205 8395 brclr REUSE_LED18,outputpins,cd2_done ; want 1 } spark c A399 076202 8396 brclr REUSE_LED18_2,outputpins,cd2_done ; want 1 } A39C 2053 8397 bra cd2_cont 8398 cd2_done: A39E macro 8399 DwellRail ; check if negative or less than mindischarge A39E B698 8400 LDA DWELLTMPXOP A3A0 2706 8401 BEQ DWLNWCHK A3A2 A580 8402 BIT #$80 A3A4 260D 8403 BNE DWLNWRAIL A3A6 2014 8404 BRA DWLNWOK 8405 DWLNWCHK: A3A8 B699 8406 LDA DWELLTMPHOP A3AA 2610 8407 BNE DWLNWOK A3AC B69A 8408 LDA DWELLTMPLOP A3AE C1E08F 8409 CMP MINDISCHG_F A3B1 2409 8410 BHS DWLNWOK 8411 DWLNWRAIL: A3B3 3F98 8412 CLR DWELLTMPXOP A3B5 3F99 8413 CLR DWELLTMPHOP A3B7 C6E08F 8414 LDA MINDISCHG_F A3BA B79A 8415 STA DWELLTMPLOP 8416 DWLNWOK: A3BC macro 8417 DwellDiv ; convert microseconds to 0.1ms units A3BC 8C 8418 CLRH A3BD AE64 8419 LDX #100T A3BF B698 8420 LDA DWELLTMPXOP A3C1 52 8421 DIV A3C2 B79B 8422 STA DWELLTMPXMS A3C4 B699 8423 LDA DWELLTMPHOP A3C6 52 8424 DIV A3C7 B79C 8425 STA DWELLTMPHMS A3C9 B69A 8426 LDA DWELLTMPLOP A3CB 52 8427 DIV A3CC B79D 8428 STA DWELLTMPLMS A3CE B69B 8429 LDA DWELLTMPXMS A3D0 2706 8430 BEQ DWLLDEND A3D2 A6FF 8431 LDA #255T A3D4 B79C 8432 STA DWELLTMPHMS A3D6 B79D 8433 STA DWELLTMPLMS 8434 DWLLDEND: A3D8 B69C 8435 LDA DWELLTMPHMS A3DA 260E 8436 BNE SAVE_DWELL A3DC B69D 8437 LDA DWELLTMPLMS A3DE C1E08F 8438 CMP MINDISCHG_F A3E1 2207 8439 BHI SAVE_DWELL 8440 DWELL_LIM: A3E3 3F9C 8441 CLR DWELLTMPHMS A3E5 C6E08F 8442 LDA MINDISCHG_F A3E8 B79D 8443 STA DWELLTMPLMS 8444 SAVE_DWELL: A3EA 559C 8445 LDHX DWELLTMPHMS A3EC 35EA 8446 sthx dwelldelay2 8447 ; ldhx #0 8448 ; sthx dwelldelay3 8449 ; sthx dwelldelay4 A3EE CCA727 8450 jmp really_done_dwell 8451 8452 cd2_cont: 8453 ;check to see if value we _would_ store in dwelldelay2 is negative 8454 ; ie. top bit set A3F1 B698 8455 lda dwelltmpXop A3F3 2B32 8456 bmi cd_2rail ; if pos ok, else set to zero ?? is BPL correct? A3F5 macro 8457 DwellDiv A3F5 8C 8458 CLRH A3F6 AE64 8459 LDX #100T A3F8 B698 8460 LDA DWELLTMPXOP A3FA 52 8461 DIV A3FB B79B 8462 STA DWELLTMPXMS A3FD B699 8463 LDA DWELLTMPHOP A3FF 52 8464 DIV A400 B79C 8465 STA DWELLTMPHMS A402 B69A 8466 LDA DWELLTMPLOP msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 75 MC68HC908GP32 User Bootloader A404 52 8467 DIV A405 B79D 8468 STA DWELLTMPLMS A407 B69B 8469 LDA DWELLTMPXMS A409 2706 8470 BEQ DWLLDEND A40B A6FF 8471 LDA #255T A40D B79C 8472 STA DWELLTMPHMS A40F B79D 8473 STA DWELLTMPLMS 8474 DWLLDEND: A411 B69C 8475 LDA DWELLTMPHMS A413 260E 8476 BNE SAVE_DWELL A415 B69D 8477 LDA DWELLTMPLMS A417 C1E08F 8478 CMP MINDISCHG_F A41A 2207 8479 BHI SAVE_DWELL 8480 DWELL_LIM: A41C 3F9C 8481 CLR DWELLTMPHMS A41E C6E08F 8482 LDA MINDISCHG_F A421 B79D 8483 STA DWELLTMPLMS 8484 SAVE_DWELL: A423 559C 8485 LDHX DWELLTMPHMS A425 2003 8486 bra cd_2store 8487 cd_2rail: A427 450000 8488 ldhx #0 8489 cd_2store: A42A 35EA 8490 sthx dwelldelay2 8491 8492 cd_3: 8493 ;3 periods = 3dt-1 + 3ddt 8494 ;3x dt-1 8495 ;save a copy in dwelltmp?p 8496 A42C B6A1 8497 lda dwelltmpLp ; period without dwell removed A42E BB97 8498 add dwelltmpL A430 B7A1 8499 sta dwelltmpLp ; now 3 periods ready for next calc A432 B79A 8500 sta dwelltmpLop A434 B6A0 8501 lda dwelltmpHp A436 B996 8502 adc dwelltmpH A438 B7A0 8503 sta dwelltmpHp A43A B799 8504 sta dwelltmpHop A43C B69F 8505 lda dwelltmpXp A43E B995 8506 adc dwelltmpX A440 B79F 8507 sta dwelltmpXp A442 B798 8508 sta dwelltmpXop 8509 A444 B69A 8510 lda dwelltmpLop A446 BBA9 8511 add dwelltmpLac A448 B79A 8512 sta dwelltmpLop A44A B699 8513 lda dwelltmpHop A44C B9A8 8514 adc dwelltmpHac A44E B799 8515 sta dwelltmpHop A450 B698 8516 lda dwelltmpXop A452 B9A7 8517 adc dwelltmpXac A454 B798 8518 sta dwelltmpXop 8519 A456 macro 8520 SubDwell ; subtract dwell A456 B69A 8521 LDA DWELLTMPLOP A458 B0FA 8522 SUB DWELLUSL A45A B79A 8523 STA DWELLTMPLOP A45C B699 8524 LDA DWELLTMPHOP A45E B2F9 8525 SBC DWELLUSH A460 B799 8526 STA DWELLTMPHOP A462 B698 8527 LDA DWELLTMPXOP A464 A200 8528 SBC #0 A466 B798 8529 STA DWELLTMPXOP 8530 A468 086453 8531 brset out3sparkd,feature2,cd3_cont ; if 4 outputs 8532 cd3_done: A46B macro 8533 DwellRail ; check if negative or less than mindischarge A46B B698 8534 LDA DWELLTMPXOP A46D 2706 8535 BEQ DWLNWCHK A46F A580 8536 BIT #$80 A471 260D 8537 BNE DWLNWRAIL A473 2014 8538 BRA DWLNWOK 8539 DWLNWCHK: A475 B699 8540 LDA DWELLTMPHOP A477 2610 8541 BNE DWLNWOK A479 B69A 8542 LDA DWELLTMPLOP A47B C1E08F 8543 CMP MINDISCHG_F A47E 2409 8544 BHS DWLNWOK 8545 DWLNWRAIL: A480 3F98 8546 CLR DWELLTMPXOP A482 3F99 8547 CLR DWELLTMPHOP A484 C6E08F 8548 LDA MINDISCHG_F A487 B79A 8549 STA DWELLTMPLOP 8550 DWLNWOK: A489 macro 8551 DwellDiv ; convert microseconds to 0.1ms units A489 8C 8552 CLRH A48A AE64 8553 LDX #100T A48C B698 8554 LDA DWELLTMPXOP A48E 52 8555 DIV A48F B79B 8556 STA DWELLTMPXMS A491 B699 8557 LDA DWELLTMPHOP A493 52 8558 DIV A494 B79C 8559 STA DWELLTMPHMS A496 B69A 8560 LDA DWELLTMPLOP A498 52 8561 DIV A499 B79D 8562 STA DWELLTMPLMS A49B B69B 8563 LDA DWELLTMPXMS A49D 2706 8564 BEQ DWLLDEND A49F A6FF 8565 LDA #255T A4A1 B79C 8566 STA DWELLTMPHMS A4A3 B79D 8567 STA DWELLTMPLMS 8568 DWLLDEND: A4A5 B69C 8569 LDA DWELLTMPHMS A4A7 260E 8570 BNE SAVE_DWELL A4A9 B69D 8571 LDA DWELLTMPLMS A4AB C1E08F 8572 CMP MINDISCHG_F A4AE 2207 8573 BHI SAVE_DWELL 8574 DWELL_LIM: A4B0 3F9C 8575 CLR DWELLTMPHMS A4B2 C6E08F 8576 LDA MINDISCHG_F A4B5 B79D 8577 STA DWELLTMPLMS 8578 SAVE_DWELL: A4B7 559C 8579 LDHX DWELLTMPHMS A4B9 35EC 8580 sthx dwelldelay3 8581 ; ldhx #0 8582 ; sthx dwelldelay4 A4BB CCA727 8583 jmp really_done_dwell 8584 8585 cd3_cont: 8586 ;check to see if value we _would_ store in dwelldelay3 is negative 8587 ; ie. top bit set A4BE B698 8588 lda dwelltmpXop A4C0 2B32 8589 bmi cd_3rail ; if pos ok, else set to zero ?? is BPL correct? A4C2 macro 8590 DwellDiv A4C2 8C 8591 CLRH A4C3 AE64 8592 LDX #100T A4C5 B698 8593 LDA DWELLTMPXOP A4C7 52 8594 DIV A4C8 B79B 8595 STA DWELLTMPXMS A4CA B699 8596 LDA DWELLTMPHOP A4CC 52 8597 DIV A4CD B79C 8598 STA DWELLTMPHMS A4CF B69A 8599 LDA DWELLTMPLOP A4D1 52 8600 DIV A4D2 B79D 8601 STA DWELLTMPLMS A4D4 B69B 8602 LDA DWELLTMPXMS msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 76 MC68HC908GP32 User Bootloader A4D6 2706 8603 BEQ DWLLDEND A4D8 A6FF 8604 LDA #255T A4DA B79C 8605 STA DWELLTMPHMS A4DC B79D 8606 STA DWELLTMPLMS 8607 DWLLDEND: A4DE B69C 8608 LDA DWELLTMPHMS A4E0 260E 8609 BNE SAVE_DWELL A4E2 B69D 8610 LDA DWELLTMPLMS A4E4 C1E08F 8611 CMP MINDISCHG_F A4E7 2207 8612 BHI SAVE_DWELL 8613 DWELL_LIM: A4E9 3F9C 8614 CLR DWELLTMPHMS A4EB C6E08F 8615 LDA MINDISCHG_F A4EE B79D 8616 STA DWELLTMPLMS 8617 SAVE_DWELL: A4F0 559C 8618 LDHX DWELLTMPHMS A4F2 2003 8619 bra cd_3store 8620 cd_3rail: A4F4 450000 8621 ldhx #0 8622 cd_3store: A4F7 35EC 8623 sthx dwelldelay3 8624 8625 8626 8627 cd_4: 8628 ; suspicion that this calc is not working right 8629 ;4 periods = 4dt-1 + 10ddt 8630 ;double ac factor again to make it -4ddt ; but we wanted -10ddt ?! A4F9 38A9 8631 lsl dwelltmpLac A4FB 39A8 8632 rol dwelltmpHac A4FD 39A7 8633 rol dwelltmpXac 8634 A4FF B6A1 8635 lda dwelltmpLp ; period without dwell removed A501 BB97 8636 add dwelltmpL 8637 ; sta dwelltmpLp ; now 4 periods ready for next calc A503 B79A 8638 sta dwelltmpLop A505 B6A0 8639 lda dwelltmpHp A507 B996 8640 adc dwelltmpH 8641 ; sta dwelltmpHp A509 B799 8642 sta dwelltmpHop A50B B69F 8643 lda dwelltmpXp A50D B995 8644 adc dwelltmpX 8645 ; sta dwelltmpXp A50F B798 8646 sta dwelltmpXop 8647 A511 B69A 8648 lda dwelltmpLop A513 BBA9 8649 add dwelltmpLac A515 B79A 8650 sta dwelltmpLop A517 B699 8651 lda dwelltmpHop A519 B9A8 8652 adc dwelltmpHac A51B B799 8653 sta dwelltmpHop A51D B698 8654 lda dwelltmpXop A51F B9A7 8655 adc dwelltmpXac A521 B798 8656 sta dwelltmpXop 8657 A523 macro 8658 SubDwell ; subtract dwell A523 B69A 8659 LDA DWELLTMPLOP A525 B0FA 8660 SUB DWELLUSL A527 B79A 8661 STA DWELLTMPLOP A529 B699 8662 LDA DWELLTMPHOP A52B B2F9 8663 SBC DWELLUSH A52D B799 8664 STA DWELLTMPHOP A52F B698 8665 LDA DWELLTMPXOP A531 A200 8666 SBC #0 A533 B798 8667 STA DWELLTMPXOP 8668 A535 C6E074 8669 lda feature8_f A538 A508 8670 bit #spkeopb A53A 2653 8671 bne cd4_cont ; if 5 outputs 8672 cd4_done: A53C macro 8673 DwellRail ; check if negative or less than mindischarge A53C B698 8674 LDA DWELLTMPXOP A53E 2706 8675 BEQ DWLNWCHK A540 A580 8676 BIT #$80 A542 260D 8677 BNE DWLNWRAIL A544 2014 8678 BRA DWLNWOK 8679 DWLNWCHK: A546 B699 8680 LDA DWELLTMPHOP A548 2610 8681 BNE DWLNWOK A54A B69A 8682 LDA DWELLTMPLOP A54C C1E08F 8683 CMP MINDISCHG_F A54F 2409 8684 BHS DWLNWOK 8685 DWLNWRAIL: A551 3F98 8686 CLR DWELLTMPXOP A553 3F99 8687 CLR DWELLTMPHOP A555 C6E08F 8688 LDA MINDISCHG_F A558 B79A 8689 STA DWELLTMPLOP 8690 DWLNWOK: A55A macro 8691 DwellDiv ; convert microseconds to 0.1ms units A55A 8C 8692 CLRH A55B AE64 8693 LDX #100T A55D B698 8694 LDA DWELLTMPXOP A55F 52 8695 DIV A560 B79B 8696 STA DWELLTMPXMS A562 B699 8697 LDA DWELLTMPHOP A564 52 8698 DIV A565 B79C 8699 STA DWELLTMPHMS A567 B69A 8700 LDA DWELLTMPLOP A569 52 8701 DIV A56A B79D 8702 STA DWELLTMPLMS A56C B69B 8703 LDA DWELLTMPXMS A56E 2706 8704 BEQ DWLLDEND A570 A6FF 8705 LDA #255T A572 B79C 8706 STA DWELLTMPHMS A574 B79D 8707 STA DWELLTMPLMS 8708 DWLLDEND: A576 B69C 8709 LDA DWELLTMPHMS A578 260E 8710 BNE SAVE_DWELL A57A B69D 8711 LDA DWELLTMPLMS A57C C1E08F 8712 CMP MINDISCHG_F A57F 2207 8713 BHI SAVE_DWELL 8714 DWELL_LIM: A581 3F9C 8715 CLR DWELLTMPHMS A583 C6E08F 8716 LDA MINDISCHG_F A586 B79D 8717 STA DWELLTMPLMS 8718 SAVE_DWELL: A588 559C 8719 LDHX DWELLTMPHMS A58A 35EE 8720 sthx dwelldelay4 8721 ; ldhx #0 8722 ; sthx dwelldelay5 A58C CCA727 8723 jmp really_done_dwell 8724 8725 cd4_cont: 8726 ;check to see if value we _would_ store in dwelldelay4 is negative 8727 ; ie. top bit set A58F B698 8728 lda dwelltmpXop A591 2B32 8729 bmi cd_4rail ; if pos ok, else set to zero ?? is BPL correct? A593 macro 8730 DwellDiv A593 8C 8731 CLRH A594 AE64 8732 LDX #100T A596 B698 8733 LDA DWELLTMPXOP A598 52 8734 DIV A599 B79B 8735 STA DWELLTMPXMS A59B B699 8736 LDA DWELLTMPHOP A59D 52 8737 DIV A59E B79C 8738 STA DWELLTMPHMS msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 77 MC68HC908GP32 User Bootloader A5A0 B69A 8739 LDA DWELLTMPLOP A5A2 52 8740 DIV A5A3 B79D 8741 STA DWELLTMPLMS A5A5 B69B 8742 LDA DWELLTMPXMS A5A7 2706 8743 BEQ DWLLDEND A5A9 A6FF 8744 LDA #255T A5AB B79C 8745 STA DWELLTMPHMS A5AD B79D 8746 STA DWELLTMPLMS 8747 DWLLDEND: A5AF B69C 8748 LDA DWELLTMPHMS A5B1 260E 8749 BNE SAVE_DWELL A5B3 B69D 8750 LDA DWELLTMPLMS A5B5 C1E08F 8751 CMP MINDISCHG_F A5B8 2207 8752 BHI SAVE_DWELL 8753 DWELL_LIM: A5BA 3F9C 8754 CLR DWELLTMPHMS A5BC C6E08F 8755 LDA MINDISCHG_F A5BF B79D 8756 STA DWELLTMPLMS 8757 SAVE_DWELL: A5C1 559C 8758 LDHX DWELLTMPHMS A5C3 2003 8759 bra cd_4store 8760 cd_4rail: A5C5 450000 8761 ldhx #0 8762 cd_4store: A5C8 35EE 8763 sthx dwelldelay4 8764 8765 cd_5: 8766 ;---------------------- 8767 ;5 periods = 5dt-1 + 10ddt 8768 ;double ac factor again to make it -4ddt ; but we wanted -10ddt ?! A5CA 38A9 8769 lsl dwelltmpLac ; really ?? A5CC 39A8 8770 rol dwelltmpHac A5CE 39A7 8771 rol dwelltmpXac 8772 A5D0 B6A1 8773 lda dwelltmpLp ; period without dwell removed A5D2 BB97 8774 add dwelltmpL 8775 ; sta dwelltmpLp ; now 4 periods ready for next calc A5D4 B79A 8776 sta dwelltmpLop A5D6 B6A0 8777 lda dwelltmpHp A5D8 B996 8778 adc dwelltmpH 8779 ; sta dwelltmpHp A5DA B799 8780 sta dwelltmpHop A5DC B69F 8781 lda dwelltmpXp A5DE B995 8782 adc dwelltmpX 8783 ; sta dwelltmpXp A5E0 B798 8784 sta dwelltmpXop 8785 A5E2 B69A 8786 lda dwelltmpLop A5E4 BBA9 8787 add dwelltmpLac A5E6 B79A 8788 sta dwelltmpLop A5E8 B699 8789 lda dwelltmpHop A5EA B9A8 8790 adc dwelltmpHac A5EC B799 8791 sta dwelltmpHop A5EE B698 8792 lda dwelltmpXop A5F0 B9A7 8793 adc dwelltmpXac A5F2 B798 8794 sta dwelltmpXop 8795 A5F4 macro 8796 SubDwell ; subtract dwell A5F4 B69A 8797 LDA DWELLTMPLOP A5F6 B0FA 8798 SUB DWELLUSL A5F8 B79A 8799 STA DWELLTMPLOP A5FA B699 8800 LDA DWELLTMPHOP A5FC B2F9 8801 SBC DWELLUSH A5FE B799 8802 STA DWELLTMPHOP A600 B698 8803 LDA DWELLTMPXOP A602 A200 8804 SBC #0 A604 B798 8805 STA DWELLTMPXOP 8806 A606 C6E074 8807 lda feature8_f A609 A510 8808 bit #spkfopb A60B 2653 8809 bne cd5_cont ; if 6 outputs 8810 cd5_done: A60D macro 8811 DwellRail ; check if negative or less than mindischarge A60D B698 8812 LDA DWELLTMPXOP A60F 2706 8813 BEQ DWLNWCHK A611 A580 8814 BIT #$80 A613 260D 8815 BNE DWLNWRAIL A615 2014 8816 BRA DWLNWOK 8817 DWLNWCHK: A617 B699 8818 LDA DWELLTMPHOP A619 2610 8819 BNE DWLNWOK A61B B69A 8820 LDA DWELLTMPLOP A61D C1E08F 8821 CMP MINDISCHG_F A620 2409 8822 BHS DWLNWOK 8823 DWLNWRAIL: A622 3F98 8824 CLR DWELLTMPXOP A624 3F99 8825 CLR DWELLTMPHOP A626 C6E08F 8826 LDA MINDISCHG_F A629 B79A 8827 STA DWELLTMPLOP 8828 DWLNWOK: A62B macro 8829 DwellDiv ; convert microseconds to 0.1ms units A62B 8C 8830 CLRH A62C AE64 8831 LDX #100T A62E B698 8832 LDA DWELLTMPXOP A630 52 8833 DIV A631 B79B 8834 STA DWELLTMPXMS A633 B699 8835 LDA DWELLTMPHOP A635 52 8836 DIV A636 B79C 8837 STA DWELLTMPHMS A638 B69A 8838 LDA DWELLTMPLOP A63A 52 8839 DIV A63B B79D 8840 STA DWELLTMPLMS A63D B69B 8841 LDA DWELLTMPXMS A63F 2706 8842 BEQ DWLLDEND A641 A6FF 8843 LDA #255T A643 B79C 8844 STA DWELLTMPHMS A645 B79D 8845 STA DWELLTMPLMS 8846 DWLLDEND: A647 B69C 8847 LDA DWELLTMPHMS A649 260E 8848 BNE SAVE_DWELL A64B B69D 8849 LDA DWELLTMPLMS A64D C1E08F 8850 CMP MINDISCHG_F A650 2207 8851 BHI SAVE_DWELL 8852 DWELL_LIM: A652 3F9C 8853 CLR DWELLTMPHMS A654 C6E08F 8854 LDA MINDISCHG_F A657 B79D 8855 STA DWELLTMPLMS 8856 SAVE_DWELL: A659 559C 8857 LDHX DWELLTMPHMS A65B 35F0 8858 sthx dwelldelay5 A65D CCA727 8859 jmp really_done_dwell 8860 8861 cd5_cont: 8862 ;check to see if value we _would_ store in dwelldelay4 is negative 8863 ; ie. top bit set A660 B698 8864 lda dwelltmpXop A662 2B32 8865 bmi cd_5rail ; if pos ok, else set to zero ?? is BPL correct? A664 macro 8866 DwellDiv A664 8C 8867 CLRH A665 AE64 8868 LDX #100T A667 B698 8869 LDA DWELLTMPXOP A669 52 8870 DIV A66A B79B 8871 STA DWELLTMPXMS A66C B699 8872 LDA DWELLTMPHOP A66E 52 8873 DIV A66F B79C 8874 STA DWELLTMPHMS msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 78 MC68HC908GP32 User Bootloader A671 B69A 8875 LDA DWELLTMPLOP A673 52 8876 DIV A674 B79D 8877 STA DWELLTMPLMS A676 B69B 8878 LDA DWELLTMPXMS A678 2706 8879 BEQ DWLLDEND A67A A6FF 8880 LDA #255T A67C B79C 8881 STA DWELLTMPHMS A67E B79D 8882 STA DWELLTMPLMS 8883 DWLLDEND: A680 B69C 8884 LDA DWELLTMPHMS A682 260E 8885 BNE SAVE_DWELL A684 B69D 8886 LDA DWELLTMPLMS A686 C1E08F 8887 CMP MINDISCHG_F A689 2207 8888 BHI SAVE_DWELL 8889 DWELL_LIM: A68B 3F9C 8890 CLR DWELLTMPHMS A68D C6E08F 8891 LDA MINDISCHG_F A690 B79D 8892 STA DWELLTMPLMS 8893 SAVE_DWELL: A692 559C 8894 LDHX DWELLTMPHMS A694 2003 8895 bra cd_5store 8896 cd_5rail: A696 450000 8897 ldhx #0 8898 cd_5store: A699 35F0 8899 sthx dwelldelay5 8900 8901 8902 cd_6: 8903 ;---------------------- 8904 ;6 periods = 6dt-1 + ??ddt 8905 ;double ac factor again to make it -4ddt ; but we wanted -10ddt ?! 8906 ;these calculations need some serious thought for 5 & 6 A69B 38A9 8907 lsl dwelltmpLac ; really ?? A69D 39A8 8908 rol dwelltmpHac A69F 39A7 8909 rol dwelltmpXac 8910 A6A1 B6A1 8911 lda dwelltmpLp ; period without dwell removed A6A3 BB97 8912 add dwelltmpL 8913 ; sta dwelltmpLp ; now 4 periods ready for next calc A6A5 B79A 8914 sta dwelltmpLop A6A7 B6A0 8915 lda dwelltmpHp A6A9 B996 8916 adc dwelltmpH 8917 ; sta dwelltmpHp A6AB B799 8918 sta dwelltmpHop A6AD B69F 8919 lda dwelltmpXp A6AF B995 8920 adc dwelltmpX 8921 ; sta dwelltmpXp A6B1 B798 8922 sta dwelltmpXop 8923 A6B3 B69A 8924 lda dwelltmpLop A6B5 BBA9 8925 add dwelltmpLac A6B7 B79A 8926 sta dwelltmpLop A6B9 B699 8927 lda dwelltmpHop A6BB B9A8 8928 adc dwelltmpHac A6BD B799 8929 sta dwelltmpHop A6BF B698 8930 lda dwelltmpXop A6C1 B9A7 8931 adc dwelltmpXac A6C3 B798 8932 sta dwelltmpXop 8933 A6C5 macro 8934 SubDwell ; subtract dwell A6C5 B69A 8935 LDA DWELLTMPLOP A6C7 B0FA 8936 SUB DWELLUSL A6C9 B79A 8937 STA DWELLTMPLOP A6CB B699 8938 LDA DWELLTMPHOP A6CD B2F9 8939 SBC DWELLUSH A6CF B799 8940 STA DWELLTMPHOP A6D1 B698 8941 LDA DWELLTMPXOP A6D3 A200 8942 SBC #0 A6D5 B798 8943 STA DWELLTMPXOP 8944 8945 ;cd6_done: A6D7 macro 8946 DwellRail ; check if negative or less than mindischarge A6D7 B698 8947 LDA DWELLTMPXOP A6D9 2706 8948 BEQ DWLNWCHK A6DB A580 8949 BIT #$80 A6DD 260D 8950 BNE DWLNWRAIL A6DF 2014 8951 BRA DWLNWOK 8952 DWLNWCHK: A6E1 B699 8953 LDA DWELLTMPHOP A6E3 2610 8954 BNE DWLNWOK A6E5 B69A 8955 LDA DWELLTMPLOP A6E7 C1E08F 8956 CMP MINDISCHG_F A6EA 2409 8957 BHS DWLNWOK 8958 DWLNWRAIL: A6EC 3F98 8959 CLR DWELLTMPXOP A6EE 3F99 8960 CLR DWELLTMPHOP A6F0 C6E08F 8961 LDA MINDISCHG_F A6F3 B79A 8962 STA DWELLTMPLOP 8963 DWLNWOK: A6F5 macro 8964 DwellDiv ; convert microseconds to 0.1ms units A6F5 8C 8965 CLRH A6F6 AE64 8966 LDX #100T A6F8 B698 8967 LDA DWELLTMPXOP A6FA 52 8968 DIV A6FB B79B 8969 STA DWELLTMPXMS A6FD B699 8970 LDA DWELLTMPHOP A6FF 52 8971 DIV A700 B79C 8972 STA DWELLTMPHMS A702 B69A 8973 LDA DWELLTMPLOP A704 52 8974 DIV A705 B79D 8975 STA DWELLTMPLMS A707 B69B 8976 LDA DWELLTMPXMS A709 2706 8977 BEQ DWLLDEND A70B A6FF 8978 LDA #255T A70D B79C 8979 STA DWELLTMPHMS A70F B79D 8980 STA DWELLTMPLMS 8981 DWLLDEND: A711 B69C 8982 LDA DWELLTMPHMS A713 260E 8983 BNE SAVE_DWELL A715 B69D 8984 LDA DWELLTMPLMS A717 C1E08F 8985 CMP MINDISCHG_F A71A 2207 8986 BHI SAVE_DWELL 8987 DWELL_LIM: A71C 3F9C 8988 CLR DWELLTMPHMS A71E C6E08F 8989 LDA MINDISCHG_F A721 B79D 8990 STA DWELLTMPLMS 8991 SAVE_DWELL: A723 559C 8992 LDHX DWELLTMPHMS A725 35F2 8993 sthx dwelldelay6 8994 ; jmp really_done_dwell 8995 8996 really_done_dwell: 8997 ;finally we've calculated everything we need to for dwell and saved it away - phew! 8998 A727 006A03 8999 brset rotary2,EnhancedBits5,rotary_split ; are we doing rotary split A72A CCA845 9000 jmp misc_spark_end 9001 ;**************** 9002 ; Rotary trailing split 9003 ; 9004 ; first check if using a fixed split 9005 ;**************** 9006 rotary_split: A72D 4EA0A8 9007 mov dwelltmpHp,dwelltmpHac ;save delay for rotary A730 4EA1A9 9008 mov dwelltmpLp,dwelltmpLac A733 C60106 9009 lda page A736 A107 9010 cmp #7 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 79 MC68HC908GP32 User Bootloader A738 2605 9011 bne fixspl_fl A73A C601D0 9012 lda {VE_r+FixedSplit_f-flash_table7} ; load ram value A73D 2003 9013 bra fixspl_c A73F C6E7C1 9014 fixspl_fl: lda FixedSplit_f 9015 fixspl_c: A742 A103 9016 cmp #$03 A744 2505 9017 blo rs_STEP_1 ; Added this as MT doesnt 9018 ; send a perfect 00T A746 B799 9019 sta tmp6 ; else use this fixed advance A748 CCA7D6 9020 jmp split_lookup_done 9021 9022 rs_STEP_1: A74B 45E7BA 9023 ldhx #KPARANGEsplit_f A74E 3594 9024 sthx tmp1 A750 6E0596 9025 mov #$05,tmp3 ; 6x6 A753 4EDB97 9026 mov kpa_n,tmp4 A756 CDCF9B 9027 jsr tableLookup A759 4E989B 9028 mov tmp5,tmp8 ; Index A75C 4E949C 9029 mov tmp1,tmp9 ; X1 A75F 4E959D 9030 mov tmp2,tmp10 ; X2 9031 9032 rs1_STEP_2: A762 45E7B4 9033 ldhx #RPMRANGEsplit_f A765 3594 9034 sthx tmp1 A767 6E0596 9035 mov #$05,tmp3 ; 6x6 A76A 4E4D97 9036 mov rpm,tmp4 A76D CDCF9B 9037 jsr tableLookup A770 4E989E 9038 mov tmp5,tmp11 ; Index A773 4E94A0 9039 mov tmp1,tmp13 ; X1 A776 4E95A1 9040 mov tmp2,tmp14 ; X2 9041 9042 rs1_STEP_3: A779 8C 9043 clrh A77A AE06 9044 ldx #$06 ; 6x6 A77C B69B 9045 lda tmp8 A77E 4A 9046 deca A77F 42 9047 mul A780 BB9E 9048 add tmp11 A782 4A 9049 deca A783 97 9050 tax A784 macro 9051 rs1X A784 C60106 9052 LDA PAGE A787 A107 9053 CMP #07T A789 2605 9054 BNE RS1XF A78B D6019F 9055 LDA {VE_R+SPLIT_F-FLASH_TABLE7},X A78E 2003 9056 BRA RS1XC A790 D6E790 9057 RS1XF: LDA SPLIT_F,X 9058 RS1XC: A793 B7A2 9059 sta tmp15 A795 5C 9060 incx A796 macro 9061 rs1X A796 C60106 9062 LDA PAGE A799 A107 9063 CMP #07T A79B 2605 9064 BNE RS1XF A79D D6019F 9065 LDA {VE_R+SPLIT_F-FLASH_TABLE7},X A7A0 2003 9066 BRA RS1XC A7A2 D6E790 9067 RS1XF: LDA SPLIT_F,X 9068 RS1XC: A7A5 B7A3 9069 sta tmp16 A7A7 AE06 9070 ldx #$06 ; 6x6 A7A9 B69B 9071 lda tmp8 A7AB 42 9072 mul A7AC BB9E 9073 add tmp11 A7AE 4A 9074 deca A7AF 97 9075 tax A7B0 macro 9076 rs1X A7B0 C60106 9077 LDA PAGE A7B3 A107 9078 CMP #07T A7B5 2605 9079 BNE RS1XF A7B7 D6019F 9080 LDA {VE_R+SPLIT_F-FLASH_TABLE7},X A7BA 2003 9081 BRA RS1XC A7BC D6E790 9082 RS1XF: LDA SPLIT_F,X 9083 RS1XC: A7BF B7A4 9084 sta tmp17 A7C1 5C 9085 incx A7C2 macro 9086 rs1X A7C2 C60106 9087 LDA PAGE A7C5 A107 9088 CMP #07T A7C7 2605 9089 BNE RS1XF A7C9 D6019F 9090 LDA {VE_R+SPLIT_F-FLASH_TABLE7},X A7CC 2003 9091 BRA RS1XC A7CE D6E790 9092 RS1XF: LDA SPLIT_F,X 9093 RS1XC: A7D1 B7A5 9094 sta tmp18 9095 A7D3 CD9DC9 9096 jsr VE_STEP_4 9097 ; result in tmp6 - contains split degrees (0-255 = 0-89.5 deg) 9098 9099 9100 split_lookup_done: 9101 ;special values 9102 ; 0 deg = no split, simultaneous 9103 ; >20 deg = do not fire trailing at all A7D6 B699 9104 lda tmp6 A7D8 A155 9105 cmp #85T ; 20deg A7DA 220C 9106 bhi trail_off ; now set >20deg for no trailing A7DC A14A 9107 cmp #74T ; 16deg A7DE 2402 9108 bhs sld2 A7E0 186A 9109 bset rsh_s,EnhancedBits5 ; set split hysteresis bit 9110 sld2: A7E2 A11F 9111 cmp #31T ; (31T = 1 deg) A7E4 250A 9112 blo trail_simult 9113 ; lda dwelltmpXac 9114 ; beq trail_split ; only do split if fast enough 9115 ; ;at slow speeds < 537rpm no trailing 9116 ; ; this is a technical limitation because the trailing split would need 9117 ; ; re-writing using the 0.1ms spark as well. No plans to do this at the mo. A7E6 2014 9118 bra trail_split ; changed by KC 9119 9120 trail_off: A7E8 6E5599 9121 mov #85T,tmp6 ; rail calc at 20deg, disabling handled elsewhere A7EB 196A 9122 bclr rsh_s,EnhancedBits5 ; clear split hysteresis bit A7ED CCA828 9123 jmp split_calc_done 9124 9125 trail_simult: A7F0 4F 9126 clra A7F1 9B 9127 sei A7F2 C70100 9128 sta splitdelH A7F5 C70101 9129 sta splitdelL A7F8 9A 9130 cli A7F9 CCA828 9131 jmp split_calc_done 9132 ; the above gives intermittent spark? so rail at 1 deg minimum 9133 ; mov #31T,tmp6 9134 9135 trail_split: A7FC B699 9136 lda tmp6 A7FE A01C 9137 sub #28T ; remove 10 deg offset A800 B799 9138 sta tmp6 ; can't go neg 9139 9140 ; now convert this split into a delay, leading to trailing 9141 ;dwelltmp?ac contains predicted period = 180 deg 9142 ;divide by 2 to get 90deg time 9143 ; already determined dwelltmpXac is zero above 9144 A802 34A8 9145 lsr dwelltmpHac ; not working ?? A804 36A9 9146 ror dwelltmpLac ; msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 80 MC68HC908GP32 User Bootloader 9147 9148 rs_mult: 9149 ;nb Sparkdlt? is equ'd to tmp17,18,19 at top 9150 ; Calculate time for delay angle 9151 ; Time for 90 deg * Angle (256=90 deg)/256 A806 B699 9152 lda tmp6 ; split angle A808 BEA9 9153 ldx dwelltmpLac A80A 42 9154 mul A80B BF97 9155 stx SparkdltL 9156 ;don't care for A 9157 A80D B699 9158 lda tmp6 A80F BEA8 9159 ldx dwelltmpHac A811 42 9160 mul A812 BF96 9161 stx SparkdltH A814 BB97 9162 add SparkdltL A816 B797 9163 sta SparkdltL A818 2402 9164 bcc rsm_ok A81A 3C96 9165 inc SparkdltH 9166 9167 rsm_ok: 9168 ;now we've calculated, save to working vars A81C 9B 9169 sei A81D B696 9170 lda SparkdltH A81F C70100 9171 sta splitdelH A822 B697 9172 lda SparkdltL A824 C70101 9173 sta splitdelL A827 9A 9174 cli 9175 split_calc_done: 9176 ;now do rpm based hysteresis of trailing on/off A828 B64D 9177 lda rpm A82A A107 9178 cmp #7T A82C 2508 9179 blo spcd2 A82E A108 9180 cmp #8T A830 2508 9181 blo trail_hys_ck A832 1A6A 9182 bset rsh_r,EnhancedBits5 ; set rpm hysteresis bit A834 2004 9183 bra trail_hys_ck 9184 spcd2: A836 1B6A 9185 bclr rsh_r,EnhancedBits5 ; clear rpm hysteresis bit A838 2003 9186 bra trail_dwell_kill 9187 trail_hys_ck: A83A 086A08 9188 brset rsh_s,EnhancedBits5,misc_spark_end 9189 9190 trail_dwell_kill: 9191 ;make sure we don't charge the trailing coil A83D 3FB7 9192 clr SparkOnleftch A83F 3FB8 9193 clr SparkOnleftcl A841 3FB9 9194 clr SparkOnleftdh A843 3FBA 9195 clr SparkOnleftdl 9196 9197 misc_spark_end: A845 81 9198 rts 9199 9200 *************************************************************************** 9201 ** 9202 ** * * * * Interrupt Section * * * * * 9203 ** 9204 ** Following interrupt service routines: 9205 ** - Timer Overflow 9206 ** - ADC Conversion Complete 9207 ** - IRQ input line transistion from high to low 9208 ** - Serial Communication received character 9209 ** - Serial Communications transmit buffer empty (send another character) 9210 ** 9211 *************************************************************************** 9212 9213 ;First some Macros used within the interrupt sections 9214 A846 9215 $MACRO COILNEG 9216 brset REUSE_FIDLE,outputpins,dslsx 9217 brset rotary2,EnhancedBits5,rot2neg ; twin rotor code 9218 brclr TOY_DLI,outputpins,nils ; note, Toyota Multiplex only 9219 ; NON-inverted 9220 brset coilabit,coilsel,fcnita 9221 brset coilbbit,coilsel,fcnitb 9222 brset coilcbit,coilsel,fcnitc 9223 fcnita: 9224 bclr coilb,portc 9225 bclr wled,portc 9226 bra dslsa 9227 fcnitb: 9228 bset coilb,portc 9229 bclr wled,portc 9230 bra dslsa 9231 fcnitc: 9232 bclr coilb,portc 9233 bset wled,portc 9234 bra dslsa 9235 rot2neg: 9236 brset rotaryFDign,feature1,fireFD 9237 brset coilcbit,coilsel,rot2cn 9238 brset coildbit,coilsel,rot2dn 9239 ;either A or B both fire the single leading coil on LED17 9240 bra dslsa 9241 rot2cn: 9242 bclr wled,portc ; select 9243 bset coilb,portc 9244 bra cn_end 9245 rot2dn: 9246 bset wled,portc 9247 bset coilb,portc 9248 bra cn_end 9249 nils: ; normal sparking non inverted 9250 brset coilabit,coilsel,dslsa 9251 brset coilbbit,coilsel,dslsb 9252 brset coilcbit,coilsel,dslsc 9253 brset coildbit,coilsel,dslsd 9254 brset coilebit,coilsel,dslse 9255 brset coilfbit,coilsel,dslsf 9256 bra cn_end ; should never get here 9257 9258 fireFD: 9259 brset coilcbit,coilsel,dslsb 9260 brset coildbit,coilsel,dslsc 9261 9262 dslsa: 9263 bset coila,portc ; Set spark on 9264 bra cn_end 9265 9266 dslsb: 9267 bset coilb,portc ; Set spark on 9268 bra cn_end 9269 dslsc: 9270 bset wled,portc ; Set spark on 9271 bra cn_end 9272 dslsd: 9273 bset output3,portd ; Set spark on 9274 bra cn_end 9275 dslse: 9276 bset pin10,portc ; Set spark on 9277 bra cn_end 9278 dslsf: 9279 bset knockin,portd ; Set spark on 9280 bra cn_end 9281 dslsx: 9282 bset iasc,porta msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 81 MC68HC908GP32 User Bootloader 9283 cn_end: A846 9284 $MACROEND 9285 9286 *************************************************************************** 9287 A846 9288 $MACRO COILPOS 9289 brset REUSE_FIDLE,outputpins,ilsox 9290 brset rotary2,EnhancedBits5,rot2pos 9291 ; note no Toyota, because 9292 ; never inverted - ??? is this right 9293 brset coilabit,coilsel,ilsoa 9294 brset coilbbit,coilsel,ilsob 9295 brset coilcbit,coilsel,ilsoc 9296 brset coildbit,coilsel,ilsod 9297 brset coilebit,coilsel,ilsoe 9298 brset coilfbit,coilsel,ilsof 9299 bra fc_end ; should never get here 9300 rot2pos: 9301 brset rotaryFDign,feature1,chargeFD 9302 brset coilcbit,coilsel,rot2cp 9303 brset coildbit,coilsel,rot2dp 9304 ;either A or B both fire the single leading coil on LED17 9305 bra ilsoa 9306 rot2cp: 9307 ; bclr wled,portc ; select. Commented by KC, b/c there's no 9308 ; rotary inverted... if using stock hardware. 9309 bclr coilb,portc 9310 bra fc_end 9311 rot2dp: 9312 ; bset wled,portc 9313 bclr coilb,portc 9314 bra fc_end 9315 chargeFD: 9316 brset coilcbit,coilsel,ilsoc 9317 brset coildbit,coilsel,ilsob 9318 ilsoa: 9319 bclr coila,portc 9320 bra fc_end 9321 ilsob: 9322 bclr coilb,portc 9323 bra fc_end 9324 ilsoc: 9325 bclr wled,portc 9326 bra fc_end 9327 ilsod: 9328 bclr output3,portd 9329 bra fc_end 9330 ilsoe: 9331 bclr pin10,portc 9332 bra fc_end 9333 ilsof: 9334 bclr knockin,portd 9335 bra fc_end 9336 ilsox: 9337 bclr iasc,porta 9338 fc_end: A846 9339 $MACROEND 9340 9341 *************************************************************************** 9342 ** 9343 ** Timer Rollover - Occurs every 1/10 of a millisecond - main timing clock 9344 ** 9345 ** 9346 ** Generate time rates: 9347 ** 1/10 milliseconds 9348 ** 1 milliseconds 9349 ** 1/10 seconds 9350 ** seconds 9351 ** 9352 ** Also, in 1/10 millisecond section, turn on/off injector and 9353 ** check RPM for stall condition 9354 ** In milliseconds section, fire off ADC conversion for next channel (5 total), 9355 ** and wrap back when all channels done 9356 ** 9357 *************************************************************************** 9358 A846 9359 $MACRO CalcDwellspk 9360 ; This is now one massive macro. There is a section of code depending on how many spark 9361 ; outputs there are - 1,2,3,4,5,6 9362 ;022g - macro is now used to apply dwelldelay value calculated in main loop. 9363 ; macro only used after spark when mainloop will??? have had time to calc since trigger 9364 brset wspk,EnhancedBits4,wastedwell 9365 ;for single output dwell always use dwelldelay1 9366 ldhx dwelldelay1 9367 brset coilabit,coilsel,dd_a 9368 brset coilbbit,coilsel,dd_b ; surely these will never happen though 9369 brset coilcbit,coilsel,dd_c 9370 brset coildbit,coilsel,dd_d 9371 ; no need to consider 5th, 6th because wpsk will always be set 9372 bra jdd_end ; how? 9373 dd_a: sthx SparkOnLeftah ; Store time to keep output the same 9374 bra jdd_end 9375 dd_b: sthx SparkOnLeftbh ; Store time to keep output the same 9376 bra jdd_end 9377 dd_c: sthx SparkOnLeftch ; Store time to keep output the same 9378 bra jdd_end 9379 dd_d: sthx SparkOnLeftdh ; Store time to keep output the same 9380 jdd_end: jmp dd_end 9381 9382 jwdwell6op: jmp wdwell6op 9383 jwdwell5op: jmp wdwell5op 9384 9385 jwdwell4op: jmp wdwell4op 9386 jwdwell2op: jmp wdwell2op 9387 9388 wastedwell: 9389 ;one section each for 2,3,4,5,6 outputs 9390 ;nothing needed for rotary, it's not considered wasted spark 9391 lda feature8_f 9392 bit #spkfopb 9393 bne jwdwell6op 9394 bit #spkeopb 9395 bne jwdwell5op 9396 9397 brset out3sparkd,feature2,jwdwell4op ; if 4 o/ps 9398 ;check if 3rd spark output in use 9399 ;no need to check for 2nd output, wouldn't have got here otherwise (wspk above) 9400 brclr REUSE_LED18,outputpins,jwdwell2op ; want 1 } spark c 9401 brclr REUSE_LED18_2,outputpins,jwdwell2op ; want 1 } 9402 wdwell3op: 9403 ;first off always store a 360deg dwell delay 9404 ldhx dwelldelay3 ; precalculated to rail at mindischg 9405 brset coilabit,coilsel,wd3a360 9406 brset coilbbit,coilsel,wd3b360 9407 brset coilcbit,coilsel,wd3c360 9408 wd3a360: sthx SparkOnLeftah 9409 bra wd3end360 9410 wd3b360: sthx SparkOnLeftbh 9411 bra wd3end360 9412 wd3c360: sthx SparkOnLeftch 9413 wd3end360: 9414 9415 ;we've now set the 360deg wait, see if we can delay off previous spark (120deg) 9416 lda dwelldelay1 9417 bne wd3ok120 9418 lda dwelldelay1+1 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 82 MC68HC908GP32 User Bootloader 9419 cmp #2 9420 blo wd3skip120 ; check if more than 0.2ms 9421 ; if less then dwell might get missed 9422 wd3ok120: 9423 ldhx dwelldelay1 9424 brset coilabit,coilsel,wd3a120 9425 brset coilbbit,coilsel,wd3b120 9426 brset coilcbit,coilsel,wd3c120 9427 wd3a120: sthx SparkOnLeftbh 9428 bra wd3end120 9429 wd3b120: sthx SparkOnLeftch 9430 bra wd3end120 9431 wd3c120: sthx SparkOnLeftah 9432 wd3end120: 9433 ;;;;;;;;;; jmp dd_end ; always apply all three 9434 9435 wd3skip120: 9436 ;not enough time in 120deg period, see if 240deg will work 9437 lda dwelldelay2 9438 bne wd3ok240 9439 lda dwelldelay2+1 9440 cmp #2 9441 blo wd3end240 ; check if more than 0.2ms 9442 ; if less then dwell might get missed 9443 wd3ok240: 9444 ldhx dwelldelay2 9445 brset coilabit,coilsel,wd3a240 9446 brset coilbbit,coilsel,wd3b240 9447 brset coilcbit,coilsel,wd3c240 9448 wd3a240: sthx SparkOnLeftch 9449 bra wd3end240 9450 wd3b240: sthx SparkOnLeftah 9451 bra wd3end240 9452 wd3c240: sthx SparkOnLeftbh 9453 wd3end240: jmp dd_end 9454 9455 ;**************** 9456 wdwell2op: 9457 ;first off always store a 360deg dwell delay 9458 ldhx dwelldelay2 ; precalculated to rail at mindischg 9459 ;;redundant brset coilabit,coilsel,wd2a360 9460 brset coilbbit,coilsel,wd2b360 9461 wd2a360: sthx SparkOnLeftah 9462 bra wd2end360 9463 wd2b360: sthx SparkOnLeftbh 9464 wd2end360: 9465 ;consider oddfire, do not delay from previous spark 9466 lda SparkConfig1_f 9467 bit #M_SC1oddfire 9468 bne wd2skip 9469 9470 ;we've now set the 360deg wait, see if we can delay off previous spark (180deg) 9471 lda dwelldelay1 9472 bne wd2ok 9473 lda dwelldelay1+1 9474 cmp #2 9475 blo wd2skip ; check if more than 0.2ms 9476 ; if less then dwell might get missed 9477 wd2ok: 9478 ldhx dwelldelay1 9479 brset coilabit,coilsel,wd2a180 9480 brset coilbbit,coilsel,wd2b180 9481 wd2a180: sthx SparkOnLeftbh 9482 bra wd2end180 9483 wd2b180: sthx SparkOnLeftah 9484 wd2end180: 9485 9486 wd2skip: jmp dd_end 9487 9488 ;**************** 9489 9490 wdwell4op: 9491 ;first off always store a 360deg dwell delay 9492 ldhx dwelldelay4 ; precalculated to rail at mindischg 9493 brset coilabit,coilsel,wd4a360 9494 brset coilbbit,coilsel,wd4b360 9495 brset coilcbit,coilsel,wd4c360 9496 brset coildbit,coilsel,wd4d360 9497 wd4a360: sthx SparkOnLeftah 9498 bra wd4end360 9499 wd4b360: sthx SparkOnLeftbh 9500 bra wd4end360 9501 wd4c360: sthx SparkOnLeftch 9502 bra wd4end360 9503 wd4d360: sthx SparkOnLeftdh 9504 wd4end360: 9505 9506 ;consider oddfire, do not delay from previous spark 9507 lda sparkconfig1_f 9508 bit #M_SC1oddfire 9509 bne wd4skip90 9510 9511 ;we've now set the 360deg wait, see if we can delay off previous spark (90deg) 9512 lda dwelldelay1 9513 bne wd4ok90 ; if non zero then long delay so ok 9514 lda dwelldelay1+1 9515 cmp #2 9516 blo wd4skip90 ; check if more than 0.2ms 9517 ; if less, then dwell might get missed 9518 wd4ok90: 9519 ldhx dwelldelay1 9520 brset coilabit,coilsel,wd4a90 9521 brset coilbbit,coilsel,wd4b90 9522 brset coilcbit,coilsel,wd4c90 9523 brset coildbit,coilsel,wd4d90 9524 wd4a90: sthx SparkOnLeftbh 9525 bra wd4end90 9526 wd4b90: sthx SparkOnLeftch 9527 bra wd4end90 9528 wd4c90: sthx SparkOnLeftdh 9529 bra wd4end90 9530 wd4d90: sthx SparkOnLeftah 9531 wd4end90: 9532 ;;; bra dd_end 9533 ;;note! may want to change this so that intermediate periods are set too so that there 9534 ;is a smoother transition from 90deg dwell to 180deg etc. 9535 9536 wd4skip90: 9537 ;not enough time in 90deg period, see if 180deg will work 9538 lda dwelldelay2 9539 bne wd4ok180 9540 lda dwelldelay2+1 9541 cmp #2 9542 blo wd4skip180 ; check if more than 0.2ms 9543 ; if less then dwell might get missed 9544 wd4ok180: 9545 ldhx dwelldelay2 9546 brset coilabit,coilsel,wd4a180 9547 brset coilbbit,coilsel,wd4b180 9548 brset coilcbit,coilsel,wd4c180 9549 brset coildbit,coilsel,wd4d180 9550 wd4a180: sthx SparkOnLeftch 9551 bra wd4end180 9552 wd4b180: sthx SparkOnLeftdh 9553 bra wd4end180 9554 wd4c180: sthx SparkOnLeftah msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 83 MC68HC908GP32 User Bootloader 9555 bra wd4end180 9556 wd4d180: sthx SparkOnLeftbh 9557 wd4end180: 9558 ;; bra dd_end 9559 9560 wd4skip180: 9561 ;consider oddfire, do not delay from previous spark 9562 lda sparkconfig1_f 9563 bit #M_SC1oddfire 9564 bne wd4end270 9565 9566 ;not enough time in 180deg period, see if 270deg will work 9567 lda dwelldelay3 9568 bne wd4ok270 9569 lda dwelldelay3+1 9570 cmp #2 9571 blo wd4end270 ; check if more than 0.2ms 9572 ; if less then dwell might get missed 9573 wd4ok270: 9574 ldhx dwelldelay3 9575 brset coilabit,coilsel,wd4a270 9576 brset coilbbit,coilsel,wd4b270 9577 brset coilcbit,coilsel,wd4c270 9578 brset coildbit,coilsel,wd4d270 9579 wd4a270: sthx SparkOnLeftdh 9580 bra wd4end270 9581 wd4b270: sthx SparkOnLeftah 9582 bra wd4end270 9583 wd4c270: sthx SparkOnLeftbh 9584 bra wd4end270 9585 wd4d270: sthx SparkOnLeftch 9586 wd4end270: 9587 jmp dd_end 9588 9589 ;******************* 9590 ; 5 spark outputs, angular names as if V10, will actually be double if 5cyl COP 9591 ;******************* 9592 wdwell5op: 9593 ;first off always store a 360deg dwell delay 9594 ldhx dwelldelay5 ; precalculated to rail at mindischg 9595 brset coilabit,coilsel,wd5a360 9596 brset coilbbit,coilsel,wd5b360 9597 brset coilcbit,coilsel,wd5c360 9598 brset coildbit,coilsel,wd5d360 9599 brset coildbit,coilsel,wd5e360 9600 wd5a360: sthx SparkOnLeftah 9601 bra wd5end360 9602 wd5b360: sthx SparkOnLeftbh 9603 bra wd5end360 9604 wd5c360: sthx SparkOnLeftch 9605 bra wd5end360 9606 wd5d360: sthx SparkOnLeftdh 9607 bra wd5end360 9608 wd5e360: sthx SparkOnLefteh 9609 wd5end360: 9610 ;we've now set the 360deg wait, see if we can delay off previous spark (72deg) 9611 lda dwelldelay1 9612 bne wd5ok72 ; if non zero then long delay so ok 9613 lda dwelldelay1+1 9614 cmp #2 9615 blo wd5skip72 ; check if more than 0.2ms 9616 ; if less, then dwell might get missed 9617 wd5ok72: 9618 ldhx dwelldelay1 9619 brset coilabit,coilsel,wd5a72 9620 brset coilbbit,coilsel,wd5b72 9621 brset coilcbit,coilsel,wd5c72 9622 brset coildbit,coilsel,wd5d72 9623 brset coilebit,coilsel,wd5e72 9624 wd5a72: sthx SparkOnLeftbh 9625 bra wd5end72 9626 wd5b72: sthx SparkOnLeftch 9627 bra wd5end72 9628 wd5c72: sthx SparkOnLeftdh 9629 bra wd5end72 9630 wd5d72: sthx SparkOnLefteh 9631 bra wd5end72 9632 wd5e72: sthx SparkOnLeftah 9633 wd5end72: 9634 ;;; bra dd_end 9635 ;;note! may want to change this so that intermediate periods are set too so that there 9636 ;is a smoother transition from 72deg dwell to 144deg etc. 9637 9638 wd5skip72: 9639 9640 lda dwelldelay2 9641 bne wd5ok144 9642 lda dwelldelay2+1 9643 cmp #2 9644 blo wd5skip144 ; check if more than 0.2ms 9645 ; if less then dwell might get missed 9646 wd5ok144: 9647 ldhx dwelldelay2 9648 brset coilabit,coilsel,wd5a144 9649 brset coilbbit,coilsel,wd5b144 9650 brset coilcbit,coilsel,wd5c144 9651 brset coildbit,coilsel,wd5d144 9652 brset coilebit,coilsel,wd5e144 9653 wd5a144: sthx SparkOnLeftch 9654 bra wd5end144 9655 wd5b144: sthx SparkOnLeftdh 9656 bra wd5end144 9657 wd5c144: sthx SparkOnLefteh 9658 bra wd5end144 9659 wd5d144: sthx SparkOnLeftah 9660 bra wd5end144 9661 wd5e144: sthx SparkOnLeftbh 9662 wd5end144: 9663 ;; bra dd_end 9664 9665 wd5skip144: 9666 ;not enough time in 144deg period, see if 216deg will work 9667 lda dwelldelay3 9668 bne wd5ok216 9669 lda dwelldelay3+1 9670 cmp #2 9671 blo wd5skip216 ; check if more than 0.2ms 9672 ; if less then dwell might get missed 9673 wd5ok216: 9674 ldhx dwelldelay3 9675 brset coilabit,coilsel,wd5a216 9676 brset coilbbit,coilsel,wd5b216 9677 brset coilcbit,coilsel,wd5c216 9678 brset coildbit,coilsel,wd5d216 9679 brset coilebit,coilsel,wd5e216 9680 wd5a216: sthx SparkOnLeftdh 9681 bra wd5end216 9682 wd5b216: sthx SparkOnLefteh 9683 bra wd5end216 9684 wd5c216: sthx SparkOnLeftah 9685 bra wd5end216 9686 wd5d216: sthx SparkOnLeftbh 9687 bra wd5end216 9688 wd5e216: sthx SparkOnLeftch 9689 wd5end216: 9690 ; bra dd_end msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 84 MC68HC908GP32 User Bootloader 9691 9692 wd5skip216: 9693 ;not enough time in 216deg period, see if 288deg will work 9694 lda dwelldelay4 9695 bne wd5ok288 9696 lda dwelldelay4+1 9697 cmp #2 9698 blo wd5skip288 ; check if more than 0.2ms 9699 ; if less then dwell might get missed 9700 wd5ok288: 9701 ldhx dwelldelay4 9702 brset coilabit,coilsel,wd5a288 9703 brset coilbbit,coilsel,wd5b288 9704 brset coilcbit,coilsel,wd5c288 9705 brset coildbit,coilsel,wd5d288 9706 brset coilebit,coilsel,wd5e288 9707 wd5a288: sthx SparkOnLefteh 9708 bra wd5end288 9709 wd5b288: sthx SparkOnLeftah 9710 bra wd5end288 9711 wd5c288: sthx SparkOnLeftbh 9712 bra wd5end288 9713 wd5d288: sthx SparkOnLeftch 9714 bra wd5end288 9715 wd5e288: sthx SparkOnLeftdh 9716 wd5end288: 9717 wd5skip288: 9718 jmp dd_end 9719 9720 ;******************* 9721 ; 6 spark outputs, angular names as if V12, will actually be double if 6cyl COP 9722 ;******************* 9723 wdwell6op: 9724 ;first off always store a 360deg dwell delay 9725 ldhx dwelldelay6 ; precalculated to rail at mindischg 9726 brset coilabit,coilsel,wd6a360 9727 brset coilbbit,coilsel,wd6b360 9728 brset coilcbit,coilsel,wd6c360 9729 brset coildbit,coilsel,wd6d360 9730 brset coilebit,coilsel,wd6e360 9731 brset coilfbit,coilsel,wd6f360 9732 wd6a360: sthx SparkOnLeftah 9733 bra wd6end360 9734 wd6b360: sthx SparkOnLeftbh 9735 bra wd6end360 9736 wd6c360: sthx SparkOnLeftch 9737 bra wd6end360 9738 wd6d360: sthx SparkOnLeftdh 9739 bra wd6end360 9740 wd6e360: sthx SparkOnLefteh 9741 bra wd6end360 9742 wd6f360: sthx SparkOnLeftfh 9743 wd6end360: 9744 ;consider oddfire, do not delay from previous spark 9745 lda sparkconfig1_f 9746 bit #M_SC1oddfire 9747 bne wd6skip60 9748 9749 ;we've now set the 360deg wait, see if we can delay off previous spark (60deg) 9750 lda dwelldelay1 9751 bne wd6ok60 ; if non zero then long delay so ok 9752 lda dwelldelay1+1 9753 cmp #5 9754 blo wd6skip60 ; check if more than 0.2ms 9755 ; if less, then dwell might get missed 9756 wd6ok60: 9757 ldhx dwelldelay1 9758 brset coilabit,coilsel,wd6a60 9759 brset coilbbit,coilsel,wd6b60 9760 brset coilcbit,coilsel,wd6c60 9761 brset coildbit,coilsel,wd6d60 9762 brset coilebit,coilsel,wd6e60 9763 brset coilfbit,coilsel,wd6f60 9764 wd6a60: sthx SparkOnLeftbh 9765 bra wd6end60 9766 wd6b60: sthx SparkOnLeftch 9767 bra wd6end60 9768 wd6c60: sthx SparkOnLeftdh 9769 bra wd6end60 9770 wd6d60: sthx SparkOnLefteh 9771 bra wd6end60 9772 wd6e60: sthx SparkOnLeftfh 9773 bra wd6end60 9774 wd6f60: sthx SparkOnLeftah 9775 wd6end60: 9776 ;;; bra dd_end 9777 ;;note! may want to change this so that intermediate periods are set too so that there 9778 ;is a smoother transition from 60deg dwell to 120deg etc. 9779 9780 wd6skip60: 9781 ;not enough time in 60deg period, see if 120deg will work 9782 lda dwelldelay2 9783 bne wd6ok120 9784 lda dwelldelay2+1 9785 cmp #5 9786 blo wd6skip120 ; check if more than 0.2ms 9787 ; if less then dwell might get missed 9788 wd6ok120: 9789 ldhx dwelldelay2 9790 brset coilabit,coilsel,wd6a120 9791 brset coilbbit,coilsel,wd6b120 9792 brset coilcbit,coilsel,wd6c120 9793 brset coildbit,coilsel,wd6d120 9794 brset coilebit,coilsel,wd6e120 9795 brset coilfbit,coilsel,wd6f120 9796 wd6a120: sthx SparkOnLeftch 9797 bra wd6end120 9798 wd6b120: sthx SparkOnLeftdh 9799 bra wd6end120 9800 wd6c120: sthx SparkOnLefteh 9801 bra wd6end120 9802 wd6d120: sthx SparkOnLeftfh 9803 bra wd6end120 9804 wd6e120: sthx SparkOnLeftah 9805 bra wd6end120 9806 wd6f120: sthx SparkOnLeftbh 9807 wd6end120: 9808 ;; bra dd_end 9809 9810 wd6skip120: 9811 ;consider oddfire, do not delay from previous spark 9812 lda sparkconfig1_f 9813 bit #M_SC1oddfire 9814 bne wd6skip180 9815 9816 ;not enough time in 120deg period, see if 180deg will work 9817 lda dwelldelay3 9818 bne wd6ok180 9819 lda dwelldelay3+1 9820 cmp #5 9821 blo wd6skip180 ; check if more than 0.2ms 9822 ; if less then dwell might get missed 9823 wd6ok180: 9824 ldhx dwelldelay3 9825 brset coilabit,coilsel,wd6a180 9826 brset coilbbit,coilsel,wd6b180 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 85 MC68HC908GP32 User Bootloader 9827 brset coilcbit,coilsel,wd6c180 9828 brset coildbit,coilsel,wd6d180 9829 brset coilebit,coilsel,wd6e180 9830 brset coilfbit,coilsel,wd6f180 9831 wd6a180: sthx SparkOnLeftdh 9832 bra wd6end180 9833 wd6b180: sthx SparkOnLefteh 9834 bra wd6end180 9835 wd6c180: sthx SparkOnLeftfh 9836 bra wd6end180 9837 wd6d180: sthx SparkOnLeftah 9838 bra wd6end180 9839 wd6e180: sthx SparkOnLeftbh 9840 bra wd6end180 9841 wd6f180: sthx SparkOnLeftch 9842 wd6end180: 9843 bra dd_end 9844 9845 wd6skip180: 9846 ;not enough time in 180deg period, see if 240deg will work 9847 lda dwelldelay4 9848 bne wd6ok240 9849 lda dwelldelay4+1 9850 cmp #5 9851 blo wd6skip240 ; check if more than 0.2ms 9852 ; if less then dwell might get missed 9853 wd6ok240: 9854 ldhx dwelldelay4 9855 brset coilabit,coilsel,wd6a240 9856 brset coilbbit,coilsel,wd6b240 9857 brset coilcbit,coilsel,wd6c240 9858 brset coildbit,coilsel,wd6d240 9859 brset coilebit,coilsel,wd6e240 9860 brset coilfbit,coilsel,wd6f240 9861 wd6a240: sthx SparkOnLefteh 9862 bra wd6end240 9863 wd6b240: sthx SparkOnLeftfh 9864 bra wd6end240 9865 wd6c240: sthx SparkOnLeftah 9866 bra wd6end240 9867 wd6d240: sthx SparkOnLeftbh 9868 bra wd6end240 9869 wd6e240: sthx SparkOnLeftch 9870 bra wd6end240 9871 wd6f240: sthx SparkOnLeftdh 9872 wd6end240: 9873 ; jmp dd_end 9874 9875 wd6skip240: 9876 ;consider oddfire, do not delay from previous spark 9877 lda sparkconfig1_f 9878 bit #M_SC1oddfire 9879 bne wd6skip300 9880 9881 ;not enough time in 240deg period, see if 300deg will work 9882 lda dwelldelay5 9883 bne wd6ok300 9884 lda dwelldelay5+1 9885 cmp #5 9886 blo wd6skip300 ; check if more than 0.2ms 9887 ; if less then dwell might get missed 9888 wd6ok300: 9889 ldhx dwelldelay5 9890 brset coilabit,coilsel,wd6a300 9891 brset coilbbit,coilsel,wd6b300 9892 brset coilcbit,coilsel,wd6c300 9893 brset coildbit,coilsel,wd6d300 9894 brset coilebit,coilsel,wd6e300 9895 brset coilfbit,coilsel,wd6f300 9896 wd6a300: sthx SparkOnLefteh 9897 bra wd6end300 9898 wd6b300: sthx SparkOnLeftfh 9899 bra wd6end300 9900 wd6c300: sthx SparkOnLeftah 9901 bra wd6end300 9902 wd6d300: sthx SparkOnLeftbh 9903 bra wd6end300 9904 wd6e300: sthx SparkOnLeftch 9905 bra wd6end300 9906 wd6f300: sthx SparkOnLeftdh 9907 wd6end300: 9908 9909 wd6skip300: 9910 9911 9912 dd_end: A846 9913 $MACROEND 9914 9915 ******************************************************************************** 9916 ** EDIS control section up here to permit relative jumps in 0.1ms section 9917 ** 2nd EDIS output control 9918 ******************************************************************************** 9919 9920 edis2_fire: A846 09624F 9921 brclr REUSE_LED19,outputpins,go_inj_fire2 ; if 2nd output not 9922 ;enabled then skip A849 55B3 9923 ldhx SparkOnLeftah ; skip if already zero A84B 274B 9924 beq go_inj_fire2 9925 A84D AFFF 9926 aix #-1 ; is it time to start 2nd SAW A84F 35B3 9927 sthx SparkOnLeftah A851 650000 9928 cphx #0 A854 2642 9929 bne go_inj_fire2 ; skip if non-zero 9930 9931 ; start 2nd SAW here and set timer to turn it off A856 3F68 9932 clr coilsel A858 1268 9933 bset coilbbit,coilsel ; only support 2nd spark output 9934 ; assume that other outputs cannot get set A85A 1660 9935 bset sparkon,revlimbits ; note that spark is on 9936 A85C 0C6904 9937 brset invspk,EnhancedBits4,InvSparkOn2 A85F 1202 9938 bset coilb,portc A861 2002 9939 bra set_saw_on2 9940 InvSparkOn2: A863 1302 9941 bclr coilb,portc 9942 9943 set_saw_on2: ; now set timer for SAW on period 9944 ; using sawh/l calculated in main loop 9945 9946 ; Calculate width of SAW pulse 9947 ; grab current timer values - uses same variable as squirt section below. 9948 ; But no cli so ok 9949 ; A865 B62D 9950 lda T2CNTL ; unlatch low byte A867 BE2C 9951 ldx T2CNTH A869 CF0203 9952 stx T2CurrH ; Save current counter value A86C B62D 9953 lda T2CNTL A86E C70204 9954 sta T2CurrL ; Save current counter value 9955 A871 03420F 9956 brclr crank,engine,SAW_COUNTER2 A874 C6E042 9957 lda feature4_f A877 A508 9958 bit #multisparkb A879 2708 9959 beq SAW_COUNTER2 9960 ; brclr multispark,feature4,SAW_COUNTER2 9961 ; at crank we always send 2048us as calibration and multi-spark init A87B A600 9962 lda #$00 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 86 MC68HC908GP32 User Bootloader A87D B7F5 9963 sta sawl A87F A608 9964 lda #$08 A881 B7F4 9965 sta sawh 9966 9967 ;Read the calculated width and store in timer 9968 SAW_COUNTER2: A883 B6F5 9969 lda sawl A885 CB0204 9970 add T2CurrL A888 97 9971 tax A889 B6F4 9972 lda sawh A88B C90203 9973 adc T2CurrH A88E B734 9974 sta T2CH1H A890 BF35 9975 stx T2CH1L 9976 A892 115F 9977 bclr SparkTrigg,Sparkbits ; Clear spark trigg. Next time we get int turn off SAW 9978 A894 1F33 9979 bclr TOF,T2SC1 ; clear any pending interrupt A896 1C33 9980 bset TOIE,T2SC1 ; Enable timer interrupt 9981 go_inj_fire2: A898 CCAF4C 9982 jmp INJ_FIRE_CTL 9983 **** end of 2nd EDIS bit ** 9984 edis2_fire_a: A89B 20A9 9985 bra edis2_fire ; to permit relative jump below 9986 9987 ****************************************************************************** 9988 ;some timerroll equates - local variables that can only be used with irqs blocked 9989 ;we'll start using itmp00 - itmp0f in here 9990 9991 TIMERROLL: 9992 A89D 136A 9993 bclr checkbit,EnhancedBits5 A89F 8B 9994 pshh ; Stack h A8A0 B630 9995 lda T2SC0 ; ack the interrupt A8A2 1F30 9996 bclr CHxF,T2SC0 ; clear pending bit A8A4 B62D 9997 lda T2CNTL ; unlatch any previous read (added JSM) 9998 9999 ;* revised section - from Dan Hiebert's TFI code A8A6 5531 10000 ldhx T2CH0H ; Load index register with value 10001 ; in TIM2 CH0 10002 ; register H:L (output compare value) A8A8 AF64 10003 aix #100T ; Add decimal 100 (100 uS) A8AA 3531 10004 sthx T2CH0H ; Copy result to TIM2 CH0 register 10005 ;(new output compare value) 10006 ;* end revised section 10007 10008 A8AC 3CF7 10009 inc lowresL ; 16bit 0.1ms timer A8AE 2602 10010 bne TIMER_DONE A8B0 3CF6 10011 inc lowresH 10012 ; otherwise done 10013 TIMER_DONE: A8B2 1D30 10014 bclr TOIE,T2SC0 ; disable 0.1ms interrupt to 10015 ; prevent re-entry A8B4 9A 10016 cli ; allow interrupts during the large 10017 ; chunk of code below. This 10018 ; significantly reduces spark 10019 ; jitter. Without it there is 10020 ; ~6deg at 9000rpm 10021 ; only really want IRQ to be allowed 10022 10023 *************************************************************************** 10024 ***************** 0.1 millisecond section ******************************** 10025 *************************************************************************** 10026 A8B5 0E641B 10027 brset config_error,feature2,error_exit A8B8 3C7D 10028 inc mms ; bump up 0.1 millisec variable 10029 10030 ; Added for boost control - Hope it doesnt screw up the timer - 10031 ; James will kill me if it does A8BA 01640F 10032 brclr BoostControl,feature2,bcActDone A8BD 3CE4 10033 inc mmsDiv ; Counts up to bcFreqDiv. A8BF B6E4 10034 lda mmsDiv ; Counter at multiples of 0.1 ms A8C1 C1E00E 10035 cmp bcFreqDiv_f ; 1=39.1 Hz, 2=19.5, 3=13.0 and so on. A8C4 2506 10036 blo bcActDone A8C6 3FE4 10037 clr mmsDiv A8C8 3CD4 10038 inc bcActClock A8CA B6D4 10039 lda bcActClock 10040 bcActDone: A8CC B661 10041 lda personality A8CE 260B 10042 bne irq_monitor A8D0 CCAF4C 10043 jmp INJ_FIRE_CTL ; skip this section if not 10044 ; controlling spark 10045 10046 error_exit: A8D3 8A 10047 pulh A8D4 80 10048 rti 10049 10050 go_inj_fire3: A8D5 CCAF4C 10051 jmp INJ_FIRE_CTL 10052 10053 j_tfi_spk: A8D8 CCAF1F 10054 jmp tfi_spk ; branch to next chunk 10055 10056 irq_monitor: A8DB 0A61BD 10057 brset DUALEDIS,personality,edis2_fire_a A8DE 0861F4 10058 brset EDIS,personality,go_inj_fire3 A8E1 0C61F4 10059 brset TFI,personality,j_tfi_spk 10060 A8E4 03610D 10061 brclr MSNEON,personality,skip_irq_neon 10062 10063 ; Neon crank decoding 10064 ; See if we have seen a rising IRQ edge and save it 10065 A8E7 2E0B 10066 bil skip_irq_neon 10067 10068 skip_irq_chk2: A8E9 085F08 10069 brset rise,sparkbits,skip_irq_neon ; only store the rising edge A8EC 185F 10070 bset rise,sparkbits 10071 A8EE 4EF7C2 10072 mov lowresL,SparkTempL A8F1 4EF6C1 10073 mov lowresH,SparkTempH 10074 10075 skip_irq_neon: 10076 ;more bloat... check for second "reset" spark input A8F4 016311 10077 brclr wd_2trig,feature1,no_wd_trig 10078 ;on rising edge of input reset wheelcount to zero A8F7 085F09 10079 brset rise,sparkbits,wd_rise ; already found so see if ready to clear 10080 ;not already in high state so see if pin has been asserted A8FA 08020B 10081 brset pin11,portc,no_wd_trig ; inactive 10082 ;we've found a rising edge of pin11, so clear wheelcount (tooth zero) and set rise bit A8FD 185F 10083 bset rise,sparkbits ; this bit used to monitor the edge of the input A8FF 166B 10084 bset trigger2,EnhancedBits6 ; flag the trigger A901 2005 10085 bra no_wd_trig 10086 wd_rise: A903 090202 10087 brclr pin11,portc,no_wd_trig A906 195F 10088 bclr rise,sparkbits 10089 no_wd_trig: 10090 10091 ; now with multi-dwell check them all each time (how much delay to 10092 ; 0.1ms routine?) this routine is flawed but only slightly - when one 10093 ; coil gets to zero those below don't get decremented so will be 0.1ms 10094 ; late. a jsr would be nice. 10095 ; A908 9B 10096 sei ; no ints while we are 10097 ; stealing this variable A909 4E68C3 10098 mov coilsel,SparkCarry; temporary msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 87 MC68HC908GP32 User Bootloader 10099 A90C 096903 10100 brclr indwell,EnhancedBits4,sin_a A90F 006A26 10101 brset rotary2,EnhancedBits5,clr_a_b 10102 10103 sin_a: A912 55B3 10104 ldhx SparkOnLeftah A914 270F 10105 beq sin_b A916 AFFF 10106 aix #-1 ; is it time to start charging A918 35B3 10107 sthx SparkOnLeftah A91A 650000 10108 cphx #0 A91D 2606 10109 bne sin_b A91F 3F68 10110 clr coilsel A921 1068 10111 bset coilabit,coilsel A923 206D 10112 bra lowspdspk 10113 sin_b: A925 55B5 10114 ldhx SparkOnLeftbh A927 2716 10115 beq sin_c A929 AFFF 10116 aix #-1 ; is it time to start charging A92B 35B5 10117 sthx SparkOnLeftbh A92D 650000 10118 cphx #0 A930 260D 10119 bne sin_c A932 3F68 10120 clr coilsel A934 1268 10121 bset coilbbit,coilsel A936 205A 10122 bra lowspdspk 10123 clr_a_b: A938 450000 10124 ldhx #0 A93B 35B3 10125 sthx SparkOnLeftah A93D 35B5 10126 sthx SparkOnLeftbh 10127 sin_c: A93F 55B7 10128 ldhx SparkOnLeftch A941 270F 10129 beq sin_d A943 AFFF 10130 aix #-1 ; is it time to start charging A945 35B7 10131 sthx SparkOnLeftch A947 650000 10132 cphx #0 A94A 2606 10133 bne sin_d A94C 3F68 10134 clr coilsel A94E 1468 10135 bset coilcbit,coilsel A950 2040 10136 bra lowspdspk 10137 sin_d: A952 55B9 10138 ldhx SparkOnLeftdh A954 270F 10139 beq sin_e A956 AFFF 10140 aix #-1 ; is it time to start charging A958 35B9 10141 sthx SparkOnLeftdh A95A 650000 10142 cphx #0 A95D 2606 10143 bne sin_e A95F 3F68 10144 clr coilsel A961 1668 10145 bset coildbit,coilsel A963 202D 10146 bra lowspdspk 10147 10148 sin_e: A965 55BB 10149 ldhx SparkOnLefteh A967 270F 10150 beq sin_f A969 AFFF 10151 aix #-1 ; is it time to start charging A96B 35BB 10152 sthx SparkOnLefteh A96D 650000 10153 cphx #0 A970 2606 10154 bne sin_f A972 3F68 10155 clr coilsel A974 1868 10156 bset coilebit,coilsel A976 201A 10157 bra lowspdspk 10158 sin_f: A978 55BD 10159 ldhx SparkOnLeftfh A97A 270F 10160 beq j_CSL A97C AFFF 10161 aix #-1 ; is it time to start charging A97E 35BD 10162 sthx SparkOnLeftfh A980 650000 10163 cphx #0 A983 2606 10164 bne j_CSL A985 3F68 10165 clr coilsel A987 1A68 10166 bset coilfbit,coilsel A989 2007 10167 bra lowspdspk 10168 10169 j_CSL: A98B 9A 10170 cli A98C CCAA81 10171 jmp CHECK_SPARK_LATE 10172 10173 go_inj_fire: A98F CCAF4C 10174 jmp INJ_FIRE_CTL 10175 10176 10177 lowspdspk: A992 016A13 10178 brclr rotary2,EnhancedBits5,chkindwell A995 006810 10179 brset coilabit,coilsel,chkindwell A998 02680D 10180 brset coilbbit,coilsel,chkindwell A99B C60100 10181 lda splitdelH A99E A1FF 10182 cmp #$FF ; if trailing is OFF then don't charge coil A9A0 276A 10183 beq blssd 10184 lss2: 10185 ; add check for rotary, which checks for coilcbit/coildbit 10186 chkcoilcd: ; make sure that we dwell coil c/d even if indwell. A9A2 046806 10187 brset coilcbit,coilsel,dodwell A9A5 066803 10188 brset coildbit,coilsel,dodwell 10189 chkindwell: A9A8 086961 10190 brset indwell,EnhancedBits4,blssd ; if doing hi-res 10191 ; dwell then don't turn on coil now 10192 dodwell: A9AB 1760 10193 bclr sparkon,revlimbits ; spark now off 10194 ;this used to be in SPARKTIME but could have overheated ignitors A9AD B6D8 10195 lda SparkCutCnt ; Check Spark Counter A9AF 4C 10196 inca A9B0 C1E04E 10197 cmp SparkCutBase_f ; How many sparks to count to A9B3 2502 10198 blo Dont_ResetCnt A9B5 A601 10199 lda #01T 10200 Dont_ResetCnt: A9B7 B7D8 10201 sta SparkCutCnt ; Store new value to spark counter A9B9 0A6050 10202 brset sparkCut,RevLimBits,blssd ; If in spark cut 10203 ; mode jump past spark 10204 A9BC 0C694F 10205 brset invspk,EnhancedBits4,lsspk_inv ; check if noninv or inv spark A9BF macro 10206 COILPOS ; charge coil for non-inverted A9BF 006248 10207 BRSET REUSE_FIDLE,OUTPUTPINS,ILSOX A9C2 006A14 10208 BRSET ROTARY2,ENHANCEDBITS5,ROT2POS A9C5 00682A 10209 BRSET COILABIT,COILSEL,ILSOA A9C8 02682B 10210 BRSET COILBBIT,COILSEL,ILSOB A9CB 04682C 10211 BRSET COILCBIT,COILSEL,ILSOC A9CE 06682D 10212 BRSET COILDBIT,COILSEL,ILSOD A9D1 08682E 10213 BRSET COILEBIT,COILSEL,ILSOE A9D4 0A682F 10214 BRSET COILFBIT,COILSEL,ILSOF A9D7 2033 10215 BRA FC_END 10216 ROT2POS: A9D9 086310 10217 BRSET ROTARYFDIGN,FEATURE1,CHARGEFD A9DC 046805 10218 BRSET COILCBIT,COILSEL,ROT2CP A9DF 066806 10219 BRSET COILDBIT,COILSEL,ROT2DP A9E2 200E 10220 BRA ILSOA 10221 ROT2CP: A9E4 1302 10222 BCLR COILB,PORTC A9E6 2024 10223 BRA FC_END 10224 ROT2DP: A9E8 1302 10225 BCLR COILB,PORTC A9EA 2020 10226 BRA FC_END 10227 CHARGEFD: A9EC 04680B 10228 BRSET COILCBIT,COILSEL,ILSOC A9EF 066804 10229 BRSET COILDBIT,COILSEL,ILSOB 10230 ILSOA: A9F2 1102 10231 BCLR COILA,PORTC A9F4 2016 10232 BRA FC_END 10233 ILSOB: A9F6 1302 10234 BCLR COILB,PORTC msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 88 MC68HC908GP32 User Bootloader A9F8 2012 10235 BRA FC_END 10236 ILSOC: A9FA 1502 10237 BCLR WLED,PORTC A9FC 200E 10238 BRA FC_END 10239 ILSOD: A9FE 1103 10240 BCLR OUTPUT3,PORTD AA00 200A 10241 BRA FC_END 10242 ILSOE: AA02 1702 10243 BCLR PIN10,PORTC AA04 2006 10244 BRA FC_END 10245 ILSOF: AA06 1503 10246 BCLR KNOCKIN,PORTD AA08 2002 10247 BRA FC_END 10248 ILSOX: AA0A 1300 10249 BCLR IASC,PORTA 10250 FC_END: 10251 blssd: AA0C 206F 10252 bra lsspk_done 10253 lsspk_inv: AA0E macro 10254 COILNEG ; charge coil for inverted AA0E 00626A 10255 BRSET REUSE_FIDLE,OUTPUTPINS,DSLSX AA11 006A1E 10256 BRSET ROTARY2,ENHANCEDBITS5,ROT2NEG AA14 0F6232 10257 BRCLR TOY_DLI,OUTPUTPINS,NILS AA17 006806 10258 BRSET COILABIT,COILSEL,FCNITA AA1A 026809 10259 BRSET COILBBIT,COILSEL,FCNITB AA1D 04680C 10260 BRSET COILCBIT,COILSEL,FCNITC 10261 FCNITA: AA20 1302 10262 BCLR COILB,PORTC AA22 1502 10263 BCLR WLED,PORTC AA24 203D 10264 BRA DSLSA 10265 FCNITB: AA26 1202 10266 BSET COILB,PORTC AA28 1502 10267 BCLR WLED,PORTC AA2A 2037 10268 BRA DSLSA 10269 FCNITC: AA2C 1302 10270 BCLR COILB,PORTC AA2E 1402 10271 BSET WLED,PORTC AA30 2031 10272 BRA DSLSA 10273 ROT2NEG: AA32 086328 10274 BRSET ROTARYFDIGN,FEATURE1,FIREFD AA35 046805 10275 BRSET COILCBIT,COILSEL,ROT2CN AA38 066808 10276 BRSET COILDBIT,COILSEL,ROT2DN AA3B 2026 10277 BRA DSLSA 10278 ROT2CN: AA3D 1502 10279 BCLR WLED,PORTC AA3F 1202 10280 BSET COILB,PORTC AA41 203A 10281 BRA CN_END 10282 ROT2DN: AA43 1402 10283 BSET WLED,PORTC AA45 1202 10284 BSET COILB,PORTC AA47 2034 10285 BRA CN_END 10286 NILS: AA49 006817 10287 BRSET COILABIT,COILSEL,DSLSA AA4C 026818 10288 BRSET COILBBIT,COILSEL,DSLSB AA4F 046819 10289 BRSET COILCBIT,COILSEL,DSLSC AA52 06681A 10290 BRSET COILDBIT,COILSEL,DSLSD AA55 08681B 10291 BRSET COILEBIT,COILSEL,DSLSE AA58 0A681C 10292 BRSET COILFBIT,COILSEL,DSLSF AA5B 2020 10293 BRA CN_END 10294 FIREFD: AA5D 046807 10295 BRSET COILCBIT,COILSEL,DSLSB AA60 066808 10296 BRSET COILDBIT,COILSEL,DSLSC 10297 DSLSA: AA63 1002 10298 BSET COILA,PORTC AA65 2016 10299 BRA CN_END 10300 DSLSB: AA67 1202 10301 BSET COILB,PORTC AA69 2012 10302 BRA CN_END 10303 DSLSC: AA6B 1402 10304 BSET WLED,PORTC AA6D 200E 10305 BRA CN_END 10306 DSLSD: AA6F 1003 10307 BSET OUTPUT3,PORTD AA71 200A 10308 BRA CN_END 10309 DSLSE: AA73 1602 10310 BSET PIN10,PORTC AA75 2006 10311 BRA CN_END 10312 DSLSF: AA77 1403 10313 BSET KNOCKIN,PORTD AA79 2002 10314 BRA CN_END 10315 DSLSX: AA7B 1200 10316 BSET IASC,PORTA 10317 CN_END: 10318 lsspk_done: AA7D 4EC368 10319 mov SparkCarry,coilsel; put it back as we found it AA80 9A 10320 cli 10321 10322 CHECK_SPARK_LATE: AA81 055F1B 10323 brclr SparkLSpeed,SparkBits,jINJ_FIRE_CTL ; Skip if not low 10324 ; speed sparking AA84 015F18 10325 brclr sparktrigg,sparkbits,jINJ_FIRE_CTL ; Skip if spark 10326 ; already done 10327 10328 ; brclr crank,engine,timebased ; if not cranking don't do 10329 ; ; irq_spark (NEW 021v) 10330 ;Phil R reports problems with this, so try cant_crank instead 10331 ;this will give a 1-2 second delay before timebased is used 10332 ; hopefully this will not be a problem AA87 066707 10333 brset cant_crank,EnhancedBits2,timebased 10334 AA8A C6E3AD 10335 lda SparkConfig1_f ; check if noninv or inv spark AA8D A504 10336 bit #M_SC1TimCrnk ; Check if spark on time or IRQ 10337 ; return (SparkConfig1 already in A) AA8F 2711 10338 beq IRQ_SPARK 10339 10340 timebased: 10341 ;Check if time for spark AA91 B672 10342 lda rpmch AA93 B1B1 10343 cmp SparkDelayH AA95 2608 10344 bne jINJ_FIRE_CTL AA97 B673 10345 lda rpmcl AA99 B1B2 10346 cmp SparkDelayL AA9B 2602 10347 bne jINJ_FIRE_CTL AA9D 200B 10348 bra ChkHold 10349 ;** 10350 jINJ_FIRE_CTL: ; convenient place to branch to AA9F CCAF4C 10351 jmp INJ_FIRE_CTL 10352 ;** 10353 10354 IRQ_SPARK: AAA2 026116 10355 brset MSNEON,personality,irq_spark_neon AAA5 046113 10356 brset WHEEL,personality,irq_spark_neon AAA8 2EF5 10357 bil jINJ_FIRE_CTL ; IRQ still low? then skip 10358 10359 ChkHold: AAAA 115F 10360 bclr sparktrigg,sparkbits ; No more sparks for this IRQ AAAC 026113 10361 brset MSNEON,personality,DoSparkLSpeed AAAF 046110 10362 brset WHEEL,personality,DoSparkLSpeed ; no hold off on wheel decoder AAB2 B6E7 10363 lda wheelcount ; (HoldSpark) 10364 ; Check if spark is held (after 10365 ; stall and restart) AAB4 270C 10366 beq DoSparkLSpeed AAB6 3AE7 10367 dec wheelcount ; (HoldSpark) 10368 ; One spark has been held, x to go AAB8 CCAF4C 10369 jmp INJ_FIRE_CTL 10370 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 89 MC68HC908GP32 User Bootloader 10371 ; This will not work with wheel decoder, need to use a flag 10372 ; Treat end of third pulse as trigger return 10373 irq_spark_neon: AABB 0D5FE1 10374 brclr trigret,SparkBits,jINJ_FIRE_CTL AABE 1D5F 10375 bclr trigret,SparkBits ; clear it now AAC0 115F 10376 bclr sparktrigg,sparkbits ; No more sparks for this IRQ 10377 10378 DoSparkLSpeed: AAC2 1660 10379 bset sparkon,revlimbits ; spark now on 10380 AAC4 0C6971 10381 brset invspk,EnhancedBits4,dosls_inv AAC7 macro 10382 COILNEG ; macro = fire coil for non-inverted AAC7 00626A 10383 BRSET REUSE_FIDLE,OUTPUTPINS,DSLSX AACA 006A1E 10384 BRSET ROTARY2,ENHANCEDBITS5,ROT2NEG AACD 0F6232 10385 BRCLR TOY_DLI,OUTPUTPINS,NILS AAD0 006806 10386 BRSET COILABIT,COILSEL,FCNITA AAD3 026809 10387 BRSET COILBBIT,COILSEL,FCNITB AAD6 04680C 10388 BRSET COILCBIT,COILSEL,FCNITC 10389 FCNITA: AAD9 1302 10390 BCLR COILB,PORTC AADB 1502 10391 BCLR WLED,PORTC AADD 203D 10392 BRA DSLSA 10393 FCNITB: AADF 1202 10394 BSET COILB,PORTC AAE1 1502 10395 BCLR WLED,PORTC AAE3 2037 10396 BRA DSLSA 10397 FCNITC: AAE5 1302 10398 BCLR COILB,PORTC AAE7 1402 10399 BSET WLED,PORTC AAE9 2031 10400 BRA DSLSA 10401 ROT2NEG: AAEB 086328 10402 BRSET ROTARYFDIGN,FEATURE1,FIREFD AAEE 046805 10403 BRSET COILCBIT,COILSEL,ROT2CN AAF1 066808 10404 BRSET COILDBIT,COILSEL,ROT2DN AAF4 2026 10405 BRA DSLSA 10406 ROT2CN: AAF6 1502 10407 BCLR WLED,PORTC AAF8 1202 10408 BSET COILB,PORTC AAFA 203A 10409 BRA CN_END 10410 ROT2DN: AAFC 1402 10411 BSET WLED,PORTC AAFE 1202 10412 BSET COILB,PORTC AB00 2034 10413 BRA CN_END 10414 NILS: AB02 006817 10415 BRSET COILABIT,COILSEL,DSLSA AB05 026818 10416 BRSET COILBBIT,COILSEL,DSLSB AB08 046819 10417 BRSET COILCBIT,COILSEL,DSLSC AB0B 06681A 10418 BRSET COILDBIT,COILSEL,DSLSD AB0E 08681B 10419 BRSET COILEBIT,COILSEL,DSLSE AB11 0A681C 10420 BRSET COILFBIT,COILSEL,DSLSF AB14 2020 10421 BRA CN_END 10422 FIREFD: AB16 046807 10423 BRSET COILCBIT,COILSEL,DSLSB AB19 066808 10424 BRSET COILDBIT,COILSEL,DSLSC 10425 DSLSA: AB1C 1002 10426 BSET COILA,PORTC AB1E 2016 10427 BRA CN_END 10428 DSLSB: AB20 1202 10429 BSET COILB,PORTC AB22 2012 10430 BRA CN_END 10431 DSLSC: AB24 1402 10432 BSET WLED,PORTC AB26 200E 10433 BRA CN_END 10434 DSLSD: AB28 1003 10435 BSET OUTPUT3,PORTD AB2A 200A 10436 BRA CN_END 10437 DSLSE: AB2C 1602 10438 BSET PIN10,PORTC AB2E 2006 10439 BRA CN_END 10440 DSLSF: AB30 1403 10441 BSET KNOCKIN,PORTD AB32 2002 10442 BRA CN_END 10443 DSLSX: AB34 1200 10444 BSET IASC,PORTA 10445 CN_END: AB36 204D 10446 bra dosls_done 10447 dosls_inv: AB38 macro 10448 COILPOS ; macro = fire coil for inverted AB38 006248 10449 BRSET REUSE_FIDLE,OUTPUTPINS,ILSOX AB3B 006A14 10450 BRSET ROTARY2,ENHANCEDBITS5,ROT2POS AB3E 00682A 10451 BRSET COILABIT,COILSEL,ILSOA AB41 02682B 10452 BRSET COILBBIT,COILSEL,ILSOB AB44 04682C 10453 BRSET COILCBIT,COILSEL,ILSOC AB47 06682D 10454 BRSET COILDBIT,COILSEL,ILSOD AB4A 08682E 10455 BRSET COILEBIT,COILSEL,ILSOE AB4D 0A682F 10456 BRSET COILFBIT,COILSEL,ILSOF AB50 2033 10457 BRA FC_END 10458 ROT2POS: AB52 086310 10459 BRSET ROTARYFDIGN,FEATURE1,CHARGEFD AB55 046805 10460 BRSET COILCBIT,COILSEL,ROT2CP AB58 066806 10461 BRSET COILDBIT,COILSEL,ROT2DP AB5B 200E 10462 BRA ILSOA 10463 ROT2CP: AB5D 1302 10464 BCLR COILB,PORTC AB5F 2024 10465 BRA FC_END 10466 ROT2DP: AB61 1302 10467 BCLR COILB,PORTC AB63 2020 10468 BRA FC_END 10469 CHARGEFD: AB65 04680B 10470 BRSET COILCBIT,COILSEL,ILSOC AB68 066804 10471 BRSET COILDBIT,COILSEL,ILSOB 10472 ILSOA: AB6B 1102 10473 BCLR COILA,PORTC AB6D 2016 10474 BRA FC_END 10475 ILSOB: AB6F 1302 10476 BCLR COILB,PORTC AB71 2012 10477 BRA FC_END 10478 ILSOC: AB73 1502 10479 BCLR WLED,PORTC AB75 200E 10480 BRA FC_END 10481 ILSOD: AB77 1103 10482 BCLR OUTPUT3,PORTD AB79 200A 10483 BRA FC_END 10484 ILSOE: AB7B 1702 10485 BCLR PIN10,PORTC AB7D 2006 10486 BRA FC_END 10487 ILSOF: AB7F 1503 10488 BCLR KNOCKIN,PORTD AB81 2002 10489 BRA FC_END 10490 ILSOX: AB83 1300 10491 BCLR IASC,PORTA 10492 FC_END: 10493 dosls_done: 10494 ; changed - low speed and dwell control, schedule dwell at same time 10495 ; as we schedule the spark to maintain a consistent dwell 10496 ; AB85 026505 10497 brset dwellcont,feature7,b_INJFC2 ; don't schedule chg time 10498 ; here (low speed) AB88 0A6402 10499 brset min_dwell,feature2,b_INJFC2 ; don't schedule chg time here AB8B 2009 10500 bra dosls_cd 10501 b_INJFC2: AB8D CCAF4C 10502 jmp INJ_FIRE_CTL 10503 dosls_fd: 10504 ; if doing dwell control, figure out when to schedule dwell. AB90 034203 10505 brclr crank,engine,dosls_cd AB93 0A64F7 10506 brset min_dwell,feature2,b_INJFC2 ; don't schedule chg time here msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 90 MC68HC908GP32 User Bootloader 10507 ; in dwell mode min_dwell means turn coil to charge at trigger point, 10508 ; but this can give a very long dwell period which won't be good for IGBTs 10509 ; 10510 dosls_cd: AB96 9B 10511 sei AB97 macro 10512 CalcDwellspk ; Calculate spark on time AB97 06692D 10513 BRSET WSPK,ENHANCEDBITS4,WASTEDWELL AB9A 55E8 10514 LDHX DWELLDELAY1 AB9C 00680B 10515 BRSET COILABIT,COILSEL,DD_A AB9F 02680C 10516 BRSET COILBBIT,COILSEL,DD_B ABA2 04680D 10517 BRSET COILCBIT,COILSEL,DD_C ABA5 06680E 10518 BRSET COILDBIT,COILSEL,DD_D ABA8 200E 10519 BRA JDD_END ABAA 35B3 10520 DD_A: STHX SPARKONLEFTAH ABAC 200A 10521 BRA JDD_END ABAE 35B5 10522 DD_B: STHX SPARKONLEFTBH ABB0 2006 10523 BRA JDD_END ABB2 35B7 10524 DD_C: STHX SPARKONLEFTCH ABB4 2002 10525 BRA JDD_END ABB6 35B9 10526 DD_D: STHX SPARKONLEFTDH ABB8 CCAF1C 10527 JDD_END: JMP DD_END ABBB CCADD7 10528 JWDWELL6OP: JMP WDWELL6OP ABBE CCACFD 10529 JWDWELL5OP: JMP WDWELL5OP ABC1 CCAC5E 10530 JWDWELL4OP: JMP WDWELL4OP ABC4 CCAC31 10531 JWDWELL2OP: JMP WDWELL2OP 10532 WASTEDWELL: ABC7 C6E074 10533 LDA FEATURE8_F ABCA A510 10534 BIT #SPKFOPB ABCC 26ED 10535 BNE JWDWELL6OP ABCE A508 10536 BIT #SPKEOPB ABD0 26EC 10537 BNE JWDWELL5OP ABD2 0864EC 10538 BRSET OUT3SPARKD,FEATURE2,JWDWELL4OP ABD5 0562EC 10539 BRCLR REUSE_LED18,OUTPUTPINS,JWDWELL2OP ABD8 0762E9 10540 BRCLR REUSE_LED18_2,OUTPUTPINS,JWDWELL2OP 10541 WDWELL3OP: ABDB 55EC 10542 LDHX DWELLDELAY3 ABDD 006806 10543 BRSET COILABIT,COILSEL,WD3A360 ABE0 026807 10544 BRSET COILBBIT,COILSEL,WD3B360 ABE3 046808 10545 BRSET COILCBIT,COILSEL,WD3C360 ABE6 35B3 10546 WD3A360: STHX SPARKONLEFTAH ABE8 2006 10547 BRA WD3END360 ABEA 35B5 10548 WD3B360: STHX SPARKONLEFTBH ABEC 2002 10549 BRA WD3END360 ABEE 35B7 10550 WD3C360: STHX SPARKONLEFTCH 10551 WD3END360: ABF0 B6E8 10552 LDA DWELLDELAY1 ABF2 2606 10553 BNE WD3OK120 ABF4 B6E9 10554 LDA DWELLDELAY1+1 ABF6 A102 10555 CMP #2 ABF8 2515 10556 BLO WD3SKIP120 10557 WD3OK120: ABFA 55E8 10558 LDHX DWELLDELAY1 ABFC 006806 10559 BRSET COILABIT,COILSEL,WD3A120 ABFF 026807 10560 BRSET COILBBIT,COILSEL,WD3B120 AC02 046808 10561 BRSET COILCBIT,COILSEL,WD3C120 AC05 35B5 10562 WD3A120: STHX SPARKONLEFTBH AC07 2006 10563 BRA WD3END120 AC09 35B7 10564 WD3B120: STHX SPARKONLEFTCH AC0B 2002 10565 BRA WD3END120 AC0D 35B3 10566 WD3C120: STHX SPARKONLEFTAH 10567 WD3END120: 10568 WD3SKIP120: AC0F B6EA 10569 LDA DWELLDELAY2 AC11 2606 10570 BNE WD3OK240 AC13 B6EB 10571 LDA DWELLDELAY2+1 AC15 A102 10572 CMP #2 AC17 2515 10573 BLO WD3END240 10574 WD3OK240: AC19 55EA 10575 LDHX DWELLDELAY2 AC1B 006806 10576 BRSET COILABIT,COILSEL,WD3A240 AC1E 026807 10577 BRSET COILBBIT,COILSEL,WD3B240 AC21 046808 10578 BRSET COILCBIT,COILSEL,WD3C240 AC24 35B7 10579 WD3A240: STHX SPARKONLEFTCH AC26 2006 10580 BRA WD3END240 AC28 35B3 10581 WD3B240: STHX SPARKONLEFTAH AC2A 2002 10582 BRA WD3END240 AC2C 35B5 10583 WD3C240: STHX SPARKONLEFTBH AC2E CCAF1C 10584 WD3END240: JMP DD_END 10585 WDWELL2OP: AC31 55EA 10586 LDHX DWELLDELAY2 AC33 026804 10587 BRSET COILBBIT,COILSEL,WD2B360 AC36 35B3 10588 WD2A360: STHX SPARKONLEFTAH AC38 2002 10589 BRA WD2END360 AC3A 35B5 10590 WD2B360: STHX SPARKONLEFTBH 10591 WD2END360: AC3C C6E3AD 10592 LDA SPARKCONFIG1_F AC3F A510 10593 BIT #M_SC1ODDFIRE AC41 2618 10594 BNE WD2SKIP AC43 B6E8 10595 LDA DWELLDELAY1 AC45 2606 10596 BNE WD2OK AC47 B6E9 10597 LDA DWELLDELAY1+1 AC49 A102 10598 CMP #2 AC4B 250E 10599 BLO WD2SKIP 10600 WD2OK: AC4D 55E8 10601 LDHX DWELLDELAY1 AC4F 006803 10602 BRSET COILABIT,COILSEL,WD2A180 AC52 026804 10603 BRSET COILBBIT,COILSEL,WD2B180 AC55 35B5 10604 WD2A180: STHX SPARKONLEFTBH AC57 2002 10605 BRA WD2END180 AC59 35B3 10606 WD2B180: STHX SPARKONLEFTAH 10607 WD2END180: AC5B CCAF1C 10608 WD2SKIP: JMP DD_END 10609 WDWELL4OP: AC5E 55EE 10610 LDHX DWELLDELAY4 AC60 006809 10611 BRSET COILABIT,COILSEL,WD4A360 AC63 02680A 10612 BRSET COILBBIT,COILSEL,WD4B360 AC66 04680B 10613 BRSET COILCBIT,COILSEL,WD4C360 AC69 06680C 10614 BRSET COILDBIT,COILSEL,WD4D360 AC6C 35B3 10615 WD4A360: STHX SPARKONLEFTAH AC6E 200A 10616 BRA WD4END360 AC70 35B5 10617 WD4B360: STHX SPARKONLEFTBH AC72 2006 10618 BRA WD4END360 AC74 35B7 10619 WD4C360: STHX SPARKONLEFTCH AC76 2002 10620 BRA WD4END360 AC78 35B9 10621 WD4D360: STHX SPARKONLEFTDH 10622 WD4END360: AC7A C6E3AD 10623 LDA SPARKCONFIG1_F AC7D A510 10624 BIT #M_SC1ODDFIRE AC7F 2626 10625 BNE WD4SKIP90 AC81 B6E8 10626 LDA DWELLDELAY1 AC83 2606 10627 BNE WD4OK90 AC85 B6E9 10628 LDA DWELLDELAY1+1 AC87 A102 10629 CMP #2 AC89 251C 10630 BLO WD4SKIP90 10631 WD4OK90: AC8B 55E8 10632 LDHX DWELLDELAY1 AC8D 006809 10633 BRSET COILABIT,COILSEL,WD4A90 AC90 02680A 10634 BRSET COILBBIT,COILSEL,WD4B90 AC93 04680B 10635 BRSET COILCBIT,COILSEL,WD4C90 AC96 06680C 10636 BRSET COILDBIT,COILSEL,WD4D90 AC99 35B5 10637 WD4A90: STHX SPARKONLEFTBH AC9B 200A 10638 BRA WD4END90 AC9D 35B7 10639 WD4B90: STHX SPARKONLEFTCH AC9F 2006 10640 BRA WD4END90 ACA1 35B9 10641 WD4C90: STHX SPARKONLEFTDH ACA3 2002 10642 BRA WD4END90 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 91 MC68HC908GP32 User Bootloader ACA5 35B3 10643 WD4D90: STHX SPARKONLEFTAH 10644 WD4END90: 10645 WD4SKIP90: ACA7 B6EA 10646 LDA DWELLDELAY2 ACA9 2606 10647 BNE WD4OK180 ACAB B6EB 10648 LDA DWELLDELAY2+1 ACAD A102 10649 CMP #2 ACAF 251C 10650 BLO WD4SKIP180 10651 WD4OK180: ACB1 55EA 10652 LDHX DWELLDELAY2 ACB3 006809 10653 BRSET COILABIT,COILSEL,WD4A180 ACB6 02680A 10654 BRSET COILBBIT,COILSEL,WD4B180 ACB9 04680B 10655 BRSET COILCBIT,COILSEL,WD4C180 ACBC 06680C 10656 BRSET COILDBIT,COILSEL,WD4D180 ACBF 35B7 10657 WD4A180: STHX SPARKONLEFTCH ACC1 200A 10658 BRA WD4END180 ACC3 35B9 10659 WD4B180: STHX SPARKONLEFTDH ACC5 2006 10660 BRA WD4END180 ACC7 35B3 10661 WD4C180: STHX SPARKONLEFTAH ACC9 2002 10662 BRA WD4END180 ACCB 35B5 10663 WD4D180: STHX SPARKONLEFTBH 10664 WD4END180: 10665 WD4SKIP180: ACCD C6E3AD 10666 LDA SPARKCONFIG1_F ACD0 A510 10667 BIT #M_SC1ODDFIRE ACD2 2626 10668 BNE WD4END270 ACD4 B6EC 10669 LDA DWELLDELAY3 ACD6 2606 10670 BNE WD4OK270 ACD8 B6ED 10671 LDA DWELLDELAY3+1 ACDA A102 10672 CMP #2 ACDC 251C 10673 BLO WD4END270 10674 WD4OK270: ACDE 55EC 10675 LDHX DWELLDELAY3 ACE0 006809 10676 BRSET COILABIT,COILSEL,WD4A270 ACE3 02680A 10677 BRSET COILBBIT,COILSEL,WD4B270 ACE6 04680B 10678 BRSET COILCBIT,COILSEL,WD4C270 ACE9 06680C 10679 BRSET COILDBIT,COILSEL,WD4D270 ACEC 35B9 10680 WD4A270: STHX SPARKONLEFTDH ACEE 200A 10681 BRA WD4END270 ACF0 35B3 10682 WD4B270: STHX SPARKONLEFTAH ACF2 2006 10683 BRA WD4END270 ACF4 35B5 10684 WD4C270: STHX SPARKONLEFTBH ACF6 2002 10685 BRA WD4END270 ACF8 35B7 10686 WD4D270: STHX SPARKONLEFTCH 10687 WD4END270: ACFA CCAF1C 10688 JMP DD_END 10689 WDWELL5OP: ACFD 55F0 10690 LDHX DWELLDELAY5 ACFF 00680C 10691 BRSET COILABIT,COILSEL,WD5A360 AD02 02680D 10692 BRSET COILBBIT,COILSEL,WD5B360 AD05 04680E 10693 BRSET COILCBIT,COILSEL,WD5C360 AD08 06680F 10694 BRSET COILDBIT,COILSEL,WD5D360 AD0B 066810 10695 BRSET COILDBIT,COILSEL,WD5E360 AD0E 35B3 10696 WD5A360: STHX SPARKONLEFTAH AD10 200E 10697 BRA WD5END360 AD12 35B5 10698 WD5B360: STHX SPARKONLEFTBH AD14 200A 10699 BRA WD5END360 AD16 35B7 10700 WD5C360: STHX SPARKONLEFTCH AD18 2006 10701 BRA WD5END360 AD1A 35B9 10702 WD5D360: STHX SPARKONLEFTDH AD1C 2002 10703 BRA WD5END360 AD1E 35BB 10704 WD5E360: STHX SPARKONLEFTEH 10705 WD5END360: AD20 B6E8 10706 LDA DWELLDELAY1 AD22 2606 10707 BNE WD5OK72 AD24 B6E9 10708 LDA DWELLDELAY1+1 AD26 A102 10709 CMP #2 AD28 2523 10710 BLO WD5SKIP72 10711 WD5OK72: AD2A 55E8 10712 LDHX DWELLDELAY1 AD2C 00680C 10713 BRSET COILABIT,COILSEL,WD5A72 AD2F 02680D 10714 BRSET COILBBIT,COILSEL,WD5B72 AD32 04680E 10715 BRSET COILCBIT,COILSEL,WD5C72 AD35 06680F 10716 BRSET COILDBIT,COILSEL,WD5D72 AD38 086810 10717 BRSET COILEBIT,COILSEL,WD5E72 AD3B 35B5 10718 WD5A72: STHX SPARKONLEFTBH AD3D 200E 10719 BRA WD5END72 AD3F 35B7 10720 WD5B72: STHX SPARKONLEFTCH AD41 200A 10721 BRA WD5END72 AD43 35B9 10722 WD5C72: STHX SPARKONLEFTDH AD45 2006 10723 BRA WD5END72 AD47 35BB 10724 WD5D72: STHX SPARKONLEFTEH AD49 2002 10725 BRA WD5END72 AD4B 35B3 10726 WD5E72: STHX SPARKONLEFTAH 10727 WD5END72: 10728 WD5SKIP72: AD4D B6EA 10729 LDA DWELLDELAY2 AD4F 2606 10730 BNE WD5OK144 AD51 B6EB 10731 LDA DWELLDELAY2+1 AD53 A102 10732 CMP #2 AD55 2523 10733 BLO WD5SKIP144 10734 WD5OK144: AD57 55EA 10735 LDHX DWELLDELAY2 AD59 00680C 10736 BRSET COILABIT,COILSEL,WD5A144 AD5C 02680D 10737 BRSET COILBBIT,COILSEL,WD5B144 AD5F 04680E 10738 BRSET COILCBIT,COILSEL,WD5C144 AD62 06680F 10739 BRSET COILDBIT,COILSEL,WD5D144 AD65 086810 10740 BRSET COILEBIT,COILSEL,WD5E144 AD68 35B7 10741 WD5A144: STHX SPARKONLEFTCH AD6A 200E 10742 BRA WD5END144 AD6C 35B9 10743 WD5B144: STHX SPARKONLEFTDH AD6E 200A 10744 BRA WD5END144 AD70 35BB 10745 WD5C144: STHX SPARKONLEFTEH AD72 2006 10746 BRA WD5END144 AD74 35B3 10747 WD5D144: STHX SPARKONLEFTAH AD76 2002 10748 BRA WD5END144 AD78 35B5 10749 WD5E144: STHX SPARKONLEFTBH 10750 WD5END144: 10751 WD5SKIP144: AD7A B6EC 10752 LDA DWELLDELAY3 AD7C 2606 10753 BNE WD5OK216 AD7E B6ED 10754 LDA DWELLDELAY3+1 AD80 A102 10755 CMP #2 AD82 2523 10756 BLO WD5SKIP216 10757 WD5OK216: AD84 55EC 10758 LDHX DWELLDELAY3 AD86 00680C 10759 BRSET COILABIT,COILSEL,WD5A216 AD89 02680D 10760 BRSET COILBBIT,COILSEL,WD5B216 AD8C 04680E 10761 BRSET COILCBIT,COILSEL,WD5C216 AD8F 06680F 10762 BRSET COILDBIT,COILSEL,WD5D216 AD92 086810 10763 BRSET COILEBIT,COILSEL,WD5E216 AD95 35B9 10764 WD5A216: STHX SPARKONLEFTDH AD97 200E 10765 BRA WD5END216 AD99 35BB 10766 WD5B216: STHX SPARKONLEFTEH AD9B 200A 10767 BRA WD5END216 AD9D 35B3 10768 WD5C216: STHX SPARKONLEFTAH AD9F 2006 10769 BRA WD5END216 ADA1 35B5 10770 WD5D216: STHX SPARKONLEFTBH ADA3 2002 10771 BRA WD5END216 ADA5 35B7 10772 WD5E216: STHX SPARKONLEFTCH 10773 WD5END216: 10774 WD5SKIP216: ADA7 B6EE 10775 LDA DWELLDELAY4 ADA9 2606 10776 BNE WD5OK288 ADAB B6EF 10777 LDA DWELLDELAY4+1 ADAD A102 10778 CMP #2 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 92 MC68HC908GP32 User Bootloader ADAF 2523 10779 BLO WD5SKIP288 10780 WD5OK288: ADB1 55EE 10781 LDHX DWELLDELAY4 ADB3 00680C 10782 BRSET COILABIT,COILSEL,WD5A288 ADB6 02680D 10783 BRSET COILBBIT,COILSEL,WD5B288 ADB9 04680E 10784 BRSET COILCBIT,COILSEL,WD5C288 ADBC 06680F 10785 BRSET COILDBIT,COILSEL,WD5D288 ADBF 086810 10786 BRSET COILEBIT,COILSEL,WD5E288 ADC2 35BB 10787 WD5A288: STHX SPARKONLEFTEH ADC4 200E 10788 BRA WD5END288 ADC6 35B3 10789 WD5B288: STHX SPARKONLEFTAH ADC8 200A 10790 BRA WD5END288 ADCA 35B5 10791 WD5C288: STHX SPARKONLEFTBH ADCC 2006 10792 BRA WD5END288 ADCE 35B7 10793 WD5D288: STHX SPARKONLEFTCH ADD0 2002 10794 BRA WD5END288 ADD2 35B9 10795 WD5E288: STHX SPARKONLEFTDH 10796 WD5END288: 10797 WD5SKIP288: ADD4 CCAF1C 10798 JMP DD_END 10799 WDWELL6OP: ADD7 55F2 10800 LDHX DWELLDELAY6 ADD9 00680F 10801 BRSET COILABIT,COILSEL,WD6A360 ADDC 026810 10802 BRSET COILBBIT,COILSEL,WD6B360 ADDF 046811 10803 BRSET COILCBIT,COILSEL,WD6C360 ADE2 066812 10804 BRSET COILDBIT,COILSEL,WD6D360 ADE5 086813 10805 BRSET COILEBIT,COILSEL,WD6E360 ADE8 0A6814 10806 BRSET COILFBIT,COILSEL,WD6F360 ADEB 35B3 10807 WD6A360: STHX SPARKONLEFTAH ADED 2012 10808 BRA WD6END360 ADEF 35B5 10809 WD6B360: STHX SPARKONLEFTBH ADF1 200E 10810 BRA WD6END360 ADF3 35B7 10811 WD6C360: STHX SPARKONLEFTCH ADF5 200A 10812 BRA WD6END360 ADF7 35B9 10813 WD6D360: STHX SPARKONLEFTDH ADF9 2006 10814 BRA WD6END360 ADFB 35BB 10815 WD6E360: STHX SPARKONLEFTEH ADFD 2002 10816 BRA WD6END360 ADFF 35BD 10817 WD6F360: STHX SPARKONLEFTFH 10818 WD6END360: AE01 C6E3AD 10819 LDA SPARKCONFIG1_F AE04 A510 10820 BIT #M_SC1ODDFIRE AE06 2634 10821 BNE WD6SKIP60 AE08 B6E8 10822 LDA DWELLDELAY1 AE0A 2606 10823 BNE WD6OK60 AE0C B6E9 10824 LDA DWELLDELAY1+1 AE0E A105 10825 CMP #5 AE10 252A 10826 BLO WD6SKIP60 10827 WD6OK60: AE12 55E8 10828 LDHX DWELLDELAY1 AE14 00680F 10829 BRSET COILABIT,COILSEL,WD6A60 AE17 026810 10830 BRSET COILBBIT,COILSEL,WD6B60 AE1A 046811 10831 BRSET COILCBIT,COILSEL,WD6C60 AE1D 066812 10832 BRSET COILDBIT,COILSEL,WD6D60 AE20 086813 10833 BRSET COILEBIT,COILSEL,WD6E60 AE23 0A6814 10834 BRSET COILFBIT,COILSEL,WD6F60 AE26 35B5 10835 WD6A60: STHX SPARKONLEFTBH AE28 2012 10836 BRA WD6END60 AE2A 35B7 10837 WD6B60: STHX SPARKONLEFTCH AE2C 200E 10838 BRA WD6END60 AE2E 35B9 10839 WD6C60: STHX SPARKONLEFTDH AE30 200A 10840 BRA WD6END60 AE32 35BB 10841 WD6D60: STHX SPARKONLEFTEH AE34 2006 10842 BRA WD6END60 AE36 35BD 10843 WD6E60: STHX SPARKONLEFTFH AE38 2002 10844 BRA WD6END60 AE3A 35B3 10845 WD6F60: STHX SPARKONLEFTAH 10846 WD6END60: 10847 WD6SKIP60: AE3C B6EA 10848 LDA DWELLDELAY2 AE3E 2606 10849 BNE WD6OK120 AE40 B6EB 10850 LDA DWELLDELAY2+1 AE42 A105 10851 CMP #5 AE44 252A 10852 BLO WD6SKIP120 10853 WD6OK120: AE46 55EA 10854 LDHX DWELLDELAY2 AE48 00680F 10855 BRSET COILABIT,COILSEL,WD6A120 AE4B 026810 10856 BRSET COILBBIT,COILSEL,WD6B120 AE4E 046811 10857 BRSET COILCBIT,COILSEL,WD6C120 AE51 066812 10858 BRSET COILDBIT,COILSEL,WD6D120 AE54 086813 10859 BRSET COILEBIT,COILSEL,WD6E120 AE57 0A6814 10860 BRSET COILFBIT,COILSEL,WD6F120 AE5A 35B7 10861 WD6A120: STHX SPARKONLEFTCH AE5C 2012 10862 BRA WD6END120 AE5E 35B9 10863 WD6B120: STHX SPARKONLEFTDH AE60 200E 10864 BRA WD6END120 AE62 35BB 10865 WD6C120: STHX SPARKONLEFTEH AE64 200A 10866 BRA WD6END120 AE66 35BD 10867 WD6D120: STHX SPARKONLEFTFH AE68 2006 10868 BRA WD6END120 AE6A 35B3 10869 WD6E120: STHX SPARKONLEFTAH AE6C 2002 10870 BRA WD6END120 AE6E 35B5 10871 WD6F120: STHX SPARKONLEFTBH 10872 WD6END120: 10873 WD6SKIP120: AE70 C6E3AD 10874 LDA SPARKCONFIG1_F AE73 A510 10875 BIT #M_SC1ODDFIRE AE75 2636 10876 BNE WD6SKIP180 AE77 B6EC 10877 LDA DWELLDELAY3 AE79 2606 10878 BNE WD6OK180 AE7B B6ED 10879 LDA DWELLDELAY3+1 AE7D A105 10880 CMP #5 AE7F 252C 10881 BLO WD6SKIP180 10882 WD6OK180: AE81 55EC 10883 LDHX DWELLDELAY3 AE83 00680F 10884 BRSET COILABIT,COILSEL,WD6A180 AE86 026810 10885 BRSET COILBBIT,COILSEL,WD6B180 AE89 046811 10886 BRSET COILCBIT,COILSEL,WD6C180 AE8C 066812 10887 BRSET COILDBIT,COILSEL,WD6D180 AE8F 086813 10888 BRSET COILEBIT,COILSEL,WD6E180 AE92 0A6814 10889 BRSET COILFBIT,COILSEL,WD6F180 AE95 35B9 10890 WD6A180: STHX SPARKONLEFTDH AE97 2012 10891 BRA WD6END180 AE99 35BB 10892 WD6B180: STHX SPARKONLEFTEH AE9B 200E 10893 BRA WD6END180 AE9D 35BD 10894 WD6C180: STHX SPARKONLEFTFH AE9F 200A 10895 BRA WD6END180 AEA1 35B3 10896 WD6D180: STHX SPARKONLEFTAH AEA3 2006 10897 BRA WD6END180 AEA5 35B5 10898 WD6E180: STHX SPARKONLEFTBH AEA7 2002 10899 BRA WD6END180 AEA9 35B7 10900 WD6F180: STHX SPARKONLEFTCH 10901 WD6END180: AEAB 206F 10902 BRA DD_END 10903 WD6SKIP180: AEAD B6EE 10904 LDA DWELLDELAY4 AEAF 2606 10905 BNE WD6OK240 AEB1 B6EF 10906 LDA DWELLDELAY4+1 AEB3 A105 10907 CMP #5 AEB5 252A 10908 BLO WD6SKIP240 10909 WD6OK240: AEB7 55EE 10910 LDHX DWELLDELAY4 AEB9 00680F 10911 BRSET COILABIT,COILSEL,WD6A240 AEBC 026810 10912 BRSET COILBBIT,COILSEL,WD6B240 AEBF 046811 10913 BRSET COILCBIT,COILSEL,WD6C240 AEC2 066812 10914 BRSET COILDBIT,COILSEL,WD6D240 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 93 MC68HC908GP32 User Bootloader AEC5 086813 10915 BRSET COILEBIT,COILSEL,WD6E240 AEC8 0A6814 10916 BRSET COILFBIT,COILSEL,WD6F240 AECB 35BB 10917 WD6A240: STHX SPARKONLEFTEH AECD 2012 10918 BRA WD6END240 AECF 35BD 10919 WD6B240: STHX SPARKONLEFTFH AED1 200E 10920 BRA WD6END240 AED3 35B3 10921 WD6C240: STHX SPARKONLEFTAH AED5 200A 10922 BRA WD6END240 AED7 35B5 10923 WD6D240: STHX SPARKONLEFTBH AED9 2006 10924 BRA WD6END240 AEDB 35B7 10925 WD6E240: STHX SPARKONLEFTCH AEDD 2002 10926 BRA WD6END240 AEDF 35B9 10927 WD6F240: STHX SPARKONLEFTDH 10928 WD6END240: 10929 WD6SKIP240: AEE1 C6E3AD 10930 LDA SPARKCONFIG1_F AEE4 A510 10931 BIT #M_SC1ODDFIRE AEE6 2634 10932 BNE WD6SKIP300 AEE8 B6F0 10933 LDA DWELLDELAY5 AEEA 2606 10934 BNE WD6OK300 AEEC B6F1 10935 LDA DWELLDELAY5+1 AEEE A105 10936 CMP #5 AEF0 252A 10937 BLO WD6SKIP300 10938 WD6OK300: AEF2 55F0 10939 LDHX DWELLDELAY5 AEF4 00680F 10940 BRSET COILABIT,COILSEL,WD6A300 AEF7 026810 10941 BRSET COILBBIT,COILSEL,WD6B300 AEFA 046811 10942 BRSET COILCBIT,COILSEL,WD6C300 AEFD 066812 10943 BRSET COILDBIT,COILSEL,WD6D300 AF00 086813 10944 BRSET COILEBIT,COILSEL,WD6E300 AF03 0A6814 10945 BRSET COILFBIT,COILSEL,WD6F300 AF06 35BB 10946 WD6A300: STHX SPARKONLEFTEH AF08 2012 10947 BRA WD6END300 AF0A 35BD 10948 WD6B300: STHX SPARKONLEFTFH AF0C 200E 10949 BRA WD6END300 AF0E 35B3 10950 WD6C300: STHX SPARKONLEFTAH AF10 200A 10951 BRA WD6END300 AF12 35B5 10952 WD6D300: STHX SPARKONLEFTBH AF14 2006 10953 BRA WD6END300 AF16 35B7 10954 WD6E300: STHX SPARKONLEFTCH AF18 2002 10955 BRA WD6END300 AF1A 35B9 10956 WD6F300: STHX SPARKONLEFTDH 10957 WD6END300: 10958 WD6SKIP300: 10959 DD_END: AF1C 9A 10960 cli 10961 b_INJFC: AF1D 202D 10962 bra INJ_FIRE_CTL 10963 10964 ;fresh section for TFI spark to keep things clearer 10965 TFI_spk: 10966 ;if tfi & sparkon & low speed & irq high then follow 10967 ; ??? next line irrelevant ??? commented 027b 20th Nov 05 10968 ; brclr sparkon,revlimbits,INJ_FIRE_CTL ; if output not active then 10969 ; skip 10970 ; brclr sparktrigg,sparkbits,INJ_FIRE_CTL ; if sparktrigg??? 10971 ; not active then skip AF1F 055F04 10972 brclr SparkLSpeed,Sparkbits,tfi_fast ; if not slow then do high 10973 ; speed calc AF22 2E28 10974 bil INJ_FIRE_CTL ; if IRQ still low then skip AF24 200D 10975 bra tfispkoff ; irq has risen, de-activate output 10976 10977 tfi_fast: 10978 ; if high speed only need to worry about trailing (rising) edge 10979 ; of output as the firing (falling) edge of the output is done 10980 ; by the hi-res timer section 10981 ; AF26 55B3 10982 ldhx SparkOnLeftah AF28 2722 10983 beq INJ_FIRE_CTL ; shouldn't happen, but just in case AF2A AFFF 10984 aix #-1 AF2C 35B3 10985 sthx SparkOnLeftah AF2E 650000 10986 cphx #0 AF31 2619 10987 bne INJ_FIRE_CTL 10988 10989 tfispkoff: AF33 1760 10990 bclr sparkon,revlimbits ; spark now off 10991 ; with TFI as envisaged it only really makes sense to have one 10992 ; kind of wiring but keep inverted/non-inverted. Only one output 10993 ; 10994 AF35 0D690B 10995 brclr invspk,EnhancedBits4,tfioutoff 10996 ;inverted AF38 006204 10997 brset REUSE_FIDLE,outputpins,tfiif AF3B 1002 10998 bset coila,portc AF3D 200D 10999 bra INJ_FIRE_CTL 11000 tfiif: AF3F 1200 11001 bset iasc,porta AF41 2009 11002 bra INJ_FIRE_CTL 11003 11004 tfioutoff: AF43 006204 11005 brset REUSE_FIDLE,outputpins,tfiof AF46 1102 11006 bclr coila,portc AF48 2002 11007 bra INJ_FIRE_CTL 11008 tfiof: AF4A 1300 11009 bclr iasc,porta 11010 ; bra INJ_FIRE_CTL 11011 11012 INJ_FIRE_CTL: 11013 ;======== Injector Firing Control ======== 11014 ;===== Main Injector Control Logic ======= AF4C 04410C 11015 brset sched1,squirt,NEW_SQUIRT1 11016 INJF1: AF4F 084124 11017 brset sched2,squirt,NEW_SQUIRT2 11018 INJF2: AF52 06415B 11019 brset firing1,squirt,CHK_DONE_1 11020 INJF3: AF55 0A416C 11021 brset firing2,squirt,CHK_DONE_2JMP AF58 CCB036 11022 jmp inj2done 11023 11024 ;=== Injector #1 - Start New Injection === 11025 NEW_SQUIRT1: AF5B 1641 11026 bset firing1,squirt ; Turn on "firing" bit AF5D 1541 11027 bclr sched1,squirt ; Turn off schedule bit (is 11028 ; now current operation) AF5F 1041 11029 bset inj1,squirt AF61 3F6C 11030 clr pwrun1 AF63 026202 11031 brset REUSE_LED17,outputpins,nsq1 AF66 1002 11032 bset sled,portc ; squrt LED is ON 11033 nsq1: AF68 6E0026 11034 mov #$00,T1CH0H AF6B C6E199 11035 lda INJPWM_f1 AF6E B727 11036 sta T1CH0L AF70 1E00 11037 bset 7,PORTA ; ** Flyback Damper - turn on X0 11038 ; for Inj1 11039 No_FlyBk: AF72 1903 11040 bclr inject1,portd ; ^* * * Turn on Injector #1 11041 ; (inverted drive) AF74 20D9 11042 bra INJF1 11043 11044 ;=== Injector #2 - Start New Injection === 11045 NEW_SQUIRT2: AF76 1A41 11046 bset firing2,squirt ; Turn on "firing" bit AF78 1941 11047 bclr sched2,squirt ; Turn off schedule bit (is now 11048 ; current operation) AF7A 1241 11049 bset inj2,squirt AF7C 3F6D 11050 clr pwrun2 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 94 MC68HC908GP32 User Bootloader AF7E 026202 11051 brset REUSE_LED17,outputpins,nsq2 AF81 1002 11052 bset sled,portc ; squrt LED is ON 11053 nsq2: AF83 6E0029 11054 mov #$00,T1CH1H AF86 C6E021 11055 lda DTmode_f AF89 A510 11056 bit #alt_i2t2 AF8B 2705 11057 beq nsq2single 11058 AF8D C6E299 11059 lda INJPWM_f2 AF90 2003 11060 bra nsq2cont 11061 nsq2single: AF92 C6E199 11062 lda INJPWM_f1 11063 nsq2cont: AF95 B72A 11064 sta T1CH1L AF97 1C00 11065 bset 6,PORTA ; ** Flyback Damper - turn on X1 11066 ; for Injector 2 AF99 1B03 11067 bclr inject2,portd ; ^* * * Turn on Injector #2 11068 ; (inverted drive) 11069 AF9B C6E02E 11070 lda feature3_f AF9E A508 11071 bit #WaterInjb AFA0 27B0 11072 beq INJF2 11073 ; brclr WaterInj,feature3,INJF2 AFA2 0A0002 11074 brset water,porta,inject_water ; If water needed go to 11075 ; inject water AFA5 20AB 11076 bra INJF2 11077 inject_water: AFA7 0E63A8 11078 brset Nitrous,feature1,INJF2 ; If NOS Selected dont turn on 11079 ; water pulsed output AFAA 1800 11080 bset water2,porta ; Turn water injector on with 11081 ; fuel inj 2 AFAC 20A4 11082 bra INJF2 ; Carry on as normal 11083 INJF3JMP: AFAE 20A5 11084 bra INJF3 11085 ;=== Injector #1 - Check for end of Injection === 11086 CHK_DONE_1: AFB0 3C6C 11087 inc pwrun1 AFB2 B66C 11088 lda pwrun1 AFB4 B14E 11089 cmp pw1 AFB6 270E 11090 beq OFF_INJ_1 AFB8 02429A 11091 brset crank,engine,INJF3 ; do not perform PWM limiting 11092 ; when cranking AFBB B66C 11093 lda pwrun1 AFBD C1E19A 11094 cmp INJPWMT_f1 AFC0 271A 11095 beq PWM_LIMIT_1 AFC2 2091 11096 bra INJF3 11097 CHK_DONE_2JMP: AFC4 2022 11098 bra CHK_DONE_2 ; Jump added 11099 OFF_INJ_1: AFC6 1741 11100 bclr firing1,squirt AFC8 1541 11101 bclr sched1,squirt AFCA 1141 11102 bclr inj1,squirt AFCC 1F00 11103 bclr 7,PORTA ; ** Flyback Damper - turn off X0 AFCE 1803 11104 bset inject1,portd ; ^* * * Turn Off Injector #1 11105 ; (inverted drive) AFD0 6E3220 11106 mov #T1Timerstop,T1SC AFD3 6E1025 11107 mov #t1scx_NO_PWM,T1SC0 AFD6 6E0220 11108 mov #Timergo_NO_INT,T1SC 11109 ; bra INJF3 AFD9 CCAF55 11110 jmp INJF3 11111 PWM_LIMIT_1: AFDC 6E3220 11112 mov #T1Timerstop,T1SC AFDF 6E1E25 11113 mov #T1SCX_PWM,T1SC0 AFE2 6E0220 11114 mov #Timergo_NO_INT,T1SC 11115 ; bra INJF3JMP AFE5 CCAF55 11116 jmp INJF3 11117 11118 ;=== Injector #2 - Check for end of Injection === 11119 CHK_DONE_2: AFE8 3C6D 11120 inc pwrun2 AFEA B66D 11121 lda pwrun2 AFEC B153 11122 cmp pw2 AFEE 271F 11123 beq OFF_INJ_2 11124 ; brset crank,engine,CHECK_RPM ; do not perform PWM limiting 11125 ; when cranking AFF0 034203 11126 brclr crank,engine,CKDN2 AFF3 CCB084 11127 jmp CHECK_RPM 11128 CKDN2: AFF6 C6E021 11129 lda DTmode_f AFF9 A510 11130 bit #alt_i2t2 AFFB 2709 11131 beq ckd2single ; dt=0 11132 AFFD B66D 11133 lda pwrun2 ; use PWM settings from second table AFFF C1E29A 11134 cmp INJPWMT_f2 B002 2729 11135 beq PWM_LIMIT_2 B004 2030 11136 bra inj2done 11137 ckd2single: B006 B66D 11138 lda pwrun2 ; use PWM settings from first table B008 C1E19A 11139 cmp INJPWMT_f1 B00B 2720 11140 beq PWM_LIMIT_2 B00D 2027 11141 bra inj2done 11142 11143 OFF_INJ_2: B00F 1B41 11144 bclr firing2,squirt B011 1941 11145 bclr sched2,squirt B013 1341 11146 bclr inj2,squirt B015 1D00 11147 bclr 6,PORTA ; ** Flyback Damper - turn off X1 11148 ; (for Inj 2) B017 1A03 11149 bset inject2,portd ; ^* * * Turn Off Injector #2 11150 ; (inverted drive) B019 C6E02E 11151 lda feature3_f B01C A508 11152 bit #WaterInjb B01E 2702 11153 beq Dont_Clr_Water2 11154 ; brclr WaterInj,feature3,Dont_Clr_Water2 ; if not using water 11155 ; then skip B020 1900 11156 bclr water2,porta ; Turn off water injection pulse 11157 Dont_Clr_Water2: B022 6E3220 11158 mov #T1Timerstop,T1SC B025 6E1028 11159 mov #t1scx_NO_PWM,T1SC1 B028 6E0220 11160 mov #Timergo_NO_INT,T1SC B02B 2009 11161 bra inj2done 11162 PWM_LIMIT_2: B02D 6E3220 11163 mov #T1Timerstop,T1SC B030 6E1E28 11164 mov #T1SCX_PWM,T1SC1 B033 6E0220 11165 mov #Timergo_NO_INT,T1SC 11166 11167 inj2done: B036 006228 11168 brset REUSE_FIDLE,outputpins,idleActDone 11169 11170 ***************************************************************************** 11171 ** Idle Control PWM Actuator 11172 ** 11173 ** Runs at 10000/100 = 100 Hz. Must be before RPM check. 11174 ***************************************************************************** 11175 11176 idleActuator: B039 02421F 11177 brset crank,engine,idleActOn ; if cranking then keep it 11178 ; shut (rmd changed from off to on) B03C 014220 11179 brclr running,engine,idleActOff ; if not running then close it B03F 07640B 11180 brclr PWMidle,feature2,idleActCheck ; skip if on/off mode 11181 B042 3CD3 11182 inc idleActClock ; Adjust idle PWM count B044 B6D3 11183 lda idleActClock B046 C1E09A 11184 cmp idlefreq_f B049 2602 11185 bne idleActCheck B04B 3FD3 11186 clr idleActClock msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 95 MC68HC908GP32 User Bootloader 11187 11188 idleActCheck: B04D B655 11189 lda idleDC B04F A100 11190 cmp #0T B051 270C 11191 beq idleActOff B053 A1FF 11192 cmp #255T B055 2704 11193 beq idleActOn B057 B1D3 11194 cmp idleActClock B059 2304 11195 bls idleActOff 11196 11197 idleActOn: B05B 1200 11198 bset iasc,porta B05D 2002 11199 bra idleActDone 11200 11201 idleActOff: B05F 1300 11202 bclr iasc,porta 11203 11204 idleActDone: 11205 11206 ***************************************************************************** 11207 ** Boost Controller PWM 11208 ** 11209 ** Set bcDC to 0 (0% duty cycle) to 255 (100% DC). PWM frequency is 11210 ** user-defined by bcFreqDiv, see above. 11211 ** 11212 ** 11213 ** 020w3 0% = low boost, 100% = high boost in calculations 11214 ** can invert the output to reverse the sense 11215 ***************************************************************************** 11216 B061 016420 11217 brclr BoostControl,feature2,doneBoostControl 11218 doBoostControl: B064 B6CF 11219 lda bcDC B066 270D 11220 beq boostOff ; Turn it off, if duty cycle is zero. B068 B1D4 11221 cmp bcActClock B06A 2509 11222 blo boostOff 11223 11224 boostOn: B06C C6E05C 11225 lda feature6_f B06F A540 11226 bit #BoostDirb B071 260F 11227 bne bcClrout 11228 ; brset BoostDir,feature6,bcClrout ; Change dir for high 11229 ; pulsewidth reduce boost B073 2009 11230 bra bcSetout 11231 boostOff: B075 C6E05C 11232 lda feature6_f B078 A540 11233 bit #BoostDirb B07A 2602 11234 bne bcSetout 11235 ; brset BoostDir,feature6,bcSetout ; Change dir for high 11236 ; pulsewidth reduce boost B07C 2004 11237 bra bcClrout 11238 11239 bcSetout: B07E 1600 11240 bset boostP,porta B080 2002 11241 bra doneBoostControl 11242 11243 bcClrout: B082 1700 11244 bclr boostP,porta 11245 11246 doneBoostControl: 11247 11248 ;=======Check RPM Section===== 11249 CHECK_RPM: B084 01421D 11250 brclr running,engine,b_ENABLE; Branch if not running 11251 ; right now B087 064108 11252 brset firing1,squirt,CHK_RE_ENABLE B08A 0A4105 11253 brset firing2,squirt,CHK_RE_ENABLE B08D 026202 11254 brset REUSE_LED17,outputpins,CHK_RE_ENABLE B090 1102 11255 bclr sled,portc ; squrt LED is OFF - nothing 11256 ; is injecting 11257 11258 CHK_RE_ENABLE: 11259 ;====== Check for re-enabling of IRQ input pulses B092 02611D 11260 brset MSNEON,personality,INCRPMER ; irq always on in Neon mode B095 04611A 11261 brset WHEEL,personality,INCRPMER ; irq always on in Wheel mode 11262 B098 B670 11263 lda rpmph ; Get high byte of last rpm interval B09A 270B 11264 beq RPMLOWBYTECHK ; If zero go ahead check for 11265 ; half interval B09C B673 11266 lda rpmcl ; Check current rpm interval B09E A180 11267 cmp #128T ; 12.8 milliseconds is maximum 11268 ; (JSM changed this and cause 'stumble') B0A0 270C 11269 beq REARM_IRQ ; time to re-arm IRQ B0A2 200E 11270 bra INCRPMER ; Jump around rpm half interval check 11271 11272 ; Changed from JMP introduced in 021h/i to the BRA that was used previously. B0A4 CCB18E 11273 b_ENABLE: jmp ENABLE_THE_IRQ 11274 11275 RPMLOWBYTECHK: B0A7 B671 11276 lda rpmpl ; Load in the latched previous RPM value B0A9 44 11277 lsra B0AA B173 11278 cmp rpmcl ; Is it the same value as current RPM Counter? B0AC 2604 11279 bne INCRPMER ; If not then jump around this 11280 11281 REARM_IRQ: B0AE 141D 11282 bset ACK,INTSCR ; clear out any latched interrupts B0B0 131D 11283 bclr IMASK,INTSCR ; enable interrupts again for IRQ 11284 11285 INCRPMER: B0B2 9B 11286 sei B0B3 3C73 11287 inc rpmcl B0B5 2611 11288 bne jCHECK_MMS B0B7 3C72 11289 inc rpmch B0B9 01420C 11290 brclr running,engine,jCHECK_MMS ; don't do stall check if 11291 ; not running B0BC B672 11292 lda rpmch B0BE 07670A 11293 brclr cant_crank,EnhancedBits2,incrpm_crank ; if we've fully 11294 ; exited crank mode B0C1 A11E 11295 cmp #30T ; then 0.75 seconds timeout 11296 ; (<360rpm on a 2cyl) (was 0.25s) B0C3 2503 11297 blo jCHECK_MMS B0C5 9A 11298 cli ; ok, we can be interrupted again 11299 B0C6 2008 11300 bra stall B0C8 CCB190 11301 jCHECK_MMS: jmp CHECK_MMS 11302 incrpm_crank: B0CB A164 11303 cmp #$64 ; If RPMPH is 100 (or RPMPeriod = 11304 ; 2.5 sec) then engine stalled B0CD 25F9 11305 blo jCHECK_MMS B0CF 9A 11306 cli ; ok, we can be interrupted again 11307 stall: B0D0 3F42 11308 clr engine ; Engine is stalled, clear all 11309 ; in engine B0D2 1100 11310 bclr fuelp,porta ; Turn off fuel Pump B0D4 3F72 11311 clr rpmch B0D6 3F73 11312 clr rpmcl 11313 B0D8 A600 11314 lda #00T B0DA B7E5 11315 sta TCCycles ; If stalled then clear these 3 for Extra B0DC B7E1 11316 sta TCAccel ; fuel during cranking B0DE 1166 11317 bclr NosDcOk,EnhancedBits ; 11318 B0E0 A6FF 11319 lda #$FF ; changed 025n, was zero. Causing problems with wheel pickup? B0E2 B7B0 11320 sta iTimeL B0E4 B7AF 11321 sta iTimeH B0E6 B7AE 11322 sta iTimeX msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 96 MC68HC908GP32 User Bootloader 11323 B0E8 3F4E 11324 clr pw1 ; zero out pulsewidth B0EA 3F53 11325 clr pw2 ; zero out pulsewidth B0EC 3F4D 11326 clr rpm 11327 B0EE 1767 11328 bclr cant_crank,EnhancedBits2 ; if we stalled we can 11329 ; crank again 11330 B0F0 macro 11331 TurnAllSpkOff ; macro to turn off all spark outputs B0F0 0D6910 11332 BRCLR INVSPK,ENHANCEDBITS4,SOIN B0F3 1300 11333 BCLR IASC,PORTA B0F5 1102 11334 BCLR SLED,PORTC B0F7 1502 11335 BCLR WLED,PORTC B0F9 1302 11336 BCLR ALED,PORTC B0FB 1103 11337 BCLR OUTPUT3,PORTD B0FD 1702 11338 BCLR PIN10,PORTC B0FF 1503 11339 BCLR KNOCKIN,PORTD B101 203E 11340 BRA SOIN_DONE 11341 SOIN: B103 006204 11342 BRSET REUSE_FIDLE,OUTPUTPINS,SOIN1 B106 1300 11343 BCLR IASC,PORTA B108 2002 11344 BRA SOIN2 B10A 1200 11345 SOIN1: BSET IASC,PORTA B10C 026204 11346 SOIN2: BRSET REUSE_LED17,OUTPUTPINS,SOIN3 B10F 1102 11347 BCLR SLED,PORTC B111 2002 11348 BRA SOIN4 B113 1002 11349 SOIN3: BSET SLED,PORTC B115 086204 11350 SOIN4: BRSET REUSE_LED19,OUTPUTPINS,SOIN5 B118 1302 11351 BCLR ALED,PORTC B11A 2002 11352 BRA SOIN6 B11C 1202 11353 SOIN5: BSET ALED,PORTC B11E 056207 11354 SOIN6: BRCLR REUSE_LED18,OUTPUTPINS,SOIN7 B121 076204 11355 BRCLR REUSE_LED18_2,OUTPUTPINS,SOIN7 B124 1402 11356 BSET WLED,PORTC B126 2002 11357 BRA SOIN8 B128 1502 11358 SOIN7: BCLR WLED,PORTC 11359 SOIN8: B12A 096402 11360 BRCLR OUT3SPARKD,FEATURE2,SOIN9 B12D 1003 11361 BSET OUTPUT3,PORTD 11362 SOIN9: B12F C6E074 11363 LDA FEATURE8_F B132 A508 11364 BIT #SPKEOPB B134 2702 11365 BEQ SOIN10 B136 1602 11366 BSET PIN10,PORTC 11367 SOIN10: B138 C6E074 11368 LDA FEATURE8_F B13B A510 11369 BIT #SPKFOPB B13D 2702 11370 BEQ SOIN11 B13F 1403 11371 BSET KNOCKIN,PORTD 11372 SOIN11: 11373 SOIN_DONE: B141 3FB3 11374 CLR SPARKONLEFTAH B143 3FB4 11375 CLR SPARKONLEFTAL B145 3FB5 11376 CLR SPARKONLEFTBH B147 3FB6 11377 CLR SPARKONLEFTBL B149 3FB7 11378 CLR SPARKONLEFTCH B14B 3FB8 11379 CLR SPARKONLEFTCL B14D 3FB9 11380 CLR SPARKONLEFTDH B14F 3FBA 11381 CLR SPARKONLEFTDL B151 3FBB 11382 CLR SPARKONLEFTEH B153 3FBC 11383 CLR SPARKONLEFTEL B155 3FBD 11384 CLR SPARKONLEFTFH B157 3FBE 11385 CLR SPARKONLEFTFL 11386 11387 stall_cont: B159 08610B 11388 brset EDIS,personality,pass_store B15C C6E3A8 11389 lda TriggAngle_f ; Calculate crank delay angle B15F C0E3AB 11390 sub CrankAngle_f B162 AB1C 11391 add #28T ; - -10 deg B164 C70107 11392 sta DelayAngle 11393 pass_store: B167 C6E3AB 11394 lda CrankAngle_f ; Update spark angle for user interface B16A B758 11395 sta SparkAngle B16C C6E3AC 11396 lda SparkHoldCyc_f ; Hold spark after stall B16F B7E7 11397 sta wheelcount ; (HoldSpark) B171 026105 11398 brset MSNEON,personality,wc_wheel B174 046102 11399 brset WHEEL,personality,wc_wheel B177 2015 11400 bra ENABLE_THE_IRQ 11401 wc_wheel: B179 6EC5E7 11402 mov #WHEELINIT,wheelcount ; set !sync,holdoff, 3 teeth holdoff 11403 ; for wheel/Neon B17C 136B 11404 bclr wsync,EnhancedBits6 B17E 146B 11405 bset whold,EnhancedBits6 B180 A600 11406 lda #0 B182 B7F4 11407 sta avgtoothh B184 B7F5 11408 sta avgtoothl 11409 B186 3FF6 11410 clr lowresH ; low res (0.1ms) timer B188 3FF7 11411 clr lowresL ; 11412 B18A 1068 11413 bset coilabit,coilsel B18C 1860 11414 bset coilerr,RevLimBits 11415 11416 ENABLE_THE_IRQ: B18E 131D 11417 bclr IMASK,INTSCR ; Enable IRQ 11418 11419 CHECK_MMS: B190 9A 11420 cli B191 B67D 11421 lda mms B193 A109 11422 cmp #$09 B195 2203 11423 bhi MSEC ;(was #$0A beq) B197 CCB2F8 11424 jmp RTC_DONE 11425 11426 **************************************************************************** 11427 ********************* millisecond section ******************************** 11428 **************************************************************************** 11429 11430 MSEC: B19A 026302 11431 brset egoIgnCount,feature1,No_Ego_mSec ; Are we using mSec 11432 ; for ego counter? B19D 3C82 11433 inc egocount ; Increment EGO step counter 11434 No_Ego_mSec: 11435 B19F 3C7E 11436 inc ms ; bump up millisec B1A1 3F7D 11437 clr mms 11438 B1A3 056211 11439 brclr REUSE_LED18,outputpins,FIRE_ADC ; only do this if 11440 ; using as IRQ monitor B1A6 06620E 11441 brset REUSE_LED18_2,outputpins,FIRE_ADC ; not if spark c B1A9 2E04 11442 bil IRQ_LOW ; Check if IRQ pin low B1AB 1502 11443 bclr wled,portc ; Turn OFF IRQ led 11444 B1AD 2008 11445 bra FIRE_ADC 11446 11447 IRQ_LOW: B1AF 026105 11448 brset MSNEON,personality,FIRE_ADC ; irrelevant B1B2 046102 11449 brset WHEEL,personality,FIRE_ADC ; irrelevant B1B5 1402 11450 bset wled,portc ; Turn ON IRQ led (in case of 11451 ; bouncing points or what ever) 11452 11453 FIRE_ADC: 11454 ; Fire off another ADC conversion, channel is pointed to by ADSEL B1B7 B68E 11455 lda adsel B1B9 AA40 11456 ora #%01000000 B1BB B73C 11457 sta adscr 11458 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 97 MC68HC908GP32 User Bootloader B1BD 3CD5 11459 inc bcCtlClock 11460 11461 ; Tacho ouput B1BF C6E09F 11462 lda tachconf_f B1C2 A47F 11463 and #$7f B1C4 275B 11464 beq MSDONE B1C6 0C6A2C 11465 brset cto,EnhancedBits5,tachon 11466 ;tachoff: B1C9 410111 11467 cbeqa #1,tachoff_x2 B1CC 410212 11468 cbeqa #2,tachoff_x3 B1CF 410313 11469 cbeqa #3,tachoff_x4 B1D2 410414 11470 cbeqa #4,tachoff_x5 B1D5 410515 11471 cbeqa #5,tachoff_out3 B1D8 410616 11472 cbeqa #6,tachoff_pin10 B1DB 2044 11473 bra MSDONE 11474 tachoff_x2: B1DD 1B00 11475 bclr water,porta B1DF 2040 11476 bra MSDONE 11477 tachoff_x3: B1E1 1900 11478 bclr water2,porta B1E3 203C 11479 bra MSDONE 11480 tachoff_x4: B1E5 1700 11481 bclr output1,porta B1E7 2038 11482 bra MSDONE 11483 tachoff_x5: B1E9 1500 11484 bclr output2,porta B1EB 2034 11485 bra MSDONE 11486 tachoff_out3: B1ED 1103 11487 bclr output3,portd B1EF 2030 11488 bra MSDONE 11489 tachoff_pin10: B1F1 1702 11490 bclr pin10,portc B1F3 202C 11491 bra MSDONE 11492 11493 tachon: B1F5 1D6A 11494 bclr cto,EnhancedBits5 B1F7 410111 11495 cbeqa #1,tachon_x2 B1FA 410212 11496 cbeqa #2,tachon_x3 B1FD 410313 11497 cbeqa #3,tachon_x4 B200 410414 11498 cbeqa #4,tachon_x5 B203 410515 11499 cbeqa #5,tachon_out3 B206 410616 11500 cbeqa #6,tachon_pin10 B209 2016 11501 bra MSDONE 11502 tachon_x2: B20B 1A00 11503 bset water,porta B20D 2012 11504 bra MSDONE 11505 tachon_x3: B20F 1800 11506 bset water2,porta B211 200E 11507 bra MSDONE 11508 tachon_x4: B213 1600 11509 bset output1,porta B215 200A 11510 bra MSDONE 11511 tachon_x5: B217 1400 11512 bset output2,porta B219 2006 11513 bra MSDONE 11514 tachon_out3: B21B 1003 11515 bset output3,portd B21D 2002 11516 bra MSDONE 11517 tachon_pin10: B21F 1602 11518 bset pin10,portc 11519 ; bra MSDONE 11520 MSDONE: 11521 *************************************************************************** 11522 ********************* 1/100 second section ******************************** 11523 *************************************************************************** B221 B67E 11524 lda ms B223 41001D 11525 cbeqa #00,one00th ; surely there's a better/quicker way than this? B226 410A1A 11526 cbeqa #10T,one00th B229 411417 11527 cbeqa #20T,one00th B22C 411E14 11528 cbeqa #30T,one00th B22F 412811 11529 cbeqa #40T,one00th B232 41320E 11530 cbeqa #50T,one00th B235 413C0B 11531 cbeqa #60T,one00th B238 414608 11532 cbeqa #70T,one00th B23B 415005 11533 cbeqa #80T,one00th B23E 415A02 11534 cbeqa #90T,one00th B241 200D 11535 bra end100th 11536 11537 one00th: B243 07030A 11538 brclr Launch,portd,nol_timer ; Button is pressed so skip timer B246 C6010C 11539 lda n2olaunchdel B249 2705 11540 beq nol_timer ; already zero B24B A001 11541 sub #1 B24D C7010C 11542 sta n2olaunchdel 11543 nol_timer: 11544 11545 ; ;do similar for nitrous fuel hold on 11546 ; brclr ?????,????,non2o_timer ; Nitrous on so skip timer 11547 ; lda n2ohold 11548 ; beq non2o_timer ; already zero 11549 ; sub #1 11550 ; sta n2ohold 11551 ;non2o_timer: 11552 11553 end100th: B250 B67E 11554 lda ms B252 A164 11555 cmp #$64 B254 255C 11556 blo RTC_DONEJMP 11557 *************************************************************************** 11558 ********************* 1/10 second section ********************************* 11559 *************************************************************************** 11560 11561 ONETENTH: B256 3F7E 11562 clr ms 11563 ;see if need to restart tooth logger B258 C60106 11564 lda page B25B 41F005 11565 cbeqa #$F0,restart_F0 B25E 41F10F 11566 cbeqa #$F1,restart_F1 B261 201A 11567 bra oneten_notlog 11568 11569 restart_F0: B263 046A17 11570 brset toothlog,EnhancedBits5,oneten_notlog B266 B68A 11571 lda txcnt B268 2613 11572 bne oneten_notlog ; if sending data then do not restart B26A 146A 11573 bset toothlog,EnhancedBits5 ; turn logger back on (after send) B26C 176A 11574 bclr triglog,EnhancedBits5 ; turn logger back on (after send) B26E 200D 11575 bra oneten_notlog 11576 11577 restart_F1: B270 066A0A 11578 brset triglog,EnhancedBits5,oneten_notlog B273 B68A 11579 lda txcnt B275 2606 11580 bne oneten_notlog ; if sending data then do not restart B277 166A 11581 bset triglog,EnhancedBits5 ; turn logger back on (after send) B279 156A 11582 bclr toothlog,EnhancedBits5 ; turn logger back on (after send) B27B 2000 11583 bra oneten_notlog 11584 11585 oneten_notlog: B27D 3C7F 11586 inc tenth B27F 3CE6 11587 inc Out3Timer B281 B64D 11588 lda rpm B283 C70104 11589 sta rpmlast 11590 B286 B6DF 11591 lda ST2Timer B288 2702 11592 beq ST2Timer_zero B28A 3ADF 11593 dec ST2Timer 11594 ST2Timer_zero: msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 98 MC68HC908GP32 User Bootloader B28C B6E0 11595 lda VE3Timer ; VE Table3 delay timer B28E 2702 11596 beq VE3Timer_zero B290 3AE0 11597 dec VE3Timer 11598 VE3Timer_zero: B292 0C6605 11599 brset UseVE3,EnhancedBits,No_VE3_delay ; Are we running from VE3? B295 C6E05D 11600 lda VE3Delay_f B298 B7E0 11601 sta VE3Timer 11602 No_VE3_delay: B29A 030305 11603 brclr NosIn,portd,No_St2Delay B29D C6E057 11604 lda Spark2Delay_f ; If input not low reset ST2 11605 ; delay timer B2A0 B7DF 11606 sta ST2Timer 11607 No_St2Delay: 11608 B2A2 066314 11609 brset taeIgnCount,feature1,No_TPSCount B2A5 3C81 11610 inc tpsaclk 11611 11612 ; Save current TPS reading in last_tps variable to compute TPSDOT 11613 ; in acceleration enrichment section 11614 B2A7 C6E042 11615 lda feature4_f B2AA A580 11616 bit #KpaDotSetb B2AC 2707 11617 beq tps_dot_mode 11618 ; brclr KpaDotSet,feature4,tps_dot_mode ; If not in KPA dot mode 11619 ;jump past KPa settings B2AE B6CB 11620 lda kpa B2B0 2005 11621 bra Kpa_Dot_Mode 11622 ;****** 11623 RTC_DONEJMP: B2B2 CCB2F8 11624 jmp RTC_DONE 11625 ;****** 11626 tps_dot_mode: B2B5 B647 11627 lda tps 11628 Kpa_Dot_Mode: B2B7 B7D1 11629 sta TPSlast 11630 11631 No_TPSCount: 11632 11633 ; Check Magnus rev limit times 11634 B2B9 B6C4 11635 lda SRevLimTimeLeft ; Check if time left already zero B2BB 2706 11636 beq TimeLeft B2BD 3AC4 11637 dec SRevLimTimeLeft ; Count down time left B2BF 2602 11638 bne TimeLeft ; Time left done B2C1 1260 11639 bset RevLimHSoft,RevLimBits ; Set soft rev limiter fuel cut bit 11640 TimeLeft: 11641 B2C3 B67F 11642 lda tenth B2C5 A10A 11643 cmp #$0A B2C7 252F 11644 blo RTC_DONE 11645 11646 **************************************************************************** 11647 ********************** seconds section *********************************** 11648 **************************************************************************** 11649 SECONDS: B2C9 3CD7 11650 inc OverRunTime 11651 B2CB B6D9 11652 lda KnockTimLft ; Load the knock timer B2CD A100 11653 cmp #00T B2CF 2703 11654 beq Secs ; If its zero carry on with seconds B2D1 4A 11655 deca ; If not dec it B2D2 B7D9 11656 sta KnocktimLft 11657 Secs: B2D4 C6E5B3 11658 lda feature10_f5 B2D7 A501 11659 bit #ASEIgnCountb B2D9 2702 11660 beq sec_cont B2DB 3C83 11661 inc ASEcount 11662 sec_cont: 11663 ; crank mode inhibit 11664 ; make a 1-2 second delay 11665 ; if running and !cranking and !cant_delay then set cant_delay 11666 ; if running and !cranking and cant_delay then set cant_crank 11667 ; else clear cant_delay B2DD 02420E 11668 brset crank,engine,cant_off B2E0 01420B 11669 brclr running,engine,cant_off B2E3 086704 11670 brset cant_delay,EnhancedBits2,cant_set B2E6 1867 11671 bset cant_delay,EnhancedBits2 B2E8 2006 11672 bra sec_fin 11673 cant_set: B2EA 1667 11674 bset cant_crank,EnhancedBits2 B2EC 2002 11675 bra sec_fin 11676 cant_off: B2EE 1967 11677 bclr cant_delay,EnhancedBits2 11678 sec_fin: B2F0 3F7F 11679 clr tenth B2F2 3C40 11680 inc secl ; bump up second count B2F4 2602 11681 bne RTC_DONE B2F6 3C80 11682 inc sech 11683 11684 RTC_DONE: 11685 ; now check that we haven't already missed the target B2F8 9B 11686 sei B2F9 B62D 11687 lda T2CNTL ; unlatch any previous read B2FB B62C 11688 lda T2CNTH B2FD C701ED 11689 sta itmp00 B300 B62D 11690 lda T2CNTL B302 C701EE 11691 sta itmp01 11692 B305 B632 11693 lda T2CH0L B307 C001EE 11694 sub itmp01 B30A C701F0 11695 sta itmp03 B30D B631 11696 lda T2CH0H B30F C201ED 11697 sbc itmp00 11698 ; sta itmp02 11699 ;assume we need at least 5us? from setting and RTIing before output compare will work B312 2607 11700 bne RTC_reset ; if high byte non zero then we've already missed it B314 C601F0 11701 lda itmp03 B317 A10A 11702 cmp #10T B319 220F 11703 bhi RTC_DONE2 ; if less than 5us then we are likely to miss it 11704 RTC_reset: B31B C601EE 11705 lda itmp01 B31E AB0A 11706 add #10T ; allow 10us from here to be sure we don't miss it 11707 ; this will cause a "lazy" 0.1ms if it happens often 11708 ; but should eliminate total dropout B320 97 11709 tax B321 C601ED 11710 lda itmp00 B324 A900 11711 adc #0T B326 B731 11712 sta T2CH0H B328 BF32 11713 stx T2CH0L 11714 11715 RTC_DONE2: 11716 ; bclr TOF,T2SC0 B32A 1C30 11717 bset TOIE,T2SC0 ; re-enable 0.1ms interrupt B32C 8A 11718 pulh 11719 NOTSPKTIME: ; close branch for below B32D 80 11720 rti 11721 11722 *************************************************************************** 11723 ** 11724 ** Spark timing 11725 ** 11726 *************************************************************************** B32E CCBCA6 11727 INT_SPARK_OFFa: jmp INT_SPARK_OFF B331 CCB809 11728 j_hires_dwell: jmp hires_dwell 11729 11730 SPARKTIME: msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 99 MC68HC908GP32 User Bootloader B334 B633 11731 lda T2SC1 ; Read interrupt B336 1F33 11732 bclr CHxF,T2SC1 ; Reset interrupt 11733 B338 035FF2 11734 brclr SparkHSpeed,SparkBits,NOTSPKTIME ; Don't spark 11735 ; on time when going slow B33B 0869F3 11736 brset indwell,EnhancedBits4,j_hires_dwell ; start dwell 11737 ; period B33E 086103 11738 brset EDIS,personality,set_spkon B341 015FE9 11739 brclr SparkTrigg,Sparkbits,NOTSPKTIME ; Should never do this 11740 11741 ;spark cut used to be here, but moved to TIMERROLL to eliminate chance of 11742 ;overheating ignitors when in spark-cut because coils were left switched ON 11743 11744 set_spkon: B344 015FE7 11745 brclr SparkTrigg,Sparkbits,INT_SPARK_OFFa ; Check for 11746 ; spark trigg, used end of pulse 11747 set_spkon2: B347 1660 11748 bset sparkon,revlimbits ; spark now on B349 0C6971 11749 brset invspk,EnhancedBits4,sson_inv B34C macro 11750 COILNEG ; macro = fire coil for non-inverted B34C 00626A 11751 BRSET REUSE_FIDLE,OUTPUTPINS,DSLSX B34F 006A1E 11752 BRSET ROTARY2,ENHANCEDBITS5,ROT2NEG B352 0F6232 11753 BRCLR TOY_DLI,OUTPUTPINS,NILS B355 006806 11754 BRSET COILABIT,COILSEL,FCNITA B358 026809 11755 BRSET COILBBIT,COILSEL,FCNITB B35B 04680C 11756 BRSET COILCBIT,COILSEL,FCNITC 11757 FCNITA: B35E 1302 11758 BCLR COILB,PORTC B360 1502 11759 BCLR WLED,PORTC B362 203D 11760 BRA DSLSA 11761 FCNITB: B364 1202 11762 BSET COILB,PORTC B366 1502 11763 BCLR WLED,PORTC B368 2037 11764 BRA DSLSA 11765 FCNITC: B36A 1302 11766 BCLR COILB,PORTC B36C 1402 11767 BSET WLED,PORTC B36E 2031 11768 BRA DSLSA 11769 ROT2NEG: B370 086328 11770 BRSET ROTARYFDIGN,FEATURE1,FIREFD B373 046805 11771 BRSET COILCBIT,COILSEL,ROT2CN B376 066808 11772 BRSET COILDBIT,COILSEL,ROT2DN B379 2026 11773 BRA DSLSA 11774 ROT2CN: B37B 1502 11775 BCLR WLED,PORTC B37D 1202 11776 BSET COILB,PORTC B37F 203A 11777 BRA CN_END 11778 ROT2DN: B381 1402 11779 BSET WLED,PORTC B383 1202 11780 BSET COILB,PORTC B385 2034 11781 BRA CN_END 11782 NILS: B387 006817 11783 BRSET COILABIT,COILSEL,DSLSA B38A 026818 11784 BRSET COILBBIT,COILSEL,DSLSB B38D 046819 11785 BRSET COILCBIT,COILSEL,DSLSC B390 06681A 11786 BRSET COILDBIT,COILSEL,DSLSD B393 08681B 11787 BRSET COILEBIT,COILSEL,DSLSE B396 0A681C 11788 BRSET COILFBIT,COILSEL,DSLSF B399 2020 11789 BRA CN_END 11790 FIREFD: B39B 046807 11791 BRSET COILCBIT,COILSEL,DSLSB B39E 066808 11792 BRSET COILDBIT,COILSEL,DSLSC 11793 DSLSA: B3A1 1002 11794 BSET COILA,PORTC B3A3 2016 11795 BRA CN_END 11796 DSLSB: B3A5 1202 11797 BSET COILB,PORTC B3A7 2012 11798 BRA CN_END 11799 DSLSC: B3A9 1402 11800 BSET WLED,PORTC B3AB 200E 11801 BRA CN_END 11802 DSLSD: B3AD 1003 11803 BSET OUTPUT3,PORTD B3AF 200A 11804 BRA CN_END 11805 DSLSE: B3B1 1602 11806 BSET PIN10,PORTC B3B3 2006 11807 BRA CN_END 11808 DSLSF: B3B5 1403 11809 BSET KNOCKIN,PORTD B3B7 2002 11810 BRA CN_END 11811 DSLSX: B3B9 1200 11812 BSET IASC,PORTA 11813 CN_END: B3BB 204D 11814 bra SparkOnDone 11815 sson_inv: B3BD macro 11816 COILPOS ; macro = fire coil for inverted B3BD 006248 11817 BRSET REUSE_FIDLE,OUTPUTPINS,ILSOX B3C0 006A14 11818 BRSET ROTARY2,ENHANCEDBITS5,ROT2POS B3C3 00682A 11819 BRSET COILABIT,COILSEL,ILSOA B3C6 02682B 11820 BRSET COILBBIT,COILSEL,ILSOB B3C9 04682C 11821 BRSET COILCBIT,COILSEL,ILSOC B3CC 06682D 11822 BRSET COILDBIT,COILSEL,ILSOD B3CF 08682E 11823 BRSET COILEBIT,COILSEL,ILSOE B3D2 0A682F 11824 BRSET COILFBIT,COILSEL,ILSOF B3D5 2033 11825 BRA FC_END 11826 ROT2POS: B3D7 086310 11827 BRSET ROTARYFDIGN,FEATURE1,CHARGEFD B3DA 046805 11828 BRSET COILCBIT,COILSEL,ROT2CP B3DD 066806 11829 BRSET COILDBIT,COILSEL,ROT2DP B3E0 200E 11830 BRA ILSOA 11831 ROT2CP: B3E2 1302 11832 BCLR COILB,PORTC B3E4 2024 11833 BRA FC_END 11834 ROT2DP: B3E6 1302 11835 BCLR COILB,PORTC B3E8 2020 11836 BRA FC_END 11837 CHARGEFD: B3EA 04680B 11838 BRSET COILCBIT,COILSEL,ILSOC B3ED 066804 11839 BRSET COILDBIT,COILSEL,ILSOB 11840 ILSOA: B3F0 1102 11841 BCLR COILA,PORTC B3F2 2016 11842 BRA FC_END 11843 ILSOB: B3F4 1302 11844 BCLR COILB,PORTC B3F6 2012 11845 BRA FC_END 11846 ILSOC: B3F8 1502 11847 BCLR WLED,PORTC B3FA 200E 11848 BRA FC_END 11849 ILSOD: B3FC 1103 11850 BCLR OUTPUT3,PORTD B3FE 200A 11851 BRA FC_END 11852 ILSOE: B400 1702 11853 BCLR PIN10,PORTC B402 2006 11854 BRA FC_END 11855 ILSOF: B404 1503 11856 BCLR KNOCKIN,PORTD B406 2002 11857 BRA FC_END 11858 ILSOX: B408 1300 11859 BCLR IASC,PORTA 11860 FC_END: 11861 SparkOnDone: B40A 096106 11862 brclr EDIS,personality,sod_ne B40D CCB8EA 11863 jmp set_saw_on B410 CCB7A2 11864 jsod_cd_done: jmp sod_cd_done 11865 11866 sod_ne: msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 100 MC68HC908GP32 User Bootloader B413 1D33 11867 bclr TOIE,T2SC1 ; Disable interrupts B415 026503 11868 brset dwellcont,feature7,sod_cd B418 0A64F5 11869 brset min_dwell,feature2,jsod_cd_done ; don't schedule 11870 ; here if minimal dwell wanted 11871 sod_cd: B41B 8B 11872 pshh ; we need to use h in calcdwell B41C macro 11873 CalcDwellspk ; Set spark on time B41C 06692D 11874 BRSET WSPK,ENHANCEDBITS4,WASTEDWELL B41F 55E8 11875 LDHX DWELLDELAY1 B421 00680B 11876 BRSET COILABIT,COILSEL,DD_A B424 02680C 11877 BRSET COILBBIT,COILSEL,DD_B B427 04680D 11878 BRSET COILCBIT,COILSEL,DD_C B42A 06680E 11879 BRSET COILDBIT,COILSEL,DD_D B42D 200E 11880 BRA JDD_END B42F 35B3 11881 DD_A: STHX SPARKONLEFTAH B431 200A 11882 BRA JDD_END B433 35B5 11883 DD_B: STHX SPARKONLEFTBH B435 2006 11884 BRA JDD_END B437 35B7 11885 DD_C: STHX SPARKONLEFTCH B439 2002 11886 BRA JDD_END B43B 35B9 11887 DD_D: STHX SPARKONLEFTDH B43D CCB7A1 11888 JDD_END: JMP DD_END B440 CCB65C 11889 JWDWELL6OP: JMP WDWELL6OP B443 CCB582 11890 JWDWELL5OP: JMP WDWELL5OP B446 CCB4E3 11891 JWDWELL4OP: JMP WDWELL4OP B449 CCB4B6 11892 JWDWELL2OP: JMP WDWELL2OP 11893 WASTEDWELL: B44C C6E074 11894 LDA FEATURE8_F B44F A510 11895 BIT #SPKFOPB B451 26ED 11896 BNE JWDWELL6OP B453 A508 11897 BIT #SPKEOPB B455 26EC 11898 BNE JWDWELL5OP B457 0864EC 11899 BRSET OUT3SPARKD,FEATURE2,JWDWELL4OP B45A 0562EC 11900 BRCLR REUSE_LED18,OUTPUTPINS,JWDWELL2OP B45D 0762E9 11901 BRCLR REUSE_LED18_2,OUTPUTPINS,JWDWELL2OP 11902 WDWELL3OP: B460 55EC 11903 LDHX DWELLDELAY3 B462 006806 11904 BRSET COILABIT,COILSEL,WD3A360 B465 026807 11905 BRSET COILBBIT,COILSEL,WD3B360 B468 046808 11906 BRSET COILCBIT,COILSEL,WD3C360 B46B 35B3 11907 WD3A360: STHX SPARKONLEFTAH B46D 2006 11908 BRA WD3END360 B46F 35B5 11909 WD3B360: STHX SPARKONLEFTBH B471 2002 11910 BRA WD3END360 B473 35B7 11911 WD3C360: STHX SPARKONLEFTCH 11912 WD3END360: B475 B6E8 11913 LDA DWELLDELAY1 B477 2606 11914 BNE WD3OK120 B479 B6E9 11915 LDA DWELLDELAY1+1 B47B A102 11916 CMP #2 B47D 2515 11917 BLO WD3SKIP120 11918 WD3OK120: B47F 55E8 11919 LDHX DWELLDELAY1 B481 006806 11920 BRSET COILABIT,COILSEL,WD3A120 B484 026807 11921 BRSET COILBBIT,COILSEL,WD3B120 B487 046808 11922 BRSET COILCBIT,COILSEL,WD3C120 B48A 35B5 11923 WD3A120: STHX SPARKONLEFTBH B48C 2006 11924 BRA WD3END120 B48E 35B7 11925 WD3B120: STHX SPARKONLEFTCH B490 2002 11926 BRA WD3END120 B492 35B3 11927 WD3C120: STHX SPARKONLEFTAH 11928 WD3END120: 11929 WD3SKIP120: B494 B6EA 11930 LDA DWELLDELAY2 B496 2606 11931 BNE WD3OK240 B498 B6EB 11932 LDA DWELLDELAY2+1 B49A A102 11933 CMP #2 B49C 2515 11934 BLO WD3END240 11935 WD3OK240: B49E 55EA 11936 LDHX DWELLDELAY2 B4A0 006806 11937 BRSET COILABIT,COILSEL,WD3A240 B4A3 026807 11938 BRSET COILBBIT,COILSEL,WD3B240 B4A6 046808 11939 BRSET COILCBIT,COILSEL,WD3C240 B4A9 35B7 11940 WD3A240: STHX SPARKONLEFTCH B4AB 2006 11941 BRA WD3END240 B4AD 35B3 11942 WD3B240: STHX SPARKONLEFTAH B4AF 2002 11943 BRA WD3END240 B4B1 35B5 11944 WD3C240: STHX SPARKONLEFTBH B4B3 CCB7A1 11945 WD3END240: JMP DD_END 11946 WDWELL2OP: B4B6 55EA 11947 LDHX DWELLDELAY2 B4B8 026804 11948 BRSET COILBBIT,COILSEL,WD2B360 B4BB 35B3 11949 WD2A360: STHX SPARKONLEFTAH B4BD 2002 11950 BRA WD2END360 B4BF 35B5 11951 WD2B360: STHX SPARKONLEFTBH 11952 WD2END360: B4C1 C6E3AD 11953 LDA SPARKCONFIG1_F B4C4 A510 11954 BIT #M_SC1ODDFIRE B4C6 2618 11955 BNE WD2SKIP B4C8 B6E8 11956 LDA DWELLDELAY1 B4CA 2606 11957 BNE WD2OK B4CC B6E9 11958 LDA DWELLDELAY1+1 B4CE A102 11959 CMP #2 B4D0 250E 11960 BLO WD2SKIP 11961 WD2OK: B4D2 55E8 11962 LDHX DWELLDELAY1 B4D4 006803 11963 BRSET COILABIT,COILSEL,WD2A180 B4D7 026804 11964 BRSET COILBBIT,COILSEL,WD2B180 B4DA 35B5 11965 WD2A180: STHX SPARKONLEFTBH B4DC 2002 11966 BRA WD2END180 B4DE 35B3 11967 WD2B180: STHX SPARKONLEFTAH 11968 WD2END180: B4E0 CCB7A1 11969 WD2SKIP: JMP DD_END 11970 WDWELL4OP: B4E3 55EE 11971 LDHX DWELLDELAY4 B4E5 006809 11972 BRSET COILABIT,COILSEL,WD4A360 B4E8 02680A 11973 BRSET COILBBIT,COILSEL,WD4B360 B4EB 04680B 11974 BRSET COILCBIT,COILSEL,WD4C360 B4EE 06680C 11975 BRSET COILDBIT,COILSEL,WD4D360 B4F1 35B3 11976 WD4A360: STHX SPARKONLEFTAH B4F3 200A 11977 BRA WD4END360 B4F5 35B5 11978 WD4B360: STHX SPARKONLEFTBH B4F7 2006 11979 BRA WD4END360 B4F9 35B7 11980 WD4C360: STHX SPARKONLEFTCH B4FB 2002 11981 BRA WD4END360 B4FD 35B9 11982 WD4D360: STHX SPARKONLEFTDH 11983 WD4END360: B4FF C6E3AD 11984 LDA SPARKCONFIG1_F B502 A510 11985 BIT #M_SC1ODDFIRE B504 2626 11986 BNE WD4SKIP90 B506 B6E8 11987 LDA DWELLDELAY1 B508 2606 11988 BNE WD4OK90 B50A B6E9 11989 LDA DWELLDELAY1+1 B50C A102 11990 CMP #2 B50E 251C 11991 BLO WD4SKIP90 11992 WD4OK90: B510 55E8 11993 LDHX DWELLDELAY1 B512 006809 11994 BRSET COILABIT,COILSEL,WD4A90 B515 02680A 11995 BRSET COILBBIT,COILSEL,WD4B90 B518 04680B 11996 BRSET COILCBIT,COILSEL,WD4C90 B51B 06680C 11997 BRSET COILDBIT,COILSEL,WD4D90 B51E 35B5 11998 WD4A90: STHX SPARKONLEFTBH B520 200A 11999 BRA WD4END90 B522 35B7 12000 WD4B90: STHX SPARKONLEFTCH B524 2006 12001 BRA WD4END90 B526 35B9 12002 WD4C90: STHX SPARKONLEFTDH msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 101 MC68HC908GP32 User Bootloader B528 2002 12003 BRA WD4END90 B52A 35B3 12004 WD4D90: STHX SPARKONLEFTAH 12005 WD4END90: 12006 WD4SKIP90: B52C B6EA 12007 LDA DWELLDELAY2 B52E 2606 12008 BNE WD4OK180 B530 B6EB 12009 LDA DWELLDELAY2+1 B532 A102 12010 CMP #2 B534 251C 12011 BLO WD4SKIP180 12012 WD4OK180: B536 55EA 12013 LDHX DWELLDELAY2 B538 006809 12014 BRSET COILABIT,COILSEL,WD4A180 B53B 02680A 12015 BRSET COILBBIT,COILSEL,WD4B180 B53E 04680B 12016 BRSET COILCBIT,COILSEL,WD4C180 B541 06680C 12017 BRSET COILDBIT,COILSEL,WD4D180 B544 35B7 12018 WD4A180: STHX SPARKONLEFTCH B546 200A 12019 BRA WD4END180 B548 35B9 12020 WD4B180: STHX SPARKONLEFTDH B54A 2006 12021 BRA WD4END180 B54C 35B3 12022 WD4C180: STHX SPARKONLEFTAH B54E 2002 12023 BRA WD4END180 B550 35B5 12024 WD4D180: STHX SPARKONLEFTBH 12025 WD4END180: 12026 WD4SKIP180: B552 C6E3AD 12027 LDA SPARKCONFIG1_F B555 A510 12028 BIT #M_SC1ODDFIRE B557 2626 12029 BNE WD4END270 B559 B6EC 12030 LDA DWELLDELAY3 B55B 2606 12031 BNE WD4OK270 B55D B6ED 12032 LDA DWELLDELAY3+1 B55F A102 12033 CMP #2 B561 251C 12034 BLO WD4END270 12035 WD4OK270: B563 55EC 12036 LDHX DWELLDELAY3 B565 006809 12037 BRSET COILABIT,COILSEL,WD4A270 B568 02680A 12038 BRSET COILBBIT,COILSEL,WD4B270 B56B 04680B 12039 BRSET COILCBIT,COILSEL,WD4C270 B56E 06680C 12040 BRSET COILDBIT,COILSEL,WD4D270 B571 35B9 12041 WD4A270: STHX SPARKONLEFTDH B573 200A 12042 BRA WD4END270 B575 35B3 12043 WD4B270: STHX SPARKONLEFTAH B577 2006 12044 BRA WD4END270 B579 35B5 12045 WD4C270: STHX SPARKONLEFTBH B57B 2002 12046 BRA WD4END270 B57D 35B7 12047 WD4D270: STHX SPARKONLEFTCH 12048 WD4END270: B57F CCB7A1 12049 JMP DD_END 12050 WDWELL5OP: B582 55F0 12051 LDHX DWELLDELAY5 B584 00680C 12052 BRSET COILABIT,COILSEL,WD5A360 B587 02680D 12053 BRSET COILBBIT,COILSEL,WD5B360 B58A 04680E 12054 BRSET COILCBIT,COILSEL,WD5C360 B58D 06680F 12055 BRSET COILDBIT,COILSEL,WD5D360 B590 066810 12056 BRSET COILDBIT,COILSEL,WD5E360 B593 35B3 12057 WD5A360: STHX SPARKONLEFTAH B595 200E 12058 BRA WD5END360 B597 35B5 12059 WD5B360: STHX SPARKONLEFTBH B599 200A 12060 BRA WD5END360 B59B 35B7 12061 WD5C360: STHX SPARKONLEFTCH B59D 2006 12062 BRA WD5END360 B59F 35B9 12063 WD5D360: STHX SPARKONLEFTDH B5A1 2002 12064 BRA WD5END360 B5A3 35BB 12065 WD5E360: STHX SPARKONLEFTEH 12066 WD5END360: B5A5 B6E8 12067 LDA DWELLDELAY1 B5A7 2606 12068 BNE WD5OK72 B5A9 B6E9 12069 LDA DWELLDELAY1+1 B5AB A102 12070 CMP #2 B5AD 2523 12071 BLO WD5SKIP72 12072 WD5OK72: B5AF 55E8 12073 LDHX DWELLDELAY1 B5B1 00680C 12074 BRSET COILABIT,COILSEL,WD5A72 B5B4 02680D 12075 BRSET COILBBIT,COILSEL,WD5B72 B5B7 04680E 12076 BRSET COILCBIT,COILSEL,WD5C72 B5BA 06680F 12077 BRSET COILDBIT,COILSEL,WD5D72 B5BD 086810 12078 BRSET COILEBIT,COILSEL,WD5E72 B5C0 35B5 12079 WD5A72: STHX SPARKONLEFTBH B5C2 200E 12080 BRA WD5END72 B5C4 35B7 12081 WD5B72: STHX SPARKONLEFTCH B5C6 200A 12082 BRA WD5END72 B5C8 35B9 12083 WD5C72: STHX SPARKONLEFTDH B5CA 2006 12084 BRA WD5END72 B5CC 35BB 12085 WD5D72: STHX SPARKONLEFTEH B5CE 2002 12086 BRA WD5END72 B5D0 35B3 12087 WD5E72: STHX SPARKONLEFTAH 12088 WD5END72: 12089 WD5SKIP72: B5D2 B6EA 12090 LDA DWELLDELAY2 B5D4 2606 12091 BNE WD5OK144 B5D6 B6EB 12092 LDA DWELLDELAY2+1 B5D8 A102 12093 CMP #2 B5DA 2523 12094 BLO WD5SKIP144 12095 WD5OK144: B5DC 55EA 12096 LDHX DWELLDELAY2 B5DE 00680C 12097 BRSET COILABIT,COILSEL,WD5A144 B5E1 02680D 12098 BRSET COILBBIT,COILSEL,WD5B144 B5E4 04680E 12099 BRSET COILCBIT,COILSEL,WD5C144 B5E7 06680F 12100 BRSET COILDBIT,COILSEL,WD5D144 B5EA 086810 12101 BRSET COILEBIT,COILSEL,WD5E144 B5ED 35B7 12102 WD5A144: STHX SPARKONLEFTCH B5EF 200E 12103 BRA WD5END144 B5F1 35B9 12104 WD5B144: STHX SPARKONLEFTDH B5F3 200A 12105 BRA WD5END144 B5F5 35BB 12106 WD5C144: STHX SPARKONLEFTEH B5F7 2006 12107 BRA WD5END144 B5F9 35B3 12108 WD5D144: STHX SPARKONLEFTAH B5FB 2002 12109 BRA WD5END144 B5FD 35B5 12110 WD5E144: STHX SPARKONLEFTBH 12111 WD5END144: 12112 WD5SKIP144: B5FF B6EC 12113 LDA DWELLDELAY3 B601 2606 12114 BNE WD5OK216 B603 B6ED 12115 LDA DWELLDELAY3+1 B605 A102 12116 CMP #2 B607 2523 12117 BLO WD5SKIP216 12118 WD5OK216: B609 55EC 12119 LDHX DWELLDELAY3 B60B 00680C 12120 BRSET COILABIT,COILSEL,WD5A216 B60E 02680D 12121 BRSET COILBBIT,COILSEL,WD5B216 B611 04680E 12122 BRSET COILCBIT,COILSEL,WD5C216 B614 06680F 12123 BRSET COILDBIT,COILSEL,WD5D216 B617 086810 12124 BRSET COILEBIT,COILSEL,WD5E216 B61A 35B9 12125 WD5A216: STHX SPARKONLEFTDH B61C 200E 12126 BRA WD5END216 B61E 35BB 12127 WD5B216: STHX SPARKONLEFTEH B620 200A 12128 BRA WD5END216 B622 35B3 12129 WD5C216: STHX SPARKONLEFTAH B624 2006 12130 BRA WD5END216 B626 35B5 12131 WD5D216: STHX SPARKONLEFTBH B628 2002 12132 BRA WD5END216 B62A 35B7 12133 WD5E216: STHX SPARKONLEFTCH 12134 WD5END216: 12135 WD5SKIP216: B62C B6EE 12136 LDA DWELLDELAY4 B62E 2606 12137 BNE WD5OK288 B630 B6EF 12138 LDA DWELLDELAY4+1 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 102 MC68HC908GP32 User Bootloader B632 A102 12139 CMP #2 B634 2523 12140 BLO WD5SKIP288 12141 WD5OK288: B636 55EE 12142 LDHX DWELLDELAY4 B638 00680C 12143 BRSET COILABIT,COILSEL,WD5A288 B63B 02680D 12144 BRSET COILBBIT,COILSEL,WD5B288 B63E 04680E 12145 BRSET COILCBIT,COILSEL,WD5C288 B641 06680F 12146 BRSET COILDBIT,COILSEL,WD5D288 B644 086810 12147 BRSET COILEBIT,COILSEL,WD5E288 B647 35BB 12148 WD5A288: STHX SPARKONLEFTEH B649 200E 12149 BRA WD5END288 B64B 35B3 12150 WD5B288: STHX SPARKONLEFTAH B64D 200A 12151 BRA WD5END288 B64F 35B5 12152 WD5C288: STHX SPARKONLEFTBH B651 2006 12153 BRA WD5END288 B653 35B7 12154 WD5D288: STHX SPARKONLEFTCH B655 2002 12155 BRA WD5END288 B657 35B9 12156 WD5E288: STHX SPARKONLEFTDH 12157 WD5END288: 12158 WD5SKIP288: B659 CCB7A1 12159 JMP DD_END 12160 WDWELL6OP: B65C 55F2 12161 LDHX DWELLDELAY6 B65E 00680F 12162 BRSET COILABIT,COILSEL,WD6A360 B661 026810 12163 BRSET COILBBIT,COILSEL,WD6B360 B664 046811 12164 BRSET COILCBIT,COILSEL,WD6C360 B667 066812 12165 BRSET COILDBIT,COILSEL,WD6D360 B66A 086813 12166 BRSET COILEBIT,COILSEL,WD6E360 B66D 0A6814 12167 BRSET COILFBIT,COILSEL,WD6F360 B670 35B3 12168 WD6A360: STHX SPARKONLEFTAH B672 2012 12169 BRA WD6END360 B674 35B5 12170 WD6B360: STHX SPARKONLEFTBH B676 200E 12171 BRA WD6END360 B678 35B7 12172 WD6C360: STHX SPARKONLEFTCH B67A 200A 12173 BRA WD6END360 B67C 35B9 12174 WD6D360: STHX SPARKONLEFTDH B67E 2006 12175 BRA WD6END360 B680 35BB 12176 WD6E360: STHX SPARKONLEFTEH B682 2002 12177 BRA WD6END360 B684 35BD 12178 WD6F360: STHX SPARKONLEFTFH 12179 WD6END360: B686 C6E3AD 12180 LDA SPARKCONFIG1_F B689 A510 12181 BIT #M_SC1ODDFIRE B68B 2634 12182 BNE WD6SKIP60 B68D B6E8 12183 LDA DWELLDELAY1 B68F 2606 12184 BNE WD6OK60 B691 B6E9 12185 LDA DWELLDELAY1+1 B693 A105 12186 CMP #5 B695 252A 12187 BLO WD6SKIP60 12188 WD6OK60: B697 55E8 12189 LDHX DWELLDELAY1 B699 00680F 12190 BRSET COILABIT,COILSEL,WD6A60 B69C 026810 12191 BRSET COILBBIT,COILSEL,WD6B60 B69F 046811 12192 BRSET COILCBIT,COILSEL,WD6C60 B6A2 066812 12193 BRSET COILDBIT,COILSEL,WD6D60 B6A5 086813 12194 BRSET COILEBIT,COILSEL,WD6E60 B6A8 0A6814 12195 BRSET COILFBIT,COILSEL,WD6F60 B6AB 35B5 12196 WD6A60: STHX SPARKONLEFTBH B6AD 2012 12197 BRA WD6END60 B6AF 35B7 12198 WD6B60: STHX SPARKONLEFTCH B6B1 200E 12199 BRA WD6END60 B6B3 35B9 12200 WD6C60: STHX SPARKONLEFTDH B6B5 200A 12201 BRA WD6END60 B6B7 35BB 12202 WD6D60: STHX SPARKONLEFTEH B6B9 2006 12203 BRA WD6END60 B6BB 35BD 12204 WD6E60: STHX SPARKONLEFTFH B6BD 2002 12205 BRA WD6END60 B6BF 35B3 12206 WD6F60: STHX SPARKONLEFTAH 12207 WD6END60: 12208 WD6SKIP60: B6C1 B6EA 12209 LDA DWELLDELAY2 B6C3 2606 12210 BNE WD6OK120 B6C5 B6EB 12211 LDA DWELLDELAY2+1 B6C7 A105 12212 CMP #5 B6C9 252A 12213 BLO WD6SKIP120 12214 WD6OK120: B6CB 55EA 12215 LDHX DWELLDELAY2 B6CD 00680F 12216 BRSET COILABIT,COILSEL,WD6A120 B6D0 026810 12217 BRSET COILBBIT,COILSEL,WD6B120 B6D3 046811 12218 BRSET COILCBIT,COILSEL,WD6C120 B6D6 066812 12219 BRSET COILDBIT,COILSEL,WD6D120 B6D9 086813 12220 BRSET COILEBIT,COILSEL,WD6E120 B6DC 0A6814 12221 BRSET COILFBIT,COILSEL,WD6F120 B6DF 35B7 12222 WD6A120: STHX SPARKONLEFTCH B6E1 2012 12223 BRA WD6END120 B6E3 35B9 12224 WD6B120: STHX SPARKONLEFTDH B6E5 200E 12225 BRA WD6END120 B6E7 35BB 12226 WD6C120: STHX SPARKONLEFTEH B6E9 200A 12227 BRA WD6END120 B6EB 35BD 12228 WD6D120: STHX SPARKONLEFTFH B6ED 2006 12229 BRA WD6END120 B6EF 35B3 12230 WD6E120: STHX SPARKONLEFTAH B6F1 2002 12231 BRA WD6END120 B6F3 35B5 12232 WD6F120: STHX SPARKONLEFTBH 12233 WD6END120: 12234 WD6SKIP120: B6F5 C6E3AD 12235 LDA SPARKCONFIG1_F B6F8 A510 12236 BIT #M_SC1ODDFIRE B6FA 2636 12237 BNE WD6SKIP180 B6FC B6EC 12238 LDA DWELLDELAY3 B6FE 2606 12239 BNE WD6OK180 B700 B6ED 12240 LDA DWELLDELAY3+1 B702 A105 12241 CMP #5 B704 252C 12242 BLO WD6SKIP180 12243 WD6OK180: B706 55EC 12244 LDHX DWELLDELAY3 B708 00680F 12245 BRSET COILABIT,COILSEL,WD6A180 B70B 026810 12246 BRSET COILBBIT,COILSEL,WD6B180 B70E 046811 12247 BRSET COILCBIT,COILSEL,WD6C180 B711 066812 12248 BRSET COILDBIT,COILSEL,WD6D180 B714 086813 12249 BRSET COILEBIT,COILSEL,WD6E180 B717 0A6814 12250 BRSET COILFBIT,COILSEL,WD6F180 B71A 35B9 12251 WD6A180: STHX SPARKONLEFTDH B71C 2012 12252 BRA WD6END180 B71E 35BB 12253 WD6B180: STHX SPARKONLEFTEH B720 200E 12254 BRA WD6END180 B722 35BD 12255 WD6C180: STHX SPARKONLEFTFH B724 200A 12256 BRA WD6END180 B726 35B3 12257 WD6D180: STHX SPARKONLEFTAH B728 2006 12258 BRA WD6END180 B72A 35B5 12259 WD6E180: STHX SPARKONLEFTBH B72C 2002 12260 BRA WD6END180 B72E 35B7 12261 WD6F180: STHX SPARKONLEFTCH 12262 WD6END180: B730 206F 12263 BRA DD_END 12264 WD6SKIP180: B732 B6EE 12265 LDA DWELLDELAY4 B734 2606 12266 BNE WD6OK240 B736 B6EF 12267 LDA DWELLDELAY4+1 B738 A105 12268 CMP #5 B73A 252A 12269 BLO WD6SKIP240 12270 WD6OK240: B73C 55EE 12271 LDHX DWELLDELAY4 B73E 00680F 12272 BRSET COILABIT,COILSEL,WD6A240 B741 026810 12273 BRSET COILBBIT,COILSEL,WD6B240 B744 046811 12274 BRSET COILCBIT,COILSEL,WD6C240 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 103 MC68HC908GP32 User Bootloader B747 066812 12275 BRSET COILDBIT,COILSEL,WD6D240 B74A 086813 12276 BRSET COILEBIT,COILSEL,WD6E240 B74D 0A6814 12277 BRSET COILFBIT,COILSEL,WD6F240 B750 35BB 12278 WD6A240: STHX SPARKONLEFTEH B752 2012 12279 BRA WD6END240 B754 35BD 12280 WD6B240: STHX SPARKONLEFTFH B756 200E 12281 BRA WD6END240 B758 35B3 12282 WD6C240: STHX SPARKONLEFTAH B75A 200A 12283 BRA WD6END240 B75C 35B5 12284 WD6D240: STHX SPARKONLEFTBH B75E 2006 12285 BRA WD6END240 B760 35B7 12286 WD6E240: STHX SPARKONLEFTCH B762 2002 12287 BRA WD6END240 B764 35B9 12288 WD6F240: STHX SPARKONLEFTDH 12289 WD6END240: 12290 WD6SKIP240: B766 C6E3AD 12291 LDA SPARKCONFIG1_F B769 A510 12292 BIT #M_SC1ODDFIRE B76B 2634 12293 BNE WD6SKIP300 B76D B6F0 12294 LDA DWELLDELAY5 B76F 2606 12295 BNE WD6OK300 B771 B6F1 12296 LDA DWELLDELAY5+1 B773 A105 12297 CMP #5 B775 252A 12298 BLO WD6SKIP300 12299 WD6OK300: B777 55F0 12300 LDHX DWELLDELAY5 B779 00680F 12301 BRSET COILABIT,COILSEL,WD6A300 B77C 026810 12302 BRSET COILBBIT,COILSEL,WD6B300 B77F 046811 12303 BRSET COILCBIT,COILSEL,WD6C300 B782 066812 12304 BRSET COILDBIT,COILSEL,WD6D300 B785 086813 12305 BRSET COILEBIT,COILSEL,WD6E300 B788 0A6814 12306 BRSET COILFBIT,COILSEL,WD6F300 B78B 35BB 12307 WD6A300: STHX SPARKONLEFTEH B78D 2012 12308 BRA WD6END300 B78F 35BD 12309 WD6B300: STHX SPARKONLEFTFH B791 200E 12310 BRA WD6END300 B793 35B3 12311 WD6C300: STHX SPARKONLEFTAH B795 200A 12312 BRA WD6END300 B797 35B5 12313 WD6D300: STHX SPARKONLEFTBH B799 2006 12314 BRA WD6END300 B79B 35B7 12315 WD6E300: STHX SPARKONLEFTCH B79D 2002 12316 BRA WD6END300 B79F 35B9 12317 WD6F300: STHX SPARKONLEFTDH 12318 WD6END300: 12319 WD6SKIP300: 12320 DD_END: B7A1 8A 12321 pulh 12322 sod_cd_done: 12323 ;now check if we should schedule a trailing spark B7A2 006A03 12324 brset rotary2,EnhancedBits5,chktrail 12325 sparktime_exit: B7A5 115F 12326 bclr SparkTrigg,Sparkbits ; No more sparks for this IRQ 12327 NOT_SPARK_TIME: B7A7 80 12328 rti 12329 12330 ;if in twin rotor mode, check to see if we should schedule or fire the trailing 12331 chktrail: B7A8 0468FA 12332 brset coilcbit,coilsel,sparktime_exit ; already done - exit B7AB 0668F7 12333 brset coildbit,coilsel,sparktime_exit ; already done - exit 12334 B7AE 026806 12335 brset coilbbit,coilsel,ctb B7B1 3F68 12336 clr coilsel B7B3 1468 12337 bset coilcbit,coilsel ; was coila, now coilc B7B5 2004 12338 bra ct_done 12339 ctb: B7B7 3F68 12340 clr coilsel B7B9 1668 12341 bset coildbit,coilsel ; was coilc, now coild 12342 ct_done: 12343 ; if trailing split off still "fire the coil" now just in case we have 12344 ; already started charging it - don't want to burn out coil as we 12345 ; transition from trailing to no trailing 12346 ; "lowspdspk" code checks and doesn't turn coil on if trailing is off, 12347 ; see that section within 0.1ms 12348 B7BB 096A3D 12349 brclr rsh_s,EnhancedBits5,force_trail_off ; if split out of range then OFF B7BE 0B6A3A 12350 brclr rsh_r,EnhancedBits5,force_trail_off ; if rpm out of range then OFF 12351 B7C1 C60100 12352 lda splitdelH B7C4 2707 12353 beq split_min ; is zero so check for short split B7C6 A1FF 12354 cmp #$FF B7C8 260D 12355 bne split_timed B7CA CCB7FB 12356 jmp force_trail_off ; ensure trailing coil off 12357 ;maybe need some hysteresis with this to avoid jittery behaviour 12358 12359 ;check if split < 64us, then fire now 12360 split_min: B7CD C60101 12361 lda splitdelL B7D0 A140 12362 cmp #64T ; 64us B7D2 2203 12363 bhi split_timed 12364 ;split_min_set: 12365 ; clr splitdelL 12366 ; mov #64T,splitdelH B7D4 CCB347 12367 jmp set_spkon2 ; jump back up to fire next spark 12368 split_timed: B7D7 B62D 12369 lda T2CNTL ; unlatch low byte 12370 B7D9 BE2C 12371 ldx T2CNTH B7DB CF0203 12372 stx T2CurrH ; Save current counter value B7DE B62D 12373 lda T2CNTL B7E0 C70204 12374 sta T2CurrL ; Save current counter value 12375 B7E3 C60204 12376 lda T2CurrL B7E6 CB0101 12377 add splitdelL B7E9 97 12378 tax B7EA C60203 12379 lda T2CurrH B7ED C90100 12380 adc splitdelH B7F0 B734 12381 sta T2CH1H B7F2 BF35 12382 stx T2CH1L 12383 B7F4 105F 12384 bset SparkTrigg,Sparkbits ; keep spark enabled 12385 B7F6 1F33 12386 bclr TOF,T2SC1 ; clear any pending interrupt B7F8 1C33 12387 bset TOIE,T2SC1 ; Enable timer interrupt B7FA 80 12388 rti 12389 12390 force_trail_off: 12391 ;ensure trailing coil is really off B7FB 1402 12392 bset wled,portc B7FD 0C6904 12393 brset invspk,EnhancedBits4,to_inv B800 1202 12394 bset coilb,portc B802 2002 12395 bra to_exit B804 1302 12396 to_inv: bclr coilb,portc 12397 to_exit: B806 115F 12398 bclr SparkTrigg,Sparkbits ; No more sparks for this IRQ 12399 ;kill the dwell timers for trailing in the mainloop B808 80 12400 rti 12401 12402 hires_dwell: 12403 ; never do trailing dwell in "hi-res" so no need to 12404 ; consider trailing here 12405 12406 ;first turn on coil, then reset T2 to spark point saved in sparktargetH/L 12407 ;spark cut- actually cut the coil-on B809 B6D8 12408 lda SparkCutCnt ; Check Spark Counter B80B 4C 12409 inca B80C C1E04E 12410 cmp SparkCutBase_f ; How many sparks to count to msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 104 MC68HC908GP32 User Bootloader B80F 2502 12411 blo Dont_ResetCnt2 B811 A601 12412 lda #01T 12413 Dont_ResetCnt2: B813 B7D8 12414 sta SparkCutCnt ; Store new value to spark counter B815 0A6050 12415 brset sparkCut,RevLimBits,bhrds ; If in spark cut 12416 ; mode jump past spark 12417 B818 0C694F 12418 brset invspk,EnhancedBits4,hrd_inv B81B macro 12419 COILPOS ; macro = charge coil for non-inverted B81B 006248 12420 BRSET REUSE_FIDLE,OUTPUTPINS,ILSOX B81E 006A14 12421 BRSET ROTARY2,ENHANCEDBITS5,ROT2POS B821 00682A 12422 BRSET COILABIT,COILSEL,ILSOA B824 02682B 12423 BRSET COILBBIT,COILSEL,ILSOB B827 04682C 12424 BRSET COILCBIT,COILSEL,ILSOC B82A 06682D 12425 BRSET COILDBIT,COILSEL,ILSOD B82D 08682E 12426 BRSET COILEBIT,COILSEL,ILSOE B830 0A682F 12427 BRSET COILFBIT,COILSEL,ILSOF B833 2033 12428 BRA FC_END 12429 ROT2POS: B835 086310 12430 BRSET ROTARYFDIGN,FEATURE1,CHARGEFD B838 046805 12431 BRSET COILCBIT,COILSEL,ROT2CP B83B 066806 12432 BRSET COILDBIT,COILSEL,ROT2DP B83E 200E 12433 BRA ILSOA 12434 ROT2CP: B840 1302 12435 BCLR COILB,PORTC B842 2024 12436 BRA FC_END 12437 ROT2DP: B844 1302 12438 BCLR COILB,PORTC B846 2020 12439 BRA FC_END 12440 CHARGEFD: B848 04680B 12441 BRSET COILCBIT,COILSEL,ILSOC B84B 066804 12442 BRSET COILDBIT,COILSEL,ILSOB 12443 ILSOA: B84E 1102 12444 BCLR COILA,PORTC B850 2016 12445 BRA FC_END 12446 ILSOB: B852 1302 12447 BCLR COILB,PORTC B854 2012 12448 BRA FC_END 12449 ILSOC: B856 1502 12450 BCLR WLED,PORTC B858 200E 12451 BRA FC_END 12452 ILSOD: B85A 1103 12453 BCLR OUTPUT3,PORTD B85C 200A 12454 BRA FC_END 12455 ILSOE: B85E 1702 12456 BCLR PIN10,PORTC B860 2006 12457 BRA FC_END 12458 ILSOF: B862 1503 12459 BCLR KNOCKIN,PORTD B864 2002 12460 BRA FC_END 12461 ILSOX: B866 1300 12462 BCLR IASC,PORTA 12463 FC_END: 12464 bhrds: B868 206F 12465 bra hrd_set 12466 hrd_inv: B86A macro 12467 COILNEG ; macro = charge coil for inverted B86A 00626A 12468 BRSET REUSE_FIDLE,OUTPUTPINS,DSLSX B86D 006A1E 12469 BRSET ROTARY2,ENHANCEDBITS5,ROT2NEG B870 0F6232 12470 BRCLR TOY_DLI,OUTPUTPINS,NILS B873 006806 12471 BRSET COILABIT,COILSEL,FCNITA B876 026809 12472 BRSET COILBBIT,COILSEL,FCNITB B879 04680C 12473 BRSET COILCBIT,COILSEL,FCNITC 12474 FCNITA: B87C 1302 12475 BCLR COILB,PORTC B87E 1502 12476 BCLR WLED,PORTC B880 203D 12477 BRA DSLSA 12478 FCNITB: B882 1202 12479 BSET COILB,PORTC B884 1502 12480 BCLR WLED,PORTC B886 2037 12481 BRA DSLSA 12482 FCNITC: B888 1302 12483 BCLR COILB,PORTC B88A 1402 12484 BSET WLED,PORTC B88C 2031 12485 BRA DSLSA 12486 ROT2NEG: B88E 086328 12487 BRSET ROTARYFDIGN,FEATURE1,FIREFD B891 046805 12488 BRSET COILCBIT,COILSEL,ROT2CN B894 066808 12489 BRSET COILDBIT,COILSEL,ROT2DN B897 2026 12490 BRA DSLSA 12491 ROT2CN: B899 1502 12492 BCLR WLED,PORTC B89B 1202 12493 BSET COILB,PORTC B89D 203A 12494 BRA CN_END 12495 ROT2DN: B89F 1402 12496 BSET WLED,PORTC B8A1 1202 12497 BSET COILB,PORTC B8A3 2034 12498 BRA CN_END 12499 NILS: B8A5 006817 12500 BRSET COILABIT,COILSEL,DSLSA B8A8 026818 12501 BRSET COILBBIT,COILSEL,DSLSB B8AB 046819 12502 BRSET COILCBIT,COILSEL,DSLSC B8AE 06681A 12503 BRSET COILDBIT,COILSEL,DSLSD B8B1 08681B 12504 BRSET COILEBIT,COILSEL,DSLSE B8B4 0A681C 12505 BRSET COILFBIT,COILSEL,DSLSF B8B7 2020 12506 BRA CN_END 12507 FIREFD: B8B9 046807 12508 BRSET COILCBIT,COILSEL,DSLSB B8BC 066808 12509 BRSET COILDBIT,COILSEL,DSLSC 12510 DSLSA: B8BF 1002 12511 BSET COILA,PORTC B8C1 2016 12512 BRA CN_END 12513 DSLSB: B8C3 1202 12514 BSET COILB,PORTC B8C5 2012 12515 BRA CN_END 12516 DSLSC: B8C7 1402 12517 BSET WLED,PORTC B8C9 200E 12518 BRA CN_END 12519 DSLSD: B8CB 1003 12520 BSET OUTPUT3,PORTD B8CD 200A 12521 BRA CN_END 12522 DSLSE: B8CF 1602 12523 BSET PIN10,PORTC B8D1 2006 12524 BRA CN_END 12525 DSLSF: B8D3 1403 12526 BSET KNOCKIN,PORTD B8D5 2002 12527 BRA CN_END 12528 DSLSX: B8D7 1200 12529 BSET IASC,PORTA 12530 CN_END: 12531 hrd_set: B8D9 1969 12532 bclr indwell,EnhancedBits4 ; turn it off so next 12533 ; sparktime fires coil B8DB 1760 12534 bclr sparkon,revlimbits ; spark now on 12535 ;store pre-calculated spark time into timer and set it off B8DD B6FB 12536 lda SparkTargetH B8DF B734 12537 sta T2CH1H B8E1 B6FC 12538 lda SparkTargetL B8E3 B735 12539 sta T2CH1L 12540 B8E5 1F33 12541 bclr TOF,T2SC1 ; clear any pending interrupt B8E7 1C33 12542 bset TOIE,T2SC1 ; Enable timer interrupt 12543 B8E9 80 12544 rti 12545 12546 set_saw_on: ; now set timer for SAW on period msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 105 MC68HC908GP32 User Bootloader 12547 ; using sawh/l calculated in main loop 12548 12549 ;Calculate width of SAW pulse 12550 ;grab current timer values - uses same variable as squirt section below. But no cli so ok B8EA B62D 12551 lda T2CNTL ; unlatch low byte B8EC BE2C 12552 ldx T2CNTH B8EE CF0203 12553 stx T2CurrH ; Save current counter value B8F1 B62D 12554 lda T2CNTL B8F3 C70204 12555 sta T2CurrL ; Save current counter value 12556 B8F6 03420C 12557 brclr crank,engine,SAW_COUNTER B8F9 C6E042 12558 lda feature4_f B8FC A508 12559 bit #multisparkb B8FE 2705 12560 beq SAW_COUNTER 12561 ; brclr multispark,feature4,SAW_COUNTER 12562 12563 ; at crank we always send 2048us as calibration and multi-spark init B900 3FF5 12564 clr sawl B902 6E08F4 12565 mov #$08,sawh 12566 12567 ;Read the calculated width and store in timer 12568 SAW_COUNTER: B905 B6F5 12569 lda sawl B907 CB0204 12570 add T2CurrL B90A 97 12571 tax B90B B6F4 12572 lda sawh B90D C90203 12573 adc T2CurrH B910 B734 12574 sta T2CH1H B912 BF35 12575 stx T2CH1L 12576 B914 115F 12577 bclr SparkTrigg,Sparkbits ; Clear spark trigg. 12578 ; Next time we get int turn off SAW 12579 B916 1F33 12580 bclr TOF,T2SC1 ; clear any pending interrupt B918 1C33 12581 bset TOIE,T2SC1 ; Enable timer interrupt 12582 B91A 0A6101 12583 brset DUALEDIS,personality,set_edis2 B91D 80 12584 rti 12585 set_edis2: B91E 8B 12586 pshh B91F macro 12587 CalcDwellspk ; set time before the other SAW starts B91F 06692D 12588 BRSET WSPK,ENHANCEDBITS4,WASTEDWELL B922 55E8 12589 LDHX DWELLDELAY1 B924 00680B 12590 BRSET COILABIT,COILSEL,DD_A B927 02680C 12591 BRSET COILBBIT,COILSEL,DD_B B92A 04680D 12592 BRSET COILCBIT,COILSEL,DD_C B92D 06680E 12593 BRSET COILDBIT,COILSEL,DD_D B930 200E 12594 BRA JDD_END B932 35B3 12595 DD_A: STHX SPARKONLEFTAH B934 200A 12596 BRA JDD_END B936 35B5 12597 DD_B: STHX SPARKONLEFTBH B938 2006 12598 BRA JDD_END B93A 35B7 12599 DD_C: STHX SPARKONLEFTCH B93C 2002 12600 BRA JDD_END B93E 35B9 12601 DD_D: STHX SPARKONLEFTDH B940 CCBCA4 12602 JDD_END: JMP DD_END B943 CCBB5F 12603 JWDWELL6OP: JMP WDWELL6OP B946 CCBA85 12604 JWDWELL5OP: JMP WDWELL5OP B949 CCB9E6 12605 JWDWELL4OP: JMP WDWELL4OP B94C CCB9B9 12606 JWDWELL2OP: JMP WDWELL2OP 12607 WASTEDWELL: B94F C6E074 12608 LDA FEATURE8_F B952 A510 12609 BIT #SPKFOPB B954 26ED 12610 BNE JWDWELL6OP B956 A508 12611 BIT #SPKEOPB B958 26EC 12612 BNE JWDWELL5OP B95A 0864EC 12613 BRSET OUT3SPARKD,FEATURE2,JWDWELL4OP B95D 0562EC 12614 BRCLR REUSE_LED18,OUTPUTPINS,JWDWELL2OP B960 0762E9 12615 BRCLR REUSE_LED18_2,OUTPUTPINS,JWDWELL2OP 12616 WDWELL3OP: B963 55EC 12617 LDHX DWELLDELAY3 B965 006806 12618 BRSET COILABIT,COILSEL,WD3A360 B968 026807 12619 BRSET COILBBIT,COILSEL,WD3B360 B96B 046808 12620 BRSET COILCBIT,COILSEL,WD3C360 B96E 35B3 12621 WD3A360: STHX SPARKONLEFTAH B970 2006 12622 BRA WD3END360 B972 35B5 12623 WD3B360: STHX SPARKONLEFTBH B974 2002 12624 BRA WD3END360 B976 35B7 12625 WD3C360: STHX SPARKONLEFTCH 12626 WD3END360: B978 B6E8 12627 LDA DWELLDELAY1 B97A 2606 12628 BNE WD3OK120 B97C B6E9 12629 LDA DWELLDELAY1+1 B97E A102 12630 CMP #2 B980 2515 12631 BLO WD3SKIP120 12632 WD3OK120: B982 55E8 12633 LDHX DWELLDELAY1 B984 006806 12634 BRSET COILABIT,COILSEL,WD3A120 B987 026807 12635 BRSET COILBBIT,COILSEL,WD3B120 B98A 046808 12636 BRSET COILCBIT,COILSEL,WD3C120 B98D 35B5 12637 WD3A120: STHX SPARKONLEFTBH B98F 2006 12638 BRA WD3END120 B991 35B7 12639 WD3B120: STHX SPARKONLEFTCH B993 2002 12640 BRA WD3END120 B995 35B3 12641 WD3C120: STHX SPARKONLEFTAH 12642 WD3END120: 12643 WD3SKIP120: B997 B6EA 12644 LDA DWELLDELAY2 B999 2606 12645 BNE WD3OK240 B99B B6EB 12646 LDA DWELLDELAY2+1 B99D A102 12647 CMP #2 B99F 2515 12648 BLO WD3END240 12649 WD3OK240: B9A1 55EA 12650 LDHX DWELLDELAY2 B9A3 006806 12651 BRSET COILABIT,COILSEL,WD3A240 B9A6 026807 12652 BRSET COILBBIT,COILSEL,WD3B240 B9A9 046808 12653 BRSET COILCBIT,COILSEL,WD3C240 B9AC 35B7 12654 WD3A240: STHX SPARKONLEFTCH B9AE 2006 12655 BRA WD3END240 B9B0 35B3 12656 WD3B240: STHX SPARKONLEFTAH B9B2 2002 12657 BRA WD3END240 B9B4 35B5 12658 WD3C240: STHX SPARKONLEFTBH B9B6 CCBCA4 12659 WD3END240: JMP DD_END 12660 WDWELL2OP: B9B9 55EA 12661 LDHX DWELLDELAY2 B9BB 026804 12662 BRSET COILBBIT,COILSEL,WD2B360 B9BE 35B3 12663 WD2A360: STHX SPARKONLEFTAH B9C0 2002 12664 BRA WD2END360 B9C2 35B5 12665 WD2B360: STHX SPARKONLEFTBH 12666 WD2END360: B9C4 C6E3AD 12667 LDA SPARKCONFIG1_F B9C7 A510 12668 BIT #M_SC1ODDFIRE B9C9 2618 12669 BNE WD2SKIP B9CB B6E8 12670 LDA DWELLDELAY1 B9CD 2606 12671 BNE WD2OK B9CF B6E9 12672 LDA DWELLDELAY1+1 B9D1 A102 12673 CMP #2 B9D3 250E 12674 BLO WD2SKIP 12675 WD2OK: B9D5 55E8 12676 LDHX DWELLDELAY1 B9D7 006803 12677 BRSET COILABIT,COILSEL,WD2A180 B9DA 026804 12678 BRSET COILBBIT,COILSEL,WD2B180 B9DD 35B5 12679 WD2A180: STHX SPARKONLEFTBH B9DF 2002 12680 BRA WD2END180 B9E1 35B3 12681 WD2B180: STHX SPARKONLEFTAH 12682 WD2END180: msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 106 MC68HC908GP32 User Bootloader B9E3 CCBCA4 12683 WD2SKIP: JMP DD_END 12684 WDWELL4OP: B9E6 55EE 12685 LDHX DWELLDELAY4 B9E8 006809 12686 BRSET COILABIT,COILSEL,WD4A360 B9EB 02680A 12687 BRSET COILBBIT,COILSEL,WD4B360 B9EE 04680B 12688 BRSET COILCBIT,COILSEL,WD4C360 B9F1 06680C 12689 BRSET COILDBIT,COILSEL,WD4D360 B9F4 35B3 12690 WD4A360: STHX SPARKONLEFTAH B9F6 200A 12691 BRA WD4END360 B9F8 35B5 12692 WD4B360: STHX SPARKONLEFTBH B9FA 2006 12693 BRA WD4END360 B9FC 35B7 12694 WD4C360: STHX SPARKONLEFTCH B9FE 2002 12695 BRA WD4END360 BA00 35B9 12696 WD4D360: STHX SPARKONLEFTDH 12697 WD4END360: BA02 C6E3AD 12698 LDA SPARKCONFIG1_F BA05 A510 12699 BIT #M_SC1ODDFIRE BA07 2626 12700 BNE WD4SKIP90 BA09 B6E8 12701 LDA DWELLDELAY1 BA0B 2606 12702 BNE WD4OK90 BA0D B6E9 12703 LDA DWELLDELAY1+1 BA0F A102 12704 CMP #2 BA11 251C 12705 BLO WD4SKIP90 12706 WD4OK90: BA13 55E8 12707 LDHX DWELLDELAY1 BA15 006809 12708 BRSET COILABIT,COILSEL,WD4A90 BA18 02680A 12709 BRSET COILBBIT,COILSEL,WD4B90 BA1B 04680B 12710 BRSET COILCBIT,COILSEL,WD4C90 BA1E 06680C 12711 BRSET COILDBIT,COILSEL,WD4D90 BA21 35B5 12712 WD4A90: STHX SPARKONLEFTBH BA23 200A 12713 BRA WD4END90 BA25 35B7 12714 WD4B90: STHX SPARKONLEFTCH BA27 2006 12715 BRA WD4END90 BA29 35B9 12716 WD4C90: STHX SPARKONLEFTDH BA2B 2002 12717 BRA WD4END90 BA2D 35B3 12718 WD4D90: STHX SPARKONLEFTAH 12719 WD4END90: 12720 WD4SKIP90: BA2F B6EA 12721 LDA DWELLDELAY2 BA31 2606 12722 BNE WD4OK180 BA33 B6EB 12723 LDA DWELLDELAY2+1 BA35 A102 12724 CMP #2 BA37 251C 12725 BLO WD4SKIP180 12726 WD4OK180: BA39 55EA 12727 LDHX DWELLDELAY2 BA3B 006809 12728 BRSET COILABIT,COILSEL,WD4A180 BA3E 02680A 12729 BRSET COILBBIT,COILSEL,WD4B180 BA41 04680B 12730 BRSET COILCBIT,COILSEL,WD4C180 BA44 06680C 12731 BRSET COILDBIT,COILSEL,WD4D180 BA47 35B7 12732 WD4A180: STHX SPARKONLEFTCH BA49 200A 12733 BRA WD4END180 BA4B 35B9 12734 WD4B180: STHX SPARKONLEFTDH BA4D 2006 12735 BRA WD4END180 BA4F 35B3 12736 WD4C180: STHX SPARKONLEFTAH BA51 2002 12737 BRA WD4END180 BA53 35B5 12738 WD4D180: STHX SPARKONLEFTBH 12739 WD4END180: 12740 WD4SKIP180: BA55 C6E3AD 12741 LDA SPARKCONFIG1_F BA58 A510 12742 BIT #M_SC1ODDFIRE BA5A 2626 12743 BNE WD4END270 BA5C B6EC 12744 LDA DWELLDELAY3 BA5E 2606 12745 BNE WD4OK270 BA60 B6ED 12746 LDA DWELLDELAY3+1 BA62 A102 12747 CMP #2 BA64 251C 12748 BLO WD4END270 12749 WD4OK270: BA66 55EC 12750 LDHX DWELLDELAY3 BA68 006809 12751 BRSET COILABIT,COILSEL,WD4A270 BA6B 02680A 12752 BRSET COILBBIT,COILSEL,WD4B270 BA6E 04680B 12753 BRSET COILCBIT,COILSEL,WD4C270 BA71 06680C 12754 BRSET COILDBIT,COILSEL,WD4D270 BA74 35B9 12755 WD4A270: STHX SPARKONLEFTDH BA76 200A 12756 BRA WD4END270 BA78 35B3 12757 WD4B270: STHX SPARKONLEFTAH BA7A 2006 12758 BRA WD4END270 BA7C 35B5 12759 WD4C270: STHX SPARKONLEFTBH BA7E 2002 12760 BRA WD4END270 BA80 35B7 12761 WD4D270: STHX SPARKONLEFTCH 12762 WD4END270: BA82 CCBCA4 12763 JMP DD_END 12764 WDWELL5OP: BA85 55F0 12765 LDHX DWELLDELAY5 BA87 00680C 12766 BRSET COILABIT,COILSEL,WD5A360 BA8A 02680D 12767 BRSET COILBBIT,COILSEL,WD5B360 BA8D 04680E 12768 BRSET COILCBIT,COILSEL,WD5C360 BA90 06680F 12769 BRSET COILDBIT,COILSEL,WD5D360 BA93 066810 12770 BRSET COILDBIT,COILSEL,WD5E360 BA96 35B3 12771 WD5A360: STHX SPARKONLEFTAH BA98 200E 12772 BRA WD5END360 BA9A 35B5 12773 WD5B360: STHX SPARKONLEFTBH BA9C 200A 12774 BRA WD5END360 BA9E 35B7 12775 WD5C360: STHX SPARKONLEFTCH BAA0 2006 12776 BRA WD5END360 BAA2 35B9 12777 WD5D360: STHX SPARKONLEFTDH BAA4 2002 12778 BRA WD5END360 BAA6 35BB 12779 WD5E360: STHX SPARKONLEFTEH 12780 WD5END360: BAA8 B6E8 12781 LDA DWELLDELAY1 BAAA 2606 12782 BNE WD5OK72 BAAC B6E9 12783 LDA DWELLDELAY1+1 BAAE A102 12784 CMP #2 BAB0 2523 12785 BLO WD5SKIP72 12786 WD5OK72: BAB2 55E8 12787 LDHX DWELLDELAY1 BAB4 00680C 12788 BRSET COILABIT,COILSEL,WD5A72 BAB7 02680D 12789 BRSET COILBBIT,COILSEL,WD5B72 BABA 04680E 12790 BRSET COILCBIT,COILSEL,WD5C72 BABD 06680F 12791 BRSET COILDBIT,COILSEL,WD5D72 BAC0 086810 12792 BRSET COILEBIT,COILSEL,WD5E72 BAC3 35B5 12793 WD5A72: STHX SPARKONLEFTBH BAC5 200E 12794 BRA WD5END72 BAC7 35B7 12795 WD5B72: STHX SPARKONLEFTCH BAC9 200A 12796 BRA WD5END72 BACB 35B9 12797 WD5C72: STHX SPARKONLEFTDH BACD 2006 12798 BRA WD5END72 BACF 35BB 12799 WD5D72: STHX SPARKONLEFTEH BAD1 2002 12800 BRA WD5END72 BAD3 35B3 12801 WD5E72: STHX SPARKONLEFTAH 12802 WD5END72: 12803 WD5SKIP72: BAD5 B6EA 12804 LDA DWELLDELAY2 BAD7 2606 12805 BNE WD5OK144 BAD9 B6EB 12806 LDA DWELLDELAY2+1 BADB A102 12807 CMP #2 BADD 2523 12808 BLO WD5SKIP144 12809 WD5OK144: BADF 55EA 12810 LDHX DWELLDELAY2 BAE1 00680C 12811 BRSET COILABIT,COILSEL,WD5A144 BAE4 02680D 12812 BRSET COILBBIT,COILSEL,WD5B144 BAE7 04680E 12813 BRSET COILCBIT,COILSEL,WD5C144 BAEA 06680F 12814 BRSET COILDBIT,COILSEL,WD5D144 BAED 086810 12815 BRSET COILEBIT,COILSEL,WD5E144 BAF0 35B7 12816 WD5A144: STHX SPARKONLEFTCH BAF2 200E 12817 BRA WD5END144 BAF4 35B9 12818 WD5B144: STHX SPARKONLEFTDH msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 107 MC68HC908GP32 User Bootloader BAF6 200A 12819 BRA WD5END144 BAF8 35BB 12820 WD5C144: STHX SPARKONLEFTEH BAFA 2006 12821 BRA WD5END144 BAFC 35B3 12822 WD5D144: STHX SPARKONLEFTAH BAFE 2002 12823 BRA WD5END144 BB00 35B5 12824 WD5E144: STHX SPARKONLEFTBH 12825 WD5END144: 12826 WD5SKIP144: BB02 B6EC 12827 LDA DWELLDELAY3 BB04 2606 12828 BNE WD5OK216 BB06 B6ED 12829 LDA DWELLDELAY3+1 BB08 A102 12830 CMP #2 BB0A 2523 12831 BLO WD5SKIP216 12832 WD5OK216: BB0C 55EC 12833 LDHX DWELLDELAY3 BB0E 00680C 12834 BRSET COILABIT,COILSEL,WD5A216 BB11 02680D 12835 BRSET COILBBIT,COILSEL,WD5B216 BB14 04680E 12836 BRSET COILCBIT,COILSEL,WD5C216 BB17 06680F 12837 BRSET COILDBIT,COILSEL,WD5D216 BB1A 086810 12838 BRSET COILEBIT,COILSEL,WD5E216 BB1D 35B9 12839 WD5A216: STHX SPARKONLEFTDH BB1F 200E 12840 BRA WD5END216 BB21 35BB 12841 WD5B216: STHX SPARKONLEFTEH BB23 200A 12842 BRA WD5END216 BB25 35B3 12843 WD5C216: STHX SPARKONLEFTAH BB27 2006 12844 BRA WD5END216 BB29 35B5 12845 WD5D216: STHX SPARKONLEFTBH BB2B 2002 12846 BRA WD5END216 BB2D 35B7 12847 WD5E216: STHX SPARKONLEFTCH 12848 WD5END216: 12849 WD5SKIP216: BB2F B6EE 12850 LDA DWELLDELAY4 BB31 2606 12851 BNE WD5OK288 BB33 B6EF 12852 LDA DWELLDELAY4+1 BB35 A102 12853 CMP #2 BB37 2523 12854 BLO WD5SKIP288 12855 WD5OK288: BB39 55EE 12856 LDHX DWELLDELAY4 BB3B 00680C 12857 BRSET COILABIT,COILSEL,WD5A288 BB3E 02680D 12858 BRSET COILBBIT,COILSEL,WD5B288 BB41 04680E 12859 BRSET COILCBIT,COILSEL,WD5C288 BB44 06680F 12860 BRSET COILDBIT,COILSEL,WD5D288 BB47 086810 12861 BRSET COILEBIT,COILSEL,WD5E288 BB4A 35BB 12862 WD5A288: STHX SPARKONLEFTEH BB4C 200E 12863 BRA WD5END288 BB4E 35B3 12864 WD5B288: STHX SPARKONLEFTAH BB50 200A 12865 BRA WD5END288 BB52 35B5 12866 WD5C288: STHX SPARKONLEFTBH BB54 2006 12867 BRA WD5END288 BB56 35B7 12868 WD5D288: STHX SPARKONLEFTCH BB58 2002 12869 BRA WD5END288 BB5A 35B9 12870 WD5E288: STHX SPARKONLEFTDH 12871 WD5END288: 12872 WD5SKIP288: BB5C CCBCA4 12873 JMP DD_END 12874 WDWELL6OP: BB5F 55F2 12875 LDHX DWELLDELAY6 BB61 00680F 12876 BRSET COILABIT,COILSEL,WD6A360 BB64 026810 12877 BRSET COILBBIT,COILSEL,WD6B360 BB67 046811 12878 BRSET COILCBIT,COILSEL,WD6C360 BB6A 066812 12879 BRSET COILDBIT,COILSEL,WD6D360 BB6D 086813 12880 BRSET COILEBIT,COILSEL,WD6E360 BB70 0A6814 12881 BRSET COILFBIT,COILSEL,WD6F360 BB73 35B3 12882 WD6A360: STHX SPARKONLEFTAH BB75 2012 12883 BRA WD6END360 BB77 35B5 12884 WD6B360: STHX SPARKONLEFTBH BB79 200E 12885 BRA WD6END360 BB7B 35B7 12886 WD6C360: STHX SPARKONLEFTCH BB7D 200A 12887 BRA WD6END360 BB7F 35B9 12888 WD6D360: STHX SPARKONLEFTDH BB81 2006 12889 BRA WD6END360 BB83 35BB 12890 WD6E360: STHX SPARKONLEFTEH BB85 2002 12891 BRA WD6END360 BB87 35BD 12892 WD6F360: STHX SPARKONLEFTFH 12893 WD6END360: BB89 C6E3AD 12894 LDA SPARKCONFIG1_F BB8C A510 12895 BIT #M_SC1ODDFIRE BB8E 2634 12896 BNE WD6SKIP60 BB90 B6E8 12897 LDA DWELLDELAY1 BB92 2606 12898 BNE WD6OK60 BB94 B6E9 12899 LDA DWELLDELAY1+1 BB96 A105 12900 CMP #5 BB98 252A 12901 BLO WD6SKIP60 12902 WD6OK60: BB9A 55E8 12903 LDHX DWELLDELAY1 BB9C 00680F 12904 BRSET COILABIT,COILSEL,WD6A60 BB9F 026810 12905 BRSET COILBBIT,COILSEL,WD6B60 BBA2 046811 12906 BRSET COILCBIT,COILSEL,WD6C60 BBA5 066812 12907 BRSET COILDBIT,COILSEL,WD6D60 BBA8 086813 12908 BRSET COILEBIT,COILSEL,WD6E60 BBAB 0A6814 12909 BRSET COILFBIT,COILSEL,WD6F60 BBAE 35B5 12910 WD6A60: STHX SPARKONLEFTBH BBB0 2012 12911 BRA WD6END60 BBB2 35B7 12912 WD6B60: STHX SPARKONLEFTCH BBB4 200E 12913 BRA WD6END60 BBB6 35B9 12914 WD6C60: STHX SPARKONLEFTDH BBB8 200A 12915 BRA WD6END60 BBBA 35BB 12916 WD6D60: STHX SPARKONLEFTEH BBBC 2006 12917 BRA WD6END60 BBBE 35BD 12918 WD6E60: STHX SPARKONLEFTFH BBC0 2002 12919 BRA WD6END60 BBC2 35B3 12920 WD6F60: STHX SPARKONLEFTAH 12921 WD6END60: 12922 WD6SKIP60: BBC4 B6EA 12923 LDA DWELLDELAY2 BBC6 2606 12924 BNE WD6OK120 BBC8 B6EB 12925 LDA DWELLDELAY2+1 BBCA A105 12926 CMP #5 BBCC 252A 12927 BLO WD6SKIP120 12928 WD6OK120: BBCE 55EA 12929 LDHX DWELLDELAY2 BBD0 00680F 12930 BRSET COILABIT,COILSEL,WD6A120 BBD3 026810 12931 BRSET COILBBIT,COILSEL,WD6B120 BBD6 046811 12932 BRSET COILCBIT,COILSEL,WD6C120 BBD9 066812 12933 BRSET COILDBIT,COILSEL,WD6D120 BBDC 086813 12934 BRSET COILEBIT,COILSEL,WD6E120 BBDF 0A6814 12935 BRSET COILFBIT,COILSEL,WD6F120 BBE2 35B7 12936 WD6A120: STHX SPARKONLEFTCH BBE4 2012 12937 BRA WD6END120 BBE6 35B9 12938 WD6B120: STHX SPARKONLEFTDH BBE8 200E 12939 BRA WD6END120 BBEA 35BB 12940 WD6C120: STHX SPARKONLEFTEH BBEC 200A 12941 BRA WD6END120 BBEE 35BD 12942 WD6D120: STHX SPARKONLEFTFH BBF0 2006 12943 BRA WD6END120 BBF2 35B3 12944 WD6E120: STHX SPARKONLEFTAH BBF4 2002 12945 BRA WD6END120 BBF6 35B5 12946 WD6F120: STHX SPARKONLEFTBH 12947 WD6END120: 12948 WD6SKIP120: BBF8 C6E3AD 12949 LDA SPARKCONFIG1_F BBFB A510 12950 BIT #M_SC1ODDFIRE BBFD 2636 12951 BNE WD6SKIP180 BBFF B6EC 12952 LDA DWELLDELAY3 BC01 2606 12953 BNE WD6OK180 BC03 B6ED 12954 LDA DWELLDELAY3+1 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 108 MC68HC908GP32 User Bootloader BC05 A105 12955 CMP #5 BC07 252C 12956 BLO WD6SKIP180 12957 WD6OK180: BC09 55EC 12958 LDHX DWELLDELAY3 BC0B 00680F 12959 BRSET COILABIT,COILSEL,WD6A180 BC0E 026810 12960 BRSET COILBBIT,COILSEL,WD6B180 BC11 046811 12961 BRSET COILCBIT,COILSEL,WD6C180 BC14 066812 12962 BRSET COILDBIT,COILSEL,WD6D180 BC17 086813 12963 BRSET COILEBIT,COILSEL,WD6E180 BC1A 0A6814 12964 BRSET COILFBIT,COILSEL,WD6F180 BC1D 35B9 12965 WD6A180: STHX SPARKONLEFTDH BC1F 2012 12966 BRA WD6END180 BC21 35BB 12967 WD6B180: STHX SPARKONLEFTEH BC23 200E 12968 BRA WD6END180 BC25 35BD 12969 WD6C180: STHX SPARKONLEFTFH BC27 200A 12970 BRA WD6END180 BC29 35B3 12971 WD6D180: STHX SPARKONLEFTAH BC2B 2006 12972 BRA WD6END180 BC2D 35B5 12973 WD6E180: STHX SPARKONLEFTBH BC2F 2002 12974 BRA WD6END180 BC31 35B7 12975 WD6F180: STHX SPARKONLEFTCH 12976 WD6END180: BC33 206F 12977 BRA DD_END 12978 WD6SKIP180: BC35 B6EE 12979 LDA DWELLDELAY4 BC37 2606 12980 BNE WD6OK240 BC39 B6EF 12981 LDA DWELLDELAY4+1 BC3B A105 12982 CMP #5 BC3D 252A 12983 BLO WD6SKIP240 12984 WD6OK240: BC3F 55EE 12985 LDHX DWELLDELAY4 BC41 00680F 12986 BRSET COILABIT,COILSEL,WD6A240 BC44 026810 12987 BRSET COILBBIT,COILSEL,WD6B240 BC47 046811 12988 BRSET COILCBIT,COILSEL,WD6C240 BC4A 066812 12989 BRSET COILDBIT,COILSEL,WD6D240 BC4D 086813 12990 BRSET COILEBIT,COILSEL,WD6E240 BC50 0A6814 12991 BRSET COILFBIT,COILSEL,WD6F240 BC53 35BB 12992 WD6A240: STHX SPARKONLEFTEH BC55 2012 12993 BRA WD6END240 BC57 35BD 12994 WD6B240: STHX SPARKONLEFTFH BC59 200E 12995 BRA WD6END240 BC5B 35B3 12996 WD6C240: STHX SPARKONLEFTAH BC5D 200A 12997 BRA WD6END240 BC5F 35B5 12998 WD6D240: STHX SPARKONLEFTBH BC61 2006 12999 BRA WD6END240 BC63 35B7 13000 WD6E240: STHX SPARKONLEFTCH BC65 2002 13001 BRA WD6END240 BC67 35B9 13002 WD6F240: STHX SPARKONLEFTDH 13003 WD6END240: 13004 WD6SKIP240: BC69 C6E3AD 13005 LDA SPARKCONFIG1_F BC6C A510 13006 BIT #M_SC1ODDFIRE BC6E 2634 13007 BNE WD6SKIP300 BC70 B6F0 13008 LDA DWELLDELAY5 BC72 2606 13009 BNE WD6OK300 BC74 B6F1 13010 LDA DWELLDELAY5+1 BC76 A105 13011 CMP #5 BC78 252A 13012 BLO WD6SKIP300 13013 WD6OK300: BC7A 55F0 13014 LDHX DWELLDELAY5 BC7C 00680F 13015 BRSET COILABIT,COILSEL,WD6A300 BC7F 026810 13016 BRSET COILBBIT,COILSEL,WD6B300 BC82 046811 13017 BRSET COILCBIT,COILSEL,WD6C300 BC85 066812 13018 BRSET COILDBIT,COILSEL,WD6D300 BC88 086813 13019 BRSET COILEBIT,COILSEL,WD6E300 BC8B 0A6814 13020 BRSET COILFBIT,COILSEL,WD6F300 BC8E 35BB 13021 WD6A300: STHX SPARKONLEFTEH BC90 2012 13022 BRA WD6END300 BC92 35BD 13023 WD6B300: STHX SPARKONLEFTFH BC94 200E 13024 BRA WD6END300 BC96 35B3 13025 WD6C300: STHX SPARKONLEFTAH BC98 200A 13026 BRA WD6END300 BC9A 35B5 13027 WD6D300: STHX SPARKONLEFTBH BC9C 2006 13028 BRA WD6END300 BC9E 35B7 13029 WD6E300: STHX SPARKONLEFTCH BCA0 2002 13030 BRA WD6END300 BCA2 35B9 13031 WD6F300: STHX SPARKONLEFTDH 13032 WD6END300: 13033 WD6SKIP300: 13034 DD_END: BCA4 8A 13035 pulh BCA5 80 13036 rti ; uses 0.1ms timer for 1/2 cycle time 13037 13038 13039 INT_SPARK_OFF: ; this is only used for EDIS so 13040 ; coilc has no meaning (yet!) BCA6 0C6912 13041 brset invspk,EnhancedBits4,InvSparkOff 13042 BCA9 00620B 13043 brset REUSE_FIDLE,outputpins,stimef2 BCAC 026804 13044 brset coilbbit,coilsel,stimeb2 BCAF 1102 13045 bclr coila,portc ; Set spark on BCB1 2018 13046 bra SparkOffDone 13047 stimeb2: BCB3 1302 13048 bclr coilb,portc BCB5 2014 13049 bra SparkOffDone 13050 stimef2: BCB7 1300 13051 bclr iasc,porta BCB9 2010 13052 bra SparkOffDone 13053 InvSparkOff: BCBB 00620B 13054 brset REUSE_FIDLE,outputpins,isof2 BCBE 026804 13055 brset coilbbit,coilsel,isob2 BCC1 1002 13056 bset coila,portc ; Set inverted spark on BCC3 2006 13057 bra SparkOffDone 13058 isob2: BCC5 1202 13059 bset coilb,portc BCC7 2002 13060 bra SparkOffDone 13061 isof2: BCC9 1200 13062 bset iasc,porta 13063 SparkOffDone: BCCB 115F 13064 bclr SparkTrigg,Sparkbits ; No more sparks for this IRQ BCCD 1D33 13065 bclr TOIE,T2SC1 ; Disable interrupts BCCF 80 13066 rti 13067 *** end EDIS *** 13068 13069 *************************************************************************** 13070 ** 13071 ** IRQ - Input trigger for new pulse event 13072 ** 13073 ** This line is connected to the input trigger (i.e TACH signal from ignition 13074 ** system), and schedules a new injector shot (injector actually opened in 13075 ** 1/10 timer section above) 13076 ** 13077 ** Wheel encoders now removed (020p2) and available as encoder???.s19 13078 *************************************************************************** 13079 ;as we don't get interrupted can safely use some of burner area 13080 ;but beware that this is non-zero page ram hence slower instructions. 13081 ;if enough ram may put back into ZP for a small speed increase BCD0 13082 stX: equ itmp10 ; temp space used in Neon BCD0 13083 stH: equ itmp11 BCD0 13084 stL: equ itmp12 13085 BCD0 13086 cTimeHcp: equ itmp13 ; copy of predicted period BCD0 13087 cTimeLcp: equ itmp14 13088 BCD0 13089 T2CurrX: equ itmp15 ; value of T2 at start of handler BCD0 13090 T2CurrH: equ itmp16 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 109 MC68HC908GP32 User Bootloader BCD0 13091 T2CurrL: equ itmp17 13092 BCD0 13093 currtth14h: equ itmp18 ; 1/4 current tooth BCD0 13094 currtth14l: equ itmp19 ; 1/4 current tooth BCD0 13095 avgtth14h: equ itmp1a ; 1/4 avg tooth BCD0 13096 avgtth14l: equ itmp1b ; 1/4 avg tooth 13097 BCD0 13098 avgtth12h: equ itmp1c ; 1/2 of avg tooth BCD0 13099 avgtth12l: equ itmp1d ; 1/2 of avg tooth 13100 BCD0 13101 offsetstep: equ itmp1e ; offset step (used by oddfire) BCD0 13102 offsetang: equ itmp1f ; offset angle (used by oddfire) 13103 13104 DOSQUIRT: 13105 13106 ;First thing to do is read the current T2 value 13107 ;this should ensure the maximum spark accuracy. Delay value will be based on timer HERE 13108 ;rather than after all the other missing tooth calcs by the time we reach done_decode BCD0 B62D 13109 lda T2CNTL ; Unlatch any previous reads BCD2 BE2C 13110 ldx T2CNTH BCD4 CF0203 13111 stx T2CurrH ; Save current counter value BCD7 B62D 13112 lda T2CNTL BCD9 C70204 13113 sta T2CurrL ; Save current counter value BCDC B6AA 13114 lda T2CNTX ;sw byte BCDE A300 13115 cpx #0 BCE0 2604 13116 bne no_rollchk BCE2 036901 13117 brclr roll2,EnhancedBits4,no_rollchk ; we were't about to rollover 13118 ; a few ms ago or byte already 13119 ; cleared by handler - so skip BCE5 4C 13120 inca ; Missed a rollover so inc top byte 13121 no_rollchk: BCE6 C70202 13122 sta T2CurrX 13123 13124 ;check for simulator first BCE9 046316 13125 brset whlsim,feature1,jwheelsim 13126 BCEC 026116 13127 brset MSNEON,personality,decode_neon BCEF 046107 13128 brset WHEEL,personality,jdecode_wheel 13129 ;set just single coil output BCF2 3F68 13130 clr coilsel BCF4 1068 13131 bset coilabit,coilsel BCF6 CCC107 13132 jmp done_decode ; everything else that doesn't 13133 ; need wheel decoding 13134 13135 jdecode_wheel: BCF9 006303 13136 brset wd_2trig,feature1,jdecode_wheel2 BCFC CCBE12 13137 jmp decode_wheel 13138 jdecode_wheel2: BCFF CCBDDB 13139 jmp decode_wheel2 13140 13141 jwheelsim: BD02 CCBDA6 13142 jmp wheelsim 13143 13144 decode_neon: BD05 195F 13145 bclr rise,sparkbits ; reset flag so we can detect 13146 ; next rising IRQ edge 13147 ; 020r3 - do all decoding using 0.1ms timer, count the short teeth 13148 ;use lowres timer for calcs 13149 ;cTime is zero page space for faster calcs, holds time since last tooth 13150 ;sH/L is temp storage as we are about to clear lowres BD07 B6F7 13151 lda lowresL BD09 C701FF 13152 sta stL BD0C B7C0 13153 sta cTimeL BD0E B6F6 13154 lda lowresH BD10 C701FE 13155 sta stH BD13 B7BF 13156 sta cTimeH 13157 BD15 3FF7 13158 clr lowresL ; reset to zero ready for next 0.1ms int BD17 3FF6 13159 clr lowresH 13160 13161 tooth_sync: ; ignore first few pulses BD19 0DE711 13162 brclr 6,wheelcount,tooth_decode2 ; if bit 6 clr then we've 13163 ; done holdoff BD1C 3AE7 13164 dec wheelcount BD1E 2602 13165 bne tooth_rti BD20 1DE7 13166 bclr 6,wheelcount 13167 tooth_rti: 13168 ;save gap between teeth BD22 C601FF 13169 lda stL BD25 B7F5 13170 sta stLp BD27 C601FE 13171 lda stH BD2A B7F4 13172 sta stHp BD2C 80 13173 rti 13174 13175 tooth_decode2: 13176 BD2D 1D5F 13177 bclr trigret,SparkBits BD2F 0EE70C 13178 brset 7,wheelcount,tooth_decode3 ; bit 7 is !sync. 13179 ; if not synced then look for 13180 ; the long trigger BD32 B6E7 13181 lda wheelcount ; ignore the three short pulses 13182 ; after primary trigger BD34 2708 13183 beq tooth_decode3 ; =0 BD36 3AE7 13184 dec wheelcount BD38 26E8 13185 bne tooth_rti ; >0 BD3A 1C5F 13186 bset trigret,SparkBits ; =0, set trigger return BD3C 20E4 13187 bra tooth_rti 13188 tooth_decode3: 13189 ; divide this cycle time 2 BD3E 34BF 13190 lsr cTimeH BD40 36C0 13191 ror cTimeL ; was rol - typo! 13192 13193 ;now see if this period/4 > previous BD42 B6BF 13194 lda cTimeH BD44 B1F4 13195 cmp stHp BD46 25DA 13196 blo tooth_rti BD48 2208 13197 bhi tooth_found BD4A B6C0 13198 lda cTimeL BD4C B1F5 13199 cmp stLp BD4E 2202 13200 bhi tooth_found BD50 20D0 13201 bra tooth_rti 13202 13203 tooth_found: ; this is when we've found the first tooth of the sequence 13204 BD52 6E03E7 13205 mov #3T,wheelcount ; clear !sync bit in process 13206 ;move save lowres values into "previous" variable BD55 C601FF 13207 lda stL BD58 B7F5 13208 sta stLp BD5A C601FE 13209 lda stH BD5D B7F4 13210 sta stHp 13211 13212 ;calculate how long first high pulse was to determine coil pack 13213 ; using SparkTemp to store rising edge time of "irq" to conserve RAM 13214 ; The variable should be safe as it is only used in this interrupt handler 13215 ; The 0.1ms section monitors the irq line and stores the lowresH/L 13216 ; value into SparkTemp if it detects a rising edge. 13217 ; calc how long ago the input went high sparktemp = current - sparktemp 13218 BD5F C601FF 13219 lda stL BD62 B0C2 13220 sub SparkTempL BD64 B7C2 13221 sta SparkTempL BD66 C601FE 13222 lda stH BD69 B2C1 13223 sbc SparkTempH BD6B B7C1 13224 sta SparkTempH 13225 BD6D 34BF 13226 lsr cTimeH msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 110 MC68HC908GP32 User Bootloader BD6F 36C0 13227 ror cTimeL 13228 13229 ;See if the high pulse > iTimet/4 BD71 B6C1 13230 lda SparkTempH BD73 B1BF 13231 cmp cTimeH BD75 220A 13232 bhi coil_detecta BD77 251A 13233 blo coil_detectb BD79 B6C2 13234 lda SparkTempL BD7B B1C0 13235 cmp cTimeL BD7D 2202 13236 bhi coil_detecta BD7F 2012 13237 bra coil_detectb 13238 13239 ; sequence detection 13240 ; 13241 coil_detecta: BD81 086007 13242 brset coilerr,revlimbits,set_a_clr BD84 026804 13243 brset coilbbit,coilsel,set_a_clr ; we are expecting this BD87 1860 13244 bset coilerr,revlimbits ; out of sync once, so ignore 13245 ; and follow instinct BD89 2014 13246 bra set_b_detect 13247 set_a_clr: BD8B 1960 13248 bclr coilerr,revlimbits ; reset error bit 13249 set_a_detect: BD8D 3F68 13250 clr coilsel BD8F 1068 13251 bset coilabit,coilsel BD91 2010 13252 bra j_done_cd 13253 13254 coil_detectb: BD93 086007 13255 brset coilerr,revlimbits,set_b_clr BD96 006804 13256 brset coilabit,coilsel,set_b_clr ; we are expecting this BD99 1860 13257 bset coilerr,revlimbits ; out of sync once, so ignore 13258 ; and follow instinct BD9B 20F0 13259 bra set_a_detect 13260 set_b_clr: BD9D 1960 13261 bclr coilerr,revlimbits ; reset error bit 13262 set_b_detect: BD9F 3F68 13263 clr coilsel BDA1 1268 13264 bset coilbbit,coilsel 13265 BDA3 CCC107 13266 j_done_cd: jmp done_decode 13267 13268 **************************************************************************** 13269 ** Wheel simulator. Allows any special decoders to be tested on the stim 13270 ** doesn't look for any pattern, just cycles through outputs. Trigger 13271 ** return WILL NOT WORK 13272 ** Flash variable determines how many outputs, use wheelcount as counter 13273 **************************************************************************** 13274 wheelsim: BDA6 B6E7 13275 lda wheelcount BDA8 4C 13276 inca BDA9 C1E00D 13277 cmp whlsimcnt BDAC 2601 13278 bne whlsimdecode 13279 whlsimreset: BDAE 4F 13280 clra 13281 whlsimdecode: BDAF B7E7 13282 sta wheelcount BDB1 3F68 13283 clr coilsel 13284 ; cbeqa #0,wsda BDB3 410110 13285 cbeqa #1,wsdb BDB6 410211 13286 cbeqa #2,wsdc BDB9 410312 13287 cbeqa #3,wsdd BDBC 410413 13288 cbeqa #4,wsde BDBF 410514 13289 cbeqa #5,wsdf 13290 ;wsda: BDC2 1068 13291 bset coilabit,coilsel BDC4 2012 13292 bra wheelsimdone 13293 wsdb: BDC6 1268 13294 bset coilbbit,coilsel BDC8 200E 13295 bra wheelsimdone 13296 wsdc: BDCA 1468 13297 bset coilcbit,coilsel BDCC 200A 13298 bra wheelsimdone 13299 wsdd: BDCE 1668 13300 bset coildbit,coilsel BDD0 2006 13301 bra wheelsimdone 13302 wsde: BDD2 1868 13303 bset coilebit,coilsel BDD4 2002 13304 bra wheelsimdone 13305 wsdf: BDD6 1A68 13306 bset coilfbit,coilsel 13307 ; bra wheelsimdone 13308 13309 wheelsimdone: BDD8 CCC107 13310 jmp done_decode 13311 **************************************************************************** 13312 ** Wheel decoder 2. No missing teeth but a second wheel with "reset" tabs 13313 ** 13314 ** The 0.1ms section looks out for the second pulse but we check here too 13315 ** on the rising edge the wheelcount is reset to zero so the next real pulse 13316 ** is tooth no.1 13317 ** This is what the Mazda and Toyota guys are after. 13318 ** Could also be used to do COP on a 4cyl by mounting the "reset" tab on the 13319 ** cam and having two tabs on the crank. 13320 **************************************************************************** 13321 decode_wheel2: 13322 13323 ;repeat check in here, in case two triggers come at once 13324 ;on rising edge of input reset wheelcount to zero BDDB 085F09 13325 brset rise,sparkbits,wd_rise2 ; already found 13326 BDDE 080206 13327 brset pin11,portc,no_wd_trig2 ; inactive BDE1 185F 13328 bset rise,sparkbits ; input pin had gone low since we last checked BDE3 166B 13329 bset trigger2,EnhancedBits6 BDE5 2000 13330 bra no_wd_trig2 13331 wd_rise2: 13332 no_wd_trig2: 13333 13334 ;are we doing missing tooth or non-missing tooth with the 2nd trigger BDE7 C6E042 13335 lda feature4_f BDEA A501 13336 bit #miss2ndb BDEC 2624 13337 bne decode_wheel ; miss + 2nd 13338 13339 ;this is "real" start of 2nd trigger. 13340 ;see if 2nd trigger came in since last time we were in here BDEE 076B08 13341 brclr trigger2,EnhancedBits6,cksync2 ; no it didn't BDF1 176B 13342 bclr trigger2,EnhancedBits6 ; clear it BDF3 126B 13343 bset wsync,EnhancedBits6 BDF5 3FE7 13344 clr wheelcount BDF7 2006 13345 bra no_wd_trig3 13346 cksync2: BDF9 026B03 13347 brset wsync,EnhancedBits6,no_wd_trig3 BDFC CCBEB1 13348 jmp w_rti ; go to exit for normal wheel decoder 13349 13350 no_wd_trig3: 13351 BDFF B6E7 13352 lda wheelcount BE01 C1E05A 13353 cmp numteeth_f BE04 2507 13354 blo wd2_cont 13355 ;we should have received a "reset" tab by now.. declare unsynced and 13356 ;wait for another reset tab BE06 136B 13357 bclr wsync,EnhancedBits6 BE08 3FE7 13358 clr wheelcount BE0A CCBEB1 13359 jmp w_rti ; go to exit for normal wheel decoder 13360 13361 wd2_cont: BE0D 3CE7 13362 inc wheelcount msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 111 MC68HC908GP32 User Bootloader BE0F CCBF81 13363 jmp wc_op ; jump to wheel decoder o/p selection 13364 **************************************************************************** 13365 ** generic wheel decoder 13366 ** -1 Missing tooth when iTimet > 1.5 * iTimep 13367 ** -2 Missing teeth when iTimet > 2.5 * iTimep 13368 ** We don't get here until we've had a few teeth. When we've found 13369 ** missing tooth then clr top bit of wheelcount 13370 ** 13371 **************************************************************************** 13372 decode_wheel: BE12 C6E05A 13373 lda numteeth_f BE15 A117 13374 cmp #23T ; hard coded lowres/highres 13375 ; transition (was 20T) BE17 2208 13376 bhi w_high 13377 w_low: 13378 ;as per Neon, use cTimeH/L where poss as it is zp 13379 ;use lowres timer for calcs BE19 4EF7C0 13380 mov lowresL,cTimeL BE1C 4EF6BF 13381 mov lowresH,cTimeH 13382 BE1F 2027 13383 bra w_decode 13384 13385 w_high: BE21 B64D 13386 lda rpm BE23 2615 13387 bne w_high_fast 13388 ;check for very slow rpm that will cause timer overflow. 13389 ;-1 does *1.5 so max time is 65/1.5 = 43ms -> 38rpm on 36-1 13390 ;-2 does *2.5 = 26ms -> 38rpm on 60-2 13391 ;if this check omitted then wacky rpm displayed when really very slow 13392 ;65ms = $28F x0.1ms BE25 B6F6 13393 lda lowresH BE27 A102 13394 cmp #2 BE29 250F 13395 blo w_high_fast ; fast enough BE2B 2206 13396 bhi j_lost_sync2 ; must re-sync - too slow BE2D B6F7 13397 lda lowresL ; lowresH=2, so check low byte BE2F A188 13398 cmp #$88 ; give a little leeway (64.8ms) BE31 2507 13399 blo w_high_fast ; if less then ok, otherwise re-sync 13400 j_lost_sync2: BE33 3FF7 13401 clr lowresL ; always reset the lowres ready for next int BE35 3FF6 13402 clr lowresH BE37 CCC082 13403 jmp lost_sync_w 13404 w_high_fast: 13405 ;T2 already read at start of handler BE3A C60204 13406 lda T2CurrL BE3D B0C7 13407 sub T2PrevL ; Calculate cycle time BE3F B7C0 13408 sta cTimeL BE41 C60203 13409 lda T2CurrH BE44 B2C6 13410 sbc T2PrevH BE46 B7BF 13411 sta cTimeH 13412 13413 ;now try to decode pattern 13414 w_decode: 13415 ;new - are we logging teeth? BE48 056A29 13416 brclr toothlog,EnhancedBits5,w_dec_notlog 13417 ;we are logging so record something BE4B 8B 13418 pshh BE4C 8C 13419 clrh BE4D CE01D5 13420 ldx VE_r+198T BE50 B6BF 13421 lda cTimeH BE52 D7010F 13422 sta VE_r,x BE55 5C 13423 incx BE56 B6C0 13424 lda cTimeL BE58 D7010F 13425 sta VE_r,x BE5B 5C 13426 incx BE5C A3C6 13427 cpx #198T BE5E 2610 13428 bne wdtl BE60 5F 13429 clrx BE61 C6E05A 13430 lda numteeth_f BE64 A117 13431 cmp #23T ; hard coded lowres/highres 13432 ; transition (was 20T) BE66 2204 13433 bhi wdth BE68 A601 13434 lda #1 ; 1 = 0.1ms units BE6A 2001 13435 bra wdts 13436 wdth: BE6C 4F 13437 clra ; 0 = 1us units 13438 wdts: BE6D C701D6 13439 sta VE_r+199T 13440 wdtl: BE70 CF01D5 13441 stx VE_r+198T BE73 8A 13442 pulh 13443 w_dec_notlog: 13444 13445 ;Ryan reports problems with the NEW routine below, so now config option to use 024s9 13446 ;style decoder instead. This way can swap versions on the fly BE74 C6E05C 13447 lda feature6_f BE77 A508 13448 bit #wheel_oldb BE79 2702 13449 beq decoder_new ; 0 = new decoder 13450 13451 ;bypass the tooth false trigger 13452 ;load up old vars into new ones 13453 ; mov stHp,avgtoothh ; now the same thing 13454 ; mov stLp,avgtoothl BE7B 2023 13455 bra w_decode_ok 13456 13457 decoder_new: 13458 ;NEW 13459 ;calculate half of average tooth time BE7D B6F4 13460 lda avgtoothh BE7F 44 13461 lsra BE80 C70209 13462 sta avgtth12h BE83 B6F5 13463 lda avgtoothl BE85 46 13464 rora BE86 C7020A 13465 sta avgtth12l 13466 BE89 046B14 13467 brset whold,EnhancedBits6,w_decode_ok ; still in holdoff, so no check BE8C 036B11 13468 brclr wsync,EnhancedBits6,w_decode_ok ; not synced yet, so no check 13469 ;check to see if obvious false trigger BE8F B6BF 13470 lda cTimeH BE91 C10209 13471 cmp avgtth12h ; divided by two before storage BE94 220A 13472 bhi w_decode_ok BE96 2507 13473 blo w_decode_false BE98 B6C0 13474 lda cTimeL BE9A C1020A 13475 cmp avgtth12l BE9D 2201 13476 bhi w_decode_ok 13477 13478 w_decode_false: BE9F 80 13479 rti ; get out of here - false trigger 13480 13481 w_decode_ok: 13482 ;END NEW BEA0 3FF7 13483 clr lowresL ; always reset the lowres ready for next int BEA2 3FF6 13484 clr lowresH 13485 ; ignore first few pulses BEA4 056B1D 13486 brclr whold,EnhancedBits6,w_decode2 ; if bit 6 clr then we've done holdoff BEA7 3AE7 13487 dec wheelcount BEA9 B6E7 13488 lda wheelcount BEAB A43F 13489 and #$3F ; ignore top bits during holdoff downcount 13490 ; keeps wheelcount compatible with Neon mode BEAD 2602 13491 bne w_rti BEAF 156B 13492 bclr whold,EnhancedBits6 13493 w_rti: BEB1 C60203 13494 lda T2CurrH BEB4 B7C6 13495 sta T2PrevH ; Make current value tooth last BEB6 C60204 13496 lda T2CurrL BEB9 B7C7 13497 sta T2PrevL 13498 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 112 MC68HC908GP32 User Bootloader 13499 ;this section only runs during tooth holdoff - just store last tooth into average BEBB B6C0 13500 lda cTimeL BEBD B7F5 13501 sta avgtoothl BEBF B6BF 13502 lda cTimeH BEC1 B7F4 13503 sta avgtoothh BEC3 80 13504 rti 13505 13506 w_decode2: 13507 ;mult iTimeH/Lp * .5 BEC4 B6F4 13508 lda avgtoothh BEC6 44 13509 lsra BEC7 B7C1 13510 sta SparkTempH BEC9 B6F5 13511 lda avgtoothl BECB 46 13512 rora BECC B7C2 13513 sta SparkTempL 13514 ; add iTimep so * 1.5 for -1 teeth BECE B6C2 13515 lda SparkTempL BED0 BBF5 13516 add avgtoothl BED2 B7C2 13517 sta SparkTempL BED4 B6C1 13518 lda SparkTempH BED6 B9F4 13519 adc avgtoothh BED8 B7C1 13520 sta SparkTempH 13521 BEDA 07610C 13522 brclr WHEEL2,personality,w_comp 13523 ; add iTimep so * 2.5, for -2 teeth BEDD B6C2 13524 lda SparkTempL BEDF BBF5 13525 add avgtoothl BEE1 B7C2 13526 sta SparkTempL BEE3 B6C1 13527 lda SparkTempH BEE5 B9F4 13528 adc avgtoothh BEE7 B7C1 13529 sta SparkTempH 13530 13531 w_comp: 13532 ; now compare current hires time BEE9 B6BF 13533 lda cTimeH BEEB B1C1 13534 cmp SparkTempH BEED 220A 13535 bhi is_miss BEEF 2519 13536 blo not_miss BEF1 B6C0 13537 lda cTimeL BEF3 B1C2 13538 cmp SparkTempL BEF5 2202 13539 bhi is_miss BEF7 2011 13540 bra not_miss 13541 13542 is_miss: BEF9 3FE7 13543 clr wheelcount ; declare we are synced and 13544 ; reset counter 13545 ;now check if 2nd trigger input is set, if so start 2nd revolution at num teeth 13546 ; i.e. on a 60-2, 0-359 deg = 0-59 13547 ; 360-719 deg = 60-119 13548 BEFB 076B05 13549 brclr trigger2,EnhancedBits6,not_2ndmiss BEFE C6E05A 13550 lda numteeth_f BF01 176B 13551 bclr trigger2,EnhancedBits6 ; clear flag 13552 not_2ndmiss: BF03 126B 13553 bset wsync,EnhancedBits6 BF05 076102 13554 brclr WHEEL2,personality,not_miss BF08 3CE7 13555 inc wheelcount 13556 not_miss: 13557 13558 ;check if using old decoder BF0A C6E05C 13559 lda feature6_f BF0D A508 13560 bit #wheel_oldb BF0F 270A 13561 beq tooth_avg 13562 13563 ;like old method, just store previoud period BF11 B6BF 13564 lda cTimeH BF13 B7F4 13565 sta avgtoothh BF15 B6C0 13566 lda cTimeL BF17 B7F5 13567 sta avgtoothl BF19 2050 13568 bra not_miss_skip ; 1 = old decoder 13569 13570 tooth_avg: 13571 ;NEW 13572 ;update average tooth count 13573 ;new average = 3/4 old avg + 1/4 current tooth 13574 ; 13575 ;get 1/4 current tooth BF1B B6BF 13576 lda cTimeH BF1D 44 13577 lsra BF1E C70205 13578 sta currtth14h BF21 B6C0 13579 lda cTimeL BF23 46 13580 rora BF24 C70206 13581 sta currtth14l BF27 C60205 13582 lda currtth14h BF2A 44 13583 lsra BF2B C70205 13584 sta currtth14h BF2E C60206 13585 lda currtth14l BF31 46 13586 rora BF32 C70206 13587 sta currtth14l 13588 ;get 1/4 avg tooth BF35 B6F4 13589 lda avgtoothh BF37 44 13590 lsra BF38 C70207 13591 sta avgtth14h BF3B B6F5 13592 lda avgtoothl BF3D 46 13593 rora BF3E C70208 13594 sta avgtth14l BF41 C60207 13595 lda avgtth14h BF44 44 13596 lsra BF45 C70207 13597 sta avgtth14h BF48 C60208 13598 lda avgtth14l BF4B 46 13599 rora BF4C C70208 13600 sta avgtth14l 13601 ;avg tooth - 1/4 avg tooth BF4F B6F5 13602 lda avgtoothl BF51 C00208 13603 sub avgtth14l BF54 B7F5 13604 sta avgtoothl BF56 B6F4 13605 lda avgtoothh BF58 C20207 13606 sbc avgtth14h BF5B B7F4 13607 sta avgtoothh 13608 ;3/4 avg tooth + 1/4 new tooth BF5D B6F5 13609 lda avgtoothl BF5F CB0206 13610 add currtth14l BF62 B7F5 13611 sta avgtoothl BF64 B6F4 13612 lda avgtoothh BF66 C90205 13613 adc currtth14h BF69 B7F4 13614 sta avgtoothh 13615 ;END NEW 13616 not_miss_skip: 13617 BF6B B6E7 13618 lda wheelcount BF6D AB01 13619 add #1 BF6F B7E7 13620 sta wheelcount BF71 A43F 13621 and #$3f ; ignore top 2 bits. BF73 C1E05A 13622 cmp numteeth_f BF76 2303 13623 bls not_miss_ok BF78 CCC082 13624 jmp lost_sync_w 13625 not_miss_ok: BF7B 026B03 13626 brset wsync,EnhancedBits6,wc_op BF7E CCC044 13627 jmp ret_w 13628 wc_op: 13629 ;see if our tooth matches the user input trigger point BF81 B6E7 13630 lda wheelcount BF83 0B6942 13631 brclr nextcyl,EnhancedBits4,wc_op2 BF86 07693F 13632 brclr wspk,EnhancedBits4,wc_op2 ; if not multi output doesn't matter 13633 13634 ;if running next-cyl and wheel decoder we would send running output to the msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 113 MC68HC908GP32 User Bootloader 13635 ;wrong coil unless we take this action here... 13636 ;(doesn't work?) 13637 13638 ;check if 4th spark output in use BF89 086418 13639 brset out3sparkd,feature2,wdnc4 13640 ;check if 3rd spark output in use 13641 ;don't check for 2nd output, wouldn't have got here otherwise BF8C 05622C 13642 brclr REUSE_LED18,outputpins,wdnc2 ; want 1 } spark c BF8F 076229 13643 brclr REUSE_LED18_2,outputpins,wdnc2 ; want 1 } 13644 wdnc3: BF92 C1E019 13645 cmp trig1_f BF95 2779 13646 beq w_trig2 BF97 C1E01A 13647 cmp trig2_f BF9A 277E 13648 beq w_trig3 BF9C C1E01B 13649 cmp trig3_f BF9F 2768 13650 beq w_trig1 BFA1 CCBFE6 13651 jmp wc_op3 13652 wdnc4: BFA4 C1E019 13653 cmp trig1_f BFA7 2767 13654 beq w_trig2 BFA9 C1E01A 13655 cmp trig2_f BFAC 276C 13656 beq w_trig3 BFAE C1E01B 13657 cmp trig3_f BFB1 2771 13658 beq w_trig4 BFB3 C1E01C 13659 cmp trig4_f BFB6 2751 13660 beq w_trig1 BFB8 CCBFE6 13661 jmp wc_op3 13662 wdnc2: BFBB C1E019 13663 cmp trig1_f BFBE 2750 13664 beq w_trig2 BFC0 C1E01A 13665 cmp trig2_f BFC3 2744 13666 beq w_trig1 BFC5 CCBFE6 13667 jmp wc_op3 13668 13669 13670 wc_op2: 13671 ; decode multiple outputs BFC8 C1E019 13672 cmp trig1_f BFCB 273C 13673 beq w_trig1 BFCD C1E01A 13674 cmp trig2_f BFD0 273E 13675 beq w_trig2 BFD2 C1E01B 13676 cmp trig3_f BFD5 2743 13677 beq w_trig3 BFD7 C1E01C 13678 cmp trig4_f BFDA 2748 13679 beq w_trig4 BFDC C1E0A0 13680 cmp trig5_f BFDF 274D 13681 beq w_trig5 BFE1 C1E0A1 13682 cmp trig6_f BFE4 2752 13683 beq w_trig6 13684 13685 wc_op3: BFE6 0A6A5B 13686 brset rsh_r,EnhancedBits5,ret_w ; don't check if doing trailing BFE9 C1E01D 13687 cmp trig1ret_f BFEC 2761 13688 beq w_trigret1 BFEE C1E01E 13689 cmp trig2ret_f BFF1 2762 13690 beq w_trigret2 BFF3 C1E01F 13691 cmp trig3ret_f BFF6 2766 13692 beq w_trigret3 BFF8 C1E020 13693 cmp trig4ret_f BFFB 276A 13694 beq w_trigret4 BFFD C1E0A2 13695 cmp trig5ret_f C000 276E 13696 beq w_trigret5 C002 C1E0A3 13697 cmp trig6ret_f C005 2772 13698 beq w_trigret6 C007 203B 13699 bra ret_w 13700 13701 w_trig1: C009 3F68 13702 clr coilsel C00B 1068 13703 bset coilabit,coilsel C00D CCC0FB 13704 jmp w_store2 13705 13706 w_trig2: C010 0962F6 13707 brclr REUSE_LED19,outputpins,w_trig1 ; if spark B not defined 13708 ; then just one o/p C013 3F68 13709 clr coilsel C015 1268 13710 bset coilbbit,coilsel C017 CCC0FB 13711 jmp w_store2 13712 13713 w_trig3: C01A 0962EC 13714 brclr REUSE_LED19,outputpins,w_trig1 C01D 3F68 13715 clr coilsel C01F 1468 13716 bset coilcbit,coilsel C021 CCC0FB 13717 jmp w_store2 13718 13719 w_trig4: C024 0962E2 13720 brclr REUSE_LED19,outputpins,w_trig1 C027 3F68 13721 clr coilsel C029 1668 13722 bset coildbit,coilsel C02B CCC0FB 13723 jmp w_store2 13724 13725 w_trig5: C02E 0962D8 13726 brclr REUSE_LED19,outputpins,w_trig1 C031 3F68 13727 clr coilsel C033 1868 13728 bset coilebit,coilsel C035 CCC0FB 13729 jmp w_store2 13730 13731 w_trig6: C038 0962CE 13732 brclr REUSE_LED19,outputpins,w_trig1 C03B 3F68 13733 clr coilsel C03D 1A68 13734 bset coilfbit,coilsel C03F CCC0FB 13735 jmp w_store2 13736 13737 ret_w2: C042 1C5F 13738 bset trigret,SparkBits 13739 13740 ret_w: C044 C60203 13741 lda T2CurrH C047 B7C6 13742 sta T2PrevH ; Make current value tooth last C049 C60204 13743 lda T2CurrL C04C B7C7 13744 sta T2PrevL C04E 80 13745 rti 13746 13747 ; now the "trigger return" tooth for cranking timing 13748 w_trigret1: C04F 3F68 13749 clr coilsel C051 1068 13750 bset coilabit,coilsel C053 20ED 13751 bra ret_w2 13752 13753 w_trigret2: C055 0962F7 13754 brclr REUSE_LED19,outputpins,w_trigret1 ; if spark B not 13755 ; defined then just one o/p C058 3F68 13756 clr coilsel C05A 1268 13757 bset coilbbit,coilsel C05C 20E4 13758 bra ret_w2 13759 13760 w_trigret3: C05E 0962EE 13761 brclr REUSE_LED19,outputpins,w_trigret1 C061 3F68 13762 clr coilsel C063 1468 13763 bset coilcbit,coilsel C065 20DB 13764 bra ret_w2 13765 13766 w_trigret4: C067 0962E5 13767 brclr REUSE_LED19,outputpins,w_trigret1 C06A 3F68 13768 clr coilsel C06C 1668 13769 bset coildbit,coilsel C06E 20D2 13770 bra ret_w2 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 114 MC68HC908GP32 User Bootloader 13771 13772 w_trigret5: C070 0962DC 13773 brclr REUSE_LED19,outputpins,w_trigret1 C073 3F68 13774 clr coilsel C075 1868 13775 bset coilebit,coilsel C077 20C9 13776 bra ret_w2 13777 13778 w_trigret6: C079 0962D3 13779 brclr REUSE_LED19,outputpins,w_trigret1 C07C 3F68 13780 clr coilsel C07E 1A68 13781 bset coilfbit,coilsel C080 20C0 13782 bra ret_w2 13783 13784 lost_sync_w: ; we found too many teeth after 13785 ; the missing one, start syncing again 13786 ; also do holdoff. This should be 13787 ; rare, but if we lost sync that 13788 ; bad we'd better start all over C082 6EC5E7 13789 mov #WHEELINIT,wheelcount ; was %10000000 (missing #) C085 136B 13790 bclr wsync,EnhancedBits6 C087 146B 13791 bset whold,EnhancedBits6 13792 ;NEW C089 A600 13793 lda #0 C08B B7F4 13794 sta avgtoothh C08D B7F5 13795 sta avgtoothl 13796 ;NEW 13797 13798 ;worth killing the dwell timers to avoid dwells starting C08F macro 13799 TurnAllSpkOff ; call macro to turn off all C08F 0D6910 13800 BRCLR INVSPK,ENHANCEDBITS4,SOIN C092 1300 13801 BCLR IASC,PORTA C094 1102 13802 BCLR SLED,PORTC C096 1502 13803 BCLR WLED,PORTC C098 1302 13804 BCLR ALED,PORTC C09A 1103 13805 BCLR OUTPUT3,PORTD C09C 1702 13806 BCLR PIN10,PORTC C09E 1503 13807 BCLR KNOCKIN,PORTD C0A0 203E 13808 BRA SOIN_DONE 13809 SOIN: C0A2 006204 13810 BRSET REUSE_FIDLE,OUTPUTPINS,SOIN1 C0A5 1300 13811 BCLR IASC,PORTA C0A7 2002 13812 BRA SOIN2 C0A9 1200 13813 SOIN1: BSET IASC,PORTA C0AB 026204 13814 SOIN2: BRSET REUSE_LED17,OUTPUTPINS,SOIN3 C0AE 1102 13815 BCLR SLED,PORTC C0B0 2002 13816 BRA SOIN4 C0B2 1002 13817 SOIN3: BSET SLED,PORTC C0B4 086204 13818 SOIN4: BRSET REUSE_LED19,OUTPUTPINS,SOIN5 C0B7 1302 13819 BCLR ALED,PORTC C0B9 2002 13820 BRA SOIN6 C0BB 1202 13821 SOIN5: BSET ALED,PORTC C0BD 056207 13822 SOIN6: BRCLR REUSE_LED18,OUTPUTPINS,SOIN7 C0C0 076204 13823 BRCLR REUSE_LED18_2,OUTPUTPINS,SOIN7 C0C3 1402 13824 BSET WLED,PORTC C0C5 2002 13825 BRA SOIN8 C0C7 1502 13826 SOIN7: BCLR WLED,PORTC 13827 SOIN8: C0C9 096402 13828 BRCLR OUT3SPARKD,FEATURE2,SOIN9 C0CC 1003 13829 BSET OUTPUT3,PORTD 13830 SOIN9: C0CE C6E074 13831 LDA FEATURE8_F C0D1 A508 13832 BIT #SPKEOPB C0D3 2702 13833 BEQ SOIN10 C0D5 1602 13834 BSET PIN10,PORTC 13835 SOIN10: C0D7 C6E074 13836 LDA FEATURE8_F C0DA A510 13837 BIT #SPKFOPB C0DC 2702 13838 BEQ SOIN11 C0DE 1403 13839 BSET KNOCKIN,PORTD 13840 SOIN11: 13841 SOIN_DONE: C0E0 3FB3 13842 CLR SPARKONLEFTAH C0E2 3FB4 13843 CLR SPARKONLEFTAL C0E4 3FB5 13844 CLR SPARKONLEFTBH C0E6 3FB6 13845 CLR SPARKONLEFTBL C0E8 3FB7 13846 CLR SPARKONLEFTCH C0EA 3FB8 13847 CLR SPARKONLEFTCL C0EC 3FB9 13848 CLR SPARKONLEFTDH C0EE 3FBA 13849 CLR SPARKONLEFTDL C0F0 3FBB 13850 CLR SPARKONLEFTEH C0F2 3FBC 13851 CLR SPARKONLEFTEL C0F4 3FBD 13852 CLR SPARKONLEFTFH C0F6 3FBE 13853 CLR SPARKONLEFTFL C0F8 CCC044 13854 jmp ret_w 13855 13856 w_store2: C0FB 1D5F 13857 bclr trigret,SparkBits 13858 13859 w_store: C0FD C60203 13860 lda T2CurrH C100 B7C6 13861 sta T2PrevH ; Make current value tooth last C102 C60204 13862 lda T2CurrL C105 B7C7 13863 sta T2PrevL 13864 ***************************************************************************** 13865 ** When getting here we should have decoded crank signal into one pulse 13866 ** per ignition event so we can just drop into the standard MSnS code. 13867 ** A smarter implementation would use the individual teeth for more 13868 ** accurate timing 13869 ***************************************************************************** 13870 done_decode: C107 056205 13871 brclr REUSE_LED18,outputpins,dcd_no_led C10A 066202 13872 brset REUSE_LED18_2,outputpins,dcd_no_led ; if coil c C10D 1402 13873 bset wled,portc ; Turn on IRQ led, orig MSnS code 13874 dcd_no_led: 13875 13876 ;tacho output C10F C6E09F 13877 lda tachconf_f C112 A57F 13878 bit #$7f C114 2710 13879 beq tach_done C116 A580 13880 bit #$80 ; see if in divide by 2 mode C118 270A 13881 beq tach_full C11A B66A 13882 lda EnhancedBits5 C11C A880 13883 eor #ctodivb C11E B76A 13884 sta EnhancedBits5 C120 A580 13885 bit #ctodivb C122 2702 13886 beq tach_done 13887 tach_full: C124 1C6A 13888 bset cto,EnhancedBits5 ;arm tach. Output actually set in 1ms section 13889 tach_done: 13890 ;save old values C126 4EAEFD 13891 mov iTimeX,iTimepX C129 4EAFFE 13892 mov iTimeH,iTimepH C12C 4EB0FF 13893 mov iTimeL,iTimepL 13894 13895 ;T2 read at start of DOSQUIRT C12F C60204 13896 lda T2CurrL C132 B0AD 13897 sub T2LastL ; Calculate cycle time C134 B7B0 13898 sta iTimeL ; global var C136 C60203 13899 lda T2CurrH C139 B2AC 13900 sbc T2LastH C13B B7AF 13901 sta iTimeH C13D C60202 13902 lda T2CurrX C140 B2AB 13903 sbc T2LastX C142 B7AE 13904 sta iTimeX 13905 13906 ;Must check to see if iTime has gone negative. This can occur if the interrupt to increment msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 115 MC68HC908GP32 User Bootloader 13907 ; the top byte of the timer gets missed. The roll_chk code obviously does not work correctly. 13908 13909 ;;;;CODE TO FIX DROPOUT C144 0FAE0A 13910 brclr 7,iTimeX,noitx_err 13911 ;if top bit of iTimeX is set then software rollover must have got missed 13912 ;giving a negative time C147 C60202 13913 lda T2CurrX C14A AB01 13914 add #1 ; increment the saved "current" value of the timer C14C C70202 13915 sta T2CurrX 13916 ;assume value should really be zero C14F 3FAE 13917 clr iTimeX ; assume top byte is zero 13918 noitx_err: 13919 ;;;;CODE TO FIX DROPOUT 13920 13921 ;check for dual dizzy feature C151 056120 13922 brclr WHEEL,personality,nondualdizzy ; if not wheel decoder then skip C154 C6E05C 13923 lda feature6_f C157 A510 13924 bit #dualdizzyb C159 2719 13925 beq nondualdizzy C15B 026812 13926 brset coilbbit,coilsel,dualdb C15E 046809 13927 brset coilcbit,coilsel,dualda C161 06680C 13928 brset coildbit,coilsel,dualdb C164 086803 13929 brset coilebit,coilsel,dualda C167 0A6806 13930 brset coilfbit,coilsel,dualdb 13931 dualda: C16A 3F68 13932 clr coilsel C16C 1068 13933 bset coilabit,coilsel C16E 2004 13934 bra nondualdizzy 13935 dualdb: C170 3F68 13936 clr coilsel C172 1268 13937 bset coilbbit,coilsel 13938 13939 nondualdizzy: 13940 ************* 13941 ; If we are running next cyl and low advance and get a lot of engine 13942 ; accel then we can sometime receive the next trigger pulse before 13943 ; we've actually sparked. We'll know if this happens because sparktrigg 13944 ; will be set when we get here. If this is the case then we'd better 13945 ; fire the coil right now. 13946 ; C174 0B6906 13947 brclr nextcyl,EnhancedBits4,j_miss_ckskp ; ONLY for next-cylinder 13948 ;the nextcyl bit is only set for valid personalities 13949 C177 024206 13950 brset crank,engine,miss_chk ; at crank we ALWAYS fire at trigger C17A 005F03 13951 brset SparkTrigg,Sparkbits,miss_chk ; if set then we missed one 13952 C17D CCC5E5 13953 j_miss_ckskp: jmp miss_chk_skip 13954 miss_chk: 13955 C180 0C6974 13956 brset invspk,EnhancedBits4,mc_inv C183 macro 13957 COILNEG ; macro = fire coil for non-inverted C183 00626A 13958 BRSET REUSE_FIDLE,OUTPUTPINS,DSLSX C186 006A1E 13959 BRSET ROTARY2,ENHANCEDBITS5,ROT2NEG C189 0F6232 13960 BRCLR TOY_DLI,OUTPUTPINS,NILS C18C 006806 13961 BRSET COILABIT,COILSEL,FCNITA C18F 026809 13962 BRSET COILBBIT,COILSEL,FCNITB C192 04680C 13963 BRSET COILCBIT,COILSEL,FCNITC 13964 FCNITA: C195 1302 13965 BCLR COILB,PORTC C197 1502 13966 BCLR WLED,PORTC C199 203D 13967 BRA DSLSA 13968 FCNITB: C19B 1202 13969 BSET COILB,PORTC C19D 1502 13970 BCLR WLED,PORTC C19F 2037 13971 BRA DSLSA 13972 FCNITC: C1A1 1302 13973 BCLR COILB,PORTC C1A3 1402 13974 BSET WLED,PORTC C1A5 2031 13975 BRA DSLSA 13976 ROT2NEG: C1A7 086328 13977 BRSET ROTARYFDIGN,FEATURE1,FIREFD C1AA 046805 13978 BRSET COILCBIT,COILSEL,ROT2CN C1AD 066808 13979 BRSET COILDBIT,COILSEL,ROT2DN C1B0 2026 13980 BRA DSLSA 13981 ROT2CN: C1B2 1502 13982 BCLR WLED,PORTC C1B4 1202 13983 BSET COILB,PORTC C1B6 203A 13984 BRA CN_END 13985 ROT2DN: C1B8 1402 13986 BSET WLED,PORTC C1BA 1202 13987 BSET COILB,PORTC C1BC 2034 13988 BRA CN_END 13989 NILS: C1BE 006817 13990 BRSET COILABIT,COILSEL,DSLSA C1C1 026818 13991 BRSET COILBBIT,COILSEL,DSLSB C1C4 046819 13992 BRSET COILCBIT,COILSEL,DSLSC C1C7 06681A 13993 BRSET COILDBIT,COILSEL,DSLSD C1CA 08681B 13994 BRSET COILEBIT,COILSEL,DSLSE C1CD 0A681C 13995 BRSET COILFBIT,COILSEL,DSLSF C1D0 2020 13996 BRA CN_END 13997 FIREFD: C1D2 046807 13998 BRSET COILCBIT,COILSEL,DSLSB C1D5 066808 13999 BRSET COILDBIT,COILSEL,DSLSC 14000 DSLSA: C1D8 1002 14001 BSET COILA,PORTC C1DA 2016 14002 BRA CN_END 14003 DSLSB: C1DC 1202 14004 BSET COILB,PORTC C1DE 2012 14005 BRA CN_END 14006 DSLSC: C1E0 1402 14007 BSET WLED,PORTC C1E2 200E 14008 BRA CN_END 14009 DSLSD: C1E4 1003 14010 BSET OUTPUT3,PORTD C1E6 200A 14011 BRA CN_END 14012 DSLSE: C1E8 1602 14013 BSET PIN10,PORTC C1EA 2006 14014 BRA CN_END 14015 DSLSF: C1EC 1403 14016 BSET KNOCKIN,PORTD C1EE 2002 14017 BRA CN_END 14018 DSLSX: C1F0 1200 14019 BSET IASC,PORTA 14020 CN_END: C1F2 2050 14021 bra mc_fire_done 14022 C1F4 CCC5DF 14023 j_miss_ckdn2: jmp miss_chk_done 14024 mc_inv: C1F7 macro 14025 COILPOS ; macro = fire coil for inverted C1F7 006248 14026 BRSET REUSE_FIDLE,OUTPUTPINS,ILSOX C1FA 006A14 14027 BRSET ROTARY2,ENHANCEDBITS5,ROT2POS C1FD 00682A 14028 BRSET COILABIT,COILSEL,ILSOA C200 02682B 14029 BRSET COILBBIT,COILSEL,ILSOB C203 04682C 14030 BRSET COILCBIT,COILSEL,ILSOC C206 06682D 14031 BRSET COILDBIT,COILSEL,ILSOD C209 08682E 14032 BRSET COILEBIT,COILSEL,ILSOE C20C 0A682F 14033 BRSET COILFBIT,COILSEL,ILSOF C20F 2033 14034 BRA FC_END 14035 ROT2POS: C211 086310 14036 BRSET ROTARYFDIGN,FEATURE1,CHARGEFD C214 046805 14037 BRSET COILCBIT,COILSEL,ROT2CP C217 066806 14038 BRSET COILDBIT,COILSEL,ROT2DP C21A 200E 14039 BRA ILSOA 14040 ROT2CP: C21C 1302 14041 BCLR COILB,PORTC C21E 2024 14042 BRA FC_END msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 116 MC68HC908GP32 User Bootloader 14043 ROT2DP: C220 1302 14044 BCLR COILB,PORTC C222 2020 14045 BRA FC_END 14046 CHARGEFD: C224 04680B 14047 BRSET COILCBIT,COILSEL,ILSOC C227 066804 14048 BRSET COILDBIT,COILSEL,ILSOB 14049 ILSOA: C22A 1102 14050 BCLR COILA,PORTC C22C 2016 14051 BRA FC_END 14052 ILSOB: C22E 1302 14053 BCLR COILB,PORTC C230 2012 14054 BRA FC_END 14055 ILSOC: C232 1502 14056 BCLR WLED,PORTC C234 200E 14057 BRA FC_END 14058 ILSOD: C236 1103 14059 BCLR OUTPUT3,PORTD C238 200A 14060 BRA FC_END 14061 ILSOE: C23A 1702 14062 BCLR PIN10,PORTC C23C 2006 14063 BRA FC_END 14064 ILSOF: C23E 1503 14065 BCLR KNOCKIN,PORTD C240 2002 14066 BRA FC_END 14067 ILSOX: C242 1300 14068 BCLR IASC,PORTA 14069 FC_END: 14070 mc_fire_done: C244 1D33 14071 bclr TOIE,T2SC1 ; Disable timer interrupt 14072 ; (never got there) C246 036509 14073 brclr dwellcont,feature7,mc_fd 14074 ;if next_cyl and cranking then skip C249 0B6903 14075 brclr nextcyl,EnhancedBits4,mc_fd2 C24C 024209 14076 brset crank,engine,mc_cd ; can cause a conflict 14077 mc_fd2: C24F 045F03 14078 brset SparkLSpeed,SparkBits,jmcd ; low speed & dwell 14079 ; so don't schedule now 14080 mc_fd: C252 0B6403 14081 brclr min_dwell,feature2,mc_cd ; don't schedule here C255 CCC5DF 14082 jmcd: jmp miss_chk_done ; if minimal dwell wanted 14083 mc_cd: C258 8B 14084 pshh C259 macro 14085 CalcDwellspk ; Set spark on time C259 06692D 14086 BRSET WSPK,ENHANCEDBITS4,WASTEDWELL C25C 55E8 14087 LDHX DWELLDELAY1 C25E 00680B 14088 BRSET COILABIT,COILSEL,DD_A C261 02680C 14089 BRSET COILBBIT,COILSEL,DD_B C264 04680D 14090 BRSET COILCBIT,COILSEL,DD_C C267 06680E 14091 BRSET COILDBIT,COILSEL,DD_D C26A 200E 14092 BRA JDD_END C26C 35B3 14093 DD_A: STHX SPARKONLEFTAH C26E 200A 14094 BRA JDD_END C270 35B5 14095 DD_B: STHX SPARKONLEFTBH C272 2006 14096 BRA JDD_END C274 35B7 14097 DD_C: STHX SPARKONLEFTCH C276 2002 14098 BRA JDD_END C278 35B9 14099 DD_D: STHX SPARKONLEFTDH C27A CCC5DE 14100 JDD_END: JMP DD_END C27D CCC499 14101 JWDWELL6OP: JMP WDWELL6OP C280 CCC3BF 14102 JWDWELL5OP: JMP WDWELL5OP C283 CCC320 14103 JWDWELL4OP: JMP WDWELL4OP C286 CCC2F3 14104 JWDWELL2OP: JMP WDWELL2OP 14105 WASTEDWELL: C289 C6E074 14106 LDA FEATURE8_F C28C A510 14107 BIT #SPKFOPB C28E 26ED 14108 BNE JWDWELL6OP C290 A508 14109 BIT #SPKEOPB C292 26EC 14110 BNE JWDWELL5OP C294 0864EC 14111 BRSET OUT3SPARKD,FEATURE2,JWDWELL4OP C297 0562EC 14112 BRCLR REUSE_LED18,OUTPUTPINS,JWDWELL2OP C29A 0762E9 14113 BRCLR REUSE_LED18_2,OUTPUTPINS,JWDWELL2OP 14114 WDWELL3OP: C29D 55EC 14115 LDHX DWELLDELAY3 C29F 006806 14116 BRSET COILABIT,COILSEL,WD3A360 C2A2 026807 14117 BRSET COILBBIT,COILSEL,WD3B360 C2A5 046808 14118 BRSET COILCBIT,COILSEL,WD3C360 C2A8 35B3 14119 WD3A360: STHX SPARKONLEFTAH C2AA 2006 14120 BRA WD3END360 C2AC 35B5 14121 WD3B360: STHX SPARKONLEFTBH C2AE 2002 14122 BRA WD3END360 C2B0 35B7 14123 WD3C360: STHX SPARKONLEFTCH 14124 WD3END360: C2B2 B6E8 14125 LDA DWELLDELAY1 C2B4 2606 14126 BNE WD3OK120 C2B6 B6E9 14127 LDA DWELLDELAY1+1 C2B8 A102 14128 CMP #2 C2BA 2515 14129 BLO WD3SKIP120 14130 WD3OK120: C2BC 55E8 14131 LDHX DWELLDELAY1 C2BE 006806 14132 BRSET COILABIT,COILSEL,WD3A120 C2C1 026807 14133 BRSET COILBBIT,COILSEL,WD3B120 C2C4 046808 14134 BRSET COILCBIT,COILSEL,WD3C120 C2C7 35B5 14135 WD3A120: STHX SPARKONLEFTBH C2C9 2006 14136 BRA WD3END120 C2CB 35B7 14137 WD3B120: STHX SPARKONLEFTCH C2CD 2002 14138 BRA WD3END120 C2CF 35B3 14139 WD3C120: STHX SPARKONLEFTAH 14140 WD3END120: 14141 WD3SKIP120: C2D1 B6EA 14142 LDA DWELLDELAY2 C2D3 2606 14143 BNE WD3OK240 C2D5 B6EB 14144 LDA DWELLDELAY2+1 C2D7 A102 14145 CMP #2 C2D9 2515 14146 BLO WD3END240 14147 WD3OK240: C2DB 55EA 14148 LDHX DWELLDELAY2 C2DD 006806 14149 BRSET COILABIT,COILSEL,WD3A240 C2E0 026807 14150 BRSET COILBBIT,COILSEL,WD3B240 C2E3 046808 14151 BRSET COILCBIT,COILSEL,WD3C240 C2E6 35B7 14152 WD3A240: STHX SPARKONLEFTCH C2E8 2006 14153 BRA WD3END240 C2EA 35B3 14154 WD3B240: STHX SPARKONLEFTAH C2EC 2002 14155 BRA WD3END240 C2EE 35B5 14156 WD3C240: STHX SPARKONLEFTBH C2F0 CCC5DE 14157 WD3END240: JMP DD_END 14158 WDWELL2OP: C2F3 55EA 14159 LDHX DWELLDELAY2 C2F5 026804 14160 BRSET COILBBIT,COILSEL,WD2B360 C2F8 35B3 14161 WD2A360: STHX SPARKONLEFTAH C2FA 2002 14162 BRA WD2END360 C2FC 35B5 14163 WD2B360: STHX SPARKONLEFTBH 14164 WD2END360: C2FE C6E3AD 14165 LDA SPARKCONFIG1_F C301 A510 14166 BIT #M_SC1ODDFIRE C303 2618 14167 BNE WD2SKIP C305 B6E8 14168 LDA DWELLDELAY1 C307 2606 14169 BNE WD2OK C309 B6E9 14170 LDA DWELLDELAY1+1 C30B A102 14171 CMP #2 C30D 250E 14172 BLO WD2SKIP 14173 WD2OK: C30F 55E8 14174 LDHX DWELLDELAY1 C311 006803 14175 BRSET COILABIT,COILSEL,WD2A180 C314 026804 14176 BRSET COILBBIT,COILSEL,WD2B180 C317 35B5 14177 WD2A180: STHX SPARKONLEFTBH C319 2002 14178 BRA WD2END180 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 117 MC68HC908GP32 User Bootloader C31B 35B3 14179 WD2B180: STHX SPARKONLEFTAH 14180 WD2END180: C31D CCC5DE 14181 WD2SKIP: JMP DD_END 14182 WDWELL4OP: C320 55EE 14183 LDHX DWELLDELAY4 C322 006809 14184 BRSET COILABIT,COILSEL,WD4A360 C325 02680A 14185 BRSET COILBBIT,COILSEL,WD4B360 C328 04680B 14186 BRSET COILCBIT,COILSEL,WD4C360 C32B 06680C 14187 BRSET COILDBIT,COILSEL,WD4D360 C32E 35B3 14188 WD4A360: STHX SPARKONLEFTAH C330 200A 14189 BRA WD4END360 C332 35B5 14190 WD4B360: STHX SPARKONLEFTBH C334 2006 14191 BRA WD4END360 C336 35B7 14192 WD4C360: STHX SPARKONLEFTCH C338 2002 14193 BRA WD4END360 C33A 35B9 14194 WD4D360: STHX SPARKONLEFTDH 14195 WD4END360: C33C C6E3AD 14196 LDA SPARKCONFIG1_F C33F A510 14197 BIT #M_SC1ODDFIRE C341 2626 14198 BNE WD4SKIP90 C343 B6E8 14199 LDA DWELLDELAY1 C345 2606 14200 BNE WD4OK90 C347 B6E9 14201 LDA DWELLDELAY1+1 C349 A102 14202 CMP #2 C34B 251C 14203 BLO WD4SKIP90 14204 WD4OK90: C34D 55E8 14205 LDHX DWELLDELAY1 C34F 006809 14206 BRSET COILABIT,COILSEL,WD4A90 C352 02680A 14207 BRSET COILBBIT,COILSEL,WD4B90 C355 04680B 14208 BRSET COILCBIT,COILSEL,WD4C90 C358 06680C 14209 BRSET COILDBIT,COILSEL,WD4D90 C35B 35B5 14210 WD4A90: STHX SPARKONLEFTBH C35D 200A 14211 BRA WD4END90 C35F 35B7 14212 WD4B90: STHX SPARKONLEFTCH C361 2006 14213 BRA WD4END90 C363 35B9 14214 WD4C90: STHX SPARKONLEFTDH C365 2002 14215 BRA WD4END90 C367 35B3 14216 WD4D90: STHX SPARKONLEFTAH 14217 WD4END90: 14218 WD4SKIP90: C369 B6EA 14219 LDA DWELLDELAY2 C36B 2606 14220 BNE WD4OK180 C36D B6EB 14221 LDA DWELLDELAY2+1 C36F A102 14222 CMP #2 C371 251C 14223 BLO WD4SKIP180 14224 WD4OK180: C373 55EA 14225 LDHX DWELLDELAY2 C375 006809 14226 BRSET COILABIT,COILSEL,WD4A180 C378 02680A 14227 BRSET COILBBIT,COILSEL,WD4B180 C37B 04680B 14228 BRSET COILCBIT,COILSEL,WD4C180 C37E 06680C 14229 BRSET COILDBIT,COILSEL,WD4D180 C381 35B7 14230 WD4A180: STHX SPARKONLEFTCH C383 200A 14231 BRA WD4END180 C385 35B9 14232 WD4B180: STHX SPARKONLEFTDH C387 2006 14233 BRA WD4END180 C389 35B3 14234 WD4C180: STHX SPARKONLEFTAH C38B 2002 14235 BRA WD4END180 C38D 35B5 14236 WD4D180: STHX SPARKONLEFTBH 14237 WD4END180: 14238 WD4SKIP180: C38F C6E3AD 14239 LDA SPARKCONFIG1_F C392 A510 14240 BIT #M_SC1ODDFIRE C394 2626 14241 BNE WD4END270 C396 B6EC 14242 LDA DWELLDELAY3 C398 2606 14243 BNE WD4OK270 C39A B6ED 14244 LDA DWELLDELAY3+1 C39C A102 14245 CMP #2 C39E 251C 14246 BLO WD4END270 14247 WD4OK270: C3A0 55EC 14248 LDHX DWELLDELAY3 C3A2 006809 14249 BRSET COILABIT,COILSEL,WD4A270 C3A5 02680A 14250 BRSET COILBBIT,COILSEL,WD4B270 C3A8 04680B 14251 BRSET COILCBIT,COILSEL,WD4C270 C3AB 06680C 14252 BRSET COILDBIT,COILSEL,WD4D270 C3AE 35B9 14253 WD4A270: STHX SPARKONLEFTDH C3B0 200A 14254 BRA WD4END270 C3B2 35B3 14255 WD4B270: STHX SPARKONLEFTAH C3B4 2006 14256 BRA WD4END270 C3B6 35B5 14257 WD4C270: STHX SPARKONLEFTBH C3B8 2002 14258 BRA WD4END270 C3BA 35B7 14259 WD4D270: STHX SPARKONLEFTCH 14260 WD4END270: C3BC CCC5DE 14261 JMP DD_END 14262 WDWELL5OP: C3BF 55F0 14263 LDHX DWELLDELAY5 C3C1 00680C 14264 BRSET COILABIT,COILSEL,WD5A360 C3C4 02680D 14265 BRSET COILBBIT,COILSEL,WD5B360 C3C7 04680E 14266 BRSET COILCBIT,COILSEL,WD5C360 C3CA 06680F 14267 BRSET COILDBIT,COILSEL,WD5D360 C3CD 066810 14268 BRSET COILDBIT,COILSEL,WD5E360 C3D0 35B3 14269 WD5A360: STHX SPARKONLEFTAH C3D2 200E 14270 BRA WD5END360 C3D4 35B5 14271 WD5B360: STHX SPARKONLEFTBH C3D6 200A 14272 BRA WD5END360 C3D8 35B7 14273 WD5C360: STHX SPARKONLEFTCH C3DA 2006 14274 BRA WD5END360 C3DC 35B9 14275 WD5D360: STHX SPARKONLEFTDH C3DE 2002 14276 BRA WD5END360 C3E0 35BB 14277 WD5E360: STHX SPARKONLEFTEH 14278 WD5END360: C3E2 B6E8 14279 LDA DWELLDELAY1 C3E4 2606 14280 BNE WD5OK72 C3E6 B6E9 14281 LDA DWELLDELAY1+1 C3E8 A102 14282 CMP #2 C3EA 2523 14283 BLO WD5SKIP72 14284 WD5OK72: C3EC 55E8 14285 LDHX DWELLDELAY1 C3EE 00680C 14286 BRSET COILABIT,COILSEL,WD5A72 C3F1 02680D 14287 BRSET COILBBIT,COILSEL,WD5B72 C3F4 04680E 14288 BRSET COILCBIT,COILSEL,WD5C72 C3F7 06680F 14289 BRSET COILDBIT,COILSEL,WD5D72 C3FA 086810 14290 BRSET COILEBIT,COILSEL,WD5E72 C3FD 35B5 14291 WD5A72: STHX SPARKONLEFTBH C3FF 200E 14292 BRA WD5END72 C401 35B7 14293 WD5B72: STHX SPARKONLEFTCH C403 200A 14294 BRA WD5END72 C405 35B9 14295 WD5C72: STHX SPARKONLEFTDH C407 2006 14296 BRA WD5END72 C409 35BB 14297 WD5D72: STHX SPARKONLEFTEH C40B 2002 14298 BRA WD5END72 C40D 35B3 14299 WD5E72: STHX SPARKONLEFTAH 14300 WD5END72: 14301 WD5SKIP72: C40F B6EA 14302 LDA DWELLDELAY2 C411 2606 14303 BNE WD5OK144 C413 B6EB 14304 LDA DWELLDELAY2+1 C415 A102 14305 CMP #2 C417 2523 14306 BLO WD5SKIP144 14307 WD5OK144: C419 55EA 14308 LDHX DWELLDELAY2 C41B 00680C 14309 BRSET COILABIT,COILSEL,WD5A144 C41E 02680D 14310 BRSET COILBBIT,COILSEL,WD5B144 C421 04680E 14311 BRSET COILCBIT,COILSEL,WD5C144 C424 06680F 14312 BRSET COILDBIT,COILSEL,WD5D144 C427 086810 14313 BRSET COILEBIT,COILSEL,WD5E144 C42A 35B7 14314 WD5A144: STHX SPARKONLEFTCH msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 118 MC68HC908GP32 User Bootloader C42C 200E 14315 BRA WD5END144 C42E 35B9 14316 WD5B144: STHX SPARKONLEFTDH C430 200A 14317 BRA WD5END144 C432 35BB 14318 WD5C144: STHX SPARKONLEFTEH C434 2006 14319 BRA WD5END144 C436 35B3 14320 WD5D144: STHX SPARKONLEFTAH C438 2002 14321 BRA WD5END144 C43A 35B5 14322 WD5E144: STHX SPARKONLEFTBH 14323 WD5END144: 14324 WD5SKIP144: C43C B6EC 14325 LDA DWELLDELAY3 C43E 2606 14326 BNE WD5OK216 C440 B6ED 14327 LDA DWELLDELAY3+1 C442 A102 14328 CMP #2 C444 2523 14329 BLO WD5SKIP216 14330 WD5OK216: C446 55EC 14331 LDHX DWELLDELAY3 C448 00680C 14332 BRSET COILABIT,COILSEL,WD5A216 C44B 02680D 14333 BRSET COILBBIT,COILSEL,WD5B216 C44E 04680E 14334 BRSET COILCBIT,COILSEL,WD5C216 C451 06680F 14335 BRSET COILDBIT,COILSEL,WD5D216 C454 086810 14336 BRSET COILEBIT,COILSEL,WD5E216 C457 35B9 14337 WD5A216: STHX SPARKONLEFTDH C459 200E 14338 BRA WD5END216 C45B 35BB 14339 WD5B216: STHX SPARKONLEFTEH C45D 200A 14340 BRA WD5END216 C45F 35B3 14341 WD5C216: STHX SPARKONLEFTAH C461 2006 14342 BRA WD5END216 C463 35B5 14343 WD5D216: STHX SPARKONLEFTBH C465 2002 14344 BRA WD5END216 C467 35B7 14345 WD5E216: STHX SPARKONLEFTCH 14346 WD5END216: 14347 WD5SKIP216: C469 B6EE 14348 LDA DWELLDELAY4 C46B 2606 14349 BNE WD5OK288 C46D B6EF 14350 LDA DWELLDELAY4+1 C46F A102 14351 CMP #2 C471 2523 14352 BLO WD5SKIP288 14353 WD5OK288: C473 55EE 14354 LDHX DWELLDELAY4 C475 00680C 14355 BRSET COILABIT,COILSEL,WD5A288 C478 02680D 14356 BRSET COILBBIT,COILSEL,WD5B288 C47B 04680E 14357 BRSET COILCBIT,COILSEL,WD5C288 C47E 06680F 14358 BRSET COILDBIT,COILSEL,WD5D288 C481 086810 14359 BRSET COILEBIT,COILSEL,WD5E288 C484 35BB 14360 WD5A288: STHX SPARKONLEFTEH C486 200E 14361 BRA WD5END288 C488 35B3 14362 WD5B288: STHX SPARKONLEFTAH C48A 200A 14363 BRA WD5END288 C48C 35B5 14364 WD5C288: STHX SPARKONLEFTBH C48E 2006 14365 BRA WD5END288 C490 35B7 14366 WD5D288: STHX SPARKONLEFTCH C492 2002 14367 BRA WD5END288 C494 35B9 14368 WD5E288: STHX SPARKONLEFTDH 14369 WD5END288: 14370 WD5SKIP288: C496 CCC5DE 14371 JMP DD_END 14372 WDWELL6OP: C499 55F2 14373 LDHX DWELLDELAY6 C49B 00680F 14374 BRSET COILABIT,COILSEL,WD6A360 C49E 026810 14375 BRSET COILBBIT,COILSEL,WD6B360 C4A1 046811 14376 BRSET COILCBIT,COILSEL,WD6C360 C4A4 066812 14377 BRSET COILDBIT,COILSEL,WD6D360 C4A7 086813 14378 BRSET COILEBIT,COILSEL,WD6E360 C4AA 0A6814 14379 BRSET COILFBIT,COILSEL,WD6F360 C4AD 35B3 14380 WD6A360: STHX SPARKONLEFTAH C4AF 2012 14381 BRA WD6END360 C4B1 35B5 14382 WD6B360: STHX SPARKONLEFTBH C4B3 200E 14383 BRA WD6END360 C4B5 35B7 14384 WD6C360: STHX SPARKONLEFTCH C4B7 200A 14385 BRA WD6END360 C4B9 35B9 14386 WD6D360: STHX SPARKONLEFTDH C4BB 2006 14387 BRA WD6END360 C4BD 35BB 14388 WD6E360: STHX SPARKONLEFTEH C4BF 2002 14389 BRA WD6END360 C4C1 35BD 14390 WD6F360: STHX SPARKONLEFTFH 14391 WD6END360: C4C3 C6E3AD 14392 LDA SPARKCONFIG1_F C4C6 A510 14393 BIT #M_SC1ODDFIRE C4C8 2634 14394 BNE WD6SKIP60 C4CA B6E8 14395 LDA DWELLDELAY1 C4CC 2606 14396 BNE WD6OK60 C4CE B6E9 14397 LDA DWELLDELAY1+1 C4D0 A105 14398 CMP #5 C4D2 252A 14399 BLO WD6SKIP60 14400 WD6OK60: C4D4 55E8 14401 LDHX DWELLDELAY1 C4D6 00680F 14402 BRSET COILABIT,COILSEL,WD6A60 C4D9 026810 14403 BRSET COILBBIT,COILSEL,WD6B60 C4DC 046811 14404 BRSET COILCBIT,COILSEL,WD6C60 C4DF 066812 14405 BRSET COILDBIT,COILSEL,WD6D60 C4E2 086813 14406 BRSET COILEBIT,COILSEL,WD6E60 C4E5 0A6814 14407 BRSET COILFBIT,COILSEL,WD6F60 C4E8 35B5 14408 WD6A60: STHX SPARKONLEFTBH C4EA 2012 14409 BRA WD6END60 C4EC 35B7 14410 WD6B60: STHX SPARKONLEFTCH C4EE 200E 14411 BRA WD6END60 C4F0 35B9 14412 WD6C60: STHX SPARKONLEFTDH C4F2 200A 14413 BRA WD6END60 C4F4 35BB 14414 WD6D60: STHX SPARKONLEFTEH C4F6 2006 14415 BRA WD6END60 C4F8 35BD 14416 WD6E60: STHX SPARKONLEFTFH C4FA 2002 14417 BRA WD6END60 C4FC 35B3 14418 WD6F60: STHX SPARKONLEFTAH 14419 WD6END60: 14420 WD6SKIP60: C4FE B6EA 14421 LDA DWELLDELAY2 C500 2606 14422 BNE WD6OK120 C502 B6EB 14423 LDA DWELLDELAY2+1 C504 A105 14424 CMP #5 C506 252A 14425 BLO WD6SKIP120 14426 WD6OK120: C508 55EA 14427 LDHX DWELLDELAY2 C50A 00680F 14428 BRSET COILABIT,COILSEL,WD6A120 C50D 026810 14429 BRSET COILBBIT,COILSEL,WD6B120 C510 046811 14430 BRSET COILCBIT,COILSEL,WD6C120 C513 066812 14431 BRSET COILDBIT,COILSEL,WD6D120 C516 086813 14432 BRSET COILEBIT,COILSEL,WD6E120 C519 0A6814 14433 BRSET COILFBIT,COILSEL,WD6F120 C51C 35B7 14434 WD6A120: STHX SPARKONLEFTCH C51E 2012 14435 BRA WD6END120 C520 35B9 14436 WD6B120: STHX SPARKONLEFTDH C522 200E 14437 BRA WD6END120 C524 35BB 14438 WD6C120: STHX SPARKONLEFTEH C526 200A 14439 BRA WD6END120 C528 35BD 14440 WD6D120: STHX SPARKONLEFTFH C52A 2006 14441 BRA WD6END120 C52C 35B3 14442 WD6E120: STHX SPARKONLEFTAH C52E 2002 14443 BRA WD6END120 C530 35B5 14444 WD6F120: STHX SPARKONLEFTBH 14445 WD6END120: 14446 WD6SKIP120: C532 C6E3AD 14447 LDA SPARKCONFIG1_F C535 A510 14448 BIT #M_SC1ODDFIRE C537 2636 14449 BNE WD6SKIP180 C539 B6EC 14450 LDA DWELLDELAY3 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 119 MC68HC908GP32 User Bootloader C53B 2606 14451 BNE WD6OK180 C53D B6ED 14452 LDA DWELLDELAY3+1 C53F A105 14453 CMP #5 C541 252C 14454 BLO WD6SKIP180 14455 WD6OK180: C543 55EC 14456 LDHX DWELLDELAY3 C545 00680F 14457 BRSET COILABIT,COILSEL,WD6A180 C548 026810 14458 BRSET COILBBIT,COILSEL,WD6B180 C54B 046811 14459 BRSET COILCBIT,COILSEL,WD6C180 C54E 066812 14460 BRSET COILDBIT,COILSEL,WD6D180 C551 086813 14461 BRSET COILEBIT,COILSEL,WD6E180 C554 0A6814 14462 BRSET COILFBIT,COILSEL,WD6F180 C557 35B9 14463 WD6A180: STHX SPARKONLEFTDH C559 2012 14464 BRA WD6END180 C55B 35BB 14465 WD6B180: STHX SPARKONLEFTEH C55D 200E 14466 BRA WD6END180 C55F 35BD 14467 WD6C180: STHX SPARKONLEFTFH C561 200A 14468 BRA WD6END180 C563 35B3 14469 WD6D180: STHX SPARKONLEFTAH C565 2006 14470 BRA WD6END180 C567 35B5 14471 WD6E180: STHX SPARKONLEFTBH C569 2002 14472 BRA WD6END180 C56B 35B7 14473 WD6F180: STHX SPARKONLEFTCH 14474 WD6END180: C56D 206F 14475 BRA DD_END 14476 WD6SKIP180: C56F B6EE 14477 LDA DWELLDELAY4 C571 2606 14478 BNE WD6OK240 C573 B6EF 14479 LDA DWELLDELAY4+1 C575 A105 14480 CMP #5 C577 252A 14481 BLO WD6SKIP240 14482 WD6OK240: C579 55EE 14483 LDHX DWELLDELAY4 C57B 00680F 14484 BRSET COILABIT,COILSEL,WD6A240 C57E 026810 14485 BRSET COILBBIT,COILSEL,WD6B240 C581 046811 14486 BRSET COILCBIT,COILSEL,WD6C240 C584 066812 14487 BRSET COILDBIT,COILSEL,WD6D240 C587 086813 14488 BRSET COILEBIT,COILSEL,WD6E240 C58A 0A6814 14489 BRSET COILFBIT,COILSEL,WD6F240 C58D 35BB 14490 WD6A240: STHX SPARKONLEFTEH C58F 2012 14491 BRA WD6END240 C591 35BD 14492 WD6B240: STHX SPARKONLEFTFH C593 200E 14493 BRA WD6END240 C595 35B3 14494 WD6C240: STHX SPARKONLEFTAH C597 200A 14495 BRA WD6END240 C599 35B5 14496 WD6D240: STHX SPARKONLEFTBH C59B 2006 14497 BRA WD6END240 C59D 35B7 14498 WD6E240: STHX SPARKONLEFTCH C59F 2002 14499 BRA WD6END240 C5A1 35B9 14500 WD6F240: STHX SPARKONLEFTDH 14501 WD6END240: 14502 WD6SKIP240: C5A3 C6E3AD 14503 LDA SPARKCONFIG1_F C5A6 A510 14504 BIT #M_SC1ODDFIRE C5A8 2634 14505 BNE WD6SKIP300 C5AA B6F0 14506 LDA DWELLDELAY5 C5AC 2606 14507 BNE WD6OK300 C5AE B6F1 14508 LDA DWELLDELAY5+1 C5B0 A105 14509 CMP #5 C5B2 252A 14510 BLO WD6SKIP300 14511 WD6OK300: C5B4 55F0 14512 LDHX DWELLDELAY5 C5B6 00680F 14513 BRSET COILABIT,COILSEL,WD6A300 C5B9 026810 14514 BRSET COILBBIT,COILSEL,WD6B300 C5BC 046811 14515 BRSET COILCBIT,COILSEL,WD6C300 C5BF 066812 14516 BRSET COILDBIT,COILSEL,WD6D300 C5C2 086813 14517 BRSET COILEBIT,COILSEL,WD6E300 C5C5 0A6814 14518 BRSET COILFBIT,COILSEL,WD6F300 C5C8 35BB 14519 WD6A300: STHX SPARKONLEFTEH C5CA 2012 14520 BRA WD6END300 C5CC 35BD 14521 WD6B300: STHX SPARKONLEFTFH C5CE 200E 14522 BRA WD6END300 C5D0 35B3 14523 WD6C300: STHX SPARKONLEFTAH C5D2 200A 14524 BRA WD6END300 C5D4 35B5 14525 WD6D300: STHX SPARKONLEFTBH C5D6 2006 14526 BRA WD6END300 C5D8 35B7 14527 WD6E300: STHX SPARKONLEFTCH C5DA 2002 14528 BRA WD6END300 C5DC 35B9 14529 WD6F300: STHX SPARKONLEFTDH 14530 WD6END300: 14531 WD6SKIP300: 14532 DD_END: C5DE 8A 14533 pulh 14534 miss_chk_done: C5DF 034203 14535 brclr crank,engine,miss_chk_skip ; if not cranking then continue as normal C5E2 CCCA00 14536 jmp SKIP_CYCLE_CALC 14537 ***************************************************************************** 14538 14539 miss_chk_skip: C5E5 105F 14540 bset SparkTrigg,Sparkbits ; IRQ triggered, but no spark yet 14541 C5E7 3CD2 14542 inc idleCtlClock ; Idle PWM Clock counter 14543 C5E9 B684 14544 lda igncount1 C5EB 261D 14545 bne EGOBUMP ; Only increment counters if 14546 ; cylinder count is zero C5ED C6E5B3 14547 lda feature10_f5 C5F0 A501 14548 bit #ASEIgnCountb C5F2 2602 14549 bne TPS_COUNTER C5F4 3C83 14550 inc asecount ; Increment after-start enrichment 14551 ; counter 14552 14553 TPS_COUNTER: C5F6 076311 14554 brclr taeIgnCount,feature1,EGOBUMP ; Are we in Cycle counter 14555 ; mode for TPS Accel? C5F9 3C81 14556 inc tpsaclk ; Yes so increment counter 14557 14558 ; Save current TPS reading in last_tps variable to compute TPSDOT in 14559 ; acceleration enrichment section or KPa in KPa last if in MAP dot 14560 C5FB C6E042 14561 lda feature4_f C5FE A580 14562 bit #KpaDotSetb C600 2704 14563 beq tps_dot_on 14564 ; brclr KpaDotSet,feature4,tps_dot_on ; If not in KPA dot mode 14565 ; jump past KPa settings C602 B6CB 14566 lda kpa C604 2002 14567 bra Kpa_Dot_on 14568 tps_dot_on: C606 B647 14569 lda tps 14570 Kpa_Dot_on: C608 B7D1 14571 sta TPSlast 14572 14573 EGOBUMP: C60A B64D 14574 lda rpm 14575 ; sta old_rpm1 ; Used in odd-fire code - save the last computed RPM for average 14576 C60C 036302 14577 brclr egoIgnCount,feature1,No_Ego_Cnt C60F 3C82 14578 inc egocount ; Increment EGO step counter 14579 No_Ego_Cnt: C611 004203 14580 brset running,engine,CYCLE_CALC ; should always be running 14581 ; if we get here C614 CCCA00 14582 jmp SKIP_CYCLE_CALC 14583 CYCLE_CALC: 14584 14585 ; revised section new in 015d 14586 ; hi-res timer is only 16bit and runs at 1MHz. 1 tick = 1us msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 120 MC68HC908GP32 User Bootloader 14587 ; so timer rollover occurs at about 65.5ms. Hence if period > 65.5ms 14588 ; we have to use the lo-res spark calculation i.e. use the 0.1ms 14589 ; routine instead of the hi-res output compare method in "SPARKTIME" 14590 ; 70ms equates to rpmh = $2, rpml = $BC. Choose set point as $200 as 14591 ; simpler. 65ms is $28F 14592 ; 14593 14594 ;022b 0 T2 is now 24 bit with the extra software byte but may slow this routine 14595 ;excessively if we do 24bit maths here in an interrupt handler. 14596 ;Stick with Magnus' 0.1ms method for now as it works. 14597 C617 096103 14598 brclr EDIS,personality,non_edis C61A CCC6A4 14599 jmp edis_speed 14600 non_edis: 14601 ;are we doing oddfire wheel ? C61D C6E3AD 14602 lda SparkConfig1_f C620 A510 14603 bit #M_SC1oddfire C622 2768 14604 beq CCnot_odd C624 006811 14605 brset coilabit,coilsel,CCofa C627 02681C 14606 brset coilbbit,coilsel,CCofb C62A 046827 14607 brset coilcbit,coilsel,CCofc C62D 066832 14608 brset coildbit,coilsel,CCofd C630 06683D 14609 brset coildbit,coilsel,CCofe C633 066848 14610 brset coildbit,coilsel,CCoff C636 2054 14611 bra CCnot_odd 14612 CCofa: C638 C6E6A6 14613 lda outaoffs_f C63B C7020B 14614 sta offsetstep C63E C6E6A7 14615 lda outaoffv_f C641 C7020C 14616 sta offsetang C644 204E 14617 bra CC_cont 14618 14619 CCofb: C646 C6E6A8 14620 lda outboffs_f C649 C7020B 14621 sta offsetstep C64C C6E6A9 14622 lda outboffv_f C64F C7020C 14623 sta offsetang C652 2040 14624 bra CC_cont 14625 14626 CCofc: C654 C6E6AA 14627 lda outcoffs_f C657 C7020B 14628 sta offsetstep C65A C6E6AB 14629 lda outcoffv_f C65D C7020C 14630 sta offsetang C660 2032 14631 bra CC_cont 14632 14633 CCofd: C662 C6E6AC 14634 lda outdoffs_f C665 C7020B 14635 sta offsetstep C668 C6E6AD 14636 lda outdoffv_f C66B C7020C 14637 sta offsetang C66E 2024 14638 bra CC_cont 14639 14640 CCofe: C670 C6E6AE 14641 lda outeoffs_f C673 C7020B 14642 sta offsetstep C676 C6E6AF 14643 lda outeoffv_f C679 C7020C 14644 sta offsetang C67C 2016 14645 bra CC_cont 14646 14647 CCoff: C67E C6E6B0 14648 lda outfoffs_f C681 C7020B 14649 sta offsetstep C684 C6E6B1 14650 lda outfoffv_f C687 C7020C 14651 sta offsetang C68A 2008 14652 bra CC_cont 14653 14654 CCnot_odd: C68C A600 14655 lda #0 C68E C7020C 14656 sta offsetang C691 C7020B 14657 sta offsetstep 14658 CC_cont: C694 B672 14659 lda rpmch C696 A101 14660 cmp #$1 C698 222B 14661 bhi LOW_SPEED ; rpmc > $200 slow C69A 2558 14662 blo HIGH_SPEED ; < $100 fast C69C B673 14663 lda rpmcl C69E A180 14664 cmp #$80 C6A0 2552 14665 blo HIGH_SPEED ; < $180 fast C6A2 2048 14666 bra ASIS_SPEED ; in between leave as it was 14667 14668 edis_speed: C6A4 3F68 14669 clr coilsel C6A6 1068 14670 bset coilabit,coilsel 14671 ;If trigg angle zero used fixed delay C6A8 C6E3A8 14672 lda TriggAngle_f C6AB C70107 14673 sta DelayAngle C6AE 2644 14674 bne VARIABLE_DELAY C6B0 A640 14675 lda #$40 ; 10us delay. Try 64us C6B2 B7B2 14676 sta SparkDelayL C6B4 A600 14677 lda #$00 C6B6 B7B1 14678 sta SparkDelayH C6B8 125F 14679 bset SparkHSpeed,SparkBits ; Turn on high speed ignition C6BA 155F 14680 bclr SparkLSpeed,SparkBits ; Turn off low speed ignition C6BC 4EB0C0 14681 mov iTimeL,cTimeL ; Prepare to calculate with C6BF 4EAFBF 14682 mov iTimeH,cTimeH ; highres time C6C2 CCC928 14683 jmp set_spk_timer 14684 14685 LOW_SPEED: C6C5 135F 14686 bclr SparkHSpeed,SparkBits ; Turn off high speed ignition C6C7 145F 14687 bset SparkLSpeed,SparkBits ; Turn on low speed ignition C6C9 0D611E 14688 brclr TFI,personality,LOW_cont 14689 ;TFI mode - set the output now (follow IRQ at low speed) C6CC 1660 14690 bset sparkon,revlimbits ; spark now on C6CE 115F 14691 bclr sparktrigg,sparkbits ; don't want another one 14692 C6D0 0C690B 14693 brset invspk,EnhancedBits4,InvLSparkOn2 14694 ;; Don't support coils b,c,d in TFI 14695 14696 NInvLSparkOn2: C6D3 006204 14697 brset REUSE_FIDLE,outputpins,dslsf2 C6D6 1002 14698 bset coila,portc ; Set spark on C6D8 200D 14699 bra tfi_cont 14700 dslsf2: C6DA 1200 14701 bset iasc,porta C6DC 2009 14702 bra tfi_cont 14703 InvLSparkOn2: C6DE 006204 14704 brset REUSE_FIDLE,outputpins,ilsof2 C6E1 1102 14705 bclr coila,portc ; Set inverted spark on C6E3 2002 14706 bra tfi_cont 14707 ilsof2: C6E5 1300 14708 bclr iasc,porta 14709 tfi_cont: C6E7 CCCA00 14710 jmp SKIP_CYCLE_CALC 14711 14712 LOW_cont: 14713 C6EA 200C 14714 bra DELAY_CALC 14715 14716 ASIS_SPEED: 14717 ;need to check for low speed+TFI or we'll miss the output C6EC 0D6109 14718 brclr TFI,personality,DELAY_CALC C6EF 055F06 14719 brclr SparkLSpeed,SparkBits,DELAY_CALC C6F2 20D1 14720 bra LOW_SPEED 14721 14722 VARIABLE_DELAY: msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 121 MC68HC908GP32 User Bootloader 14723 14724 HIGH_SPEED: 14725 ; brclr TFI,personality,HIGH_cont 14726 ; lda rpm 14727 ; cmp #6 ; if < 600rpm and TFI then low speed 14728 ; blo LOW_SPEED 14729 HIGH_cont: 14730 ;hei7 bypass now in main loop C6F4 125F 14731 bset SparkHSpeed,SparkBits ; Turn on high speed ignition C6F6 155F 14732 bclr SparkLSpeed,SparkBits ; Turn off low speed ignition 14733 14734 DELAY_CALC: C6F8 C6E1B6 14735 lda config11_f1 ; Get engine config C6FB 62 14736 nsa C6FC A40F 14737 and #$0f ; Mask out cylinders (was $07) C6FE 4C 14738 inca ; Prepare loop counter C6FF 97 14739 tax ; stick in into X for safe keeping 14740 14741 ; accel/decel correction.. 14742 ; If engine is accelerating or decelerating predict our expected next 14743 ; cycle time for more accurate spark control. Tom Hafner reported a big 14744 ; improvement with a similar method in his MegaSpark. 14745 ; Calc is as follows: predicted ctime = ctime + (ctime - ctime prev) = 14746 ; 2x ctime - ctimep 14747 C700 045F20 14748 brset SparkLSpeed,SparkBits,dc_low C703 4EB0C0 14749 mov iTimeL,cTimeL ; Prepare to calculate with 14750 ; highres time C706 4EAFBF 14751 mov iTimeH,cTimeH 14752 14753 ;do high speed accel/decel correction C709 B6FE 14754 lda iTimepH C70B 2604 14755 bne hispdcorr C70D B6FF 14756 lda iTimepL C70F 2730 14757 beq ReCalcDelay ; if previous is zero then skip routine 14758 hispdcorr: 14759 ; clr SparkCarry C711 38C0 14760 lsl cTimeL C713 39BF 14761 rol cTimeH 14762 ; rol SparkCarry ; redundant. If it overflows we'll 14763 ; only subtract it in a sec C715 B6C0 14764 lda cTimeL C717 B0FF 14765 sub iTimepL C719 B7C0 14766 sta cTimeL C71B B6BF 14767 lda cTimeH C71D B2FE 14768 sbc iTimepH C71F B7BF 14769 sta cTimeH 14770 C721 201E 14771 bra ReCalcDelay 14772 dc_low: C723 4E73C0 14773 mov rpmcl,cTimeL ; Prepare to calculate with lowres time C726 4E72BF 14774 mov rpmch,cTimeH 14775 ;do low speed accel/decel correction C729 B670 14776 lda rpmph C72B 2604 14777 bne lospdcorr C72D B671 14778 lda rpmpl C72F 2710 14779 beq ReCalcDelay ; if previous is zero then skip routine 14780 lospdcorr: 14781 ; clr SparkCarry C731 38C0 14782 lsl cTimeL C733 39BF 14783 rol cTimeH 14784 ; rol SparkCarry ; redundant. If it overflows we'll 14785 ; only subtract it in a sec C735 B6C0 14786 lda cTimeL C737 B071 14787 sub rpmpl C739 B7C0 14788 sta cTimeL C73B B6BF 14789 lda cTimeH C73D B270 14790 sbc rpmph C73F B7BF 14791 sta cTimeH 14792 14793 ReCalcDelay: C741 4EC0C2 14794 mov cTimeL,SparkTempL C744 4EBFC1 14795 mov cTimeH,SparkTempH C747 3FC3 14796 clr SparkCarry 14797 ;take a copy - used later by next-cyl calcs C749 B6C0 14798 lda cTimeL C74B C70201 14799 sta ctimeLcp C74E B6BF 14800 lda cTimeH C750 C70200 14801 sta ctimeHcp 14802 C753 9F 14803 txa C754 A104 14804 cmp #4 C756 221F 14805 bhi more4cyl ; more than 4cyl C758 410352 14806 cbeqa #3T,cyl3 ; 3cyl does 2/4 stroke internally 14807 C75B 97 14808 tax ;1,2,4 are so simple do them here C75C C6E1B6 14809 lda config11_f1 C75F A504 14810 bit #M_TwoStroke C761 270A 14811 beq lt4_4s ; eq 0 so branch 4 stroke 14812 ; 2 stroke for 1,2,4 C763 9F 14813 txa C764 41013D 14814 cbeqa #1T,jsmd4 C767 41023D 14815 cbeqa #2T,jsmd2 C76A 41043D 14816 cbeqa #4T,jsmt 14817 ; 4 stroke for 1,2,4 14818 lt4_4s: C76D 9F 14819 txa C76E 410130 14820 cbeqa #1T,jsmd8 C771 410230 14821 cbeqa #2T,jsmd4 C774 410430 14822 cbeqa #4T,jsmd2 14823 14824 more4cyl: C777 97 14825 tax C778 C6E1B6 14826 lda config11_f1 C77B A504 14827 bit #M_TwoStroke C77D 2613 14828 bne cyl_invalid ; don't support 2 stroke >4 cyl C77F 9F 14829 txa C780 410549 14830 cbeqa #5T,cyl5 ; quick calc routines for speed C783 410664 14831 cbeqa #6T,cyl6 C786 41080C 14832 cbeqa #8T,cyl8a C789 410A0C 14833 cbeqa #10T,cyl10a C78C 410C0C 14834 cbeqa #12T,cyl12a C78F 41100C 14835 cbeqa #16T,cyl16a 14836 cyl_invalid: C792 CCCA00 14837 jmp SKIP_CYCLE_CALC ; if 7,9,11,13,14,15 don't do timing 14838 C795 CCC80A 14839 cyl8a: jmp cyl8 C798 CCC812 14840 cyl10a: jmp cyl10 C79B CCC838 14841 cyl12a: jmp cyl12 C79E CCC858 14842 cyl16a: jmp cyl16 14843 14844 ;********** 14845 ;some jumps C7A1 CCC864 14846 jsmd8: jmp spk_mult_div8 C7A4 CCC86A 14847 jsmd4: jmp spk_mult_div4 C7A7 CCC870 14848 jsmd2: jmp spk_mult_div2 C7AA CCC876 14849 jsmt: jmp spk_mult 14850 14851 ;** special faster routines to calculate the delay. ** 14852 ;********** 14853 cyl3: ; *3 / 8 C7AD 38C2 14854 lsl sparkTempL ; *2 C7AF 39C1 14855 rol sparkTempH C7B1 39C3 14856 rol SparkCarry 14857 C7B3 B6C2 14858 lda SparkTempL ; +1 more msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 122 MC68HC908GP32 User Bootloader C7B5 BBC0 14859 add cTimeL C7B7 B7C2 14860 sta SparkTempL C7B9 B6C1 14861 lda SparkTempH C7BB B9BF 14862 adc cTimeH C7BD B7C1 14863 sta SparkTempH C7BF 2402 14864 bcc cyl3nc C7C1 3CC3 14865 inc SparkCarry 14866 cyl3nc: C7C3 C6E1B6 14867 lda config11_f1 C7C6 A504 14868 bit #M_TwoStroke C7C8 263A 14869 bne bsmd4 ; if 2 stroke div4. 4 stroke div8 C7CA 2036 14870 bra bsmd8 14871 14872 ;********** 14873 cyl5: ; *5 /8 14874 C7CC 38C2 14875 lsl SparkTempL ; *2 C7CE 39C1 14876 rol SparkTempH C7D0 39C3 14877 rol SparkCarry 14878 C7D2 38C2 14879 lsl SparkTempL ; *2 C7D4 39C1 14880 rol SparkTempH C7D6 39C3 14881 rol SparkCarry 14882 C7D8 B6C2 14883 lda SparkTempL ; +1 more C7DA BBC0 14884 add cTimeL C7DC B7C2 14885 sta SparkTempL C7DE B6C1 14886 lda SparkTempH C7E0 B9BF 14887 adc cTimeH C7E2 B7C1 14888 sta SparkTempH C7E4 247E 14889 bcc spk_mult_div8 C7E6 3CC3 14890 inc SparkCarry C7E8 207A 14891 bra spk_mult_div8 14892 14893 ;********** 14894 cyl6: ; *3 / 4 C7EA 38C2 14895 lsl sparkTempL ; *2 C7EC 39C1 14896 rol sparkTempH C7EE 39C3 14897 rol SparkCarry 14898 C7F0 B6C2 14899 lda SparkTempL ; +1 more C7F2 BBC0 14900 add cTimeL C7F4 B7C2 14901 sta SparkTempL C7F6 B6C1 14902 lda SparkTempH C7F8 B9BF 14903 adc cTimeH C7FA B7C1 14904 sta SparkTempH C7FC 246C 14905 bcc spk_mult_div4 C7FE 3CC3 14906 inc SparkCarry C800 2068 14907 bra spk_mult_div4 14908 14909 ;********** 14910 ;some relative jumps C802 2060 14911 bsmd8: bra spk_mult_div8 C804 2064 14912 bsmd4: bra spk_mult_div4 C806 2068 14913 bsmd2: bra spk_mult_div2 C808 206C 14914 bsm: bra spk_mult 14915 ;********** 14916 cyl8: ; no change, period - 90 deg already C80A 4EC0C2 14917 mov cTimeL,SparkTempL C80D 4EBFC1 14918 mov cTimeH,SparkTempH C810 2064 14919 bra spk_mult 14920 14921 cyl10: ; *5 /4 C812 4EC0C2 14922 mov cTimeL,SparkTempL C815 4EBFC1 14923 mov cTimeH,SparkTempH C818 3FC3 14924 clr SparkCarry 14925 C81A 38C2 14926 lsl SparkTempL ; *2 C81C 39C1 14927 rol SparkTempH C81E 39C3 14928 rol SparkCarry 14929 C820 38C2 14930 lsl SparkTempL ; *2 C822 39C1 14931 rol SparkTempH C824 39C3 14932 rol SparkCarry 14933 C826 B6C2 14934 lda SparkTempL ; +1 more C828 BBC0 14935 add cTimeL C82A B7C2 14936 sta SparkTempL C82C B6C1 14937 lda SparkTempH C82E B9BF 14938 adc cTimeH C830 B7C1 14939 sta SparkTempH C832 2436 14940 bcc spk_mult_div4 C834 3CC3 14941 inc SparkCarry C836 2032 14942 bra spk_mult_div4 14943 14944 ;********** 14945 cyl12: C838 4EC0C2 14946 mov cTimeL,SparkTempL C83B 4EBFC1 14947 mov cTimeH,SparkTempH C83E 3FC3 14948 clr SparkCarry 14949 C840 38C2 14950 lsl sparkTempL ; *2 C842 39C1 14951 rol sparkTempH C844 39C3 14952 rol SparkCarry 14953 C846 B6C2 14954 lda SparkTempL ; +1 more C848 BBC0 14955 add cTimeL C84A B7C2 14956 sta SparkTempL C84C B6C1 14957 lda SparkTempH C84E B9BF 14958 adc cTimeH C850 B7C1 14959 sta SparkTempH C852 241C 14960 bcc spk_mult_div2 C854 3CC3 14961 inc SparkCarry C856 2018 14962 bra spk_mult_div2 14963 ;********** 14964 cyl16: ; x2 to get 90 deg period (we will lose a bit below 150 rpm) C858 4EC0C2 14965 mov cTimeL,SparkTempL C85B 4EBFC1 14966 mov cTimeH,SparkTempH C85E 38C2 14967 lsl sparkTempL C860 39C1 14968 rol sparkTempH C862 2012 14969 bra spk_mult 14970 14971 ;********** 14972 spk_mult_div8: C864 34C3 14973 lsr SparkCarry ; /2 C866 36C1 14974 ror SparkTempH C868 36C2 14975 ror SparkTempL 14976 14977 spk_mult_div4: C86A 34C3 14978 lsr SparkCarry ; /2 C86C 36C1 14979 ror SparkTempH C86E 36C2 14980 ror SparkTempL 14981 14982 spk_mult_div2: C870 34C3 14983 lsr SparkCarry ; /2 C872 36C1 14984 ror SparkTempH C874 36C2 14985 ror SparkTempL 14986 14987 spk_mult: 14988 ; Calculate time for delay angle 14989 ; Time for 90 deg * Angle (256=90 deg)/256 C876 C60107 14990 lda DelayAngle C879 CB020C 14991 add offsetang ; for oddfire, zero otherwise C87C BEC1 14992 ldx SparkTempH C87E 42 14993 mul C87F BFB1 14994 stx SparkDelayH msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 123 MC68HC908GP32 User Bootloader C881 B7C3 14995 sta SparkCarry C883 C60107 14996 lda DelayAngle C886 CB020C 14997 add offsetang ; for oddfire, zero otherwise C889 BEC2 14998 ldx SparkTempL C88B 42 14999 mul C88C 9F 15000 txa C88D BBC3 15001 add SparkCarry C88F B7B2 15002 sta SparkDelayL C891 2402 15003 bcc NoSparkCarry C893 3CB1 15004 inc SparkDelayH 15005 15006 NoSparkCarry: 15007 15008 ;check for oddfire offset C895 C6E3AD 15009 lda SparkConfig1_f C898 A510 15010 bit #M_SC1oddfire C89A 2718 15011 beq ck_xlong ; not oddfire, use normal method 15012 ;now add oddfire triggers C89C C6020B 15013 lda offsetstep C89F 2732 15014 beq ck_nextcyl ; if no offset step then skip 15015 C8A1 A502 15016 bit #outoff_45b C8A3 2609 15017 bne of45 ; add 45 deg 15018 C8A5 C6020B 15019 lda offsetstep C8A8 A504 15020 bit #outoff_90b C8AA 261B 15021 bne AddLongTrigg ; already contains 90 deg time, add it 15022 ;shouldn't get here C8AC 2025 15023 bra ck_nextcyl 15024 15025 of45: C8AE 34C1 15026 lsr SparkTempH C8B0 36C2 15027 ror SparkTempL C8B2 2013 15028 bra AddLongTrigg 15029 15030 ck_xlong: 15031 ; Check for long trigger (more than 90 deg) C8B4 C6E3AD 15032 lda SparkConfig1_f C8B7 A501 15033 bit #M_SC1LngTrg C8B9 2718 15034 beq ck_nextcyl 15035 15036 xl45: 15037 ; Divide 90 deg time by 2 to get 45 deg time (112.5 to 135 deg) C8BB 34C1 15038 lsr SparkTempH C8BD 36C2 15039 ror SparkTempL 15040 15041 ; Jump out if extra long trigger C8BF A502 15042 bit #M_SC1XLngTrg C8C1 2604 15043 bne AddLongTrigg 15044 15045 xl22: 15046 ; Divide 45 deg time by 2 to get 22.5 deg time (90 to 112.5 deg) C8C3 34C1 15047 lsr SparkTempH C8C5 36C2 15048 ror SparkTempL 15049 15050 AddLongTrigg: 15051 ; Add extra time for long trigger C8C7 B6B2 15052 lda SparkDelayL C8C9 BBC2 15053 add SparkTempL C8CB B7B2 15054 sta SparkDelayL C8CD B6B1 15055 lda SparkDelayH C8CF B9C1 15056 adc SparkTempH C8D1 B7B1 15057 sta SparkDelayH 15058 15059 ck_nextcyl: 15060 ;check for next cyl mode - only get here if NOT in long-trigger C8D3 0B690E 15061 brclr nextcyl,EnhancedBits4,SDelayDone 15062 15063 ;now actual delay = itime - "spark delay" 15064 ; so we calc the time for 7 deg and then take that time off the iTime 15065 ;cTime?cp was saved earlier as the predicted time for this period C8D6 C60201 15066 lda cTimeLcp C8D9 B0B2 15067 sub SparkDelayL C8DB B7B2 15068 sta SparkDelayL C8DD C60200 15069 lda cTimeHcp C8E0 B2B1 15070 sbc SparkDelayH C8E2 B7B1 15071 sta SparkDelayH 15072 15073 SDelayDone: 15074 C8E4 025F41 15075 brset SparkHSpeed,SparkBits,set_spk_timer ; High speed set timer C8E7 036527 15076 brclr dwellcont,feature7,j_SSC 15077 ;if next_cyl and cranking then skip C8EA 0B6903 15078 brclr nextcyl,EnhancedBits4,sdd2 C8ED 024221 15079 brset crank,engine,j_SSC ; can cause a conflict 15080 15081 sdd2: 15082 ; low speed dwell 15083 ; a copy of some of Calcdwell, but simplified... 15084 15085 ; uses SparkTempH/L for temporary space 15086 C8F0 B6B2 15087 lda SparkDelayL C8F2 B0F8 15088 sub dwelldms C8F4 B7C2 15089 sta SparkTempL C8F6 B6B1 15090 lda SparkDelayH C8F8 A200 15091 sbc #0 C8FA B7C1 15092 sta SparkTempH C8FC 2405 15093 bcc lsd_done 15094 ; < zero = OOOPS! set minimal period 15095 lsd_min: ; target dwell period>available period C8FE 8C 15096 clrh C8FF AE01 15097 ldx #1 ; turn on coil as soon as we can C901 2002 15098 bra lsd_done2 15099 lsd_done: C903 55C1 15100 ldhx SparkTempH 15101 lsd_done2: C905 00680C 15102 brset coilabit,coilsel,lsd_a C908 02680E 15103 brset coilbbit,coilsel,lsd_b C90B 046810 15104 brset coilcbit,coilsel,lsd_c C90E 066812 15105 brset coildbit,coilsel,lsd_d 15106 j_SSC: C911 CCCA00 15107 jmp SKIP_CYCLE_CALC C914 35B3 15108 lsd_a: sthx SparkOnLeftah ; Store time to keep output the same C916 CCCA00 15109 jmp SKIP_CYCLE_CALC C919 35B5 15110 lsd_b: sthx SparkOnLeftbh ; Store time to keep output the same C91B CCCA00 15111 jmp SKIP_CYCLE_CALC C91E 35B7 15112 lsd_c: sthx SparkOnLeftch ; Store time to keep output the same C920 CCCA00 15113 jmp SKIP_CYCLE_CALC C923 35B9 15114 lsd_d: sthx SparkOnLeftdh ; Store time to keep output the same C925 CCCA00 15115 jmp SKIP_CYCLE_CALC 15116 15117 set_spk_timer: C928 036566 15118 brclr dwellcont,feature7,do_set_spk 15119 ;if next_cyl and cranking then skip C92B 0B6903 15120 brclr nextcyl,EnhancedBits4,sst2 C92E 024260 15121 brset crank,engine,do_set_spk ; can cause a conflict 15122 sst2: 15123 ; now see if we've time for dwell before spark 15124 ; this will work when rpm/advance are low and dwell doesn't start 15125 ; before trigger this doesn't leave any margin... could be trying to start 15126 ; dwell too soon after now and due to latency we'll miss it? 15127 15128 ;026g add hysteresis to hrd mode to see if it helps my "1500rpm miss" 15129 ; if time < 0.512ms then OFF 15130 ; if time > 0.768ms then ON msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 124 MC68HC908GP32 User Bootloader 15131 ;in between follows last state 15132 C931 B6B2 15133 lda SparkDelayL C933 B0FA 15134 sub dwellusl C935 97 15135 tax C936 B6B1 15136 lda SparkDelayH C938 B2F9 15137 sbc dwellush C93A 2515 15138 bcs hrd_off ; if negative then OFF C93C A101 15139 cmp #1 C93E 2311 15140 bls hrd_off ; <= .511ms so OFF C940 A102 15141 cmp #2 C942 2202 15142 bhi hrd_on ; > 0.768ms so ON C944 200D 15143 bra hrd_ck ; in between so no change 15144 15145 hrd_on: 15146 ; for testing we can disable hi-res dwell altogether C946 C6E05C 15147 lda feature6_f C949 A504 15148 bit #hrd_disableb C94B 2604 15149 bne hrd_off ; disabled C94D 106B 15150 bset hrdwon,EnhancedBits6 C94F 2002 15151 bra hrd_ck 15152 hrd_off: C951 116B 15153 bclr hrdwon,EnhancedBits6 15154 hrd_ck: C953 016B3B 15155 brclr hrdwon,EnhancedBits6,do_set_spk ; hrd bit off, so skip 15156 15157 ; now want to work out the dwell delay. 15158 ;first work out the target time for the spark and store away 15159 dwl_ok: C956 B6B2 15160 lda SparkDelayL C958 CB0204 15161 add T2CurrL C95B B7FC 15162 sta SparkTargetL ; Store low byte in target area C95D B6B1 15163 lda SparkDelayH C95F C90203 15164 adc T2CurrH C962 B7FB 15165 sta SparkTargetH 15166 15167 ;now calc dwell start point into SparkDelay C964 B6B2 15168 lda SparkDelayL C966 B0FA 15169 sub dwellusl C968 B7B2 15170 sta SparkDelayL ; now dwell delay L C96A B6B1 15171 lda SparkDelayH C96C B2F9 15172 sbc dwellush C96E B7B1 15173 sta SparkDelayH ; H C970 1869 15174 bset indwell,EnhancedBits4 ; flag that we are doing dwell 15175 ; delay not spark delay 15176 15177 ; make sure lowres dwell timers are zero to prevent early less accurate dwell 15178 ; change... don't reset the timer. If the timer gets there first it 15179 ; should be ignored, but that doesn't FFFFING work???!?!? so zero out the 15180 ; timers here anyway 15181 ; C972 450000 15182 ldhx #0 C975 00680B 15183 brset coilabit,coilsel,zd_a C978 02680C 15184 brset coilbbit,coilsel,zd_b C97B 04680D 15185 brset coilcbit,coilsel,zd_c C97E 06680E 15186 brset coildbit,coilsel,zd_d C981 200E 15187 bra do_set_spk ; how? C983 35B3 15188 zd_a: sthx SparkOnLeftah ; Store time to keep output the same C985 200A 15189 bra do_set_spk C987 35B5 15190 zd_b: sthx SparkOnLeftbh ; Store time to keep output the same C989 2006 15191 bra do_set_spk C98B 35B7 15192 zd_c: sthx SparkOnLeftch ; Store time to keep output the same C98D 2002 15193 bra do_set_spk C98F 35B9 15194 zd_d: sthx SparkOnLeftdh ; Store time to keep output the same 15195 15196 do_set_spk: 15197 ;check not too soon - minimum delay of 64us C991 B6B1 15198 lda SparkDelayH C993 260A 15199 bne setit C995 B6B2 15200 lda SparkDelayL C997 A140 15201 cmp #$40 C999 2204 15202 bhi setit C99B A640 15203 lda #$40 C99D 2002 15204 bra setit2 15205 setit: 15206 ; Add total highres spark delay time to timer value from IRQ 15207 ; start and set interrupt C99F B6B2 15208 lda SparkDelayL 15209 setit2: C9A1 CB0204 15210 add T2CurrL C9A4 97 15211 tax ; Store low byte C9A5 B6B1 15212 lda SparkDelayH C9A7 C90203 15213 adc T2CurrH C9AA B734 15214 sta T2CH1H ; Write high byte timer output 15215 ; compare first C9AC BF35 15216 stx T2CH1L ; Then low byte 15217 C9AE 1F33 15218 bclr TOF,T2SC1 ; clear pending interrupt C9B0 1C33 15219 bset TOIE,T2SC1 ; Enable timer interrupt 15220 15221 ; rotary low revs ... 15222 C9B2 016A03 15223 brclr rotary2,EnhancedBits5,skip_rotary_jmp C9B5 086903 15224 brset indwell,EnhancedBits4,do_rotary_dwl 15225 skip_rotary_jmp: C9B8 CCCA00 15226 jmp SKIP_CYCLE_CALC 15227 15228 do_rotary_dwl: C9BB 096A42 15229 brclr rsh_s,EnhancedBits5,SKIP_CYCLE_CALC C9BE 0B6A3F 15230 brclr rsh_r,EnhancedBits5,SKIP_CYCLE_CALC 15231 15232 ; Add rotary split to the SparkDelay 15233 C9C1 B6B2 15234 lda SparkDelayL C9C3 CB0101 15235 add splitdelL C9C6 B7C2 15236 sta SparkTempL C9C8 B6B1 15237 lda SparkDelayH C9CA C90100 15238 adc splitdelH C9CD B7C1 15239 sta SparkTempH 15240 15241 ; Div by 100 to get 1/10th ms value 15242 C9CF 8B 15243 pshh C9D0 8C 15244 clrh C9D1 AE64 15245 ldx #100T C9D3 B6C1 15246 lda SparkTempH C9D5 52 15247 div C9D6 B7C1 15248 sta SparkTempH C9D8 B6C2 15249 lda SparkTempL C9DA 52 15250 div C9DB B7C2 15251 sta SparkTempL 15252 15253 ; now pick which coil gets the dwell, and store it there. 15254 C9DD 450000 15255 ldhx #0T C9E0 35B7 15256 sthx SparkOnLeftch C9E2 35B9 15257 sthx SparkOnLeftdh C9E4 55C1 15258 ldhx SparkTempH C9E6 086308 15259 brset rotaryFDign,feature1,set_FD_coils C9E9 00680D 15260 brset coilabit,coilsel,rotary_set_coilc C9EC 02680E 15261 brset coilbbit,coilsel,rotary_set_coild C9EF 200E 15262 bra end_rotary_dwell ; shouldn't get here 15263 15264 set_FD_coils: C9F1 006809 15265 brset coilabit,coilsel,rotary_set_coild C9F4 026802 15266 brset coilbbit,coilsel,rotary_set_coilc msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 125 MC68HC908GP32 User Bootloader C9F7 2006 15267 bra end_rotary_dwell ; shouldn't get here 15268 15269 rotary_set_coilc: C9F9 35B7 15270 sthx SparkOnLeftch C9FB 2002 15271 bra end_rotary_dwell 15272 15273 rotary_set_coild: C9FD 35B9 15274 sthx SparkOnLeftdh 15275 15276 end_rotary_dwell: C9FF 8A 15277 pulh 15278 15279 SKIP_CYCLE_CALC: 15280 ; are we logging triggers? CA00 076A38 15281 brclr triglog,EnhancedBits5,w_dec_notlogt 15282 ;we are logging so record something CA03 8B 15283 pshh CA04 8C 15284 clrh 15285 CA05 CE01D5 15286 ldx VE_r+198T CA08 025F0F 15287 brset SparkHSpeed,SparkBits,tl_high 15288 ;tl_low: CA0B A601 15289 lda #1 CA0D C701D6 15290 sta VE_r+199T CA10 B672 15291 lda rpmch CA12 D7010F 15292 sta VE_r,x CA15 5C 15293 incx CA16 B673 15294 lda rpmcl CA18 2014 15295 bra tl_cont 15296 tl_high: CA1A 4F 15297 clra CA1B C701D6 15298 sta VE_r+199T CA1E B6AF 15299 lda iTimeH CA20 2602 15300 bne tlhh CA22 A6FF 15301 lda #$FF 15302 tlhh: CA24 D7010F 15303 sta VE_r,x CA27 5C 15304 incx CA28 B6B0 15305 lda iTimeL CA2A 2602 15306 bne tl_cont CA2C A6FF 15307 lda #$FF 15308 tl_cont: CA2E D7010F 15309 sta VE_r,x CA31 5C 15310 incx CA32 A3C6 15311 cpx #198T CA34 2601 15312 bne wdtlt CA36 5F 15313 clrx 15314 wdtlt: CA37 CF01D5 15315 stx VE_r+198T CA3A 8A 15316 pulh 15317 w_dec_notlogt: 15318 CA3B C60202 15319 lda T2CurrX CA3E B7AB 15320 sta T2LastX ; Make current value last CA40 C60203 15321 lda T2CurrH CA43 B7AC 15322 sta T2LastH CA45 C60204 15323 lda T2CurrL CA48 B7AD 15324 sta T2LastL 15325 CA4A 4E7270 15326 mov rpmch,rpmph CA4D 4E7371 15327 mov rpmcl,rpmpl 15328 CA50 3F72 15329 clr rpmch CA52 3F73 15330 clr rpmcl CA54 1000 15331 bset fuelp,porta ; Turn on fuel Pump 15332 ;scc_run: CA56 1042 15333 bset running,engine ; Set engine running value CA58 036503 15334 brclr dwellcont,feature7,no_dwell 15335 ;figure out if we want to schedule dwell now 15336 ;; brclr crank,engine,bsc1 ; we don't 15337 ; if in crank mode then min_dwell does same thing CA5B CCCB24 15338 jmp squirtCheck1 15339 15340 no_dwell: CA5E 0B6452 15341 brclr min_dwell,feature2,bsc1 15342 ; if minimal dwell set coil to charge in 0.1ms 15343 ; this should help HEI4 pin until I've written dwell 15344 ; control as the high time starts at the trigger 15345 scc_hei4: CA61 1760 15346 bclr sparkon,revlimbits ; spark now off CA63 0C694F 15347 brset invspk,EnhancedBits4,sccr_inv CA66 macro 15348 COILPOS ; charge coil for non-inverted CA66 006248 15349 BRSET REUSE_FIDLE,OUTPUTPINS,ILSOX CA69 006A14 15350 BRSET ROTARY2,ENHANCEDBITS5,ROT2POS CA6C 00682A 15351 BRSET COILABIT,COILSEL,ILSOA CA6F 02682B 15352 BRSET COILBBIT,COILSEL,ILSOB CA72 04682C 15353 BRSET COILCBIT,COILSEL,ILSOC CA75 06682D 15354 BRSET COILDBIT,COILSEL,ILSOD CA78 08682E 15355 BRSET COILEBIT,COILSEL,ILSOE CA7B 0A682F 15356 BRSET COILFBIT,COILSEL,ILSOF CA7E 2033 15357 BRA FC_END 15358 ROT2POS: CA80 086310 15359 BRSET ROTARYFDIGN,FEATURE1,CHARGEFD CA83 046805 15360 BRSET COILCBIT,COILSEL,ROT2CP CA86 066806 15361 BRSET COILDBIT,COILSEL,ROT2DP CA89 200E 15362 BRA ILSOA 15363 ROT2CP: CA8B 1302 15364 BCLR COILB,PORTC CA8D 2024 15365 BRA FC_END 15366 ROT2DP: CA8F 1302 15367 BCLR COILB,PORTC CA91 2020 15368 BRA FC_END 15369 CHARGEFD: CA93 04680B 15370 BRSET COILCBIT,COILSEL,ILSOC CA96 066804 15371 BRSET COILDBIT,COILSEL,ILSOB 15372 ILSOA: CA99 1102 15373 BCLR COILA,PORTC CA9B 2016 15374 BRA FC_END 15375 ILSOB: CA9D 1302 15376 BCLR COILB,PORTC CA9F 2012 15377 BRA FC_END 15378 ILSOC: CAA1 1502 15379 BCLR WLED,PORTC CAA3 200E 15380 BRA FC_END 15381 ILSOD: CAA5 1103 15382 BCLR OUTPUT3,PORTD CAA7 200A 15383 BRA FC_END 15384 ILSOE: CAA9 1702 15385 BCLR PIN10,PORTC CAAB 2006 15386 BRA FC_END 15387 ILSOF: CAAD 1503 15388 BCLR KNOCKIN,PORTD CAAF 2002 15389 BRA FC_END 15390 ILSOX: CAB1 1300 15391 BCLR IASC,PORTA 15392 FC_END: 15393 bsc1: CAB3 206F 15394 bra squirtCheck1 15395 sccr_inv: CAB5 macro 15396 COILNEG ; charge coil for inverted CAB5 00626A 15397 BRSET REUSE_FIDLE,OUTPUTPINS,DSLSX CAB8 006A1E 15398 BRSET ROTARY2,ENHANCEDBITS5,ROT2NEG CABB 0F6232 15399 BRCLR TOY_DLI,OUTPUTPINS,NILS CABE 006806 15400 BRSET COILABIT,COILSEL,FCNITA CAC1 026809 15401 BRSET COILBBIT,COILSEL,FCNITB CAC4 04680C 15402 BRSET COILCBIT,COILSEL,FCNITC msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 126 MC68HC908GP32 User Bootloader 15403 FCNITA: CAC7 1302 15404 BCLR COILB,PORTC CAC9 1502 15405 BCLR WLED,PORTC CACB 203D 15406 BRA DSLSA 15407 FCNITB: CACD 1202 15408 BSET COILB,PORTC CACF 1502 15409 BCLR WLED,PORTC CAD1 2037 15410 BRA DSLSA 15411 FCNITC: CAD3 1302 15412 BCLR COILB,PORTC CAD5 1402 15413 BSET WLED,PORTC CAD7 2031 15414 BRA DSLSA 15415 ROT2NEG: CAD9 086328 15416 BRSET ROTARYFDIGN,FEATURE1,FIREFD CADC 046805 15417 BRSET COILCBIT,COILSEL,ROT2CN CADF 066808 15418 BRSET COILDBIT,COILSEL,ROT2DN CAE2 2026 15419 BRA DSLSA 15420 ROT2CN: CAE4 1502 15421 BCLR WLED,PORTC CAE6 1202 15422 BSET COILB,PORTC CAE8 203A 15423 BRA CN_END 15424 ROT2DN: CAEA 1402 15425 BSET WLED,PORTC CAEC 1202 15426 BSET COILB,PORTC CAEE 2034 15427 BRA CN_END 15428 NILS: CAF0 006817 15429 BRSET COILABIT,COILSEL,DSLSA CAF3 026818 15430 BRSET COILBBIT,COILSEL,DSLSB CAF6 046819 15431 BRSET COILCBIT,COILSEL,DSLSC CAF9 06681A 15432 BRSET COILDBIT,COILSEL,DSLSD CAFC 08681B 15433 BRSET COILEBIT,COILSEL,DSLSE CAFF 0A681C 15434 BRSET COILFBIT,COILSEL,DSLSF CB02 2020 15435 BRA CN_END 15436 FIREFD: CB04 046807 15437 BRSET COILCBIT,COILSEL,DSLSB CB07 066808 15438 BRSET COILDBIT,COILSEL,DSLSC 15439 DSLSA: CB0A 1002 15440 BSET COILA,PORTC CB0C 2016 15441 BRA CN_END 15442 DSLSB: CB0E 1202 15443 BSET COILB,PORTC CB10 2012 15444 BRA CN_END 15445 DSLSC: CB12 1402 15446 BSET WLED,PORTC CB14 200E 15447 BRA CN_END 15448 DSLSD: CB16 1003 15449 BSET OUTPUT3,PORTD CB18 200A 15450 BRA CN_END 15451 DSLSE: CB1A 1602 15452 BSET PIN10,PORTC CB1C 2006 15453 BRA CN_END 15454 DSLSF: CB1E 1403 15455 BSET KNOCKIN,PORTD CB20 2002 15456 BRA CN_END 15457 DSLSX: CB22 1200 15458 BSET IASC,PORTA 15459 CN_END: 15460 15461 *********** now schedule some fuel injection ************ 15462 15463 squirtCheck1: CB24 02421D 15464 brset crank,engine,schedule1a ; Squirt on every pulse 15465 ; if cranking 15466 CB27 3C84 15467 inc IgnCount1 ; Check to see if we are to 15468 ; squirt or skip CB29 B684 15469 lda IgnCount1 CB2B C1E195 15470 cmp divider_f1 CB2E 2708 15471 beq schedule1 CB30 A110 15472 cmp #16T ; The maximum allowed - reset if match CB32 2519 15473 blo squirtDone1 CB34 3F84 15474 clr IgnCount1 CB36 2015 15475 bra squirtDone1 15476 15477 schedule1: CB38 3F84 15478 clr IgnCount1 15479 15480 ; lda DTmode_f ; check if DT in use 15481 ; bit #alt_i2t2 15482 ; bne schedule1a ; i2t2=1 15483 CB3A C6E196 15484 lda alternate_f1 CB3D 2705 15485 beq schedule1a CB3F 3C86 15486 inc altcount1 CB41 008609 15487 brset 0,altcount1,squirtDone1 15488 schedule1a: CB44 4E6E4E 15489 mov pwcalc1,pw1 CB47 2704 15490 beq squirtDone1 ; check for zero pulse CB49 1441 15491 bset sched1,squirt CB4B 1041 15492 bset inj1,squirt 15493 squirtDone1: 15494 15495 ;------------------------------------------------------------------------------- 15496 15497 squirtCheck2: CB4D C6E021 15498 lda DTmode_f ; check if DT in use CB50 A510 15499 bit #alt_i2t2 CB52 262D 15500 bne sc2dual ; i2t2=1 15501 15502 sc2single: CB54 02421F 15503 brset crank,engine,schedule2sa ; Squirt on every pulse 15504 ; if cranking 15505 CB57 3C85 15506 inc IgnCount2 ; Check to see if we are to 15507 ; squirt or skip CB59 B685 15508 lda IgnCount2 CB5B C1E195 15509 cmp divider_f1 CB5E 270A 15510 beq schedule2s CB60 B685 15511 lda IgnCount2 CB62 A110 15512 cmp #16T ; The maximum allowed - reset if match CB64 2546 15513 blo squirtDone2 CB66 3F85 15514 clr IgnCount2 CB68 2042 15515 bra squirtDone2 15516 15517 schedule2s: CB6A 3F85 15518 clr IgnCount2 CB6C C6E196 15519 lda alternate_f1 CB6F 2705 15520 beq schedule2sa CB71 3C87 15521 inc altcount2 CB73 018736 15522 brclr 0,altcount2,squirtDone2 15523 schedule2sa: CB76 4E6F53 15524 mov pwcalc2,pw2 CB79 2731 15525 beq squirtDone2 ; check for zero pulse CB7B 1841 15526 bset sched2,squirt CB7D 1241 15527 bset inj2,squirt CB7F 202B 15528 bra squirtDone2 15529 15530 sc2dual: CB81 02421F 15531 brset crank,engine,schedule2da ; Squirt on every pulse 15532 ; if cranking 15533 CB84 3C85 15534 inc IgnCount2 ; Check to see if we are to 15535 ; squirt or skip CB86 B685 15536 lda IgnCount2 CB88 C1E295 15537 cmp divider_f2 CB8B 270A 15538 beq schedule2d msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 127 MC68HC908GP32 User Bootloader CB8D B685 15539 lda IgnCount2 CB8F A110 15540 cmp #16T ; The maximum allowed - reset if match CB91 2619 15541 bne squirtDone2 CB93 3F85 15542 clr IgnCount2 CB95 2015 15543 bra squirtDone2 15544 15545 schedule2d: CB97 3F85 15546 clr IgnCount2 CB99 C6E196 15547 lda alternate_f1 CB9C 2705 15548 beq schedule2da CB9E 3C87 15549 inc altcount2 CBA0 018709 15550 brclr 0,altcount2,squirtDone2 15551 schedule2da: CBA3 4E6F53 15552 mov pwcalc2,pw2 CBA6 2704 15553 beq squirtDone2 ; check for zero pulse CBA8 1841 15554 bset sched2,squirt CBAA 1241 15555 bset inj2,squirt 15556 15557 squirtDone2: 15558 15559 IRQ_EXIT: CBAC 026109 15560 brset MSNEON,personality,IRQ_EXIT2 CBAF 046106 15561 brset WHEEL,personality,IRQ_EXIT2 15562 ; These are used to reduce/prevent false triggers but no good for 15563 ; the multi-toothed wheels CBB2 141D 15564 bset ACK,INTSCR ; Flush out any new interrupts pending CBB4 121D 15565 bset IMASK,INTSCR ; Disable IRQ interrupts CBB6 161D 15566 bset IRQF,INTSCR ; read only ?!?! Won't do anything 15567 IRQ_EXIT2: CBB8 80 15568 rti 15569 15570 *************************************************************************** 15571 ** 15572 ** ADC - Interrupt for ADC conversion complete 15573 ** 15574 *************************************************************************** 15575 ADCDONE: CBB9 8B 15576 pshh ; Do this because processor does 15577 ; not stack H 15578 CBBA 8C 15579 clrh 15580 ; Store previous values for derivative CBBB B68E 15581 lda adsel CBBD 270A 15582 beq KPa_ADC_Check ; If doing ADC 0 then check for fixed KPa CBBF A106 15583 cmp #$06 CBC1 274B 15584 beq FUEL_JUMP ; Check the fuel pressure sensor CBC3 A107 15585 cmp #$07 CBC5 2752 15586 beq EGT_JUMP ; Check the EGT input CBC7 202D 15587 bra Normal_ADSEL 15588 15589 KPa_ADC_Check: CBC9 054229 15590 brclr startw,engine,NormMAP_Count ; Are we in ASE mode? CBCC C6E5B3 15591 lda feature10_f5 CBCF A504 15592 bit #MAPHoldb ; Are we holding the MAP at a fixed value during ASE? CBD1 2722 15593 beq NormMAP_Count CBD3 0E691F 15594 brset FxdASEDone,EnhancedBits4,NormMAP_Count ; Is Fixed ASE done? 15595 CBD6 B6CC 15596 lda coolant ; We are in fixed MAP mode CBD8 C1E5B5 15597 cmp CltFixASE_f ; so are we below the temperature setpoint? CBDB 2302 15598 bls FixdMAP_ASE CBDD 2016 15599 bra NormMAP_Count ; Normal MAP mode 15600 15601 FixdMAP_ASE: CBDF B683 15602 lda ASEcount CBE1 C1E5B4 15603 cmp TimFixASE_f CBE4 2504 15604 blo FixdMAP2 ; Have we passed the Fixed timer yet? 15605 CBE6 1E69 15606 bset FxdASEDone,EnhancedBits4 ; SET the Fixed bit so we dont do it again. CBE8 200B 15607 bra NormMAP_Count ; Normal MAP mode 15608 15609 FixdMAP2: CBEA B63D 15610 lda adr CBEC C6E5B6 15611 lda MAPFixASE_f ; We are in fixed MAP mode during ASE, load value CBEF B744 15612 sta map CBF1 B777 15613 sta lmap CBF3 200D 15614 bra Done_FIXMAP 15615 15616 NormMAP_Count: CBF5 4F 15617 clra ; reset offset to zero 15618 15619 Normal_ADSEL: CBF6 97 15620 tax CBF7 E644 15621 lda map,x CBF9 E777 15622 sta lmap,x ; Store the old value 15623 CBFB B63D 15624 lda adr ; Load in the new ADC reading CBFD EB44 15625 add map,x ; Perform (map + last_map)/2 15626 ; averaging (for all ADC readings) CBFF 46 15627 rora CC00 E744 15628 sta map,x ; MAP is entry point, offset is 15629 ; loaded in index register 15630 Done_FIXMAP: CC02 B68E 15631 lda adsel CC04 4C 15632 inca CC05 A108 15633 cmp #$08 CC07 2601 15634 bne ADCPTR CC09 4F 15635 clra 15636 ADCPTR: CC0A B78E 15637 sta adsel CC0C 8A 15638 pulh CC0D 80 15639 rti 15640 FUEL_JUMP: CC0E B63D 15641 lda adr CC10 B75A 15642 sta o2_fpadc ; Fuel Pressure, wheel sensor or 15643 ; second O2 sensor CC12 B68E 15644 lda adsel CC14 4C 15645 inca CC15 B78E 15646 sta adsel CC17 8A 15647 pulh CC18 80 15648 rti 15649 EGT_JUMP: CC19 B63D 15650 lda adr CC1B B75B 15651 sta egtadc ; EGT sensor or wheel sensor input. CC1D 4F 15652 clra CC1E B78E 15653 sta adsel CC20 8A 15654 pulh CC21 80 15655 rti 15656 *************************************************************************** 15657 ** 15658 ** SCI Communications 15659 ** 15660 ** Communications is established when the PC communications program sends 15661 ** a command character - the particular character sets the mode: 15662 ** 15663 ** "A" = send all of the realtime variables via txport. 15664 ** "V" = send the VE table and constants via txport (128 bytes) 15665 ** "W"++ = receive new VE or constant byte value and 15666 ** store in offset location 15667 ** "X"++++.... = receive series of new data bytes 15668 ** "B" = jump to flash burner routine and burn VE/constant values in RAM into flash 15669 ** "C" = Test communications - echo back SECL 15670 ** "Q" = Send over Embedded Code Revision Number (irrelevant in Extra, send zero) 15671 ** "S" = Signature - update every time there is a change in data format 32 bytes 15672 ** "T" = full code revision in text. 32 bytes 15673 ** "P"+ = load page of data from Flash to RAM 15674 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 128 MC68HC908GP32 User Bootloader 15675 ** txmode: 15676 ** 01 = Getting realtime data 15677 ** 02 = ? 15678 ** 03 = Sending VE 15679 ** 04 = sending signature 15680 ** 05 = Getting offset VE 15681 ** 06 = Getting data VE 15682 ** 07 = Getting offset chunk write 15683 ** 08 = Getting count chunk write 15684 ** 09 = Getting data chunk write 15685 ** 0A = Bootloader 15686 ** 0B = version string 15687 ** 0C = getting table number 15688 ** 0D = config error message 15689 ** 0E = format string 15690 *************************************************************************** 15691 IN_SCI_RCV: CC22 8B 15692 pshh CC23 B616 15693 lda SCS1 ; Clear the SCRF bit by reading 15694 ; this register 15695 CC25 B68C 15696 lda txmode ; Check if we are in the middle 15697 ; of a receive new VE/constant CC27 410515 15698 cbeqa #$05,TXMODE_5 CC2A 41061A 15699 cbeqa #$06,TXMODE_6 CC2D 410727 15700 cbeqa #$07,TXMODE_7 CC30 41082C 15701 cbeqa #$08,TXMODE_8 CC33 410931 15702 cbeqa #$09,TXMODE_9 CC36 410C03 15703 cbeqa #$0C,TXMODE_C1 CC39 CCCD0C 15704 jmp CHECK_TXCMD CC3C CCCF45 15705 TXMODE_C1: jmp TXMODE_C 15706 15707 TXMODE_5: ; Getting offset for W command CC3F 4E188D 15708 mov SCDR,rxoffset CC42 3C8C 15709 inc txmode ; continue to next mode CC44 CCCDBC 15710 jmp DONE_RCV 15711 TXMODE_6: CC47 0C670A 15712 brset mv_mode,EnhancedBits2,TX6_MV CC4A 8C 15713 clrh CC4B BE8D 15714 ldx rxoffset CC4D B618 15715 lda SCDR CC4F D7010F 15716 sta VE_r,x CC52 3F8C 15717 clr txmode 15718 TX6_MV: ; in MV mode, just ignore any data sent CC54 CCCDBC 15719 jmp DONE_RCV 15720 15721 TXMODE_7: ; Getting offset for X command CC57 4E188D 15722 mov SCDR,rxoffset CC5A 3C8C 15723 inc txmode ; continue to next mode CC5C CCCDBC 15724 jmp DONE_RCV 15725 15726 TXMODE_8: ; Getting count for X command CC5F 4E188B 15727 mov SCDR,txgoal ; borrow txgoal as we aren't 15728 ; going to using it CC62 3C8C 15729 inc txmode ; continue to next mode CC64 CCCDBC 15730 jmp DONE_RCV 15731 15732 TXMODE_9: CC67 8C 15733 clrh CC68 B68D 15734 lda rxoffset CC6A 97 15735 tax CC6B B618 15736 lda SCDR CC6D D7010F 15737 sta VE_r,x CC70 3C8D 15738 inc rxoffset CC72 3A8B 15739 dec txgoal ; count down CC74 2602 15740 bne TXMODE_9_CONT CC76 3F8C 15741 clr txmode ; have received all bytes we expected 15742 TXMODE_9_CONT: CC78 CCCDBC 15743 jmp DONE_RCV 15744 15745 ;MODE_B moved up here to enable relative branches 15746 MODE_B: CC7B C60106 15747 lda page CC7E A110 15748 cmp #$10 ; see if tooth logging or invalid page CC80 2503 15749 blo MODE_B_OK ; if it is then do not burn CC82 CCCD07 15750 jmp DONE_B 15751 MODE_B_OK: CC85 1B14 15752 bclr SCRIE,SCC2 ; turn off receive interrupt 15753 ; so don't re-enter 15754 ; cli ; re-enable interrupts to reduce 15755 ; stumble during Burn. Too bad CC87 6ECC76 15756 mov #$CC,flocker CC8A CDD0AB 15757 jsr burnConst ; routine disables interrupts during 15758 ; critical sections 15759 ; cli ; returns with ints off CC8D 3F76 15760 clr flocker CC8F 3F8C 15761 clr txmode 15762 CC91 C60106 15763 lda page ; check if page0, if so reload 15764 ; quick vars CC94 2708 15765 beq ck_page0 CC96 41033D 15766 cbeqa #3,ck_page3 ; do trigger angle / next cyl calc CC99 41075C 15767 cbeqa #7,ck_page7 ; do rotary setting check CC9C 2069 15768 bra DONE_B 15769 15770 ck_page0: 15771 ; Set up RAM Variable - also when burning page0 search for "burning page0" CC9E C6E00B 15772 lda feature1_f CCA1 B763 15773 sta feature1 CCA3 C6E00C 15774 lda feature2_f CCA6 B764 15775 sta feature2 15776 ; lda feature3_f 15777 ; sta feature3 ; ram copy removed 15778 ; lda feature4_f 15779 ; sta feature4 ; ram copy removed 15780 ; lda feature5_f 15781 ; sta feature5 ; ram copy removed 15782 ; lda feature6_f 15783 ; sta feature6 ; ram copy removed CCA8 C6E06D 15784 lda feature7_f CCAB B765 15785 sta feature7 15786 ; lda feature8_f 15787 ; sta feature8 ; ram copy removed CCAD C6E001 15788 lda outputpins_f CCB0 B762 15789 sta outputpins CCB2 C6E000 15790 lda personality_f CCB5 B761 15791 sta personality ; move from flash to ram 15792 15793 ;is PTC4 (pin11) an input (trig2) or output (shiftlight) CCB7 016304 15794 brclr wd_2trig,feature1,ckp0_norm_ddrc CCBA A60F 15795 lda #%00001111 ; make PTC4 an input for second trigger CCBC 2002 15796 bra ckp0_ddrc 15797 ckp0_norm_ddrc: CCBE A61F 15798 lda #%00011111 ; ** Was 11111111 15799 ckp0_ddrc: CCC0 B706 15800 sta ddrc ; Outputs for LED 15801 15802 ;decide if we are doing multiple wasted spark outputs 15803 ;check this here so a changed setting or MSQ load will correctly init the variables CCC2 026107 15804 brset MSNEON,personality,pz_wspk CCC5 046104 15805 brset WHEEL,personality,pz_wspk 15806 pz_nwspk: CCC8 1769 15807 bclr wspk,EnhancedBits4 ; set that we are NOT doing wasted spark CCCA 203B 15808 bra DONE_B 15809 pz_wspk: CCCC 0962F9 15810 brclr REUSE_LED19,outputpins,pz_nwspk msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 129 MC68HC908GP32 User Bootloader CCCF 006AF6 15811 brset rotary2,EnhancedBits5,pz_nwspk CCD2 1669 15812 bset wspk,EnhancedBits4 ; set that we are doing wasted spark CCD4 2031 15813 bra DONE_B 15814 15815 ck_page3: 15816 ;see if inverted or non-inv output and use a quick bit CCD6 C6E3AD 15817 lda SparkConfig1_f ; check if noninv or inv spark CCD9 A508 15818 bit #M_SC1InvSpark CCDB 2604 15819 bne ckp3_inv CCDD 1D69 15820 bclr invspk,EnhancedBits4 ; set non-inverted CCDF 2002 15821 bra ckp3_i_done 15822 ckp3_inv: CCE1 1C69 15823 bset invspk,EnhancedBits4 ; set inverted 15824 ckp3_i_done: 15825 15826 15827 ;EDIS and NEON are never next-cylinder CCE3 08610E 15828 brset EDIS,personality,not_nc CCE6 02610B 15829 brset MSNEON,personality,not_nc 15830 CCE9 C6E3A8 15831 lda TriggAngle_f CCEC A139 15832 cmp #57T ; check for next cyl mode CCEE 2204 15833 bhi not_nc ; trigger angle > 20, continue CCF0 1A69 15834 bset nextcyl,EnhancedBits4 CCF2 2013 15835 bra DONE_B 15836 not_nc: CCF4 1B69 15837 bclr nextcyl,EnhancedBits4 CCF6 200F 15838 bra DONE_B 15839 15840 ck_page7: CCF8 C6E7C0 15841 lda p7feat1_f CCFB A501 15842 bit #rotary2b CCFD 2706 15843 beq ckp7nr CCFF 106A 15844 bset rotary2,EnhancedBits5 CD01 1769 15845 bclr wspk,EnhancedBits4 ; set that we are NOT doing normal wasted spark CD03 2002 15846 bra DONE_B 15847 ckp7nr: CD05 116A 15848 bclr rotary2,EnhancedBits5 15849 DONE_B: CD07 1A14 15850 bset SCRIE,SCC2 ; re-enable receive interrupt 15851 ; bra DONE_RCV CD09 CCCDBC 15852 jmp DONE_RCV 15853 ; 15854 CHECK_TXCMD: CD0C B618 15855 lda SCDR ; Get the command byte CD0E 41413C 15856 cbeqa #'A',MODE_A ; realtime vars CD11 414221 15857 cbeqa #'B',jMODE_B ; All I hear is BURN CD14 414346 15858 cbeqa #'C',MODE_C ; Comm test CD17 41564C 15859 cbeqa #'V',MODE_V ; (VE) read page CD1A 41571B 15860 cbeqa #'W',jMODE_W ; Write byte CD1D 41511B 15861 cbeqa #'Q',jMODE_Q ; Query version CD20 41501B 15862 cbeqa #'P',jMODE_P ; Page select CD23 41211B 15863 cbeqa #'!',jMODE_BOOT ; bootloader CD26 41531B 15864 cbeqa #'S',jMODE_SIGN ; signature CD29 415226 15865 cbeqa #'R',MODE_R ; Added for enhanced stuff was "a" 15866 ; now "R" for Megatunix compatabilty CD2C 415818 15867 cbeqa #'X',jMODE_X ; Chunk write CD2F 415418 15868 cbeqa #'T',jMODE_T ; Text version CD32 CCCDBC 15869 jmp DONE_RCV 15870 CD35 CCCC7B 15871 jMODE_B: jmp MODE_B CD38 CCCD88 15872 jMODE_W: jmp MODE_W CD3B CCCD94 15873 jMODE_Q: jmp MODE_Q CD3E CCCDA6 15874 jMODE_P: jmp MODE_P CD41 CCCDBE 15875 jMODE_BOOT: jmp MODE_BOOT CD44 CCCDAD 15876 jMODE_SIGN: jmp MODE_SIGN CD47 CCCD8D 15877 jMODE_X: jmp MODE_X CD4A CCCD9D 15878 jMODE_T: jmp MODE_T 15879 15880 MODE_A: ; Big A CD4D 6E178B 15881 mov #$17,txgoal ; B&G mode ($17) For Megaview use CD50 2005 15882 bra MODE_AA_cont 15883 15884 MODE_R: ; Big R CD52 1D67 15885 bclr mv_mode,EnhancedBits2 ; clear MegaView mode to allow 15886 ; enhanced comms CD54 6E278B 15887 mov #39T,txgoal ; was 32T in 021, was 36T in 021u, 15888 ; 38T from 021x1 onwards, 023b2:39T 15889 ; mov #47T,txgoal ; added another 8 bytes for debug 15890 15891 MODE_AA_cont: 15892 ;not here - only save when about to send 15893 ; mov iTimeL,cTimeCommL ; Copy cycle time to comm area 15894 ; mov iTimeH,cTimeCommH ; otherwise it might get out of 15895 ; sync during communication CD57 3F8A 15896 clr txcnt ; Send back all real-time variables CD59 A601 15897 lda #$01 CD5B 2059 15898 bra EN_XMIT 15899 15900 MODE_C: CD5D 3F8A 15901 clr txcnt ; Just send back SECL variable to 15902 ; test comm port CD5F 6E028B 15903 mov #$2,txgoal CD62 A601 15904 lda #$01 CD64 2050 15905 bra EN_XMIT 15906 15907 MODE_V: CD66 3F8A 15908 clr txcnt CD68 0C6716 15909 brset mv_mode,EnhancedBits2,MODE_V_MV CD6B 6EC98B 15910 mov #201T,txgoal ; no. of bytes to send back 15911 ; (was $7e) was 201 now 213 15912 ; for 12x12 NOW 201 again:-) CD6E C60106 15913 lda page CD71 41F005 15914 cbeqa #$F0,MODE_V_F0 CD74 41F106 15915 cbeqa #$F1,MODE_V_F1 CD77 200B 15916 bra MODE_V2 15917 MODE_V_F0: CD79 156A 15918 bclr toothlog,EnhancedBits5 CD7B 2007 15919 bra MODE_V2 15920 MODE_V_F1: CD7D 176A 15921 bclr triglog,EnhancedBits5 CD7F 2003 15922 bra MODE_V2 15923 MODE_V_MV: CD81 6E7E8B 15924 mov #$7E,txgoal 15925 MODE_V2: CD84 A603 15926 lda #$03 CD86 202E 15927 bra EN_XMIT 15928 MODE_W: CD88 6E058C 15929 mov #$05,txmode CD8B 202F 15930 bra DONE_RCV 15931 15932 MODE_X: CD8D 1D67 15933 bclr mv_mode,EnhancedBits2 ; clear MegaView mode to allow 15934 ; enhanced comms CD8F 6E078C 15935 mov #$07,txmode CD92 2028 15936 bra DONE_RCV 15937 15938 MODE_Q: CD94 3F8A 15939 clr txcnt ; Just send back SECL variable 15940 ; to test comm port CD96 6E028B 15941 mov #$2,txgoal CD99 A605 15942 lda #$05 CD9B 2019 15943 bra EN_XMIT 15944 15945 MODE_T: CD9D 3F8A 15946 clr txcnt msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 130 MC68HC908GP32 User Bootloader CD9F 6E218B 15947 mov #$21,txgoal ; Send 32 Chars of Text version CDA2 A60E 15948 lda #$0E ; TXMode = sending format string CDA4 2010 15949 bra EN_XMIT 15950 15951 MODE_P: CDA6 1D67 15952 bclr mv_mode,EnhancedBits2 ; clear MegaView mode to allow 15953 ; enhanced comms CDA8 6E0C8C 15954 mov #$0C,txmode ; txmode = getting page number CDAB 200F 15955 bra DONE_RCV 15956 15957 MODE_SIGN: ; Send Signature text - DJLH CDAD 1D67 15958 bclr mv_mode,EnhancedBits2 ; clear MegaView mode to allow 15959 ; enhanced comms CDAF 3F8A 15960 clr txcnt CDB1 6E218B 15961 mov #$21,txgoal ; Send 32 Chars of Signature CDB4 A604 15962 lda #$04 ; TXMode = sending signature 15963 EN_XMIT: CDB6 B78C 15964 sta txmode CDB8 1614 15965 bset TE,SCC2 ; Enable Transmit CDBA 1E14 15966 bset SCTIE,SCC2 ; Enable transmit interrupt 15967 15968 DONE_RCV: CDBC 8A 15969 pulh CDBD 80 15970 rti 15971 15972 MODE_BOOT: CDBE B68C 15973 lda txmode CDC0 A10A 15974 cmp #$0A CDC2 2705 15975 beq jBootLoad CDC4 6E0A8C 15976 mov #$0A,txmode CDC7 20F3 15977 bra DONE_RCV 15978 jBootLoad: CDC9 CCCE9F 15979 jmp BootLoad 15980 15981 CONF_ERR: CDCC 5598 15982 ldhx tmp5 ; tmp5,6 contain absolute 15983 ; address of data CDCE F6 15984 lda ,x CDCF 2604 15985 bne conf_err2 ; zero is string terminator CDD1 3F8C 15986 clr txmode CDD3 2076 15987 bra FIN_TXJMP 15988 conf_err2: CDD5 B718 15989 sta SCDR ; Send char CDD7 AF01 15990 aix #1 CDD9 3598 15991 sthx tmp5 CDDB 2070 15992 bra DONE_BYTEJMP 15993 CDDD CCCE7B 15994 jIN_SIGN_MODE: jmp IN_SIGN_MODE CDE0 CCCE80 15995 jIN_T_MODE: jmp IN_T_MODE 15996 *** Transmit Character Interrupt Handler *************** 15997 IN_SCI_TX: CDE3 8B 15998 pshh CDE4 B616 15999 lda SCS1 ; Clear the SCRF bit by reading 16000 ; this register CDE6 8C 16001 clrh CDE7 BE8A 16002 ldx txcnt CDE9 B68C 16003 lda txmode CDEB 410561 16004 cbeqa #$05,IN_Q_MODEJMP CDEE 4104EC 16005 cbeqa #$04,jIN_SIGN_MODE ; see above CDF1 410DD8 16006 cbeqa #$0D,CONF_ERR ; see above CDF4 410EE9 16007 cbeqa #$0E,jIN_T_MODE ; see above CDF7 A101 16008 cmp #$01 CDF9 2675 16009 bne IN_V_MODE 16010 IN_A_OR_C_MODE: 16011 ;check for iTime sending. Now send three bytes but don't waste extra byte, only store two CDFB A316 16012 cpx #22T CDFD 260B 16013 bne ac_chk37 CDFF B6AF 16014 lda iTimeH CE01 4EB057 16015 mov iTimeL,cTimeCommL ; Copy cycle time to comm area CE04 4EAE56 16016 mov iTimeX,cTimeCommH ; otherwise it might get out of CE07 CCCE88 16017 jmp CONT_TX ; sync during communication 16018 ac_chk37: CE0A A325 16019 cpx #37T 16020 ; bhi R_otherbytes CE0C 2604 16021 bne ac_chk36 CE0E B656 16022 lda cTimeCommH ; actually holds iTimeX CE10 2076 16023 bra CONT_TX 16024 16025 ;R_otherbytes: 16026 ; lda dwelldelay1-38T,X ; send dwell delays, may get data corruption 16027 ; bra CONT_TX 16028 ac_chk36: CE12 A324 16029 cpx #36T CE14 2604 16030 bne NotTPSLAst_Yet CE16 B6D1 16031 lda TPSlast CE18 206E 16032 bra CONT_TX 16033 16034 NotTPSLAst_Yet: CE1A A323 16035 cpx #35T CE1C 2604 16036 bne inac_cont CE1E 95 16037 tsx ; send stack CE1F 9F 16038 txa CE20 2066 16039 bra CONT_TX 16040 inac_cont: CE22 A31E 16041 cpx #30T CE24 2243 16042 bhi send_ports 16043 16044 ;Added for MV compatability with 300 & 400KPa MAP sensors CE26 A304 16045 cpx #04T ; Are we about to send the MAP value? CE28 263B 16046 bne Send_Data_Normal ; No so carry on as normal CE2A 0D6738 16047 brclr mv_mode,EnhancedBits2,Send_Data_Normal ; Yes so are we in 16048 ; MV mode? 16049 CE2D C6E074 16050 lda feature8_f ; Are we using a normal MAP sensor? CE30 A501 16051 bit #KPa300b CE32 2731 16052 beq Send_Data_Normal 16053 CE34 C6E074 16054 lda feature8_f ; OK so are we using 400KPa sensor CE37 A502 16055 bit #KPa400b CE39 2616 16056 bne KPa400_Reading 16057 16058 ; If we are here we are using a 300KPa sensor and we have a MV connected, 16059 ; so send 86% of the raw map value to MV so it converts it correctly CE3B B6CB 16060 lda kpa CE3D A1D9 16061 cmp #217T CE3F 2220 16062 bhi Load_Max_Map ; If raw map > 217 then we are 16063 ; above 255KPa, thats the limit in MV CE41 97 16064 tax CE42 A6DB 16065 lda #219T ; 86% = 219 in 255 bytes CE44 42 16066 mul CE45 9F 16067 txa CE46 241B 16068 bcc Send_Fudged_Data CE48 4C 16069 inca CE49 2018 16070 bra Send_Fudged_Data 16071 16072 FIN_TXJMP: CE4B 2046 16073 bra FIN_TX 16074 DONE_BYTEJMP: CE4D 204E 16075 bra DONE_BYTE 16076 IN_Q_MODEJMP: CE4F 2034 16077 bra IN_Q_MODE 16078 16079 ; If we get here we are using a 400KPa sensor and we have a MV connected, 16080 ; so send 63% of the raw map value to MV 16081 KPa400_Reading: CE51 B6CB 16082 lda kpa msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 131 MC68HC908GP32 User Bootloader CE53 A19F 16083 cmp #159T CE55 220A 16084 bhi Load_Max_Map ; If raw map > 159 then we are 16085 ; above 255KPa, the limit in MV CE57 97 16086 tax CE58 A6A0 16087 lda #160T CE5A 42 16088 mul CE5B 9F 16089 txa CE5C 2405 16090 bcc Send_Fudged_Data CE5E 4C 16091 inca CE5F 2002 16092 bra Send_Fudged_Data 16093 16094 Load_Max_Map: CE61 A6FF 16095 lda #255T ; Load in KPa limit 16096 Send_Fudged_Data: CE63 2023 16097 bra CONT_TX 16098 16099 16100 Send_Data_Normal: CE65 E640 16101 lda secl,X CE67 201F 16102 bra CONT_TX 16103 send_ports: CE69 9F 16104 txa CE6A A01F 16105 sub #31T CE6C 97 16106 tax CE6D F6 16107 lda porta,X ; load porta,b,c,d 31=a, 34=d CE6E 2018 16108 bra CONT_TX 16109 IN_V_MODE CE70 0C6705 16110 brset mv_mode,EnhancedBits2,IN_V_MV CE73 D6010F 16111 lda ve_r,x ; get data from RAM (must have 16112 ; loaded a page first) CE76 2010 16113 bra CONT_TX 16114 IN_V_MV: CE78 CCCF33 16115 jmp MV_V_EMUL 16116 IN_SIGN_MODE: CE7B D6D833 16117 lda SIGNATURE,x CE7E 2008 16118 bra CONT_TX 16119 IN_T_MODE: CE80 D6D813 16120 lda textversion_f,x CE83 2003 16121 bra CONT_TX 16122 IN_Q_MODE: CE85 D6D812 16123 lda REVNUM,X 16124 16125 CONT_TX: CE88 B718 16126 sta SCDR ; Send char CE8A B68A 16127 lda txcnt CE8C 4C 16128 inca ; Increase number of chars sent CE8D B78A 16129 sta txcnt CE8F B18B 16130 cmp txgoal ; Check if done CE91 260A 16131 bne DONE_BYTE ; Branch if NOT finished to DONE_BYTE 16132 16133 FIN_TX: CE93 3F8A 16134 clr txcnt CE95 3F8B 16135 clr txgoal CE97 3F8C 16136 clr txmode 16137 CE99 1714 16138 bclr TE,SCC2 ; Disable Transmit CE9B 1F14 16139 bclr SCTIE,SCC2 ; Disable transmit interrupt 16140 16141 DONE_BYTE: CE9D 8A 16142 pulh CE9E 80 16143 rti 16144 16145 BootLoad: CE9F 121D 16146 bset IMASK,INTSCR ; disable interrupts for IRQ 16147 ; (the ignition i/p) 16148 16149 ; that should be enough to stop the engine and then keep it stalled 16150 ; I wouldn't recommend updating the flash with a running engine anyway 16151 ; stop timers, disable interrupts CEA1 1A20 16152 bset TSTOP,T1SC CEA3 1D20 16153 bclr TOIE,T1SC CEA5 1A2B 16154 bset TSTOP,T2SC CEA7 1D2B 16155 bclr TOIE,T2SC 16156 16157 ; switch off inj1 CEA9 1803 16158 bset inject1,portd ; ^* * * Turn Off Injector #1 16159 ; (inverted drive) CEAB 1741 16160 bclr firing1,squirt CEAD 1541 16161 bclr sched1,squirt CEAF 1141 16162 bclr inj1,squirt 16163 16164 ; switch off inj2 CEB1 1A03 16165 bset inject2,portd ; ^* * * Turn Off Injector #2 16166 ; (inverted drive) CEB3 1B41 16167 bclr firing2,squirt CEB5 1941 16168 bclr sched2,squirt CEB7 1341 16169 bclr inj2,squirt 16170 CEB9 3F42 16171 clr engine ; Engine is stalled, clear all 16172 ; in engine settings CEBB 1100 16173 bclr fuelp,porta ; Turn off fuel pump CEBD 3F72 16174 clr rpmch CEBF 3F73 16175 clr rpmcl CEC1 3F4E 16176 clr pw1 ; zero out pulsewidths CEC3 3F53 16177 clr pw2 CEC5 3F4D 16178 clr rpm 16179 16180 ; turn spark outputs to inactive to avoid burning out coil. This will 16181 ; cause coils to fire, but that in unavoidable. A "non-inverted" output 16182 ; charges coil when signal from board is high i.e. the output pin is low. 16183 ; So to make inactive set these pins high 16184 ; if inverted set low 16185 CEC7 macro 16186 TurnAllSpkOff ; macro to turn off all spark outputs CEC7 0D6910 16187 BRCLR INVSPK,ENHANCEDBITS4,SOIN CECA 1300 16188 BCLR IASC,PORTA CECC 1102 16189 BCLR SLED,PORTC CECE 1502 16190 BCLR WLED,PORTC CED0 1302 16191 BCLR ALED,PORTC CED2 1103 16192 BCLR OUTPUT3,PORTD CED4 1702 16193 BCLR PIN10,PORTC CED6 1503 16194 BCLR KNOCKIN,PORTD CED8 203E 16195 BRA SOIN_DONE 16196 SOIN: CEDA 006204 16197 BRSET REUSE_FIDLE,OUTPUTPINS,SOIN1 CEDD 1300 16198 BCLR IASC,PORTA CEDF 2002 16199 BRA SOIN2 CEE1 1200 16200 SOIN1: BSET IASC,PORTA CEE3 026204 16201 SOIN2: BRSET REUSE_LED17,OUTPUTPINS,SOIN3 CEE6 1102 16202 BCLR SLED,PORTC CEE8 2002 16203 BRA SOIN4 CEEA 1002 16204 SOIN3: BSET SLED,PORTC CEEC 086204 16205 SOIN4: BRSET REUSE_LED19,OUTPUTPINS,SOIN5 CEEF 1302 16206 BCLR ALED,PORTC CEF1 2002 16207 BRA SOIN6 CEF3 1202 16208 SOIN5: BSET ALED,PORTC CEF5 056207 16209 SOIN6: BRCLR REUSE_LED18,OUTPUTPINS,SOIN7 CEF8 076204 16210 BRCLR REUSE_LED18_2,OUTPUTPINS,SOIN7 CEFB 1402 16211 BSET WLED,PORTC CEFD 2002 16212 BRA SOIN8 CEFF 1502 16213 SOIN7: BCLR WLED,PORTC 16214 SOIN8: CF01 096402 16215 BRCLR OUT3SPARKD,FEATURE2,SOIN9 CF04 1003 16216 BSET OUTPUT3,PORTD 16217 SOIN9: CF06 C6E074 16218 LDA FEATURE8_F msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 132 MC68HC908GP32 User Bootloader CF09 A508 16219 BIT #SPKEOPB CF0B 2702 16220 BEQ SOIN10 CF0D 1602 16221 BSET PIN10,PORTC 16222 SOIN10: CF0F C6E074 16223 LDA FEATURE8_F CF12 A510 16224 BIT #SPKFOPB CF14 2702 16225 BEQ SOIN11 CF16 1403 16226 BSET KNOCKIN,PORTD 16227 SOIN11: 16228 SOIN_DONE: CF18 3FB3 16229 CLR SPARKONLEFTAH CF1A 3FB4 16230 CLR SPARKONLEFTAL CF1C 3FB5 16231 CLR SPARKONLEFTBH CF1E 3FB6 16232 CLR SPARKONLEFTBL CF20 3FB7 16233 CLR SPARKONLEFTCH CF22 3FB8 16234 CLR SPARKONLEFTCL CF24 3FB9 16235 CLR SPARKONLEFTDH CF26 3FBA 16236 CLR SPARKONLEFTDL CF28 3FBB 16237 CLR SPARKONLEFTEH CF2A 3FBC 16238 CLR SPARKONLEFTEL CF2C 3FBD 16239 CLR SPARKONLEFTFH CF2E 3FBE 16240 CLR SPARKONLEFTFL 16241 CF30 CCFB59 16242 jmp BootReset1 16243 16244 MV_V_EMUL: 16245 ; we are in Megaview mode. Ideally we'd like to return a B&G 16246 ;style view of our data CF33 A374 16247 cpx #116T CF35 250A 16248 blo V_MV2 CF37 9F 16249 txa ; need to return config11,12,13 16250 ; to get correct map reading CF38 AB58 16251 add #88T ; B&G byte 116 is at 204 in this code CF3A 97 16252 tax CF3B D6E1B6 16253 lda config11_f1,x CF3E CCCE88 16254 jmp CONT_TX 16255 V_MV2: CF41 4F 16256 clra ; for now, return zero. CF42 CCCE88 16257 jmp CONT_TX 16258 16259 TXMODE_C: CF45 B618 16260 lda SCDR ; expect 0 to 7 or $F0 or $F1 CF47 C10106 16261 cmp page ; check if already loaded CF4A 273D 16262 beq DONE_LOAD CF4C 41F024 16263 cbeqa #$F0,toothl_F0 CF4F 41F125 16264 cbeqa #$F1,toothl_F1 CF52 156A 16265 bclr toothlog,EnhancedBits5 ; ensure tooth logger is off CF54 176A 16266 bclr triglog,EnhancedBits5 ; ensure tooth logger is off CF56 A107 16267 cmp #07T ; Changed to 7 from 8 as removed 16268 ; the hyperterm test CF58 222F 16269 bhi DONE_LOAD CF5A 5F 16270 clrx CF5B C70106 16271 sta page CF5E ABE0 16272 add #$E0 ; hardcoded high byte of page 16273 ; area $Ex00 CF60 87 16274 psha CF61 8A 16275 pulh CF62 1B14 16276 bclr SCRIE,SCC2 ; turn off receive interrupt so 16277 ; don't re-enter CF64 9A 16278 cli ; re-enable interrupts to reduce 16279 ; stumble when MT changes page 16280 load_table: CF65 F6 16281 lda 0,x ; h:x CF66 8B 16282 pshh CF67 8C 16283 clrh CF68 D7010F 16284 sta VE_r,x ; dump into RAM. Bit of a kludge, 16285 ; want h=0 CF6B 8A 16286 pulh CF6C 5C 16287 incx CF6D A3C9 16288 cpx #201T ; copy 256 bytes 16289 ; reduced to 200 16290 ; Increased to 212 for 12x12 16291 ; Back to 200 now for 022+ CF6F 26F4 16292 bne load_table CF71 2016 16293 bra DONE_LOAD 16294 16295 toothl_F0: CF73 146A 16296 bset toothlog,EnhancedBits5 CF75 2002 16297 bra tooth_log_setup 16298 toothl_F1: CF77 166A 16299 bset triglog,EnhancedBits5 16300 tooth_log_setup: CF79 C70106 16301 sta page CF7C 1B14 16302 bclr SCRIE,SCC2 CF7E 4F 16303 clra CF7F 5F 16304 clrx CF80 8C 16305 clrh 16306 clear_table: CF81 D7010F 16307 sta VE_r,x ; dump into RAM. Bit of a kludge, CF84 5C 16308 incx CF85 A3C9 16309 cpx #201T ; clear 201 bytes CF87 26F8 16310 bne clear_table 16311 16312 ;bytes VE_r+0 - VE_r+197 = data, VE_r+198 = counter 16313 16314 DONE_LOAD: CF89 1A14 16315 bset SCRIE,SCC2 ; re-enable receive interrupt CF8B 3F8C 16316 clr txmode CF8D 8A 16317 pulh ; (same as DONE_RECV) CF8E 80 16318 rti 16319 16320 *************************************************************************** 16321 ** 16322 ** Timer 2 overflow, extends hardware timer with an extra byte in software 16323 ** 16324 *************************************************************************** 16325 T2overflow: CF8F B62B 16326 lda T2SC ; Read interrupt CF91 1F2B 16327 bclr TOF,T2SC ; Reset interrupt CF93 3CAA 16328 inc T2CNTX 16329 ; inca ; outside zp so cannot use inc T2CNTX 16330 ; sta T2CNTX ; increment software byte CF95 1169 16331 bclr roll1,EnhancedBits4 ; clear the roll-over detect bits CF97 1369 16332 bclr roll2,EnhancedBits4 CF99 80 16333 rti 16334 *************************************************************************** 16335 ** 16336 ** Dummy ISR - just performs RTS 16337 ** 16338 *************************************************************************** 16339 Dummy: ; Dummy vector - there just to 16340 ; keep the assembler happy CF9A 80 16341 rti 16342 16343 *************************************************************************** 16344 ** 16345 ** Various functions/subroutines Follow 16346 ** 16347 ** - Ordered Table Search 16348 ** - Linear Interpolation 16349 ** - 32 x 16 divide 16350 *************************************************************************** 16351 16352 16353 *************************************************************************** 16354 ** msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 133 MC68HC908GP32 User Bootloader 16355 ** Ordered Table Search 16356 ** 16357 ** X is pointing to the start of the first value in the table 16358 ** tmp1:2 initially hold the start of table address, then they hold the bound values 16359 ** tmp3 is the end of the table (nelements - 1) 16360 ** tmp4 is the comparison value 16361 ** tmp5 is the index result - if zero then comp value is less than beginning of table, and 16362 ** if equal to nelements then it is rail-ed at upper end 16363 ** 16364 *************************************************************************** 16365 tablelookup: 16366 ORD_TABLE_FIND: CF9B 3F98 16367 clr tmp5 CF9D 5594 16368 ldhx tmp1 CF9F F6 16369 lda ,x CFA0 B794 16370 sta tmp1 CFA2 B795 16371 sta tmp2 16372 ; cmp tmp4 16373 ; bhi GOT_ORD_NUM 16374 REENT: CFA4 5C 16375 incx CFA5 3C98 16376 inc tmp5 CFA7 4E9594 16377 mov tmp2,tmp1 CFAA F6 16378 lda ,x CFAB B795 16379 sta tmp2 16380 CFAD B197 16381 cmp tmp4 CFAF 2206 16382 bhi GOT_ORD_NUM CFB1 B698 16383 lda tmp5 CFB3 B196 16384 cmp tmp3 CFB5 26ED 16385 bne REENT 16386 16387 ; inc tmp5 16388 ; mov tmp2,tmp1 16389 GOT_ORD_NUM: CFB7 81 16390 rts 16391 16392 *************************************************************************** 16393 ** 16394 ** Linear Interpolation - 2D 16395 ** 16396 ** (y2 - y1) 16397 ** Y = Y1 + --------- * (x - x1) 16398 ** (x2 - x1) 16399 ** 16400 ** tmp1 = x1 16401 ** tmp2 = x2 16402 ** tmp3 = y1 16403 ** tmp4 = y2 16404 ** tmp5 = x 16405 ** tmp6 = y 16406 *************************************************************************** 16407 LININTERP: CFB8 3F9A 16408 clr tmp7 ; This is the negative slope 16409 ; detection bit CFBA 4E9699 16410 mov tmp3,tmp6 16411 CHECK_LESS_THAN: CFBD B698 16412 lda tmp5 CFBF B194 16413 cmp tmp1 CFC1 2202 16414 bhi CHECK_GREATER_THAN CFC3 2044 16415 bra DONE_WITH_INTERP 16416 CHECK_GREATER_THAN: CFC5 B698 16417 lda tmp5 CFC7 B195 16418 cmp tmp2 CFC9 2505 16419 blo DO_INTERP CFCB 4E9799 16420 mov tmp4,tmp6 CFCE 2039 16421 bra DONE_WITH_INTERP 16422 16423 DO_INTERP: CFD0 4E9699 16424 mov tmp3,tmp6 CFD3 B695 16425 lda tmp2 CFD5 B094 16426 sub tmp1 CFD7 2730 16427 beq DONE_WITH_INTERP CFD9 87 16428 psha CFDA B697 16429 lda tmp4 CFDC B096 16430 sub tmp3 CFDE 2403 16431 bcc POSINTERP CFE0 40 16432 nega CFE1 3C9A 16433 inc tmp7 16434 POSINTERP: CFE3 87 16435 psha CFE4 B698 16436 lda tmp5 CFE6 B094 16437 sub tmp1 CFE8 271D 16438 beq ZERO_SLOPE CFEA 88 16439 pulx CFEB 42 16440 mul CFEC 89 16441 pshx CFED 8A 16442 pulh CFEE 88 16443 pulx 16444 CFEF 52 16445 div 16446 CFF0 87 16447 psha CFF1 B69A 16448 lda tmp7 CFF3 2607 16449 bne NEG_SLOPE CFF5 86 16450 pula CFF6 BB96 16451 add tmp3 CFF8 B799 16452 sta tmp6 CFFA 200D 16453 bra DONE_WITH_INTERP 16454 NEG_SLOPE: CFFC 86 16455 pula CFFD B79A 16456 sta tmp7 CFFF B696 16457 lda tmp3 D001 B09A 16458 sub tmp7 D003 B799 16459 sta tmp6 D005 2002 16460 bra DONE_WITH_INTERP 16461 ZERO_SLOPE: D007 86 16462 pula ;clean stack D008 86 16463 pula ;clean stack 16464 DONE_WITH_INTERP: D009 81 16465 rts 16466 16467 16468 ******************************************************************************** 16469 ** Multiply then divide. 16470 ******************************************************************************** 16471 16472 uMulAndDiv: 16473 16474 ******************************************************************************** 16475 ** 8 x 16 Multiply 16476 ** 16477 ** 8-bit value in Accumulator, 16-bit value in tmp11-12, result overwrites 16478 ** 16-bit input. Assumes result cannot overflow. 16479 ******************************************************************************** 16480 16481 uMul16: D00A 87 16482 psha ; Save multiplier. D00B BE9E 16483 ldx tmp11 ; LSB of multiplicand. D00D 42 16484 mul D00E B79E 16485 sta tmp11 ; LSB of result stored. D010 86 16486 pula ; Pop off multiplier. D011 89 16487 pshx ; Carry on stack. D012 BE9F 16488 ldx tmp12 ; MSB of multiplicand. D014 42 16489 mul D015 9EEB01 16490 add 1,SP ; Add in carry from LSB. msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 134 MC68HC908GP32 User Bootloader D018 B79F 16491 sta tmp12 ; MSB of result. D01A 86 16492 pula ; Clear the stack. 16493 16494 ******************************************************************************** 16495 ** 16-bit divide by 100T 16496 ** 16497 ** 16-bit value in tmp11-12 is divided by 100T. Result is left in tmp11-12. 16498 ******************************************************************************** 16499 16500 uDivBy100: D01B 8C 16501 clrh D01C B69F 16502 lda tmp12 ; MSB of dividend. D01E AE64 16503 ldx #100T ; Divisor. D020 52 16504 div D021 B79F 16505 sta tmp12 ; MSB of quotient. D023 B69E 16506 lda tmp11 ; LSB of dividend. D025 52 16507 div D026 B79E 16508 sta tmp11 ; LSB of quotient. 16509 16510 ; See if we need to round up the quotient. D028 8B 16511 pshh D029 86 16512 pula ; Remainder in A. D02A A132 16513 cmp #50T ; Half of the divisor. D02C 9306 16514 ble uDivRoundingDone D02E 3C9E 16515 inc tmp11 D030 2402 16516 bcc uDivRoundingDone D032 3C9F 16517 inc tmp12 16518 uDivRoundingDone: D034 81 16519 rts 16520 16521 ******************************************************************************** 16522 ******************************************************************************** 16523 * 16524 * 32 / 16 Unsigned Divide 16525 * 16526 * This routine takes the 32-bit dividend stored in INTACC1.....INTACC1+3 16527 * and divides it by the 16-bit divisor stored in INTACC2:INTACC2+1. 16528 * The quotient replaces the dividend and the remainder replaces the divisor. 16529 * 16530 * Re-written a bit by JSM to eliminate stack usage and use tmp vars instead of 16531 * 8 bytes of reserved ram 16532 ; 1,SP = tmp9 16533 ; 2,SP = tmp10 16534 ; 3,SP = tmp11 16535 UDVD32: 16536 * D035 16537 DIVIDEND EQU INTACC1+2 D035 16538 DIVISOR EQU INTACC2 D035 16539 QUOTIENT EQU INTACC1 D035 16540 REMAINDER EQU INTACC1 16541 * 16542 ;only called twice in code and regs don't need preserving D035 A620 16543 LDA #!32 ; D037 B79E 16544 STA tmp11 ; loop counter for number of shifts D039 B698 16545 LDA DIVISOR ; get divisor msb D03B B79C 16546 STA tmp9 ; put divisor msb in working storage D03D B699 16547 LDA DIVISOR+1 ; get divisor lsb D03F B79D 16548 STA tmp10 ; put divisor lsb in working storage 16549 * 16550 * Shift all four bytes of dividend 16 bits to the right and clear 16551 * both bytes of the temporary remainder location 16552 * D041 4E9799 16553 MOV DIVIDEND+1,DIVIDEND+3 ; shift dividend lsb D044 4E9698 16554 MOV DIVIDEND,DIVIDEND+2 ; shift 2nd byte of dividend D047 4E9597 16555 MOV DIVIDEND-1,DIVIDEND+1 ; shift 3rd byte of dividend D04A 4E9496 16556 MOV DIVIDEND-2,DIVIDEND ; shift dividend msb D04D 3F94 16557 CLR REMAINDER ; zero remainder msb D04F 3F95 16558 CLR REMAINDER+1 ; zero remainder lsb 16559 * 16560 * Shift each byte of dividend and remainder one bit to the left 16561 * D051 B694 16562 SHFTLP LDA REMAINDER ; get remainder msb D053 49 16563 ROLA ; shift remainder msb into carry D054 3999 16564 ROL DIVIDEND+3 ; shift dividend lsb D056 3998 16565 ROL DIVIDEND+2 ; shift 2nd byte of dividend D058 3997 16566 ROL DIVIDEND+1 ; shift 3rd byte of dividend D05A 3996 16567 ROL DIVIDEND ; shift dividend msb D05C 3995 16568 ROL REMAINDER+1 ; shift remainder lsb D05E 3994 16569 ROL REMAINDER ; shift remainder msb 16570 * 16571 * Subtract both bytes of the divisor from the remainder 16572 * D060 B695 16573 LDA REMAINDER+1 ; get remainder lsb D062 B09D 16574 SUB tmp10 ; subtract divisor lsb from 16575 ; remainder lsb D064 B795 16576 STA REMAINDER+1 ; store new remainder lsb D066 B694 16577 LDA REMAINDER ; get remainder msb D068 B29C 16578 SBC tmp9 ; subtract divisor msb from 16579 ; remainder msb D06A B794 16580 STA REMAINDER ; store new remainder msb D06C B699 16581 LDA DIVIDEND+3 ; get low byte of dividend/quotient D06E A200 16582 SBC #0 ; dividend low bit holds subtract carry D070 B799 16583 STA DIVIDEND+3 ; store low byte of dividend/quotient 16584 * 16585 * Check dividend/quotient lsb. If clear, set lsb of quotient to indicate 16586 * successful subraction, else add both bytes of divisor back to remainder 16587 * D072 019914 16588 BRCLR 0,DIVIDEND+3,SETLSB ; check for a carry from subtraction 16589 ; and add divisor to remainder if set D075 B695 16590 LDA REMAINDER+1 ; get remainder lsb D077 BB9D 16591 ADD tmp10 ; add divisor lsb to remainder lsb D079 B795 16592 STA REMAINDER+1 ; store remainder lsb D07B B694 16593 LDA REMAINDER ; get remainder msb D07D B99C 16594 ADC tmp9 ; add divisor msb to remainder msb D07F B794 16595 STA REMAINDER ; store remainder msb D081 B699 16596 LDA DIVIDEND+3 ; get low byte of dividend D083 A900 16597 ADC #0 ; add carry to low bit of dividend D085 B799 16598 STA DIVIDEND+3 ; store low byte of dividend D087 2002 16599 BRA DECRMT ; do next shift and subtract 16600 D089 1099 16601 SETLSB BSET 0,DIVIDEND+3 ; set lsb of quotient to indicate 16602 ; successive subtraction D08B 3B9EC3 16603 DECRMT DBNZ tmp11,SHFTLP ; decrement loop counter and do next 16604 ; shift 16605 * 16606 * Move 32-bit dividend into INTACC1.....INTACC1+3 and put 16-bit 16607 * remainder in INTACC2:INTACC2+1 16608 * D08E B694 16609 LDA REMAINDER ; get remainder msb D090 B79C 16610 STA tmp9 ; temporarily store remainder msb D092 B695 16611 LDA REMAINDER+1 ; get remainder lsb D094 B79D 16612 STA tmp10 ; temporarily store remainder lsb D096 4E9694 16613 MOV DIVIDEND,QUOTIENT ; D099 4E9795 16614 MOV DIVIDEND+1,QUOTIENT+1 ; shift all four bytes of quotient D09C 4E9896 16615 MOV DIVIDEND+2,QUOTIENT+2 ; 16 bits to the left D09F 4E9997 16616 MOV DIVIDEND+3,QUOTIENT+3 ; D0A2 B69C 16617 LDA tmp9 ; get final remainder msb D0A4 B798 16618 STA INTACC2 ; store final remainder msb D0A6 B69D 16619 LDA tmp10 ; get final remainder lsb D0A8 B799 16620 STA INTACC2+1 ; store final remainder lsb 16621 * D0AA 81 16622 RTS ; return 16623 D0AB 16624 include "burner8b.asm" 16625 ;***************************************************************************** 16626 ; Meagasquirt Flash page erase and programming routines msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 135 MC68HC908GP32 User Bootloader 16627 ; heavily based on the routines from boot_r12.asm 16628 ; 16629 ;***************************************************************************** 16630 ; JSM - revised timing for 8MHz 16631 ; 12 Sep 04. Re-enabled interrupts during programming to avoid missing them 16632 ; when burning lots of data. 16633 ; 24 Feb 05, took cli back out again so burner ram can be used within irqs 16634 ; 6 Nov 05 (026j7) Changed hardcoded page from $D0 to $E0 16635 ;------------------------------------------------------------------------------- 16636 ; burnConst: is a PCC compatible FLASH Programming Routine - I think 16637 ;------------------------------------------------------------------------------- 16638 16639 burnConst: D0AB B676 16640 lda flocker D0AD A1CC 16641 cmp #$CC D0AF 2701 16642 beq BURN_CONT D0B1 81 16643 rts 16644 BURN_CONT: D0B2 C60106 16645 lda page D0B5 ABE0 16646 add #$E0 ; hardcoded start of pages D0B7 87 16647 psha D0B8 8A 16648 pulh D0B9 5F 16649 clrx D0BA 3591 16650 sthx burnDst D0BC CDD0E2 16651 jsr ms_EraseFlash ; Erase the first 128 byte block (disables ints) 16652 ; cli D0BF 5591 16653 ldhx burnDst D0C1 AF40 16654 aix #64T D0C3 AF40 16655 aix #64T D0C5 3591 16656 sthx burnDst D0C7 CDD0E2 16657 jsr ms_EraseFlash ; and the second 16658 ; cli D0CA C60106 16659 lda page D0CD ABE0 16660 add #$E0 ; hardcoded start of pages D0CF 87 16661 psha D0D0 8A 16662 pulh D0D1 5F 16663 clrx D0D2 3591 16664 sthx burnDst D0D4 45010F 16665 ldhx #VE_r D0D7 358F 16666 sthx burnSrc 16667 D0D9 A6C8 16668 lda #200T ; burn 200 bytes (was 256) Now 212, NOW 200 for 022xxxxxx D0DB B793 16669 sta burncount 16670 D0DD 8C 16671 clrh D0DE 5F 16672 clrx D0DF CCD0F1 16673 jmp ms_ProgramFlash 16674 16675 ;------------------------------------------------------------------------------- 16676 16677 16678 ;* Single Flash Page Erase Subroutine ====================================== 16679 ;* 16680 ; This subroutine will copy the Flash Erase algorithm into RAM and execute 16681 ; it to erase the page starting at address pointers "burnDst" 16682 ; 16683 ms_EraseFlash: D0E2 450031 16684 ldhx #ms_EraseRamSize ; initialize pointer 16685 ms_EraseFlash1: D0E5 D6D0FF 16686 lda ms_MassErase-1,x ; get program from Flash D0E8 D701EC 16687 sta ram_exec-1,x ; copy into RAM D0EB 5BF8 16688 dbnzx ms_EraseFlash1 ; decrement pointer and loop back until done D0ED 9B 16689 sei D0EE CC01ED 16690 jmp ram_exec ; execute Flash Mass Erase algorithm from RAM 16691 16692 ;* Flash Program Subroutine ================================================ 16693 ;* 16694 ; This subroutine will copy the Flash Program algorithm into RAM and execute it 16695 ; to program 'burncount' bytes from the address pointed to by 'burnSrc' to the 16696 ; address pointed to by "burnDst" 16697 ; 16698 ms_ProgramFlash: D0F1 45004A 16699 ldhx #ms_ProgramRamSize ; initialize pointer 16700 ms_ProgramFlash1: D0F4 D6D125 16701 lda ms_Delay-1,x ; get program from Flash D0F7 D701EC 16702 sta ram_exec-1,x ; copy into RAM D0FA 5BF8 16703 dbnzx ms_ProgramFlash1 ; decrement pointer and loop back until done D0FC 9B 16704 sei D0FD CC01F8 16705 jmp {ram_exec+ms_ProgramRam} 16706 ; 16707 ; 16708 ;* Flash Erase Subroutine ================================================== 16709 ;* 16710 ;* This subroutine performs a single Page Erase @ BurnDst 16711 ;* This subroutine has been 16712 ;* tuned for a bus speed of 7.3728 MHz. 16713 ;* constants revised for 8MHz 16714 ;* This subroutine is copied into and executed from RAM. 16715 ;* 16716 ms_MassErase: D100 5591 16717 ldhx burnDst ; initialize pointer to Flash memory address 16718 16719 ; Set ERASE, read the Flash Block Protect Register and write any data into Flash page. 16720 ; D102 A602 16721 lda #{ERASE} ; set ERASE control bit D104 C7FE08 16722 sta flcr ; in Flash Control Register D107 C6FF7E 16723 lda flbpr ; read from Flash Block Protect Register D10A F7 16724 sta ,x ; write any data to address within page 16725 ; 16726 ; Wait for >10us, then set HVEN. 16727 ; D10B A601 16728 lda #1 ; wait D10D AD17 16729 bsr ms_delay ; for 11.7us (now 11.1) D10F A60A 16730 lda #{ERASE | HVEN} ; set HVEN control bit D111 C7FE08 16731 sta flcr ; in Flash Control Register 16732 ; 16733 ; Wait for >1ms, then clear ERASE. 16734 ; D114 A669 16735 lda #105T ; wait (was 100T) D116 AD0E 16736 bsr ms_delay ; for 1.005ms (now 1.012ms) D118 A608 16737 lda #{HVEN} ; clear ERASE control bit D11A C7FE08 16738 sta flcr ; in Flash Control Register 16739 ; 16740 ; Wait for >5us, then clear HVEN. 16741 ; D11D A601 16742 lda #1 ; wait D11F AD05 16743 bsr ms_delay ; for 11.7us (now 11.1) D121 4F 16744 clra ; clear HVEN control bit D122 C7FE08 16745 sta flcr ; in Flash Control Register 16746 D125 81 16747 rts ; return 16748 16749 16750 ;* Delay Subroutine ======================================================================= 16751 ;* 16752 ;* This subroutine performs a simple software delay loop based upon the value passed in ACC. 16753 ;* The following timing calculation applies: 16754 ;* 16755 ;* was supposed to be delay = ((ACC * 74) + 12) (tcyc) 16756 ;* actually delay = ((ACC * 108) + 12) (tcyc) i.e. longer/safer? delays 16757 ;* now delay = ((ACC * 77) + 12) (tcyc) 16758 ;* 16759 ;* Calling convention: 16760 ;* 16761 ;* lda data 16762 ;* jsr delay msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 136 MC68HC908GP32 User Bootloader 16763 ;* 16764 ;* Returns: nothing 16765 ;* 16766 ;* Changes: ACC 16767 ;* 16768 ms_Delay: D126 87 16769 psha ; [2] save outer delay loop parameter 16770 ms_Delay1: D127 A617 16771 lda #23T ; [2] initialize inner delay loop counter 16772 ms_Delay2: D129 4BFE 16773 dbnza ms_Delay2 ; [3] decrement inner delay loop counter D12B 9E6B01F8 16774 dbnz 1,sp,ms_Delay1 ; [6] decrement outer delay loop counter D12F 86 16775 pula ; [2] deallocate local variable D130 81 16776 rts ; [4] return 16777 D131 16778 ms_EraseRamSize: equ {*-ms_MassErase} D131 16779 ms_ProgramRam: equ {*-ms_Delay} 16780 16781 ;* Flash Program Subroutine =============================================================== 16782 ;* 16783 ;* This subroutine controls the Flash programming sequence. 16784 16785 ms_FlashProgram: 16786 16787 ms_FlashProgram1: 16788 16789 ; Set PGM, read the Flash Block Protect Register and write anywhere in desired Flash row. 16790 ; D131 A601 16791 lda #{PGM} ; set PGM control bit D133 C7FE08 16792 sta flcr ; in Flash Control Register D136 C6FF7E 16793 lda flbpr ; read from Flash Block Protect Register D139 5591 16794 ldhx burnDst D13B F7 16795 sta ,x ; write any data to first Flash address 16796 ; 16797 ; Wait for >10us, then set HVEN. D13C A601 16798 lda #1 ; wait D13E ADE6 16799 bsr ms_delay ; for 11.7us (11.1) D140 A609 16800 lda #{PGM | HVEN} ; set HVEN control bit D142 C7FE08 16801 sta flcr ; in Flash Control Register 16802 ; 16803 ; Wait for >5us. D145 A601 16804 lda #1 ; wait D147 ADDD 16805 bsr ms_delay ; for 11.7us (11.1) 16806 ; 16807 ; Write data to Flash and wait for 30 - 40us. D149 558F 16808 ldhx burnsrc D14B F6 16809 lda ,x ; get data byte D14C 5591 16810 ldhx burndst D14E F7 16811 sta ,x ; write data to Flash D14F A603 16812 lda #3 ; wait D151 ADD3 16813 bsr ms_delay ; for 31.7us (30.3) 16814 ; 16815 ; Clear PGM. D153 A608 16816 lda #{HVEN} ; clear PGM D155 C7FE08 16817 sta flcr ; in Flash Control Register 16818 ; 16819 ; Wait for >5us, then clear HVEN. D158 A601 16820 lda #1 ; wait D15A ADCA 16821 bsr ms_delay ; for 11.7us (11.1) D15C 4F 16822 clra ; clear HVEN control bit D15D C7FE08 16823 sta flcr ; in Flash Control Register 16824 ; 16825 ; Advance destination pointer and decrement data counter. 16826 ; 16827 ms_FlashProgram2: D160 558F 16828 ldhx burnsrc D162 AF01 16829 aix #1 ; advance source pointer D164 358F 16830 sthx BurnSrc D166 5591 16831 ldhx burndst D168 AF01 16832 aix #1 ; advance destination pointer D16A 3591 16833 sthx BurnDst D16C 3B93C2 16834 dbnz burncount,ms_FlashProgram1 ; decrement counter and loop 16835 ; back if not done. D16F 81 16836 rts ; return 16837 D170 16838 ms_ProgramRamSize: equ {*-ms_Delay} 16839 16840 16841 16842 16843 16844 *************************************************************************** 16845 ** 16846 ** Computation of Normalized Variables 16847 ** 16848 ** The following is the form of the evaluation for the normalized variables: 16849 ** 16850 ** (A rem A * B) 16851 ** ------------- = C rem C 16852 ** 100 16853 ** 16854 ** Where A = Whole part of the percentage, 16855 ** rem A = Remainder of A from previous calculation (range 0 to 99) 16856 ** B = Percentage multiplied (this always has a zero remainder) 16857 ** C = Whole part of result 16858 ** rem C = remainder of result 16859 ** 16860 ** 16861 ** Calculation is preformed by the following method: 16862 ** 16863 ** |(A * B) + (rem A * B)| 16864 ** | -----------| 16865 ** | 100 | 16866 ** ----------------------- = C rem C 16867 ** 100 16868 ** 16869 ** 16870 ** Inputs: tmp10 = A 16871 ** tmp11 = rem A 16872 ** tmp12 = B 16873 ** 16874 ** Outputs: tmp10 = C 16875 ** tmp11 = rem C 16876 ** tmp13 = high order part of (A rem A) * B 16877 ** tmp14 = low order part of (A rem A) * B 16878 ** 16879 *************************************************************************** 16880 Supernorm: D170 B69D 16881 lda tmp10 ; A D172 97 16882 tax D173 B69F 16883 lda tmp12 ; B D175 42 16884 mul D176 BFA0 16885 stx tmp13 ; High order of A * B D178 B7A1 16886 sta tmp14 ; Low order of A * B 16887 D17A B69E 16888 lda tmp11 ; rem A D17C 97 16889 tax D17D B69F 16890 lda tmp12 ; B D17F 42 16891 mul D180 89 16892 pshx D181 8A 16893 pulh D182 AE64 16894 ldx #$64 ; 100 D184 52 16895 div 16896 D185 B9A1 16897 adc tmp14 ; Add to lower part D187 B7A1 16898 sta tmp14 ; Store back msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 137 MC68HC908GP32 User Bootloader D189 2402 16899 bcc Roundrem ; Branch is no carry occurred D18B 3CA0 16900 inc tmp13 ; Increment high-order part because 16901 ; an overflow occurred in add 16902 16903 Roundrem: D18D 8B 16904 pshh D18E 86 16905 pula D18F A132 16906 cmp #$32 ; Round if division remainder is 16907 ; greater than 50 D191 930A 16908 ble FinalNorm D193 B6A1 16909 lda tmp14 D195 A901 16910 adc #$01 D197 B7A1 16911 sta tmp14 D199 2402 16912 bcc FinalNorm D19B 3CA0 16913 inc tmp13 16914 16915 16916 FinalNorm: D19D B6A0 16917 lda tmp13 D19F 87 16918 psha D1A0 8A 16919 pulh D1A1 B6A1 16920 lda tmp14 D1A3 AE64 16921 ldx #$64 ; 100 D1A5 52 16922 div D1A6 251A 16923 bcs RailCalc D1A8 B79D 16924 sta tmp10 D1AA 8B 16925 pshh D1AB 86 16926 pula D1AC B79E 16927 sta tmp11 16928 D1AE A132 16929 cmp #$32 ; Round if division remainder is 16930 ; greater than 50 D1B0 9313 16931 ble ExitSN D1B2 B69E 16932 lda tmp11 D1B4 A901 16933 adc #$01 D1B6 B79E 16934 sta tmp11 D1B8 240B 16935 bcc ExitSN D1BA B69D 16936 lda tmp10 D1BC AB01 16937 add #$01 D1BE B79D 16938 sta tmp10 D1C0 2603 16939 bne ExitSN 16940 16941 RailCalc: D1C2 6EFF9D 16942 mov #$FF,tmp10 ; Rail value if rollover 16943 16944 ExitSN: D1C5 81 16945 rts 16946 16947 ****************************************************************************** 16948 ** Nitrous System (P Ringwood) 16949 ** 16950 ** NOS System adds fuel required for extra bhp with NOS, so in theory 16951 ** no extra fueling is needed to be plumbed in. Be Careful, make sure 16952 ** your injectors are capable of the extra. 16953 ** Operates between user min rpm and the user Max, linearly interpolates 16954 ** between the 2 values of PW enrichment depending on RPM, as fuel needed 16955 ** for NOS is a constant over time, not rpm. 16956 ** The system checks for a max duty cycle of 93%, actually cuts around 16957 ** 90% as there is also the opening time to allow for. 16958 ** 16959 ** Added a Turbo Anti-Lag function for NOS. If KPa between setpoints it 16960 ** will fire NOS to boost engine speed and remove some lag from turbo. 16961 ** 16962 ** 16963 *********************************************************************************** 16964 EnableN2O: D1C6 056408 16965 brclr LaunchControl,feature2,enablen2o_cont ; Is Launch selected? D1C9 070367 16966 brclr Launch,portd,Clr_Nos_Out ; Launch on, so nitrous off D1CC C6010C 16967 lda N2Olaunchdel ; check the launch/nitrous delay timer D1CF 2662 16968 bne Clr_Nos_Out ; if non-zero then ensure N2O is off 16969 enablen2o_cont: 16970 D1D1 B64D 16971 lda rpm D1D3 C1E017 16972 cmp NosRpm_f ; Are we above the minimum rpm? D1D6 257B 16973 blo Clr_Nos_Ang ; No, No NOS D1D8 C1E018 16974 cmp NosRpmMax_f D1DB 2276 16975 bhi Clr_Nos_Ang ; Are we above the max rpm? D1DD B647 16976 lda tps D1DF C1E043 16977 cmp NosTps_f ; Is throttle position past the minimum? D1E2 256F 16978 blo Clr_Nos_Ang ; No, no Nos D1E4 B6CC 16979 lda coolant D1E6 C1E016 16980 cmp NosClt_f ; Is the engine warmer than the 16981 ; minimum point? D1E9 2568 16982 blo Clr_Nos_Ang ; No, no Nos D1EB 006645 16983 brset NosDcOk,EnhancedBits,Clr_Nos_Out ; Have we hit 90% DC? D1EE 016705 16984 brclr Traction,EnhancedBits2,Not_AntiRev_NOS ; Have we 16985 ; activated Anti-Rev? D1F1 016502 16986 brclr TractionNos,feature7,Not_AntiRev_NOS ; Have we selected 16987 ; to cut NOS during Anti-Rev? D1F4 205D 16988 bra Clr_Nos_Ang ; Yes so cut NOS during Anti-Rev 16989 Not_AntiRev_NOS: D1F6 C6E04C 16990 lda feature5_f D1F9 A540 16991 bit #NosLagSystemb D1FB 2719 16992 beq Nos_IP_Checked ; Have we selected 16993 ; Anti-lag? D1FD 0B6605 16994 brclr NosSysReady,EnhancedBits,Which_io_First ; If NOS 16995 ; not ready yet is the input on? D200 086607 16996 brset NosAntiLag,EnhancedBits,Anti_Lag ; If antilag bit 16997 ; set then do Anti-lag checks D203 2011 16998 bra Nos_IP_Checked ; Were in normal NOS mode 16999 17000 ; Check if input on before the output, then were in anti-lag mode 17001 Which_io_First: D205 02030E 17002 brset NosIn,portd,Nos_IP_Checked ; If input not on then 17003 ; were in normal mode D208 1866 17004 bset NosAntiLag,EnhancedBits ; We are in Anti-lag 17005 ; mode so set the bit 17006 Anti_Lag: D20A B6CB 17007 lda kpa D20C C1E055 17008 cmp NosLowKpa_f ; In anti-lag mode so are we 17009 ; above min KPa? D20F 2522 17010 blo Clr_Nos_Out D211 C1E056 17011 cmp NosHiKPa_f ; are we above max KPa? D214 221D 17012 bhi Clr_Nos_Out 17013 17014 ; Check if we need to retard Ignition with NOS Angle 17015 Nos_IP_Checked: D216 1A66 17016 bset NosSysReady,EnhancedBits; NOS System ready to go D218 1800 17017 bset water2,porta ; Turn Nos output on D21A 020328 17018 brset NosIn,portd,Clr_Nos_Angle ; Is the Input for NOS 17019 ; SET? (low=on) D21D 1266 17020 bset NosSysOn,EnhancedBits ; NOS System Is Running D21F C6E04C 17021 lda feature5_f D222 A580 17022 bit #SparkTable2b D224 263F 17023 bne Nos_Lin ; Are we using ST2? D226 A6FF 17024 lda #255T ; D228 C0E044 17025 sub NosAngle_f ; (255-NOS Angle) turns it into 17026 ; a retard angle D22B A1AA 17027 cmp #$aa ; Limit the retard to 30 degrees 17028 ; (plenty) D22D 2233 17029 bhi StoreNos D22F A6AA 17030 lda #$aa D231 202F 17031 bra StoreNos 17032 Clr_Nos_Out: D233 1900 17033 bclr water2,porta ; Turn off the output as we've 17034 ; hit 90% DC or Anti-lag over setpoints msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 138 MC68HC908GP32 User Bootloader D235 A600 17035 lda #$00 D237 C7010A 17036 sta NosPW ; Clear Nos PW and Angle D23A C70109 17037 sta NitrousAngle D23D 1366 17038 bclr NosSysOn,EnhancedBits ; Clear the Nos running bit D23F 1966 17039 bclr NosAntiLag,EnhancedBits ; Clear the antilag bit D241 1B66 17040 bclr NosSysReady,EnhancedBits; Clear the ready bit D243 2040 17041 bra Nos_Done 17042 Clr_Nos_Angle: D245 1366 17043 bclr NosSysOn,EnhancedBits ; Clear the Nos Running Bit D247 1966 17044 bclr NosAntiLag,EnhancedBits ; Clear the antilag bit D249 A600 17045 lda #$00 ; Clear the Nos angle D24B C70109 17046 sta NitrousAngle D24E C7010A 17047 sta NosPW ; Clear the NosPW D251 2032 17048 bra Nos_Done ; Dont clear the output 17049 Clr_Nos_Ang: D253 1366 17050 bclr NosSysOn,EnhancedBits ; Clear the Nos Running Bit D255 A600 17051 lda #$00 ; Clear the Nos angle D257 C70109 17052 sta NitrousAngle D25A 1B66 17053 bclr NosSysReady,EnhancedBits; Clear the ready bit D25C 1166 17054 bclr NosDcOk,EnhancedBits ; Clear the NOS DC check bit D25E 1966 17055 bclr NosAntiLag,EnhancedBits ; Clear the antilag bit D260 205B 17056 bra Clr_Nos_SystemJMP 17057 StoreNos: D262 C70109 17058 sta NitrousAngle ; Store the Angle to retard by for NOS 17059 Nos_Lin: 17060 *************************************************************************** 17061 ** 17062 ** Linear Interpolation - for finding PW for NOS. 17063 ** Added this as using the original screwed the Spark Angle up. (P. Ringwood) 17064 ** Ripped off from the original. 17065 ** 17066 ** (y2 - y1) 17067 ** Y = Y1 + --------- * (x - x1) 17068 ** (x2 - x1) 17069 ** 17070 ** 3000rpm = x1 17071 ** NosRpmMax = x2 17072 ** NosFuelLo = y1 17073 ** NosFuelHi = y2 17074 ** rpm = x 17075 ** NosPW = y 17076 *************************************************************************** D265 3F9A 17077 clr tmp7 ; This is the negative slope 17078 ; detection bit D267 C6E045 17079 lda NosFuelLo_f ; Store the minimum PW incase 17080 ; we are lower than 3000rpm D26A C7010A 17081 sta NosPW D26D B64D 17082 lda rpm D26F C1E017 17083 cmp NosRpm_f ; Are we above Min RPM for NOS? D272 2202 17084 bhi Are_We_Higher ; No so check if we are too high D274 2058 17085 bra End_Interpole ; Yes so end with minimum rpm 17086 ; value in NosPW 17087 Are_We_Higher: D276 B64D 17088 lda rpm D278 C1E018 17089 cmp NosRpmMax_f ; Are we above the max RPM? D27B 250A 17090 blo INTERP_PW ; No so interpolate values D27D C6E046 17091 lda NosFuelHi_f ; We are above max rpm, so 17092 ; store max rpm PW in NosPW D280 C7010A 17093 sta NosPW D283 2049 17094 bra End_Interpole ; End Interpolting 17095 Nos_Done: D285 2079 17096 bra Nos_Done_Now ; Added a jump as too far. 17097 INTERP_PW: D287 C6E045 17098 lda NosFuelLo_f ; Store min rpm nos PW in NosPW D28A C7010A 17099 sta NosPW D28D C6E018 17100 lda NosRpmMax_f D290 C0E017 17101 sub NosRpm_f ; Make sure settings are correctly set D293 2739 17102 beq End_Interpole ; Settings wrong so end with min 17103 ; rpm PW in NosPW D295 87 17104 psha D296 C6E046 17105 lda NosFuelHi_f D299 C0E045 17106 sub NosFuelLo_f ; Are we doing a positive interpole? D29C 2403 17107 bcc Interpole_Plus D29E 40 17108 nega D29F 3C9A 17109 inc tmp7 17110 Interpole_Plus: D2A1 87 17111 psha D2A2 B64D 17112 lda rpm D2A4 C0E017 17113 sub NosRpm_f ; Find out difference in rpm and 17114 ; min setpoint D2A7 2723 17115 beq ZERO_Interpole D2A9 88 17116 pulx D2AA 42 17117 mul D2AB 89 17118 pshx D2AC 8A 17119 pulh D2AD 88 17120 pulx D2AE 52 17121 div D2AF 87 17122 psha D2B0 B69A 17123 lda tmp7 D2B2 260B 17124 bne NEG_Interpole ; Are we doing a negative 17125 ; sloped interpolation? D2B4 86 17126 pula D2B5 CBE045 17127 add NosFuelLo_f D2B8 C7010A 17128 sta NosPW D2BB 2011 17129 bra End_Interpole 17130 17131 Clr_Nos_SystemJMP: D2BD 203A 17132 bra Clr_Nos_System 17133 17134 NEG_Interpole: D2BF 86 17135 pula D2C0 B79A 17136 sta tmp7 D2C2 C6E045 17137 lda NosFuelLo_f D2C5 B09A 17138 sub tmp7 D2C7 C7010A 17139 sta NosPW D2CA 2002 17140 bra End_Interpole 17141 ZERO_Interpole: D2CC 86 17142 pula ;clean stack D2CD 86 17143 pula ;clean stack 17144 End_Interpole: 17145 17146 ; Check if weve hit 90% Duty Cycle with NOS PW D2CE 8C 17147 clrh D2CF CEE195 17148 ldx DIVIDER_f1 ; Load x with the divider D2D2 C6E196 17149 lda Alternate_f1 ; Are we in alternating mode? D2D5 2701 17150 beq multi_it D2D7 58 17151 lslx ; Yes so multiply divider by 2 17152 multi_it: D2D8 B671 17153 lda rpmpl D2DA 42 17154 mul ; Accumulator now contains time 17155 ; between squirts D2DB A300 17156 cpx #00T ; 17157 ;; this was in error bne Stop_Nos D2DD 2621 17158 bne Nos_Done_Now ; if period > 25.5ms then must 17159 ; be ok as that is our max pulse D2DF AEED 17160 ldx #237T ; 90% (230/256=0.9) 237 allows 17161 ; for opening time D2E1 42 17162 mul D2E2 C6E042 17163 lda feature4_f D2E5 A520 17164 bit #DtNosb D2E7 2607 17165 bne Check_PW2 ; If were using Bank 2 17166 ;then check PW2 D2E9 9F 17167 txa D2EA B14E 17168 cmp pw1 ; Are we over 90%? D2EC 2509 17169 blo Stop_Nos D2EE 2010 17170 bra Nos_Done_Now ; No so dont cut out NOS System msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 139 MC68HC908GP32 User Bootloader 17171 Check_PW2: D2F0 9F 17172 txa D2F1 B153 17173 cmp pw2 ; Are we over 90%? D2F3 2502 17174 blo Stop_Nos D2F5 2009 17175 bra Nos_Done_Now ; No so dont cut out NOS System 17176 Stop_Nos: D2F7 1066 17177 bset NosDcOk,EnhancedBits ; We are over 90 DC so cut 17178 ; NOS System out 17179 Clr_Nos_System: D2F9 1900 17180 bclr water2,porta ; Turn off the Nos output 17181 Clr_Nos_PW: D2FB A600 17182 lda #00T D2FD C7010A 17183 sta NosPW ; Clear the Nos PW 17184 Nos_Done_Now: 17185 D300 81 17186 rts 17187 17188 ****************************************************************************** 17189 ** Check if were ready to use VE Table 3 17190 ****************************************************************************** 17191 17192 Check_VE3_Table: D301 0F6309 17193 brclr Nitrous,feature1,Check_VE3_NOS ; Are we using NOS? D304 03660C 17194 brclr NosSysOn,EnhancedBits,Check_VE3_Done ; NOS Mode not ready. D307 020309 17195 brset NosIn,portd,Check_VE3_Done ; If input not low dont 17196 ; use VE 3 D30A 1C66 17197 bset UseVE3,EnhancedBits D30C 81 17198 rts 17199 Check_VE3_NOS: D30D 020303 17200 brset NosIn,portd,Check_VE3_Done ; If input not low dont 17201 ; use VE 3 D310 1C66 17202 bset UseVE3,EnhancedBits D312 81 17203 rts 17204 Check_VE3_Done: D313 1D66 17205 bclr UseVE3,EnhancedBits D315 81 17206 rts 17207 17208 ****************************************************************************** 17209 ** 8x8 Target AFR Tables P Ringwood *** 17210 ** AFR Table 1 is for VE table 1 AFR Table 2 is for VE table 3 *** 17211 ****************************************************************************** 17212 AFR1_Targets: D316 0C6607 17213 brset useVE3,EnhancedBits,No_AFR_ForVE1 ; If were running 17214 ; VE3 then no need to go any further D319 B682 17215 lda EGOcount ; Are we about to check the ego? D31B C1E191 17216 cmp EGOcountcmp_f D31E 2701 17217 beq Do_Targets ; If yes then get the target from 17218 ; the table 17219 No_AFR_ForVE1: D320 81 17220 rts ; If No then return, this saves 17221 ; wasting time. 17222 17223 Do_Targets: ; VE 1 Targets from AFR Table 1 D321 0B650D 17224 brclr TPSTargetAFR,feature7,NO_TPS_SetAFR1 ; Have we selected 17225 ; to go to targets above tps setpoint? D324 B647 17226 lda tps D326 C1E079 17227 cmp AFRTarTPS_f D329 2206 17228 bhi NO_TPS_SetAFR1 ; If tps higher than setpoint then 17229 ; do tables D32B C6E1BB 17230 lda O2targetV_f ; If not load in target from 17231 ; enrichments page D32E B759 17232 sta afrTarget D330 81 17233 rts 17234 17235 NO_TPS_SetAFR1: D331 8C 17236 clrh D332 5F 17237 clrx D333 086504 17238 brset AlphaTarAFR,feature7,AFR1_AN ; Have we selected to use 17239 ; tps for target afrs instead of kpa? 17240 D336 B6CB 17241 lda kpa ; Normal Speed density D338 2002 17242 bra AFR1_STEP_1 17243 17244 AFR1_AN: D33A B647 17245 lda tps 17246 17247 AFR1_STEP_1: D33C B7DB 17248 sta kpa_n D33E 45E648 17249 ldhx #KPARANGEAFR_f1 D341 3594 17250 sthx tmp1 D343 A607 17251 lda #$07 ; 8x8 D345 B796 17252 sta tmp3 D347 B6DB 17253 lda kpa_n D349 B797 17254 sta tmp4 D34B CDCF9B 17255 jsr tableLookup D34E B694 17256 lda tmp1 D350 B695 17257 lda tmp2 D352 4E989B 17258 mov tmp5,tmp8 ; Index D355 4E949C 17259 mov tmp1,tmp9 ; X1 D358 4E959D 17260 mov tmp2,tmp10 ; X2 17261 17262 AFR1_STEP_2: D35B 45E640 17263 ldhx #RPMRANGEAFR_f1 D35E 3594 17264 sthx tmp1 D360 6E0796 17265 mov #$07,tmp3 ; 8x8 D363 4E4D97 17266 mov rpm,tmp4 D366 CDCF9B 17267 jsr tableLookup D369 4E989E 17268 mov tmp5,tmp11 ; Index D36C 4E94A0 17269 mov tmp1,tmp13 ; X1 D36F 4E95A1 17270 mov tmp2,tmp14 ; X2 17271 17272 AFR1_STEP_3: D372 8C 17273 clrh D373 AE08 17274 ldx #$08 ; 8x8 D375 B69B 17275 lda tmp8 D377 4A 17276 deca D378 42 17277 mul D379 BB9E 17278 add tmp11 D37B 4A 17279 deca D37C 97 17280 tax D37D macro 17281 AFR1X D37D C60106 17282 LDA PAGE D380 A106 17283 CMP #06T D382 2605 17284 BNE VE6XF D384 D6010F 17285 LDA VE_R,X D387 2003 17286 BRA VE6XC D389 D6E600 17287 VE6XF: LDA AFR_F1,X 17288 VE6XC: D38C B7A2 17289 sta tmp15 D38E 5C 17290 incx D38F macro 17291 AFR1X D38F C60106 17292 LDA PAGE D392 A106 17293 CMP #06T D394 2605 17294 BNE VE6XF D396 D6010F 17295 LDA VE_R,X D399 2003 17296 BRA VE6XC D39B D6E600 17297 VE6XF: LDA AFR_F1,X 17298 VE6XC: D39E B7A3 17299 sta tmp16 D3A0 AE08 17300 ldx #$08 ; 8x8 D3A2 B69B 17301 lda tmp8 D3A4 42 17302 mul D3A5 BB9E 17303 add tmp11 D3A7 4A 17304 deca D3A8 97 17305 tax D3A9 macro 17306 AFR1X msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 140 MC68HC908GP32 User Bootloader D3A9 C60106 17307 LDA PAGE D3AC A106 17308 CMP #06T D3AE 2605 17309 BNE VE6XF D3B0 D6010F 17310 LDA VE_R,X D3B3 2003 17311 BRA VE6XC D3B5 D6E600 17312 VE6XF: LDA AFR_F1,X 17313 VE6XC: D3B8 B7A4 17314 sta tmp17 D3BA 5C 17315 incx D3BB macro 17316 AFR1X D3BB C60106 17317 LDA PAGE D3BE A106 17318 CMP #06T D3C0 2605 17319 BNE VE6XF D3C2 D6010F 17320 LDA VE_R,X D3C5 2003 17321 BRA VE6XC D3C7 D6E600 17322 VE6XF: LDA AFR_F1,X 17323 VE6XC: D3CA B7A5 17324 sta tmp18 D3CC CD9DC9 17325 jsr VE_STEP_4 D3CF 4E9959 17326 mov tmp6,afrTarget D3D2 81 17327 rts 17328 17329 ***************************************************************************** 17330 ** VE 3 Targets from AFR Table 2 17331 ***************************************************************************** 17332 AFR2_Targets: D3D3 0D6607 17333 brclr useVE3,EnhancedBits,No_AFR_ForVE3 ; If were not running 17334 ;VE3 then no need to go any further D3D6 B682 17335 lda EGOcount ; Are we about to check the ego? D3D8 C1E191 17336 cmp EGOcountcmp_f D3DB 2701 17337 beq Do_Targets2 ; If yes then get the target from 17338 ; the table 17339 No_AFR_ForVE3: D3DD 81 17340 rts ; If No then return, this saves 17341 ; wasting time. 17342 17343 Do_Targets2: D3DE 0B650D 17344 brclr TPSTargetAFR,feature7,NO_TPS_SetAFR2 ; Have we selected 17345 ; to go to targets above tps setpoint? D3E1 B647 17346 lda tps D3E3 C1E079 17347 cmp AFRTarTPS_f D3E6 2206 17348 bhi NO_TPS_SetAFR2 ; If tps higher than setpoint 17349 ; then do tables D3E8 C6E1BB 17350 lda O2targetV_f ; If not load in target from 17351 ; enrichments page D3EB B759 17352 sta afrTarget D3ED 81 17353 rts 17354 17355 NO_TPS_SetAFR2: D3EE 8C 17356 clrh D3EF 5F 17357 clrx D3F0 0A6504 17358 brset TPSTargetAFR,feature7,AFR2_AN ; Have we selected to use 17359 ; tps for target afrs instead of kpa? D3F3 B6CB 17360 lda kpa D3F5 2002 17361 bra AFR2_STEP_1 17362 AFR2_AN: D3F7 B647 17363 lda tps 17364 17365 AFR2_STEP_1: D3F9 B7DB 17366 sta kpa_n D3FB 45E698 17367 ldhx #KPARANGEAFR_f2 D3FE 3594 17368 sthx tmp1 D400 A607 17369 lda #$07 ; 8x8 D402 B796 17370 sta tmp3 D404 B6DB 17371 lda kpa_n D406 B797 17372 sta tmp4 D408 CDCF9B 17373 jsr tableLookup D40B B694 17374 lda tmp1 D40D B695 17375 lda tmp2 D40F 4E989B 17376 mov tmp5,tmp8 ; Index D412 4E949C 17377 mov tmp1,tmp9 ; X1 D415 4E959D 17378 mov tmp2,tmp10 ; X2 17379 17380 AFR2_STEP_2: D418 45E690 17381 ldhx #RPMRANGEAFR_f2 D41B 3594 17382 sthx tmp1 D41D 6E0796 17383 mov #$07,tmp3 ; 8x8 D420 4E4D97 17384 mov rpm,tmp4 D423 CDCF9B 17385 jsr tableLookup D426 4E989E 17386 mov tmp5,tmp11 ; Index D429 4E94A0 17387 mov tmp1,tmp13 ; X1 D42C 4E95A1 17388 mov tmp2,tmp14 ; X2 17389 17390 AFR2_STEP_3: D42F 8C 17391 clrh D430 AE08 17392 ldx #$08 ; 8x8 D432 B69B 17393 lda tmp8 D434 4A 17394 deca D435 42 17395 mul D436 BB9E 17396 add tmp11 D438 4A 17397 deca D439 97 17398 tax D43A macro 17399 AFR2X D43A C60106 17400 LDA PAGE D43D A107 17401 CMP #07T D43F 2605 17402 BNE VE7XF D441 D6010F 17403 LDA VE_R,X D444 2003 17404 BRA VE7XC D446 D6E650 17405 VE7XF: LDA AFR_F2,X 17406 VE7XC: D449 B7A2 17407 sta tmp15 D44B 5C 17408 incx D44C macro 17409 AFR2X D44C C60106 17410 LDA PAGE D44F A107 17411 CMP #07T D451 2605 17412 BNE VE7XF D453 D6010F 17413 LDA VE_R,X D456 2003 17414 BRA VE7XC D458 D6E650 17415 VE7XF: LDA AFR_F2,X 17416 VE7XC: D45B B7A3 17417 sta tmp16 D45D AE08 17418 ldx #$08 ; 8x8 D45F B69B 17419 lda tmp8 D461 42 17420 mul D462 BB9E 17421 add tmp11 D464 4A 17422 deca D465 97 17423 tax D466 macro 17424 AFR2X D466 C60106 17425 LDA PAGE D469 A107 17426 CMP #07T D46B 2605 17427 BNE VE7XF D46D D6010F 17428 LDA VE_R,X D470 2003 17429 BRA VE7XC D472 D6E650 17430 VE7XF: LDA AFR_F2,X 17431 VE7XC: D475 B7A4 17432 sta tmp17 D477 5C 17433 incx D478 macro 17434 AFR2X D478 C60106 17435 LDA PAGE D47B A107 17436 CMP #07T D47D 2605 17437 BNE VE7XF D47F D6010F 17438 LDA VE_R,X D482 2003 17439 BRA VE7XC D484 D6E650 17440 VE7XF: LDA AFR_F2,X 17441 VE7XC: D487 B7A5 17442 sta tmp18 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 141 MC68HC908GP32 User Bootloader D489 CD9DC9 17443 jsr VE_STEP_4 D48C 4E9959 17444 mov tmp6,afrTarget D48F 81 17445 rts 17446 17447 ;------------------------------------------------------------------ 17448 ;now error messages. Exact postion in memory not important 17449 error_vector: D490 D4AA 17450 dw error_msg0 D492 D4C5 17451 dw error_msg1 D494 D509 17452 dw error_msg2 D496 D546 17453 dw error_msg3 D498 D588 17454 dw error_msg4 D49A D5D3 17455 dw error_msg5 D49C D61B 17456 dw error_msg6 D49E D668 17457 dw error_msg7 D4A0 D6B7 17458 dw error_msg8 D4A2 D6FB 17459 dw error_msg9 D4A4 D740 17460 dw error_msg10 D4A6 D783 17461 dw error_msg11 D4A8 D7C4 17462 dw error_msg12 17463 17464 error_msg0: D4AA 496E7465 17465 db 'Internal error message 0' 726E616C 20657272 6F72206D 65737361 67652030 D4C2 0D0A00 17466 db 13T,10T,0 17467 error_msg1: D4C5 596F7520 17468 db 'You have defined a spark mode but no outputs are defined as spark' 68617665 20646566 696E6564 20612073 7061726B 206D6F64 65206275 74206E6F 206F7574 70757473 20617265 20646566 696E6564 20617320 73706172 6B D506 0D0A00 17469 db 13T,10T,0 17470 error_msg2: D509 4966204E 17471 db 'If Neon mode is set you must set LED17+19 to spark outputs' 656F6E20 6D6F6465 20697320 73657420 796F7520 6D757374 20736574 204C4544 31372B31 3920746F 20737061 726B206F 75747075 7473 D543 0D0A00 17472 db 13T,10T,0 17473 error_msg3: D546 4966204D 17474 db 'If MSnS mode is set you must set LED17 or FIDLE as spark output' 536E5320 6D6F6465 20697320 73657420 796F7520 6D757374 20736574 204C4544 3137206F 72204649 444C4520 61732073 7061726B 206F7574 707574 D585 0D0A00 17475 db 13T,10T,0 17476 error_msg4: D588 596F7520 17477 db 'You cannot use FIDLE for spark control and idle control at the same time' 63616E6E 6F742075 73652046 49444C45 20666F72 20737061 726B2063 6F6E7472 6F6C2061 6E642069 646C6520 636F6E74 726F6C20 61742074 68652073 616D6520 74696D65 D5D0 0D0A00 17478 db 13T,10T,0 17479 error_msg5: D5D3 596F7520 17480 db 'You cannot use X2 as water injection and fan control at the same time' 63616E6E 6F742075 73652058 32206173 20776174 65722069 6E6A6563 74696F6E 20616E64 2066616E 20636F6E 74726F6C 20617420 74686520 73616D65 2074696D 65 D618 0D0A00 17481 db 13T,10T,0 17482 error_msg6: D61B 596F7520 17483 db 'You cannot use X4 for water injection and nitrous control at the same time' 63616E6E 6F742075 73652058 3420666F 72207761 74657220 696E6A65 6374696F 6E20616E 64206E69 74726F75 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 142 MC68HC908GP32 User Bootloader 7320636F 6E74726F 6C206174 20746865 2073616D 65207469 6D65 D665 0D0A00 17484 db 13T,10T,0 17485 error_msg7: D668 496E2048 17486 db 'In HEI7 mode you must have LED19 set as a spark output for the bypass signal' 45493720 6D6F6465 20796F75 206D7573 74206861 7665204C 45443139 20736574 20617320 61207370 61726B20 6F757470 75742066 6F722074 68652062 79706173 73207369 676E616C D6B4 0D0A00 17487 db 13T,10T,0 17488 error_msg8: D6B7 436F6E66 17489 db 'Config error with spark outputs or wheel decoder trigger settings' 69672065 72726F72 20776974 68207370 61726B20 6F757470 75747320 6F722077 6865656C 20646563 6F646572 20747269 67676572 20736574 74696E67 73 D6F8 0D0A00 17490 db 13T,10T,0 17491 error_msg9: D6FB 43616E6E 17492 db 'Cannot use FIDLE as a spark output if doing wheel decoding or Neon' 6F742075 73652046 49444C45 20617320 61207370 61726B20 6F757470 75742069 6620646F 696E6720 77686565 6C206465 636F6469 6E67206F 72204E65 6F6E D73D 0D0A00 17493 db 13T,10T,0 17494 error_msg10: D740 466F7220 17495 db 'For rotary trailing you must define LED17,18,19 as spark outputs' 726F7461 72792074 7261696C 696E6720 796F7520 6D757374 20646566 696E6520 4C454431 372C3138 2C313920 61732073 7061726B 206F7574 70757473 D780 0D0A00 17496 db 13T,10T,0 17497 error_msg11: D783 466F7220 17498 db 'For rotary trailing you must define two wheel decoder triggers' 726F7461 72792074 7261696C 696E6720 796F7520 6D757374 20646566 696E6520 74776F20 77686565 6C206465 636F6465 72207472 69676765 7273 D7C1 0D0A00 17499 db 13T,10T,0 17500 error_msg12: D7C4 526F7461 17501 db 'Rotary trailing requires the wheel decoder enabled and configured' 72792074 7261696C 696E6720 72657175 69726573 20746865 20776865 656C2064 65636F64 65722065 6E61626C 65642061 6E642063 6F6E6669 67757265 64 D805 0D0A00 17502 db 13T,10T,0 17503 17504 ;-------------- 17505 ;------------------------------------------------------------------ 17506 ; ; Constants not possible to burn 17507 17508 ; This is used to set the bin coolant range for WWU 17509 WWURANGE: D808 00 17510 db 0T D809 14 17511 db 20T D80A 28 17512 db 40T D80B 3C 17513 db 60T D80C 50 17514 db 80T D80D 64 17515 db 100T D80E 78 17516 db 120T msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 143 MC68HC908GP32 User Bootloader D80F 8C 17517 db 140T D810 AA 17518 db 170T D811 C8 17519 db 200T 17520 17521 D812 00 17522 REVNUM: db 00T ; not used, always zero D813 4D656761 17523 textversion_f: db 'MegasquirtnSpark Extra 027b ****' ; full code release 73717569 72746E53 7061726B 20457874 72612030 32376220 2A2A2A2A D833 4D536E53 17524 Signature: db 'MSnS-extra format 027a *********' ; data format for 2D657874 72612066 6F726D61 74203032 3761202A 2A2A2A2A 2A2A2A2A 17525 ; ini file matching, ONLY change this if the data format changed. 17526 ;must be 32 chars '12345678901234567890123456789012' ; (may change to 20) 17527 17528 rpmdotrate: D853 03 17529 db 3T ; 3,000 rpm delta D854 04 17530 db 4T ; 4,000 D855 06 17531 db 6T ; 6,000 D856 0A 17532 db 10T ; 10,000 17533 sliprate: D857 05 17534 db 05T ; 5% slip from driven wheels D858 0F 17535 db 15T ; 15% D859 1E 17536 db 30T ; 30% D85A 46 17537 db 70T ; 70% 17538 17539 end_of_main: ; check this var to ensure it does not exceed $DFFF 17540 17541 ;------------------------------------------------------------------ 17542 FAC3 17543 org $FAC3 ; start of bootloader-defined 17544 ; jump table/vector FAC3 12 17545 db $12 ; scbr regi init value FAC4 01 17546 db %00000001 ; config1 FAC5 01 17547 db %00000001 ; config2 FAC6 8128 17548 dw start ; megasquirt code start FAC8 FB00 17549 dw $FB00 ; bootloader start 17550 17551 ; Vector table 17552 ; org vec_timebase 17553 17554 17555 FACA CC 17556 db $CC FACB CF9A 17557 dw Dummy ; Timebase FACD CC 17558 db $CC FACE CBB9 17559 dw ADCDONE ; ADC Conversion Complete FAD0 CC 17560 db $CC FAD1 CF9A 17561 dw Dummy ; Keyboard pin FAD3 CC 17562 db $CC FAD4 CDE3 17563 dw IN_SCI_TX ; SCI transmission complete/ 17564 ; transmitter empty FAD6 CC 17565 db $CC FAD7 CC22 17566 dw IN_SCI_RCV ; SCI input idle/receiver full FAD9 CC 17567 db $CC FADA CF9A 17568 dw Dummy ; SCI parity/framing/noise/ 17569 ; receiver_overrun error FADC CC 17570 db $CC FADD CF9A 17571 dw Dummy ; SPI Transmitter empty FADF CC 17572 db $CC FAE0 CF9A 17573 dw Dummy ; SPI mode/overflow/receiver full FAE2 CC 17574 db $CC FAE3 CF8F 17575 dw T2Overflow ; TIM2 overflow FAE5 CC 17576 db $CC FAE6 B334 17577 dw SPARKTIME ; TIM2 Ch1 FAE8 CC 17578 db $CC FAE9 A89D 17579 dw TIMERROLL ; TIM2 Ch 0 FAEB CC 17580 db $CC FAEC CF9A 17581 dw Dummy ; TIM1 overflow FAEE CC 17582 db $CC FAEF CF9A 17583 dw Dummy ; TIM1 Ch1 FAF1 CC 17584 db $CC FAF2 CF9A 17585 dw Dummy ; TIM Ch0 FAF4 CC 17586 db $CC FAF5 CF9A 17587 dw Dummy ; CGM FAF7 CC 17588 db $CC FAF8 BCD0 17589 dw DOSQUIRT ; IRQ FAFA CC 17590 db $CC FAFB CF9A 17591 dw Dummy ; SWI FAFD CC 17592 db $CC FAFE 8128 17593 dw Start 17594 17595 17596 ;------------------------------------------------------------------ 17597 ; Lookup Tables F100 17598 org $F100 F100 17599 include "barofactor4115.inc" 17600 BAROFAC4115: F100 64 17601 DB 100T F101 8D 17602 DB 141T F102 8D 17603 DB 141T F103 8D 17604 DB 141T F104 8D 17605 DB 141T F105 8D 17606 DB 141T F106 8C 17607 DB 140T F107 8C 17608 DB 140T F108 8C 17609 DB 140T F109 8C 17610 DB 140T F10A 8B 17611 DB 139T F10B 8B 17612 DB 139T F10C 8B 17613 DB 139T F10D 8B 17614 DB 139T F10E 8B 17615 DB 139T F10F 8A 17616 DB 138T F110 8A 17617 DB 138T F111 8A 17618 DB 138T F112 8A 17619 DB 138T F113 8A 17620 DB 138T F114 89 17621 DB 137T F115 89 17622 DB 137T F116 89 17623 DB 137T F117 89 17624 DB 137T F118 89 17625 DB 137T F119 88 17626 DB 136T F11A 88 17627 DB 136T F11B 88 17628 DB 136T F11C 88 17629 DB 136T F11D 88 17630 DB 136T F11E 87 17631 DB 135T F11F 87 17632 DB 135T F120 87 17633 DB 135T F121 87 17634 DB 135T F122 87 17635 DB 135T F123 86 17636 DB 134T F124 86 17637 DB 134T F125 86 17638 DB 134T msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 144 MC68HC908GP32 User Bootloader F126 86 17639 DB 134T F127 86 17640 DB 134T F128 85 17641 DB 133T F129 85 17642 DB 133T F12A 85 17643 DB 133T F12B 85 17644 DB 133T F12C 85 17645 DB 133T F12D 84 17646 DB 132T F12E 84 17647 DB 132T F12F 84 17648 DB 132T F130 84 17649 DB 132T F131 84 17650 DB 132T F132 83 17651 DB 131T F133 83 17652 DB 131T F134 83 17653 DB 131T F135 83 17654 DB 131T F136 82 17655 DB 130T F137 82 17656 DB 130T F138 82 17657 DB 130T F139 82 17658 DB 130T F13A 82 17659 DB 130T F13B 81 17660 DB 129T F13C 81 17661 DB 129T F13D 81 17662 DB 129T F13E 81 17663 DB 129T F13F 81 17664 DB 129T F140 80 17665 DB 128T F141 80 17666 DB 128T F142 80 17667 DB 128T F143 80 17668 DB 128T F144 80 17669 DB 128T F145 7F 17670 DB 127T F146 7F 17671 DB 127T F147 7F 17672 DB 127T F148 7F 17673 DB 127T F149 7F 17674 DB 127T F14A 7E 17675 DB 126T F14B 7E 17676 DB 126T F14C 7E 17677 DB 126T F14D 7E 17678 DB 126T F14E 7E 17679 DB 126T F14F 7D 17680 DB 125T F150 7D 17681 DB 125T F151 7D 17682 DB 125T F152 7D 17683 DB 125T F153 7D 17684 DB 125T F154 7C 17685 DB 124T F155 7C 17686 DB 124T F156 7C 17687 DB 124T F157 7C 17688 DB 124T F158 7C 17689 DB 124T F159 7B 17690 DB 123T F15A 7B 17691 DB 123T F15B 7B 17692 DB 123T F15C 7B 17693 DB 123T F15D 7A 17694 DB 122T F15E 7A 17695 DB 122T F15F 7A 17696 DB 122T F160 7A 17697 DB 122T F161 7A 17698 DB 122T F162 79 17699 DB 121T F163 79 17700 DB 121T F164 79 17701 DB 121T F165 79 17702 DB 121T F166 79 17703 DB 121T F167 78 17704 DB 120T F168 78 17705 DB 120T F169 78 17706 DB 120T F16A 78 17707 DB 120T F16B 78 17708 DB 120T F16C 77 17709 DB 119T F16D 77 17710 DB 119T F16E 77 17711 DB 119T F16F 77 17712 DB 119T F170 77 17713 DB 119T F171 76 17714 DB 118T F172 76 17715 DB 118T F173 76 17716 DB 118T F174 76 17717 DB 118T F175 76 17718 DB 118T F176 75 17719 DB 117T F177 75 17720 DB 117T F178 75 17721 DB 117T F179 75 17722 DB 117T F17A 75 17723 DB 117T F17B 74 17724 DB 116T F17C 74 17725 DB 116T F17D 74 17726 DB 116T F17E 74 17727 DB 116T F17F 74 17728 DB 116T F180 73 17729 DB 115T F181 73 17730 DB 115T F182 73 17731 DB 115T F183 73 17732 DB 115T F184 73 17733 DB 115T F185 72 17734 DB 114T F186 72 17735 DB 114T F187 72 17736 DB 114T F188 72 17737 DB 114T F189 71 17738 DB 113T F18A 71 17739 DB 113T F18B 71 17740 DB 113T F18C 71 17741 DB 113T F18D 71 17742 DB 113T F18E 70 17743 DB 112T F18F 70 17744 DB 112T F190 70 17745 DB 112T F191 70 17746 DB 112T F192 70 17747 DB 112T F193 6F 17748 DB 111T F194 6F 17749 DB 111T F195 6F 17750 DB 111T F196 6F 17751 DB 111T F197 6F 17752 DB 111T F198 6E 17753 DB 110T F199 6E 17754 DB 110T F19A 6E 17755 DB 110T F19B 6E 17756 DB 110T F19C 6E 17757 DB 110T F19D 6D 17758 DB 109T F19E 6D 17759 DB 109T F19F 6D 17760 DB 109T F1A0 6D 17761 DB 109T F1A1 6D 17762 DB 109T F1A2 6C 17763 DB 108T F1A3 6C 17764 DB 108T F1A4 6C 17765 DB 108T F1A5 6C 17766 DB 108T F1A6 6C 17767 DB 108T F1A7 6B 17768 DB 107T F1A8 6B 17769 DB 107T F1A9 6B 17770 DB 107T F1AA 6B 17771 DB 107T F1AB 6B 17772 DB 107T F1AC 6A 17773 DB 106T F1AD 6A 17774 DB 106T msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 145 MC68HC908GP32 User Bootloader F1AE 6A 17775 DB 106T F1AF 6A 17776 DB 106T F1B0 69 17777 DB 105T F1B1 69 17778 DB 105T F1B2 69 17779 DB 105T F1B3 69 17780 DB 105T F1B4 69 17781 DB 105T F1B5 68 17782 DB 104T F1B6 68 17783 DB 104T F1B7 68 17784 DB 104T F1B8 68 17785 DB 104T F1B9 68 17786 DB 104T F1BA 67 17787 DB 103T F1BB 67 17788 DB 103T F1BC 67 17789 DB 103T F1BD 67 17790 DB 103T F1BE 67 17791 DB 103T F1BF 66 17792 DB 102T F1C0 66 17793 DB 102T F1C1 66 17794 DB 102T F1C2 66 17795 DB 102T F1C3 66 17796 DB 102T F1C4 65 17797 DB 101T F1C5 65 17798 DB 101T F1C6 65 17799 DB 101T F1C7 65 17800 DB 101T F1C8 65 17801 DB 101T F1C9 64 17802 DB 100T F1CA 64 17803 DB 100T F1CB 64 17804 DB 100T F1CC 64 17805 DB 100T F1CD 64 17806 DB 100T F1CE 63 17807 DB 99T F1CF 63 17808 DB 99T F1D0 63 17809 DB 99T F1D1 63 17810 DB 99T F1D2 63 17811 DB 99T F1D3 62 17812 DB 98T F1D4 62 17813 DB 98T F1D5 62 17814 DB 98T F1D6 62 17815 DB 98T F1D7 62 17816 DB 98T F1D8 61 17817 DB 97T F1D9 61 17818 DB 97T F1DA 61 17819 DB 97T F1DB 61 17820 DB 97T F1DC 60 17821 DB 96T F1DD 60 17822 DB 96T F1DE 60 17823 DB 96T F1DF 60 17824 DB 96T F1E0 60 17825 DB 96T F1E1 5F 17826 DB 95T F1E2 5F 17827 DB 95T F1E3 5F 17828 DB 95T F1E4 5F 17829 DB 95T F1E5 5F 17830 DB 95T F1E6 5E 17831 DB 94T F1E7 5E 17832 DB 94T F1E8 5E 17833 DB 94T F1E9 5E 17834 DB 94T F1EA 5E 17835 DB 94T F1EB 5D 17836 DB 93T F1EC 5D 17837 DB 93T F1ED 5D 17838 DB 93T F1EE 5D 17839 DB 93T F1EF 5D 17840 DB 93T F1F0 5C 17841 DB 92T F1F1 5C 17842 DB 92T F1F2 5C 17843 DB 92T F1F3 5C 17844 DB 92T F1F4 5C 17845 DB 92T F1F5 5B 17846 DB 91T F1F6 5B 17847 DB 91T F1F7 5B 17848 DB 91T F1F8 5B 17849 DB 91T F1F9 5B 17850 DB 91T F1FA 5A 17851 DB 90T F1FB 5A 17852 DB 90T F1FC 5A 17853 DB 90T F1FD 5A 17854 DB 90T F1FE 5A 17855 DB 90T F1FF 64 17856 DB 100T F200 17857 include "barofactor4250.inc" 17858 BAROFAC4250: F200 64 17859 DB 100T F201 8D 17860 DB 141T F202 8D 17861 DB 141T F203 8C 17862 DB 140T F204 8C 17863 DB 140T F205 8B 17864 DB 139T F206 8B 17865 DB 139T F207 8B 17866 DB 139T F208 8A 17867 DB 138T F209 8A 17868 DB 138T F20A 89 17869 DB 137T F20B 89 17870 DB 137T F20C 88 17871 DB 136T F20D 88 17872 DB 136T F20E 87 17873 DB 135T F20F 87 17874 DB 135T F210 86 17875 DB 134T F211 86 17876 DB 134T F212 86 17877 DB 134T F213 85 17878 DB 133T F214 85 17879 DB 133T F215 84 17880 DB 132T F216 84 17881 DB 132T F217 83 17882 DB 131T F218 83 17883 DB 131T F219 82 17884 DB 130T F21A 82 17885 DB 130T F21B 81 17886 DB 129T F21C 81 17887 DB 129T F21D 80 17888 DB 128T F21E 80 17889 DB 128T F21F 80 17890 DB 128T F220 7F 17891 DB 127T F221 7F 17892 DB 127T F222 7E 17893 DB 126T F223 7E 17894 DB 126T F224 7D 17895 DB 125T F225 7D 17896 DB 125T F226 7C 17897 DB 124T F227 7C 17898 DB 124T F228 7B 17899 DB 123T F229 7B 17900 DB 123T F22A 7A 17901 DB 122T F22B 7A 17902 DB 122T F22C 7A 17903 DB 122T F22D 79 17904 DB 121T F22E 79 17905 DB 121T F22F 78 17906 DB 120T F230 78 17907 DB 120T F231 77 17908 DB 119T F232 77 17909 DB 119T F233 76 17910 DB 118T msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 146 MC68HC908GP32 User Bootloader F234 76 17911 DB 118T F235 75 17912 DB 117T F236 75 17913 DB 117T F237 74 17914 DB 116T F238 74 17915 DB 116T F239 74 17916 DB 116T F23A 73 17917 DB 115T F23B 73 17918 DB 115T F23C 72 17919 DB 114T F23D 72 17920 DB 114T F23E 71 17921 DB 113T F23F 71 17922 DB 113T F240 70 17923 DB 112T F241 70 17924 DB 112T F242 6F 17925 DB 111T F243 6F 17926 DB 111T F244 6E 17927 DB 110T F245 6E 17928 DB 110T F246 6E 17929 DB 110T F247 6D 17930 DB 109T F248 6D 17931 DB 109T F249 6C 17932 DB 108T F24A 6C 17933 DB 108T F24B 6B 17934 DB 107T F24C 6B 17935 DB 107T F24D 6A 17936 DB 106T F24E 6A 17937 DB 106T F24F 69 17938 DB 105T F250 69 17939 DB 105T F251 68 17940 DB 104T F252 68 17941 DB 104T F253 68 17942 DB 104T F254 67 17943 DB 103T F255 67 17944 DB 103T F256 66 17945 DB 102T F257 66 17946 DB 102T F258 65 17947 DB 101T F259 65 17948 DB 101T F25A 64 17949 DB 100T F25B 64 17950 DB 100T F25C 63 17951 DB 99T F25D 63 17952 DB 99T F25E 62 17953 DB 98T F25F 62 17954 DB 98T F260 62 17955 DB 98T F261 61 17956 DB 97T F262 61 17957 DB 97T F263 60 17958 DB 96T F264 60 17959 DB 96T F265 5F 17960 DB 95T F266 5F 17961 DB 95T F267 5E 17962 DB 94T F268 5E 17963 DB 94T F269 5D 17964 DB 93T F26A 5D 17965 DB 93T F26B 5C 17966 DB 92T F26C 5C 17967 DB 92T F26D 5C 17968 DB 92T F26E 5B 17969 DB 91T F26F 5B 17970 DB 91T F270 5A 17971 DB 90T F271 5A 17972 DB 90T F272 59 17973 DB 89T F273 59 17974 DB 89T F274 58 17975 DB 88T F275 58 17976 DB 88T F276 57 17977 DB 87T F277 57 17978 DB 87T F278 57 17979 DB 87T F279 56 17980 DB 86T F27A 56 17981 DB 86T F27B 55 17982 DB 85T F27C 55 17983 DB 85T F27D 54 17984 DB 84T F27E 54 17985 DB 84T F27F 53 17986 DB 83T F280 53 17987 DB 83T F281 52 17988 DB 82T F282 52 17989 DB 82T F283 51 17990 DB 81T F284 51 17991 DB 81T F285 51 17992 DB 81T F286 50 17993 DB 80T F287 50 17994 DB 80T F288 4F 17995 DB 79T F289 4F 17996 DB 79T F28A 4E 17997 DB 78T F28B 4E 17998 DB 78T F28C 4D 17999 DB 77T F28D 4D 18000 DB 77T F28E 4C 18001 DB 76T F28F 4C 18002 DB 76T F290 4B 18003 DB 75T F291 4B 18004 DB 75T F292 4B 18005 DB 75T F293 4A 18006 DB 74T F294 4A 18007 DB 74T F295 49 18008 DB 73T F296 49 18009 DB 73T F297 48 18010 DB 72T F298 48 18011 DB 72T F299 47 18012 DB 71T F29A 47 18013 DB 71T F29B 46 18014 DB 70T F29C 46 18015 DB 70T F29D 45 18016 DB 69T F29E 45 18017 DB 69T F29F 45 18018 DB 69T F2A0 44 18019 DB 68T F2A1 44 18020 DB 68T F2A2 43 18021 DB 67T F2A3 43 18022 DB 67T F2A4 42 18023 DB 66T F2A5 42 18024 DB 66T F2A6 41 18025 DB 65T F2A7 41 18026 DB 65T F2A8 40 18027 DB 64T F2A9 40 18028 DB 64T F2AA 3F 18029 DB 63T F2AB 3F 18030 DB 63T F2AC 3F 18031 DB 63T F2AD 3E 18032 DB 62T F2AE 3E 18033 DB 62T F2AF 3D 18034 DB 61T F2B0 3D 18035 DB 61T F2B1 3C 18036 DB 60T F2B2 3C 18037 DB 60T F2B3 3B 18038 DB 59T F2B4 3B 18039 DB 59T F2B5 3A 18040 DB 58T F2B6 3A 18041 DB 58T F2B7 39 18042 DB 57T F2B8 39 18043 DB 57T F2B9 39 18044 DB 57T F2BA 38 18045 DB 56T F2BB 38 18046 DB 56T msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 147 MC68HC908GP32 User Bootloader F2BC 37 18047 DB 55T F2BD 37 18048 DB 55T F2BE 36 18049 DB 54T F2BF 36 18050 DB 54T F2C0 35 18051 DB 53T F2C1 35 18052 DB 53T F2C2 34 18053 DB 52T F2C3 34 18054 DB 52T F2C4 33 18055 DB 51T F2C5 33 18056 DB 51T F2C6 33 18057 DB 51T F2C7 32 18058 DB 50T F2C8 32 18059 DB 50T F2C9 31 18060 DB 49T F2CA 31 18061 DB 49T F2CB 30 18062 DB 48T F2CC 30 18063 DB 48T F2CD 2F 18064 DB 47T F2CE 2F 18065 DB 47T F2CF 2E 18066 DB 46T F2D0 2E 18067 DB 46T F2D1 2D 18068 DB 45T F2D2 2D 18069 DB 45T F2D3 2D 18070 DB 45T F2D4 2C 18071 DB 44T F2D5 2C 18072 DB 44T F2D6 2B 18073 DB 43T F2D7 2B 18074 DB 43T F2D8 2A 18075 DB 42T F2D9 2A 18076 DB 42T F2DA 29 18077 DB 41T F2DB 29 18078 DB 41T F2DC 28 18079 DB 40T F2DD 28 18080 DB 40T F2DE 28 18081 DB 40T F2DF 27 18082 DB 39T F2E0 27 18083 DB 39T F2E1 26 18084 DB 38T F2E2 26 18085 DB 38T F2E3 25 18086 DB 37T F2E4 25 18087 DB 37T F2E5 24 18088 DB 36T F2E6 24 18089 DB 36T F2E7 23 18090 DB 35T F2E8 23 18091 DB 35T F2E9 22 18092 DB 34T F2EA 22 18093 DB 34T F2EB 22 18094 DB 34T F2EC 21 18095 DB 33T F2ED 21 18096 DB 33T F2EE 20 18097 DB 32T F2EF 20 18098 DB 32T F2F0 1F 18099 DB 31T F2F1 1F 18100 DB 31T F2F2 1E 18101 DB 30T F2F3 1E 18102 DB 30T F2F4 1D 18103 DB 29T F2F5 1D 18104 DB 29T F2F6 1C 18105 DB 28T F2F7 1C 18106 DB 28T F2F8 1C 18107 DB 28T F2F9 1B 18108 DB 27T F2FA 1B 18109 DB 27T F2FB 1B 18110 DB 27T F2FC 1B 18111 DB 27T F2FD 1B 18112 DB 27T F2FE 1B 18113 DB 27T F2FF 64 18114 DB 100T F300 18115 include "kpafactor4115.inc" 18116 KPAFACTOR4115: F300 64 18117 DB 100T F301 0A 18118 DB 10T F302 0B 18119 DB 11T F303 0B 18120 DB 11T F304 0C 18121 DB 12T F305 0C 18122 DB 12T F306 0D 18123 DB 13T F307 0D 18124 DB 13T F308 0E 18125 DB 14T F309 0E 18126 DB 14T F30A 0E 18127 DB 14T F30B 0F 18128 DB 15T F30C 0F 18129 DB 15T F30D 10 18130 DB 16T F30E 10 18131 DB 16T F30F 11 18132 DB 17T F310 11 18133 DB 17T F311 11 18134 DB 17T F312 12 18135 DB 18T F313 12 18136 DB 18T F314 13 18137 DB 19T F315 13 18138 DB 19T F316 14 18139 DB 20T F317 14 18140 DB 20T F318 15 18141 DB 21T F319 15 18142 DB 21T F31A 15 18143 DB 21T F31B 16 18144 DB 22T F31C 16 18145 DB 22T F31D 17 18146 DB 23T F31E 17 18147 DB 23T F31F 18 18148 DB 24T F320 18 18149 DB 24T F321 18 18150 DB 24T F322 19 18151 DB 25T F323 19 18152 DB 25T F324 1A 18153 DB 26T F325 1A 18154 DB 26T F326 1B 18155 DB 27T F327 1B 18156 DB 27T F328 1B 18157 DB 27T F329 1C 18158 DB 28T F32A 1C 18159 DB 28T F32B 1D 18160 DB 29T F32C 1D 18161 DB 29T F32D 1E 18162 DB 30T F32E 1E 18163 DB 30T F32F 1F 18164 DB 31T F330 1F 18165 DB 31T F331 1F 18166 DB 31T F332 20 18167 DB 32T F333 20 18168 DB 32T F334 21 18169 DB 33T F335 21 18170 DB 33T F336 22 18171 DB 34T F337 22 18172 DB 34T F338 22 18173 DB 34T F339 23 18174 DB 35T F33A 23 18175 DB 35T F33B 24 18176 DB 36T F33C 24 18177 DB 36T F33D 25 18178 DB 37T F33E 25 18179 DB 37T F33F 26 18180 DB 38T F340 26 18181 DB 38T F341 26 18182 DB 38T msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 148 MC68HC908GP32 User Bootloader F342 27 18183 DB 39T F343 27 18184 DB 39T F344 28 18185 DB 40T F345 28 18186 DB 40T F346 29 18187 DB 41T F347 29 18188 DB 41T F348 29 18189 DB 41T F349 2A 18190 DB 42T F34A 2A 18191 DB 42T F34B 2B 18192 DB 43T F34C 2B 18193 DB 43T F34D 2C 18194 DB 44T F34E 2C 18195 DB 44T F34F 2C 18196 DB 44T F350 2D 18197 DB 45T F351 2D 18198 DB 45T F352 2E 18199 DB 46T F353 2E 18200 DB 46T F354 2F 18201 DB 47T F355 2F 18202 DB 47T F356 30 18203 DB 48T F357 30 18204 DB 48T F358 30 18205 DB 48T F359 31 18206 DB 49T F35A 31 18207 DB 49T F35B 32 18208 DB 50T F35C 32 18209 DB 50T F35D 33 18210 DB 51T F35E 33 18211 DB 51T F35F 33 18212 DB 51T F360 34 18213 DB 52T F361 34 18214 DB 52T F362 35 18215 DB 53T F363 35 18216 DB 53T F364 36 18217 DB 54T F365 36 18218 DB 54T F366 37 18219 DB 55T F367 37 18220 DB 55T F368 37 18221 DB 55T F369 38 18222 DB 56T F36A 38 18223 DB 56T F36B 39 18224 DB 57T F36C 39 18225 DB 57T F36D 3A 18226 DB 58T F36E 3A 18227 DB 58T F36F 3A 18228 DB 58T F370 3B 18229 DB 59T F371 3B 18230 DB 59T F372 3C 18231 DB 60T F373 3C 18232 DB 60T F374 3D 18233 DB 61T F375 3D 18234 DB 61T F376 3D 18235 DB 61T F377 3E 18236 DB 62T F378 3E 18237 DB 62T F379 3F 18238 DB 63T F37A 3F 18239 DB 63T F37B 40 18240 DB 64T F37C 40 18241 DB 64T F37D 41 18242 DB 65T F37E 41 18243 DB 65T F37F 41 18244 DB 65T F380 42 18245 DB 66T F381 42 18246 DB 66T F382 43 18247 DB 67T F383 43 18248 DB 67T F384 44 18249 DB 68T F385 44 18250 DB 68T F386 44 18251 DB 68T F387 45 18252 DB 69T F388 45 18253 DB 69T F389 46 18254 DB 70T F38A 46 18255 DB 70T F38B 47 18256 DB 71T F38C 47 18257 DB 71T F38D 47 18258 DB 71T F38E 48 18259 DB 72T F38F 48 18260 DB 72T F390 49 18261 DB 73T F391 49 18262 DB 73T F392 4A 18263 DB 74T F393 4A 18264 DB 74T F394 4B 18265 DB 75T F395 4B 18266 DB 75T F396 4B 18267 DB 75T F397 4C 18268 DB 76T F398 4C 18269 DB 76T F399 4D 18270 DB 77T F39A 4D 18271 DB 77T F39B 4E 18272 DB 78T F39C 4E 18273 DB 78T F39D 4E 18274 DB 78T F39E 4F 18275 DB 79T F39F 4F 18276 DB 79T F3A0 50 18277 DB 80T F3A1 50 18278 DB 80T F3A2 51 18279 DB 81T F3A3 51 18280 DB 81T F3A4 52 18281 DB 82T F3A5 52 18282 DB 82T F3A6 52 18283 DB 82T F3A7 53 18284 DB 83T F3A8 53 18285 DB 83T F3A9 54 18286 DB 84T F3AA 54 18287 DB 84T F3AB 55 18288 DB 85T F3AC 55 18289 DB 85T F3AD 55 18290 DB 85T F3AE 56 18291 DB 86T F3AF 56 18292 DB 86T F3B0 57 18293 DB 87T F3B1 57 18294 DB 87T F3B2 58 18295 DB 88T F3B3 58 18296 DB 88T F3B4 58 18297 DB 88T F3B5 59 18298 DB 89T F3B6 59 18299 DB 89T F3B7 5A 18300 DB 90T F3B8 5A 18301 DB 90T F3B9 5B 18302 DB 91T F3BA 5B 18303 DB 91T F3BB 5C 18304 DB 92T F3BC 5C 18305 DB 92T F3BD 5C 18306 DB 92T F3BE 5D 18307 DB 93T F3BF 5D 18308 DB 93T F3C0 5E 18309 DB 94T F3C1 5E 18310 DB 94T F3C2 5F 18311 DB 95T F3C3 5F 18312 DB 95T F3C4 5F 18313 DB 95T F3C5 60 18314 DB 96T F3C6 60 18315 DB 96T F3C7 61 18316 DB 97T F3C8 61 18317 DB 97T F3C9 62 18318 DB 98T msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 149 MC68HC908GP32 User Bootloader F3CA 62 18319 DB 98T F3CB 63 18320 DB 99T F3CC 63 18321 DB 99T F3CD 63 18322 DB 99T F3CE 64 18323 DB 100T F3CF 64 18324 DB 100T F3D0 65 18325 DB 101T F3D1 65 18326 DB 101T F3D2 66 18327 DB 102T F3D3 66 18328 DB 102T F3D4 66 18329 DB 102T F3D5 67 18330 DB 103T F3D6 67 18331 DB 103T F3D7 68 18332 DB 104T F3D8 68 18333 DB 104T F3D9 69 18334 DB 105T F3DA 69 18335 DB 105T F3DB 69 18336 DB 105T F3DC 6A 18337 DB 106T F3DD 6A 18338 DB 106T F3DE 6B 18339 DB 107T F3DF 6B 18340 DB 107T F3E0 6C 18341 DB 108T F3E1 6C 18342 DB 108T F3E2 6D 18343 DB 109T F3E3 6D 18344 DB 109T F3E4 6D 18345 DB 109T F3E5 6E 18346 DB 110T F3E6 6E 18347 DB 110T F3E7 6F 18348 DB 111T F3E8 6F 18349 DB 111T F3E9 70 18350 DB 112T F3EA 70 18351 DB 112T F3EB 70 18352 DB 112T F3EC 71 18353 DB 113T F3ED 71 18354 DB 113T F3EE 72 18355 DB 114T F3EF 72 18356 DB 114T F3F0 73 18357 DB 115T F3F1 73 18358 DB 115T F3F2 74 18359 DB 116T F3F3 74 18360 DB 116T F3F4 74 18361 DB 116T F3F5 75 18362 DB 117T F3F6 75 18363 DB 117T F3F7 76 18364 DB 118T F3F8 76 18365 DB 118T F3F9 77 18366 DB 119T F3FA 77 18367 DB 119T F3FB 77 18368 DB 119T F3FC 78 18369 DB 120T F3FD 78 18370 DB 120T F3FE 79 18371 DB 121T F3FF 64 18372 DB 100T F400 18373 include "kpafactor4250.inc" 18374 KPAFACTOR4250: F400 64 18375 DB 100T F401 0A 18376 DB 10T F402 0B 18377 DB 11T F403 0C 18378 DB 12T F404 0D 18379 DB 13T F405 0E 18380 DB 14T F406 0F 18381 DB 15T F407 10 18382 DB 16T F408 11 18383 DB 17T F409 12 18384 DB 18T F40A 13 18385 DB 19T F40B 14 18386 DB 20T F40C 15 18387 DB 21T F40D 16 18388 DB 22T F40E 17 18389 DB 23T F40F 18 18390 DB 24T F410 19 18391 DB 25T F411 1A 18392 DB 26T F412 1B 18393 DB 27T F413 1C 18394 DB 28T F414 1D 18395 DB 29T F415 1E 18396 DB 30T F416 1F 18397 DB 31T F417 20 18398 DB 32T F418 21 18399 DB 33T F419 22 18400 DB 34T F41A 23 18401 DB 35T F41B 24 18402 DB 36T F41C 25 18403 DB 37T F41D 26 18404 DB 38T F41E 27 18405 DB 39T F41F 28 18406 DB 40T F420 29 18407 DB 41T F421 2A 18408 DB 42T F422 2B 18409 DB 43T F423 2C 18410 DB 44T F424 2D 18411 DB 45T F425 2E 18412 DB 46T F426 2F 18413 DB 47T F427 30 18414 DB 48T F428 31 18415 DB 49T F429 32 18416 DB 50T F42A 33 18417 DB 51T F42B 34 18418 DB 52T F42C 35 18419 DB 53T F42D 36 18420 DB 54T F42E 37 18421 DB 55T F42F 38 18422 DB 56T F430 39 18423 DB 57T F431 3A 18424 DB 58T F432 3B 18425 DB 59T F433 3B 18426 DB 59T F434 3C 18427 DB 60T F435 3D 18428 DB 61T F436 3E 18429 DB 62T F437 3F 18430 DB 63T F438 40 18431 DB 64T F439 41 18432 DB 65T F43A 42 18433 DB 66T F43B 43 18434 DB 67T F43C 44 18435 DB 68T F43D 45 18436 DB 69T F43E 46 18437 DB 70T F43F 47 18438 DB 71T F440 48 18439 DB 72T F441 49 18440 DB 73T F442 4A 18441 DB 74T F443 4B 18442 DB 75T F444 4C 18443 DB 76T F445 4D 18444 DB 77T F446 4E 18445 DB 78T F447 4F 18446 DB 79T F448 50 18447 DB 80T F449 51 18448 DB 81T F44A 52 18449 DB 82T F44B 53 18450 DB 83T F44C 54 18451 DB 84T F44D 55 18452 DB 85T F44E 56 18453 DB 86T F44F 57 18454 DB 87T msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 150 MC68HC908GP32 User Bootloader F450 58 18455 DB 88T F451 59 18456 DB 89T F452 5A 18457 DB 90T F453 5B 18458 DB 91T F454 5C 18459 DB 92T F455 5D 18460 DB 93T F456 5E 18461 DB 94T F457 5F 18462 DB 95T F458 60 18463 DB 96T F459 61 18464 DB 97T F45A 62 18465 DB 98T F45B 63 18466 DB 99T F45C 64 18467 DB 100T F45D 65 18468 DB 101T F45E 66 18469 DB 102T F45F 67 18470 DB 103T F460 68 18471 DB 104T F461 69 18472 DB 105T F462 6A 18473 DB 106T F463 6B 18474 DB 107T F464 6C 18475 DB 108T F465 6D 18476 DB 109T F466 6E 18477 DB 110T F467 6E 18478 DB 110T F468 6F 18479 DB 111T F469 70 18480 DB 112T F46A 71 18481 DB 113T F46B 72 18482 DB 114T F46C 73 18483 DB 115T F46D 74 18484 DB 116T F46E 75 18485 DB 117T F46F 76 18486 DB 118T F470 77 18487 DB 119T F471 78 18488 DB 120T F472 79 18489 DB 121T F473 7A 18490 DB 122T F474 7B 18491 DB 123T F475 7C 18492 DB 124T F476 7D 18493 DB 125T F477 7E 18494 DB 126T F478 7F 18495 DB 127T F479 80 18496 DB 128T F47A 81 18497 DB 129T F47B 82 18498 DB 130T F47C 83 18499 DB 131T F47D 84 18500 DB 132T F47E 85 18501 DB 133T F47F 86 18502 DB 134T F480 87 18503 DB 135T F481 88 18504 DB 136T F482 89 18505 DB 137T F483 8A 18506 DB 138T F484 8B 18507 DB 139T F485 8C 18508 DB 140T F486 8D 18509 DB 141T F487 8E 18510 DB 142T F488 8F 18511 DB 143T F489 90 18512 DB 144T F48A 91 18513 DB 145T F48B 92 18514 DB 146T F48C 93 18515 DB 147T F48D 94 18516 DB 148T F48E 95 18517 DB 149T F48F 96 18518 DB 150T F490 97 18519 DB 151T F491 98 18520 DB 152T F492 99 18521 DB 153T F493 9A 18522 DB 154T F494 9B 18523 DB 155T F495 9C 18524 DB 156T F496 9D 18525 DB 157T F497 9E 18526 DB 158T F498 9F 18527 DB 159T F499 A0 18528 DB 160T F49A A0 18529 DB 160T F49B A1 18530 DB 161T F49C A2 18531 DB 162T F49D A3 18532 DB 163T F49E A4 18533 DB 164T F49F A5 18534 DB 165T F4A0 A6 18535 DB 166T F4A1 A7 18536 DB 167T F4A2 A8 18537 DB 168T F4A3 A9 18538 DB 169T F4A4 AA 18539 DB 170T F4A5 AB 18540 DB 171T F4A6 AC 18541 DB 172T F4A7 AD 18542 DB 173T F4A8 AE 18543 DB 174T F4A9 AF 18544 DB 175T F4AA B0 18545 DB 176T F4AB B1 18546 DB 177T F4AC B2 18547 DB 178T F4AD B3 18548 DB 179T F4AE B4 18549 DB 180T F4AF B5 18550 DB 181T F4B0 B6 18551 DB 182T F4B1 B7 18552 DB 183T F4B2 B8 18553 DB 184T F4B3 B9 18554 DB 185T F4B4 BA 18555 DB 186T F4B5 BB 18556 DB 187T F4B6 BC 18557 DB 188T F4B7 BD 18558 DB 189T F4B8 BE 18559 DB 190T F4B9 BF 18560 DB 191T F4BA C0 18561 DB 192T F4BB C1 18562 DB 193T F4BC C2 18563 DB 194T F4BD C3 18564 DB 195T F4BE C4 18565 DB 196T F4BF C5 18566 DB 197T F4C0 C6 18567 DB 198T F4C1 C7 18568 DB 199T F4C2 C8 18569 DB 200T F4C3 C9 18570 DB 201T F4C4 CA 18571 DB 202T F4C5 CB 18572 DB 203T F4C6 CC 18573 DB 204T F4C7 CD 18574 DB 205T F4C8 CE 18575 DB 206T F4C9 CF 18576 DB 207T F4CA D0 18577 DB 208T F4CB D1 18578 DB 209T F4CC D2 18579 DB 210T F4CD D2 18580 DB 210T F4CE D3 18581 DB 211T F4CF D4 18582 DB 212T F4D0 D5 18583 DB 213T F4D1 D6 18584 DB 214T F4D2 D7 18585 DB 215T F4D3 D8 18586 DB 216T F4D4 D9 18587 DB 217T F4D5 DA 18588 DB 218T F4D6 DB 18589 DB 219T F4D7 DC 18590 DB 220T msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 151 MC68HC908GP32 User Bootloader F4D8 DD 18591 DB 221T F4D9 DE 18592 DB 222T F4DA DF 18593 DB 223T F4DB E0 18594 DB 224T F4DC E1 18595 DB 225T F4DD E2 18596 DB 226T F4DE E3 18597 DB 227T F4DF E4 18598 DB 228T F4E0 E5 18599 DB 229T F4E1 E6 18600 DB 230T F4E2 E7 18601 DB 231T F4E3 E8 18602 DB 232T F4E4 E9 18603 DB 233T F4E5 EA 18604 DB 234T F4E6 EB 18605 DB 235T F4E7 EC 18606 DB 236T F4E8 ED 18607 DB 237T F4E9 EE 18608 DB 238T F4EA EF 18609 DB 239T F4EB F0 18610 DB 240T F4EC F1 18611 DB 241T F4ED F2 18612 DB 242T F4EE F3 18613 DB 243T F4EF F4 18614 DB 244T F4F0 F5 18615 DB 245T F4F1 F6 18616 DB 246T F4F2 F7 18617 DB 247T F4F3 F8 18618 DB 248T F4F4 F9 18619 DB 249T F4F5 FA 18620 DB 250T F4F6 FB 18621 DB 251T F4F7 FC 18622 DB 252T F4F8 FD 18623 DB 253T F4F9 FE 18624 DB 254T F4FA FF 18625 DB 255T F4FB FF 18626 DB 255T F4FC FF 18627 DB 255T F4FD FF 18628 DB 255T F4FE FF 18629 DB 255T F4FF 64 18630 DB 100T F500 18631 include "thermfactor.inc" 18632 ; Generated using EasyTherm4.exe 18633 ; 18634 ; Coolant Thermistor Comment Field 18635 ; 18636 ; File generated for use with stock 2490 ohm resistor at R7 18637 ; 18638 ; Steinhart-Hart coefficients: A= 1.232585E-03 B=2.981059E-04 C= -2.909625E-07 18639 ; 18640 ; Input Data Temp, degC Resistance 18641 ; 16 2860 18642 ; 42 915 18643 ; 70 342 18644 ; 18645 18646 THERMFACTOR: 18647 ; ADC Temp, degF F500 D2 18648 DB 210T ; 0 Sensor Failure - use 170 degF as default F501 FF 18649 DB 255T ; 1 483.50 F502 FF 18650 DB 255T ; 2 392.59 F503 FF 18651 DB 255T ; 3 347.34 F504 FF 18652 DB 255T ; 4 318.13 F505 FF 18653 DB 255T ; 5 296.92 F506 FF 18654 DB 255T ; 6 280.45 F507 FF 18655 DB 255T ; 7 267.08 F508 FF 18656 DB 255T ; 8 255.88 F509 FF 18657 DB 255T ; 9 246.28 F50A FF 18658 DB 255T ; 10 237.90 F50B FF 18659 DB 255T ; 11 230.48 F50C FF 18660 DB 255T ; 12 223.84 F50D FF 18661 DB 255T ; 13 217.83 F50E FC 18662 DB 252T ; 14 212.35 F50F F7 18663 DB 247T ; 15 207.32 F510 F3 18664 DB 243T ; 16 202.67 F511 EE 18665 DB 238T ; 17 198.36 F512 EA 18666 DB 234T ; 18 194.33 F513 E7 18667 DB 231T ; 19 190.56 F514 E3 18668 DB 227T ; 20 187.02 F515 E0 18669 DB 224T ; 21 183.67 F516 DD 18670 DB 221T ; 22 180.51 F517 DA 18671 DB 218T ; 23 177.50 F518 D7 18672 DB 215T ; 24 174.65 F519 D4 18673 DB 212T ; 25 171.92 F51A D1 18674 DB 209T ; 26 169.32 F51B CF 18675 DB 207T ; 27 166.83 F51C CC 18676 DB 204T ; 28 164.45 F51D CA 18677 DB 202T ; 29 162.15 F51E C8 18678 DB 200T ; 30 159.95 F51F C6 18679 DB 198T ; 31 157.82 F520 C4 18680 DB 196T ; 32 155.77 F521 C2 18681 DB 194T ; 33 153.79 F522 C0 18682 DB 192T ; 34 151.88 F523 BE 18683 DB 190T ; 35 150.03 F524 BC 18684 DB 188T ; 36 148.23 F525 BA 18685 DB 186T ; 37 146.49 F526 B9 18686 DB 185T ; 38 144.79 F527 B7 18687 DB 183T ; 39 143.15 F528 B6 18688 DB 182T ; 40 141.55 F529 B4 18689 DB 180T ; 41 139.99 F52A B2 18690 DB 178T ; 42 138.47 F52B B1 18691 DB 177T ; 43 136.99 F52C B0 18692 DB 176T ; 44 135.55 F52D AE 18693 DB 174T ; 45 134.14 F52E AD 18694 DB 173T ; 46 132.76 F52F AB 18695 DB 171T ; 47 131.42 F530 AA 18696 DB 170T ; 48 130.10 F531 A9 18697 DB 169T ; 49 128.81 F532 A8 18698 DB 168T ; 50 127.55 F533 A6 18699 DB 166T ; 51 126.31 F534 A5 18700 DB 165T ; 52 125.10 F535 A4 18701 DB 164T ; 53 123.91 F536 A3 18702 DB 163T ; 54 122.75 F537 A2 18703 DB 162T ; 55 121.60 F538 A0 18704 DB 160T ; 56 120.48 F539 9F 18705 DB 159T ; 57 119.37 F53A 9E 18706 DB 158T ; 58 118.29 F53B 9D 18707 DB 157T ; 59 117.22 F53C 9C 18708 DB 156T ; 60 116.17 F53D 9B 18709 DB 155T ; 61 115.14 F53E 9A 18710 DB 154T ; 62 114.12 F53F 99 18711 DB 153T ; 63 113.12 F540 98 18712 DB 152T ; 64 112.13 F541 97 18713 DB 151T ; 65 111.16 F542 96 18714 DB 150T ; 66 110.21 F543 95 18715 DB 149T ; 67 109.26 F544 94 18716 DB 148T ; 68 108.33 F545 93 18717 DB 147T ; 69 107.41 F546 93 18718 DB 147T ; 70 106.50 F547 92 18719 DB 146T ; 71 105.61 F548 91 18720 DB 145T ; 72 104.73 F549 90 18721 DB 144T ; 73 103.85 F54A 8F 18722 DB 143T ; 74 102.99 F54B 8E 18723 DB 142T ; 75 102.14 F54C 8D 18724 DB 141T ; 76 101.30 F54D 8C 18725 DB 140T ; 77 100.46 F54E 8C 18726 DB 140T ; 78 99.64 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 152 MC68HC908GP32 User Bootloader F54F 8B 18727 DB 139T ; 79 98.83 F550 8A 18728 DB 138T ; 80 98.02 F551 89 18729 DB 137T ; 81 97.23 F552 88 18730 DB 136T ; 82 96.44 F553 88 18731 DB 136T ; 83 95.66 F554 87 18732 DB 135T ; 84 94.88 F555 86 18733 DB 134T ; 85 94.12 F556 85 18734 DB 133T ; 86 93.36 F557 85 18735 DB 133T ; 87 92.61 F558 84 18736 DB 132T ; 88 91.87 F559 83 18737 DB 131T ; 89 91.13 F55A 82 18738 DB 130T ; 90 90.40 F55B 82 18739 DB 130T ; 91 89.67 F55C 81 18740 DB 129T ; 92 88.95 F55D 80 18741 DB 128T ; 93 88.24 F55E 80 18742 DB 128T ; 94 87.53 F55F 7F 18743 DB 127T ; 95 86.83 F560 7E 18744 DB 126T ; 96 86.13 F561 7D 18745 DB 125T ; 97 85.44 F562 7D 18746 DB 125T ; 98 84.76 F563 7C 18747 DB 124T ; 99 84.08 F564 7B 18748 DB 123T ; 100 83.40 F565 7B 18749 DB 123T ; 101 82.73 F566 7A 18750 DB 122T ; 102 82.06 F567 79 18751 DB 121T ; 103 81.40 F568 79 18752 DB 121T ; 104 80.74 F569 78 18753 DB 120T ; 105 80.09 F56A 77 18754 DB 119T ; 106 79.44 F56B 77 18755 DB 119T ; 107 78.79 F56C 76 18756 DB 118T ; 108 78.15 F56D 76 18757 DB 118T ; 109 77.51 F56E 75 18758 DB 117T ; 110 76.87 F56F 74 18759 DB 116T ; 111 76.24 F570 74 18760 DB 116T ; 112 75.61 F571 73 18761 DB 115T ; 113 74.99 F572 72 18762 DB 114T ; 114 74.37 F573 72 18763 DB 114T ; 115 73.75 F574 71 18764 DB 113T ; 116 73.13 F575 71 18765 DB 113T ; 117 72.52 F576 70 18766 DB 112T ; 118 71.91 F577 6F 18767 DB 111T ; 119 71.30 F578 6F 18768 DB 111T ; 120 70.69 F579 6E 18769 DB 110T ; 121 70.09 F57A 6D 18770 DB 109T ; 122 69.49 F57B 6D 18771 DB 109T ; 123 68.89 F57C 6C 18772 DB 108T ; 124 68.30 F57D 6C 18773 DB 108T ; 125 67.70 F57E 6B 18774 DB 107T ; 126 67.11 F57F 6B 18775 DB 107T ; 127 66.52 F580 6A 18776 DB 106T ; 128 65.93 F581 69 18777 DB 105T ; 129 65.35 F582 69 18778 DB 105T ; 130 64.76 F583 68 18779 DB 104T ; 131 64.18 F584 68 18780 DB 104T ; 132 63.60 F585 67 18781 DB 103T ; 133 63.02 F586 66 18782 DB 102T ; 134 62.44 F587 66 18783 DB 102T ; 135 61.86 F588 65 18784 DB 101T ; 136 61.29 F589 65 18785 DB 101T ; 137 60.72 F58A 64 18786 DB 100T ; 138 60.14 F58B 64 18787 DB 100T ; 139 59.57 F58C 63 18788 DB 99T ; 140 59.00 F58D 62 18789 DB 98T ; 141 58.43 F58E 62 18790 DB 98T ; 142 57.86 F58F 61 18791 DB 97T ; 143 57.29 F590 61 18792 DB 97T ; 144 56.72 F591 60 18793 DB 96T ; 145 56.16 F592 60 18794 DB 96T ; 146 55.59 F593 5F 18795 DB 95T ; 147 55.03 F594 5E 18796 DB 94T ; 148 54.46 F595 5E 18797 DB 94T ; 149 53.89 F596 5D 18798 DB 93T ; 150 53.33 F597 5D 18799 DB 93T ; 151 52.77 F598 5C 18800 DB 92T ; 152 52.20 F599 5C 18801 DB 92T ; 153 51.64 F59A 5B 18802 DB 91T ; 154 51.07 F59B 5B 18803 DB 91T ; 155 50.51 F59C 5A 18804 DB 90T ; 156 49.94 F59D 59 18805 DB 89T ; 157 49.38 F59E 59 18806 DB 89T ; 158 48.81 F59F 58 18807 DB 88T ; 159 48.25 F5A0 58 18808 DB 88T ; 160 47.68 F5A1 57 18809 DB 87T ; 161 47.12 F5A2 57 18810 DB 87T ; 162 46.55 F5A3 56 18811 DB 86T ; 163 45.98 F5A4 55 18812 DB 85T ; 164 45.41 F5A5 55 18813 DB 85T ; 165 44.84 F5A6 54 18814 DB 84T ; 166 44.27 F5A7 54 18815 DB 84T ; 167 43.70 F5A8 53 18816 DB 83T ; 168 43.13 F5A9 53 18817 DB 83T ; 169 42.56 F5AA 52 18818 DB 82T ; 170 41.98 F5AB 51 18819 DB 81T ; 171 41.41 F5AC 51 18820 DB 81T ; 172 40.83 F5AD 50 18821 DB 80T ; 173 40.25 F5AE 50 18822 DB 80T ; 174 39.67 F5AF 4F 18823 DB 79T ; 175 39.09 F5B0 4F 18824 DB 79T ; 176 38.50 F5B1 4E 18825 DB 78T ; 177 37.92 F5B2 4D 18826 DB 77T ; 178 37.33 F5B3 4D 18827 DB 77T ; 179 36.74 F5B4 4C 18828 DB 76T ; 180 36.14 F5B5 4C 18829 DB 76T ; 181 35.55 F5B6 4B 18830 DB 75T ; 182 34.95 F5B7 4A 18831 DB 74T ; 183 34.35 F5B8 4A 18832 DB 74T ; 184 33.75 F5B9 49 18833 DB 73T ; 185 33.14 F5BA 49 18834 DB 73T ; 186 32.54 F5BB 48 18835 DB 72T ; 187 31.92 F5BC 47 18836 DB 71T ; 188 31.31 F5BD 47 18837 DB 71T ; 189 30.69 F5BE 46 18838 DB 70T ; 190 30.07 F5BF 45 18839 DB 69T ; 191 29.44 F5C0 45 18840 DB 69T ; 192 28.81 F5C1 44 18841 DB 68T ; 193 28.18 F5C2 44 18842 DB 68T ; 194 27.54 F5C3 43 18843 DB 67T ; 195 26.90 F5C4 42 18844 DB 66T ; 196 26.25 F5C5 42 18845 DB 66T ; 197 25.60 F5C6 41 18846 DB 65T ; 198 24.94 F5C7 40 18847 DB 64T ; 199 24.28 F5C8 40 18848 DB 64T ; 200 23.62 F5C9 3F 18849 DB 63T ; 201 22.94 F5CA 3E 18850 DB 62T ; 202 22.26 F5CB 3E 18851 DB 62T ; 203 21.58 F5CC 3D 18852 DB 61T ; 204 20.89 F5CD 3C 18853 DB 60T ; 205 20.19 F5CE 3B 18854 DB 59T ; 206 19.48 F5CF 3B 18855 DB 59T ; 207 18.77 F5D0 3A 18856 DB 58T ; 208 18.05 F5D1 39 18857 DB 57T ; 209 17.32 F5D2 39 18858 DB 57T ; 210 16.58 F5D3 38 18859 DB 56T ; 211 15.84 F5D4 37 18860 DB 55T ; 212 15.08 F5D5 36 18861 DB 54T ; 213 14.32 F5D6 36 18862 DB 54T ; 214 13.54 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 153 MC68HC908GP32 User Bootloader F5D7 35 18863 DB 53T ; 215 12.76 F5D8 34 18864 DB 52T ; 216 11.96 F5D9 33 18865 DB 51T ; 217 11.15 F5DA 32 18866 DB 50T ; 218 10.33 F5DB 31 18867 DB 49T ; 219 9.50 F5DC 31 18868 DB 49T ; 220 8.65 F5DD 30 18869 DB 48T ; 221 7.79 F5DE 2F 18870 DB 47T ; 222 6.91 F5DF 2E 18871 DB 46T ; 223 6.01 F5E0 2D 18872 DB 45T ; 224 5.10 F5E1 2C 18873 DB 44T ; 225 4.17 F5E2 2B 18874 DB 43T ; 226 3.22 F5E3 2A 18875 DB 42T ; 227 2.25 F5E4 29 18876 DB 41T ; 228 1.26 F5E5 28 18877 DB 40T ; 229 .24 F5E6 27 18878 DB 39T ; 230 -.80 F5E7 26 18879 DB 38T ; 231 -1.87 F5E8 25 18880 DB 37T ; 232 -2.97 F5E9 24 18881 DB 36T ; 233 -4.10 F5EA 23 18882 DB 35T ; 234 -5.27 F5EB 22 18883 DB 34T ; 235 -6.47 F5EC 20 18884 DB 32T ; 236 -7.71 F5ED 1F 18885 DB 31T ; 237 -9.00 F5EE 1E 18886 DB 30T ; 238 -10.34 F5EF 1C 18887 DB 28T ; 239 -11.74 F5F0 1B 18888 DB 27T ; 240 -13.19 F5F1 19 18889 DB 25T ; 241 -14.71 F5F2 18 18890 DB 24T ; 242 -16.31 F5F3 16 18891 DB 22T ; 243 -18.00 F5F4 14 18892 DB 20T ; 244 -19.78 F5F5 12 18893 DB 18T ; 245 -21.68 F5F6 10 18894 DB 16T ; 246 -23.71 F5F7 0E 18895 DB 14T ; 247 -25.91 F5F8 0C 18896 DB 12T ; 248 -28.30 F5F9 09 18897 DB 9T ; 249 -30.93 F5FA 06 18898 DB 6T ; 250 -33.87 F5FB 03 18899 DB 3T ; 251 -37.22 F5FC 00 18900 DB 0T ; 252 -41.13 F5FD 00 18901 DB 0T ; 253 -45.91 F5FE 00 18902 DB 0T ; 254 -52.14 F5FF D2 18903 DB 210T ; 255 Sensor Failure - use 170 degF as default F600 18904 include "airdenfactor.inc" 18905 ; Generated using EasyTherm4.exe, 18906 ; 18907 ; Air Temp Thermistor Comment Field 18908 ; 18909 ; File generated for use with stock 2490 ohm resistor at R4 18910 ; 18911 ; Steinhart-Hart coefficients: A= 5.987198E-04 B=3.94987E-04 C= -5.342268E-07 18912 ; 18913 ; Input Data Temp, degC Resistance 18914 ; 10 3500 18915 ; 25 1920 18916 ; 95 270 18917 ; 18918 18919 AIRDENFACTOR: 18920 ; ADC Temp, degF F600 64 18921 DB 100T ; 0 Sensor Failure - 100% applied F601 2C 18922 DB 44T ; 1 745.15 F602 34 18923 DB 52T ; 2 562.15 F603 38 18924 DB 56T ; 3 479.48 F604 3B 18925 DB 59T ; 4 428.79 F605 3E 18926 DB 62T ; 5 393.23 F606 40 18927 DB 64T ; 6 366.30 F607 42 18928 DB 66T ; 7 344.86 F608 43 18929 DB 67T ; 8 327.20 F609 44 18930 DB 68T ; 9 312.26 F60A 46 18931 DB 70T ; 10 299.38 F60B 47 18932 DB 71T ; 11 288.10 F60C 48 18933 DB 72T ; 12 278.09 F60D 48 18934 DB 72T ; 13 269.11 F60E 49 18935 DB 73T ; 14 260.98 F60F 4A 18936 DB 74T ; 15 253.57 F610 4B 18937 DB 75T ; 16 246.77 F611 4B 18938 DB 75T ; 17 240.49 F612 4C 18939 DB 76T ; 18 234.66 F613 4D 18940 DB 77T ; 19 229.23 F614 4D 18941 DB 77T ; 20 224.15 F615 4E 18942 DB 78T ; 21 219.38 F616 4E 18943 DB 78T ; 22 214.89 F617 4F 18944 DB 79T ; 23 210.64 F618 4F 18945 DB 79T ; 24 206.62 F619 50 18946 DB 80T ; 25 202.80 F61A 50 18947 DB 80T ; 26 199.16 F61B 51 18948 DB 81T ; 27 195.69 F61C 51 18949 DB 81T ; 28 192.37 F61D 51 18950 DB 81T ; 29 189.19 F61E 52 18951 DB 82T ; 30 186.15 F61F 52 18952 DB 82T ; 31 183.22 F620 53 18953 DB 83T ; 32 180.41 F621 53 18954 DB 83T ; 33 177.70 F622 53 18955 DB 83T ; 34 175.08 F623 54 18956 DB 84T ; 35 172.55 F624 54 18957 DB 84T ; 36 170.11 F625 54 18958 DB 84T ; 37 167.75 F626 54 18959 DB 84T ; 38 165.46 F627 55 18960 DB 85T ; 39 163.24 F628 55 18961 DB 85T ; 40 161.08 F629 55 18962 DB 85T ; 41 158.99 F62A 56 18963 DB 86T ; 42 156.95 F62B 56 18964 DB 86T ; 43 154.97 F62C 56 18965 DB 86T ; 44 153.04 F62D 56 18966 DB 86T ; 45 151.16 F62E 57 18967 DB 87T ; 46 149.33 F62F 57 18968 DB 87T ; 47 147.54 F630 57 18969 DB 87T ; 48 145.80 F631 57 18970 DB 87T ; 49 144.09 F632 58 18971 DB 88T ; 50 142.42 F633 58 18972 DB 88T ; 51 140.79 F634 58 18973 DB 88T ; 52 139.20 F635 58 18974 DB 88T ; 53 137.63 F636 59 18975 DB 89T ; 54 136.10 F637 59 18976 DB 89T ; 55 134.60 F638 59 18977 DB 89T ; 56 133.13 F639 59 18978 DB 89T ; 57 131.69 F63A 5A 18979 DB 90T ; 58 130.27 F63B 5A 18980 DB 90T ; 59 128.88 F63C 5A 18981 DB 90T ; 60 127.51 F63D 5A 18982 DB 90T ; 61 126.17 F63E 5A 18983 DB 90T ; 62 124.85 F63F 5B 18984 DB 91T ; 63 123.55 F640 5B 18985 DB 91T ; 64 122.28 F641 5B 18986 DB 91T ; 65 121.02 F642 5B 18987 DB 91T ; 66 119.79 F643 5B 18988 DB 91T ; 67 118.57 F644 5C 18989 DB 92T ; 68 117.37 F645 5C 18990 DB 92T ; 69 116.19 F646 5C 18991 DB 92T ; 70 115.03 F647 5C 18992 DB 92T ; 71 113.88 F648 5C 18993 DB 92T ; 72 112.75 F649 5C 18994 DB 92T ; 73 111.63 F64A 5D 18995 DB 93T ; 74 110.53 F64B 5D 18996 DB 93T ; 75 109.44 F64C 5D 18997 DB 93T ; 76 108.37 F64D 5D 18998 DB 93T ; 77 107.31 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 154 MC68HC908GP32 User Bootloader F64E 5D 18999 DB 93T ; 78 106.26 F64F 5E 19000 DB 94T ; 79 105.23 F650 5E 19001 DB 94T ; 80 104.21 F651 5E 19002 DB 94T ; 81 103.20 F652 5E 19003 DB 94T ; 82 102.20 F653 5E 19004 DB 94T ; 83 101.22 F654 5E 19005 DB 94T ; 84 100.24 F655 5E 19006 DB 94T ; 85 99.27 F656 5F 19007 DB 95T ; 86 98.32 F657 5F 19008 DB 95T ; 87 97.37 F658 5F 19009 DB 95T ; 88 96.44 F659 5F 19010 DB 95T ; 89 95.51 F65A 5F 19011 DB 95T ; 90 94.59 F65B 5F 19012 DB 95T ; 91 93.68 F65C 60 19013 DB 96T ; 92 92.78 F65D 60 19014 DB 96T ; 93 91.89 F65E 60 19015 DB 96T ; 94 91.01 F65F 60 19016 DB 96T ; 95 90.13 F660 60 19017 DB 96T ; 96 89.26 F661 60 19018 DB 96T ; 97 88.40 F662 61 19019 DB 97T ; 98 87.55 F663 61 19020 DB 97T ; 99 86.70 F664 61 19021 DB 97T ; 100 85.86 F665 61 19022 DB 97T ; 101 85.03 F666 61 19023 DB 97T ; 102 84.20 F667 61 19024 DB 97T ; 103 83.38 F668 61 19025 DB 97T ; 104 82.56 F669 62 19026 DB 98T ; 105 81.75 F66A 62 19027 DB 98T ; 106 80.95 F66B 62 19028 DB 98T ; 107 80.15 F66C 62 19029 DB 98T ; 108 79.36 F66D 62 19030 DB 98T ; 109 78.57 F66E 62 19031 DB 98T ; 110 77.79 F66F 62 19032 DB 98T ; 111 77.02 F670 63 19033 DB 99T ; 112 76.24 F671 63 19034 DB 99T ; 113 75.48 F672 63 19035 DB 99T ; 114 74.71 F673 63 19036 DB 99T ; 115 73.95 F674 63 19037 DB 99T ; 116 73.20 F675 63 19038 DB 99T ; 117 72.45 F676 63 19039 DB 99T ; 118 71.70 F677 64 19040 DB 100T ; 119 70.96 F678 64 19041 DB 100T ; 120 70.22 F679 64 19042 DB 100T ; 121 69.49 F67A 64 19043 DB 100T ; 122 68.76 F67B 64 19044 DB 100T ; 123 68.03 F67C 64 19045 DB 100T ; 124 67.31 F67D 64 19046 DB 100T ; 125 66.59 F67E 65 19047 DB 101T ; 126 65.87 F67F 65 19048 DB 101T ; 127 65.15 F680 65 19049 DB 101T ; 128 64.44 F681 65 19050 DB 101T ; 129 63.73 F682 65 19051 DB 101T ; 130 63.03 F683 65 19052 DB 101T ; 131 62.32 F684 65 19053 DB 101T ; 132 61.62 F685 65 19054 DB 101T ; 133 60.92 F686 66 19055 DB 102T ; 134 60.23 F687 66 19056 DB 102T ; 135 59.53 F688 66 19057 DB 102T ; 136 58.84 F689 66 19058 DB 102T ; 137 58.15 F68A 66 19059 DB 102T ; 138 57.46 F68B 66 19060 DB 102T ; 139 56.78 F68C 66 19061 DB 102T ; 140 56.09 F68D 67 19062 DB 103T ; 141 55.41 F68E 67 19063 DB 103T ; 142 54.73 F68F 67 19064 DB 103T ; 143 54.05 F690 67 19065 DB 103T ; 144 53.37 F691 67 19066 DB 103T ; 145 52.69 F692 67 19067 DB 103T ; 146 52.02 F693 67 19068 DB 103T ; 147 51.34 F694 67 19069 DB 103T ; 148 50.67 F695 68 19070 DB 104T ; 149 50.00 F696 68 19071 DB 104T ; 150 49.33 F697 68 19072 DB 104T ; 151 48.66 F698 68 19073 DB 104T ; 152 47.99 F699 68 19074 DB 104T ; 153 47.32 F69A 68 19075 DB 104T ; 154 46.65 F69B 68 19076 DB 104T ; 155 45.98 F69C 69 19077 DB 105T ; 156 45.32 F69D 69 19078 DB 105T ; 157 44.65 F69E 69 19079 DB 105T ; 158 43.98 F69F 69 19080 DB 105T ; 159 43.31 F6A0 69 19081 DB 105T ; 160 42.65 F6A1 69 19082 DB 105T ; 161 41.98 F6A2 69 19083 DB 105T ; 162 41.31 F6A3 6A 19084 DB 106T ; 163 40.65 F6A4 6A 19085 DB 106T ; 164 39.98 F6A5 6A 19086 DB 106T ; 165 39.31 F6A6 6A 19087 DB 106T ; 166 38.64 F6A7 6A 19088 DB 106T ; 167 37.98 F6A8 6A 19089 DB 106T ; 168 37.31 F6A9 6A 19090 DB 106T ; 169 36.64 F6AA 6B 19091 DB 107T ; 170 35.96 F6AB 6B 19092 DB 107T ; 171 35.29 F6AC 6B 19093 DB 107T ; 172 34.62 F6AD 6B 19094 DB 107T ; 173 33.95 F6AE 6B 19095 DB 107T ; 174 33.27 F6AF 6B 19096 DB 107T ; 175 32.59 F6B0 6B 19097 DB 107T ; 176 31.91 F6B1 6C 19098 DB 108T ; 177 31.23 F6B2 6C 19099 DB 108T ; 178 30.55 F6B3 6C 19100 DB 108T ; 179 29.87 F6B4 6C 19101 DB 108T ; 180 29.18 F6B5 6C 19102 DB 108T ; 181 28.50 F6B6 6C 19103 DB 108T ; 182 27.81 F6B7 6D 19104 DB 109T ; 183 27.11 F6B8 6D 19105 DB 109T ; 184 26.42 F6B9 6D 19106 DB 109T ; 185 25.72 F6BA 6D 19107 DB 109T ; 186 25.02 F6BB 6D 19108 DB 109T ; 187 24.32 F6BC 6D 19109 DB 109T ; 188 23.61 F6BD 6D 19110 DB 109T ; 189 22.90 F6BE 6E 19111 DB 110T ; 190 22.19 F6BF 6E 19112 DB 110T ; 191 21.47 F6C0 6E 19113 DB 110T ; 192 20.75 F6C1 6E 19114 DB 110T ; 193 20.03 F6C2 6E 19115 DB 110T ; 194 19.30 F6C3 6E 19116 DB 110T ; 195 18.57 F6C4 6F 19117 DB 111T ; 196 17.83 F6C5 6F 19118 DB 111T ; 197 17.09 F6C6 6F 19119 DB 111T ; 198 16.35 F6C7 6F 19120 DB 111T ; 199 15.59 F6C8 6F 19121 DB 111T ; 200 14.84 F6C9 6F 19122 DB 111T ; 201 14.07 F6CA 70 19123 DB 112T ; 202 13.31 F6CB 70 19124 DB 112T ; 203 12.53 F6CC 70 19125 DB 112T ; 204 11.75 F6CD 70 19126 DB 112T ; 205 10.96 F6CE 70 19127 DB 112T ; 206 10.17 F6CF 71 19128 DB 113T ; 207 9.37 F6D0 71 19129 DB 113T ; 208 8.56 F6D1 71 19130 DB 113T ; 209 7.74 F6D2 71 19131 DB 113T ; 210 6.91 F6D3 71 19132 DB 113T ; 211 6.08 F6D4 72 19133 DB 114T ; 212 5.23 F6D5 72 19134 DB 114T ; 213 4.38 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 155 MC68HC908GP32 User Bootloader F6D6 72 19135 DB 114T ; 214 3.51 F6D7 72 19136 DB 114T ; 215 2.64 F6D8 72 19137 DB 114T ; 216 1.75 F6D9 73 19138 DB 115T ; 217 .85 F6DA 73 19139 DB 115T ; 218 -.06 F6DB 73 19140 DB 115T ; 219 -.99 F6DC 73 19141 DB 115T ; 220 -1.92 F6DD 74 19142 DB 116T ; 221 -2.88 F6DE 74 19143 DB 116T ; 222 -3.85 F6DF 74 19144 DB 116T ; 223 -4.83 F6E0 74 19145 DB 116T ; 224 -5.84 F6E1 75 19146 DB 117T ; 225 -6.86 F6E2 75 19147 DB 117T ; 226 -7.90 F6E3 75 19148 DB 117T ; 227 -8.97 F6E4 75 19149 DB 117T ; 228 -10.05 F6E5 76 19150 DB 118T ; 229 -11.17 F6E6 76 19151 DB 118T ; 230 -12.30 F6E7 76 19152 DB 118T ; 231 -13.47 F6E8 77 19153 DB 119T ; 232 -14.67 F6E9 77 19154 DB 119T ; 233 -15.89 F6EA 77 19155 DB 119T ; 234 -17.16 F6EB 78 19156 DB 120T ; 235 -18.46 F6EC 78 19157 DB 120T ; 236 -19.81 F6ED 78 19158 DB 120T ; 237 -21.20 F6EE 79 19159 DB 121T ; 238 -22.64 F6EF 79 19160 DB 121T ; 239 -24.14 F6F0 7A 19161 DB 122T ; 240 -25.70 F6F1 7A 19162 DB 122T ; 241 -27.33 F6F2 7B 19163 DB 123T ; 242 -29.04 F6F3 7B 19164 DB 123T ; 243 -30.84 F6F4 7C 19165 DB 124T ; 244 -32.74 F6F5 7C 19166 DB 124T ; 245 -34.77 F6F6 7D 19167 DB 125T ; 246 -36.94 F6F7 7E 19168 DB 126T ; 247 -39.27 F6F8 7E 19169 DB 126T ; 248 -41.82 F6F9 7F 19170 DB 127T ; 249 -44.63 F6FA 80 19171 DB 128T ; 250 -47.78 F6FB 81 19172 DB 129T ; 251 -51.39 F6FC 83 19173 DB 131T ; 252 -55.67 F6FD 84 19174 DB 132T ; 253 -61.03 F6FE 87 19175 DB 135T ; 254 -68.50 F6FF 64 19176 DB 100T ; 255 Sensor Failure - 100% applied F700 19177 include "matfactor.inc" 19178 ; Generated using EasyTherm4.exe, 19179 ; 19180 ; Air Temp Thermistor Comment Field 19181 ; 19182 ; File generated for use with stock 2490 ohm resistor at R4 19183 ; 19184 ; Steinhart-Hart coefficients: A= 5.987198E-04 B=3.94987E-04 C= -5.342268E-07 19185 ; 19186 ; Input Data Temp, degC Resistance 19187 ; 10 3500 19188 ; 25 1920 19189 ; 95 270 19190 ; 19191 19192 MATFACTOR: 19193 ; ADC Temp, degF F700 64 19194 DB 100T ; 0 Sensor Failure - 100% applied F701 FF 19195 DB 255T ; 1 745.15 F702 FF 19196 DB 255T ; 2 562.15 F703 FF 19197 DB 255T ; 3 479.48 F704 FF 19198 DB 255T ; 4 428.79 F705 FF 19199 DB 255T ; 5 393.23 F706 FF 19200 DB 255T ; 6 366.30 F707 FF 19201 DB 255T ; 7 344.86 F708 FF 19202 DB 255T ; 8 327.20 F709 FF 19203 DB 255T ; 9 312.26 F70A FF 19204 DB 255T ; 10 299.38 F70B FF 19205 DB 255T ; 11 288.10 F70C FF 19206 DB 255T ; 12 278.09 F70D FF 19207 DB 255T ; 13 269.11 F70E FF 19208 DB 255T ; 14 260.98 F70F FF 19209 DB 255T ; 15 253.57 F710 FF 19210 DB 255T ; 16 246.77 F711 FF 19211 DB 255T ; 17 240.49 F712 FF 19212 DB 255T ; 18 234.66 F713 FF 19213 DB 255T ; 19 229.23 F714 FF 19214 DB 255T ; 20 224.15 F715 FF 19215 DB 255T ; 21 219.38 F716 FF 19216 DB 255T ; 22 214.89 F717 FB 19217 DB 251T ; 23 210.64 F718 F7 19218 DB 247T ; 24 206.62 F719 F3 19219 DB 243T ; 25 202.80 F71A EF 19220 DB 239T ; 26 199.16 F71B EC 19221 DB 236T ; 27 195.69 F71C E8 19222 DB 232T ; 28 192.37 F71D E5 19223 DB 229T ; 29 189.19 F71E E2 19224 DB 226T ; 30 186.15 F71F DF 19225 DB 223T ; 31 183.22 F720 DC 19226 DB 220T ; 32 180.41 F721 DA 19227 DB 218T ; 33 177.70 F722 D7 19228 DB 215T ; 34 175.08 F723 D5 19229 DB 213T ; 35 172.55 F724 D2 19230 DB 210T ; 36 170.11 F725 D0 19231 DB 208T ; 37 167.75 F726 CD 19232 DB 205T ; 38 165.46 F727 CB 19233 DB 203T ; 39 163.24 F728 C9 19234 DB 201T ; 40 161.08 F729 C7 19235 DB 199T ; 41 158.99 F72A C5 19236 DB 197T ; 42 156.95 F72B C3 19237 DB 195T ; 43 154.97 F72C C1 19238 DB 193T ; 44 153.04 F72D BF 19239 DB 191T ; 45 151.16 F72E BD 19240 DB 189T ; 46 149.33 F72F BC 19241 DB 188T ; 47 147.54 F730 BA 19242 DB 186T ; 48 145.80 F731 B8 19243 DB 184T ; 49 144.09 F732 B6 19244 DB 182T ; 50 142.42 F733 B5 19245 DB 181T ; 51 140.79 F734 B3 19246 DB 179T ; 52 139.20 F735 B2 19247 DB 178T ; 53 137.63 F736 B0 19248 DB 176T ; 54 136.10 F737 AF 19249 DB 175T ; 55 134.60 F738 AD 19250 DB 173T ; 56 133.13 F739 AC 19251 DB 172T ; 57 131.69 F73A AA 19252 DB 170T ; 58 130.27 F73B A9 19253 DB 169T ; 59 128.88 F73C A8 19254 DB 168T ; 60 127.51 F73D A6 19255 DB 166T ; 61 126.17 F73E A5 19256 DB 165T ; 62 124.85 F73F A4 19257 DB 164T ; 63 123.55 F740 A2 19258 DB 162T ; 64 122.28 F741 A1 19259 DB 161T ; 65 121.02 F742 A0 19260 DB 160T ; 66 119.79 F743 9F 19261 DB 159T ; 67 118.57 F744 9D 19262 DB 157T ; 68 117.37 F745 9C 19263 DB 156T ; 69 116.19 F746 9B 19264 DB 155T ; 70 115.03 F747 9A 19265 DB 154T ; 71 113.88 F748 99 19266 DB 153T ; 72 112.75 F749 98 19267 DB 152T ; 73 111.63 F74A 97 19268 DB 151T ; 74 110.53 F74B 95 19269 DB 149T ; 75 109.44 F74C 94 19270 DB 148T ; 76 108.37 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 156 MC68HC908GP32 User Bootloader F74D 93 19271 DB 147T ; 77 107.31 F74E 92 19272 DB 146T ; 78 106.26 F74F 91 19273 DB 145T ; 79 105.23 F750 90 19274 DB 144T ; 80 104.21 F751 8F 19275 DB 143T ; 81 103.20 F752 8E 19276 DB 142T ; 82 102.20 F753 8D 19277 DB 141T ; 83 101.22 F754 8C 19278 DB 140T ; 84 100.24 F755 8B 19279 DB 139T ; 85 99.27 F756 8A 19280 DB 138T ; 86 98.32 F757 89 19281 DB 137T ; 87 97.37 F758 88 19282 DB 136T ; 88 96.44 F759 88 19283 DB 136T ; 89 95.51 F75A 87 19284 DB 135T ; 90 94.59 F75B 86 19285 DB 134T ; 91 93.68 F75C 85 19286 DB 133T ; 92 92.78 F75D 84 19287 DB 132T ; 93 91.89 F75E 83 19288 DB 131T ; 94 91.01 F75F 82 19289 DB 130T ; 95 90.13 F760 81 19290 DB 129T ; 96 89.26 F761 80 19291 DB 128T ; 97 88.40 F762 80 19292 DB 128T ; 98 87.55 F763 7F 19293 DB 127T ; 99 86.70 F764 7E 19294 DB 126T ; 100 85.86 F765 7D 19295 DB 125T ; 101 85.03 F766 7C 19296 DB 124T ; 102 84.20 F767 7B 19297 DB 123T ; 103 83.38 F768 7B 19298 DB 123T ; 104 82.56 F769 7A 19299 DB 122T ; 105 81.75 F76A 79 19300 DB 121T ; 106 80.95 F76B 78 19301 DB 120T ; 107 80.15 F76C 77 19302 DB 119T ; 108 79.36 F76D 77 19303 DB 119T ; 109 78.57 F76E 76 19304 DB 118T ; 110 77.79 F76F 75 19305 DB 117T ; 111 77.02 F770 74 19306 DB 116T ; 112 76.24 F771 73 19307 DB 115T ; 113 75.48 F772 73 19308 DB 115T ; 114 74.71 F773 72 19309 DB 114T ; 115 73.95 F774 71 19310 DB 113T ; 116 73.20 F775 70 19311 DB 112T ; 117 72.45 F776 70 19312 DB 112T ; 118 71.70 F777 6F 19313 DB 111T ; 119 70.96 F778 6E 19314 DB 110T ; 120 70.22 F779 6D 19315 DB 109T ; 121 69.49 F77A 6D 19316 DB 109T ; 122 68.76 F77B 6C 19317 DB 108T ; 123 68.03 F77C 6B 19318 DB 107T ; 124 67.31 F77D 6B 19319 DB 107T ; 125 66.59 F77E 6A 19320 DB 106T ; 126 65.87 F77F 69 19321 DB 105T ; 127 65.15 F780 68 19322 DB 104T ; 128 64.44 F781 68 19323 DB 104T ; 129 63.73 F782 67 19324 DB 103T ; 130 63.03 F783 66 19325 DB 102T ; 131 62.32 F784 66 19326 DB 102T ; 132 61.62 F785 65 19327 DB 101T ; 133 60.92 F786 64 19328 DB 100T ; 134 60.23 F787 64 19329 DB 100T ; 135 59.53 F788 63 19330 DB 99T ; 136 58.84 F789 62 19331 DB 98T ; 137 58.15 F78A 61 19332 DB 97T ; 138 57.46 F78B 61 19333 DB 97T ; 139 56.78 F78C 60 19334 DB 96T ; 140 56.09 F78D 5F 19335 DB 95T ; 141 55.41 F78E 5F 19336 DB 95T ; 142 54.73 F78F 5E 19337 DB 94T ; 143 54.05 F790 5D 19338 DB 93T ; 144 53.37 F791 5D 19339 DB 93T ; 145 52.69 F792 5C 19340 DB 92T ; 146 52.02 F793 5B 19341 DB 91T ; 147 51.34 F794 5B 19342 DB 91T ; 148 50.67 F795 5A 19343 DB 90T ; 149 50.00 F796 59 19344 DB 89T ; 150 49.33 F797 59 19345 DB 89T ; 151 48.66 F798 58 19346 DB 88T ; 152 47.99 F799 57 19347 DB 87T ; 153 47.32 F79A 57 19348 DB 87T ; 154 46.65 F79B 56 19349 DB 86T ; 155 45.98 F79C 55 19350 DB 85T ; 156 45.32 F79D 55 19351 DB 85T ; 157 44.65 F79E 54 19352 DB 84T ; 158 43.98 F79F 53 19353 DB 83T ; 159 43.31 F7A0 53 19354 DB 83T ; 160 42.65 F7A1 52 19355 DB 82T ; 161 41.98 F7A2 51 19356 DB 81T ; 162 41.31 F7A3 51 19357 DB 81T ; 163 40.65 F7A4 50 19358 DB 80T ; 164 39.98 F7A5 4F 19359 DB 79T ; 165 39.31 F7A6 4F 19360 DB 79T ; 166 38.64 F7A7 4E 19361 DB 78T ; 167 37.98 F7A8 4D 19362 DB 77T ; 168 37.31 F7A9 4D 19363 DB 77T ; 169 36.64 F7AA 4C 19364 DB 76T ; 170 35.96 F7AB 4B 19365 DB 75T ; 171 35.29 F7AC 4B 19366 DB 75T ; 172 34.62 F7AD 4A 19367 DB 74T ; 173 33.95 F7AE 49 19368 DB 73T ; 174 33.27 F7AF 49 19369 DB 73T ; 175 32.59 F7B0 48 19370 DB 72T ; 176 31.91 F7B1 47 19371 DB 71T ; 177 31.23 F7B2 47 19372 DB 71T ; 178 30.55 F7B3 46 19373 DB 70T ; 179 29.87 F7B4 45 19374 DB 69T ; 180 29.18 F7B5 44 19375 DB 68T ; 181 28.50 F7B6 44 19376 DB 68T ; 182 27.81 F7B7 43 19377 DB 67T ; 183 27.11 F7B8 42 19378 DB 66T ; 184 26.42 F7B9 42 19379 DB 66T ; 185 25.72 F7BA 41 19380 DB 65T ; 186 25.02 F7BB 40 19381 DB 64T ; 187 24.32 F7BC 40 19382 DB 64T ; 188 23.61 F7BD 3F 19383 DB 63T ; 189 22.90 F7BE 3E 19384 DB 62T ; 190 22.19 F7BF 3D 19385 DB 61T ; 191 21.47 F7C0 3D 19386 DB 61T ; 192 20.75 F7C1 3C 19387 DB 60T ; 193 20.03 F7C2 3B 19388 DB 59T ; 194 19.30 F7C3 3B 19389 DB 59T ; 195 18.57 F7C4 3A 19390 DB 58T ; 196 17.83 F7C5 39 19391 DB 57T ; 197 17.09 F7C6 38 19392 DB 56T ; 198 16.35 F7C7 38 19393 DB 56T ; 199 15.59 F7C8 37 19394 DB 55T ; 200 14.84 F7C9 36 19395 DB 54T ; 201 14.07 F7CA 35 19396 DB 53T ; 202 13.31 F7CB 35 19397 DB 53T ; 203 12.53 F7CC 34 19398 DB 52T ; 204 11.75 F7CD 33 19399 DB 51T ; 205 10.96 F7CE 32 19400 DB 50T ; 206 10.17 F7CF 31 19401 DB 49T ; 207 9.37 F7D0 31 19402 DB 49T ; 208 8.56 F7D1 30 19403 DB 48T ; 209 7.74 F7D2 2F 19404 DB 47T ; 210 6.91 F7D3 2E 19405 DB 46T ; 211 6.08 F7D4 2D 19406 DB 45T ; 212 5.23 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 157 MC68HC908GP32 User Bootloader F7D5 2C 19407 DB 44T ; 213 4.38 F7D6 2C 19408 DB 44T ; 214 3.51 F7D7 2B 19409 DB 43T ; 215 2.64 F7D8 2A 19410 DB 42T ; 216 1.75 F7D9 29 19411 DB 41T ; 217 .85 F7DA 28 19412 DB 40T ; 218 -.06 F7DB 27 19413 DB 39T ; 219 -.99 F7DC 26 19414 DB 38T ; 220 -1.92 F7DD 25 19415 DB 37T ; 221 -2.88 F7DE 24 19416 DB 36T ; 222 -3.85 F7DF 23 19417 DB 35T ; 223 -4.83 F7E0 22 19418 DB 34T ; 224 -5.84 F7E1 21 19419 DB 33T ; 225 -6.86 F7E2 20 19420 DB 32T ; 226 -7.90 F7E3 1F 19421 DB 31T ; 227 -8.97 F7E4 1E 19422 DB 30T ; 228 -10.05 F7E5 1D 19423 DB 29T ; 229 -11.17 F7E6 1C 19424 DB 28T ; 230 -12.30 F7E7 1B 19425 DB 27T ; 231 -13.47 F7E8 19 19426 DB 25T ; 232 -14.67 F7E9 18 19427 DB 24T ; 233 -15.89 F7EA 17 19428 DB 23T ; 234 -17.16 F7EB 16 19429 DB 22T ; 235 -18.46 F7EC 14 19430 DB 20T ; 236 -19.81 F7ED 13 19431 DB 19T ; 237 -21.20 F7EE 11 19432 DB 17T ; 238 -22.64 F7EF 10 19433 DB 16T ; 239 -24.14 F7F0 0E 19434 DB 14T ; 240 -25.70 F7F1 0D 19435 DB 13T ; 241 -27.33 F7F2 0B 19436 DB 11T ; 242 -29.04 F7F3 09 19437 DB 9T ; 243 -30.84 F7F4 07 19438 DB 7T ; 244 -32.74 F7F5 05 19439 DB 5T ; 245 -34.77 F7F6 03 19440 DB 3T ; 246 -36.94 F7F7 01 19441 DB 1T ; 247 -39.27 F7F8 00 19442 DB 0T ; 248 -41.82 F7F9 00 19443 DB 0T ; 249 -44.63 F7FA 00 19444 DB 0T ; 250 -47.78 F7FB 00 19445 DB 0T ; 251 -51.39 F7FC 00 19446 DB 0T ; 252 -55.67 F7FD 00 19447 DB 0T ; 253 -61.03 F7FE 00 19448 DB 0T ; 254 -68.50 F7FF 64 19449 DB 100T ; 255 Sensor Failure - 100% applied 19450 ; Room here for one more inc file only 19451 ;------------------------------------------------------------------ E000 19452 org $E000 19453 ; Tables, copied into RAM on demand 19454 ; Most functions will primarily work from the flash copy 19455 ; 8 Pages in total 19456 19457 flash_table0: ; config variables 19458 E000 01 19459 personality_f db %00000001 ; Only 1 allowed to be set unless in 19460 ; EDIS or WHEEL mode, if all are set 19461 ; to 0 then thats fuel only (std MS)! 19462 ;MSNS equ 1 Megasquirtnspark 19463 ;MSNEON equ 2 MS neon decoder 19464 ;WHEEL equ 4 generalised decoder 36-1, 60-2 etc 19465 ;WHEEL2 equ 8 If in WHEEL mode then WHEEL2 is 0 = -1 1 = -2 19466 ;EDIS equ $10 edis 19467 ;DUALEDIS equ $20 if in EDIS mode then this allows two edis 19468 ; modules (for edis4 on V8, edis6 on V12) 19469 ;TFI equ $40 Ford TFI system 19470 ;HEI7 equ $80 GM 7 pin HEI 19471 E001 06 19472 outputpins_f db %00000110 19473 ; bits= 76543210 19474 ; equ 1 FIDLE for Idle Air Valve || spark output (as per MSnS) 19475 ; equ 2 LED17 for squirt led || coila output 19476 ; 19477 ; bit 2 bit 3 19478 ; LED18_2 LED18 function 19479 ; 0 0 wled 19480 ; 0 1 irq 19481 ; 1 0 output4 or fan control (see bit 6) 19482 ; 1 1 spark c 19483 19484 ;REUSE_LED19 equ $10 LED19 for accel led || coilb output 19485 ;X2_FAN equ $20 X2 = water Inj pulsed out || fan control 19486 ; ** Please note: Water inj uses X2 to pulse output, X3 will still 19487 ; come on with water inj or NOS depending on which is on 19488 ; 19489 ;LED18_FAN equ $40 LED18 output4 || fan control 19490 ; ** only allowed if bit 2 = 1 and bit 3 = 0 19491 ;Mulitplex Ign equ $80 NORMAL || toyota DLI ignition 19492 ; multiplex 19493 E002 F0 19494 SRevLimRPM db 240T ; Standard RPM limit for spark retard (rpm*100) E003 38 19495 SRevLimAngle db 56T ; Spark retard for above +10 degrees 19496 ; 10 = 10 + 10 i.e. -10 start point. 19497 ; So 56T = 10BTDC ) E004 32 19498 SRevLimHTime db 50T ; Time in 1/10Sec in Soft limit till 19499 ; hard limit cuts in *0.1 E005 0A 19500 SRevLimCTime db 10T ; NOT USED E006 FA 19501 RevLimit_f db 250T ; Hard Rev limiter (rpm*100) E007 00 19502 Out1Lim db 0T ; Output1 On point in RAW except for 19503 ; TEMPS then its in F -40, so 200F switch 19504 ; on point = 240F 19505 E008 00 19506 Out1Source db 0T ; Output 1 source, index from secl, 19507 ; Standard Out1source 19508 ; This is secl + val up to 30 (ego2 correction) 19509 ; 31 = Traction control >31 is not valid as 19510 ; this is from RAM 19511 E009 00 19512 Out2Lim db 0T ; Output 2 limit As out1Lim 19513 E00A 00 19514 Out2Source db 0T ; Same as Out1Source 19515 E00B 42 19516 feature1_f db %01000010 19517 ;wd_2trig equ 1 wheel decoder 2nd trigger i/p - new in 023c9 19518 ;egoIgnCount equ 2 EGO Step Counter mSecs || Ignition Pulses^ 19519 ;whlsim equ 4 Wheel simulator off on 19520 ;taeIgnCount equ 8 Acceleration Timer Seconds^ || Engine Cycles 19521 ; NOT USE equ $10 NOT USED NOW 023 19522 ;hybridAlphaN equ $20 Hybrid Alpha N OFF^ || OFF 19523 ;CrankingPW2 equ $40 Fire PW2 during Cranking? YES^ || NO 19524 ;Nitrous equ $80 Nitrous system OFF || ON 19525 ;NOT allowed with W Inj 19526 E00C 00 19527 feature2_f db %00000000 ; more features 19528 ;BoostControl equ 1 Boost Controller OFF || ON 19529 ;ShiftLight equ 2 Shift Lights OFF || ON 19530 ;LaunchControl equ 4 launch Control OFF || ON 19531 ;PWMidle equ 8 PWM Mode B+G On Off || Fielding PWM 19532 ; only if outputpins_f bit 1 = 0 19533 ;out3sparkd equ $10 Output 3 Output 3 || Spark D 19534 ;min_dwell equ $20 JAMES? 19535 ;dwellduty50 equ $40 JAMES? 19536 ;config_error equ $80 this is only set if non-sense combination 19537 ; of options - don't run. 19538 E00D 04 19539 whlsimcnt db 04T ; How many outputs when simulating wheel E00E 03 19540 bcFreqDiv_f db 3T ; Solenoid PW rate BITS 0 1 and 2 used : 19541 ; "INVALID","39.0 Hz","19.5 Hz","13.0 Hz", 19542 ; "9.8 Hz","7.8 Hz","6.5 Hz","5.6 Hz" msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 158 MC68HC908GP32 User Bootloader E00F 0A 19543 bcUpdate_f db 10T ; Boost Controller Update Rate in mS 19544 ; (10min 255max) E010 40 19545 bcPgain_f db 64T ; B Controller P Gain % (0-100% = 0-255 in 19546 ; MS so MT value displayed = MS*0.3922) E011 05 19547 bcDgain_f db 5T ; Boost Controller D Gain % (0-100% = 0-255 19548 ; in MS so MT value displayed = MS*0.3922) E012 3A 19549 ShiftLo_f db 58T ; Shift light LED start point (rpm*100) E013 3C 19550 ShiftHi_f db 60T ; Shift Light Final point (RPM * 100) E014 28 19551 LaunchLimit_f db 40T ; Hard limit for Launch control (rpm*100) E015 0B 19552 edisms_f db 11T ; max rpm for EDIS multi-spark (rpm*100) E016 A0 19553 NosClt_f db 160T ; Nitrous System Min Coolant Temp Minimum 19554 ; point of coolant for NOS to enable in (F-40) E017 1E 19555 NosRpm_f db 30T ; Nitrous System Min RPM * 100, 3000rpm is 19556 ; minimum allowed (23) E018 3C 19557 NosRpmMax_f db 60T ; Nitrous Max RPM *100 (used for 19558 ; interpolating and cutting nos) 19559 E019 00 19560 Trig1_f db 0T ; wheel decoding E01A 00 19561 Trig2_f db 0T ; " E01B 00 19562 Trig3_f db 0T ; " E01C 00 19563 Trig4_f db 0T ; " E01D 00 19564 Trig1ret_f db 0T ; " E01E 00 19565 Trig2ret_f db 0T ; " E01F 00 19566 Trig3ret_f db 0T ; " E020 00 19567 Trig4ret_f db 0T ; " 19568 E021 60 19569 DTmode_f db %01100000 ; DualTable control, only 3 bits used. 19570 ; equ $10 Normal single table mode ^ || Dual Table Mode 19571 ; equ $20 Gamma E correction OFF for PW1 || Gamma E ON^ 19572 ; equ $40 Gamma E correction OFF for PW2 || Gamma E ON^ 19573 E022 69 19574 FASTIDLEtemp_f db 105T ; Feilding 2-Wire Idle control Fast Idle 19575 ; lower temperature F -40 E023 EA 19576 slowIdleTemp_f db 234T ; Feilding 2-Wire Idle control Slow Idle 19577 ; upper temperature F -40 E024 6E 19578 fastIdle_f db 110T ; Fast Idle RPM (RPM*10 100-2550 rpm range) E025 41 19579 slowIdle_f db 65T ; Slow Idle RPM (RPM*10 100-2550 rpm range) E026 1E 19580 idleThresh_f db 30T ; TPS Raw value for Idle mode to kick in. E027 FF 19581 EgoLimitKPa_f db 255T ; MAP KPa Point to change Ego +- limit (39) E028 05 19582 EgoLim2_f db 05T ; New Ego limit when MAP KPa above 19583 ; EgoLimitKPa_f E029 1E 19584 LC_Throttle_f db 30T ; Throttle position in RAW data for launch 19585 ; control mode E02A 2A 19586 LC_LimAngle_f db 42T ; Launch control soft limiter angle 19587 ; *0.352 -28.4 -10 to 45 allowed E02B 23 19588 LC_Soft_Rpm_f db 35T ; Launch Soft Limit RPM (43) E02C 00 19589 Over_B_P_f db 0T ; Over boost Protection KPa setpoint 19590 ; <100 = no boost protection E02D 03 19591 SparkCutNum_f db 3T ; Rev Limiter Hard cut spark cut number to 19592 ; remove sparks from SparkCutBase_f 19593 E02E 00 19594 feature3_f db %00000000 ; (46) 19595 ;KPaTpsOpenb equ 1 Open Loop Mode TPS || KPa 19596 ;VarLaunchb equ 2 Variable Launch OFF || ON 19597 ; Only if Launch is set on via: 19598 ; LaunchControl:feature2 19599 ;CltIatIgnitionb equ 4 Clt/Iat Related ignition OFF || ON (Spark modes Only) 19600 ;WaterInjb equ 8 Water Inj OFF || ON 19601 ; (Only if NOS is OFF) 19602 ; xx00xxxx NOT ALLOWED 19603 ; xx01xxxx RPM limiter Hard cut = Spark cut only 19604 ; xx11xxxx RPM limiter hard cut = both fuel and spark 19605 ; xx10xxxx RPM limiter hard cut = Fuel cut only 19606 ;KnockDetb equ $40 Knock Detection OFF || ON (Spark modes only) 19607 ;TargetAFRb equ $80 target AFR Tbles OFF || ON 19608 19609 E02F B4 19610 cltAdvance_f db 180T ; Advance ignition whilst temp below this value F -40 E030 1B 19611 cltDeg_f db 27T ; Add 1 degree of advance for this value(F) 19612 ; below cltAdvance_f, so if 19613 ; cltAdvance_f=120(80F) and cltDeg_f=20 then 19614 ; at 10F advance will be 80-10/20= 3.5 E031 0F 19615 maxAdvAng_f db 15T ; Limit in degrees of advance for coolant 19616 ; related advance so it doesnt add loads of 19617 ; advance when very cold *0.352 E032 12 19618 iatDeg_f db 18T ; Iat Temp for 1 degree of retard related 19619 ; to IAT, exactly the same as cltDeg_f but 19620 ; retard rather than advance and 19621 ; IAT rather that CLT. F E033 4B 19622 kpaRetard_f db 75T ; Apply the IAT related retard when above 19623 ; this KPa, to stop retard at tickover E034 C8 19624 iatDanger_f db 200T ; Iat Temp to start Retard F -40 E035 37 19625 KnockRpmL_f db 55T ; Knock sensor max rpm RPM*100 (53) E036 0F 19626 KnockRpmLL_f db 15T ; Knock sensor min rpm RPM*100 E037 FF 19627 KnockKpaL_f db 255T ; knock sensor max KPa E038 06 19628 KnockRet1_f db 06T ; First Retard amount for knock system *0.352 E039 03 19629 KnockRet2_f db 03T ; Subsequent Retard amount *0.352 E03A 03 19630 KnockAdv_f db 03T ; Advance amount for knock system *0.352 E03B 0F 19631 KnockMax_f db 15T ; Max Allowable retard *0.352 E03C 01 19632 KnockTim_f db 01T ; Timer for steps of knock advance / retard 19633 ; to be applied in Seconds 1 E03D 64 19634 iatpoint_f db 100T ; Water Inj IAT setpoint point F -40 (61) E03E 78 19635 wateripoint_f db 120T ; Water Injection KPa setpoint E03F 23 19636 wateriRpm_f db 35T ; Water Injection RPM setpoint RPM*100 E040 50 19637 kpaO2_f db 80T ; KPa Open loop setpoint for no O2 correction E041 C0 19638 tpsO2_f db 192T ; TPS Open Loop setpoint for no O2 correction Raw ADC 19639 E042 00 19640 feature4_f db %00000000; Another feature bit for enhanced (66) 19641 ;miss2ndb equ 1 missing tooth and 2nd trigger 19642 ;InvertOutOneb equ 2 Invert output1 19643 ;InvertOutTwob equ 4 Invert output2 19644 ;multisparkb equ 8 Edis multiSpark only if in EDIS mode 19645 ;KPaDotBoostb equ $10 Stop Accel Enrichment in boost? 19646 ; NEVER | IN BOOST 19647 ; (only if MAPdot bit 8 set) 19648 ;DtNosb equ $20 Only if DT(DTmode_f bit 4) which Bank do we 19649 ; add NOS PW to (Bank1=0 Bank2=1) 19650 ;OverRunOnb equ $40 Over Run fuel cut 19651 ;KpaDotSetb equ $80 Accel Enrichment TPSdot | MAPdot 19652 E043 C8 19653 NosTps_f db 200T ; Nitrous System Min TPS RAW ADC E044 32 19654 NosAngle_f db 50T ; Nitrous System Angle to remove from 19655 ; ignition *0.352 (68) E045 0C 19656 NosFuelLo_f db 12T ; Nitrous Pulse Width to add to fuel at 19657 ; 3000 rpm *0.1 in mSec this is for 19658 ; additional fuel for NOS E046 03 19659 NosFuelHi_f db 03T ; Nitrous Pulse Width to add to fuel at 19660 ; NosRpmMax_f *0.1 in mSec E047 11 19661 ORunRpm_f db 17T ; Max RPM for Over run fuel cut *100 E048 14 19662 ORunKpa_f db 20T ; Over run fuel cut when below kpa E049 05 19663 ORunTPS_f db 05T ; Over run when throttle position lower than this RAW ADC (73) E04A EA 19664 EfanOnTemp_f db 234T ; X2 or LED 17 electric fan output on temp 19665 ; F-40 E04B B9 19666 EfanOffTemp_f db 185T ; X2 or LED 17 electric fan output off temp 19667 ; F-40 19668 E04C 00 19669 feature5_f db %00000000 ; Yet another feature bit (76) 19670 ; xxxxxx00 NOT ALLOWED 19671 ; xxxxxx01 Launch control Hard cut = Spark cut only 19672 ; xxxxxx11 Launch control hard cut = both fuel and spark 19673 ; xxxxxx10 Launch control Hard cut = Fuel cut only 19674 ;staging equ $0c (bits 3 and 4) Roger Enns Staging Mode 19675 ; 00 Staging 0ff 19676 ; 01 RPM based 19677 ; 10 MAP Based 19678 ; 11 TPS based msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 159 MC68HC908GP32 User Bootloader 19679 ; xx00xxxx NOT ALLOWED 19680 ; xx01xxxx Boost Limit Hard cut = Spark cut only 19681 ; xx11xxxx Boost Limit hard cut = both fuel and spark 19682 ; xx10xxxx Boost Limit Hard cut = Fuel cut only 19683 ;NosLagSystemb: equ $40 Nos Anti-lag System (Only when Nos selected) 19684 ;SparkTable2b: equ $80 Second Spark Table used if input low 19685 E04D 03 19686 SparkCutNLC_f db 03T ; Launch control spark cut, this is the 19687 ; amount of sparks to remove from 19688 ; SparkCutBase_f when in Launch hard cut E04E 06 19689 SparkCutBase_f db 06T ; Base number to cut sparks from MS 19690 ; = MT value - 1 E04F FF 19691 SCALEFAC_f db 255T ; Scaling factor for STAGED INJECTION MODE 19692 ; (prim flow/total flow*100) 255=100% 123=50% E050 19 19693 STGTRANS_f db 25T ; Staged transition point, rpm*100, kpa, 19694 ; or tps raw adc depending on staging 19695 ; method selected (See feature5_f bits 3-4) E051 03 19696 STGDELTA_f db 03T ; Staged operation off at (STGTRANS-STGDELTA) 19697 ; so this is raw data as STGTRANS E052 C8 19698 BarroHi_f db 200T ; Barometric Correction Max Limit in KPa (82) E053 14 19699 BarroLow_f db 20T ; Barometric Correction Lower Limit in KPa E054 03 19700 SparkCutBNum_f db 03T ; Number of sparks to remove from BASE value 19701 ; when Over Boost E055 50 19702 NosLowKpa_f db 80T ; Minimum KPa to fire Nos Anti-lag E056 78 19703 NosHiKpa_f db 120T ; Maximum KPa to fire Nos Anti-lag, 19704 ; Anti-lag will switch off when this is reached E057 00 19705 Spark2Delay_f db 00T ; Delay for Spark Table 2 to come in when 19706 ; input received. *0.1 1/10Sec E058 00 19707 Out1UpLim_f db 00T ; Output 1 top limit for window, so output1 19708 ; will go off above this value unless its 0 19709 ; then its ignored E059 00 19710 Out2UpLim_f db 00T ; Output 2 top limit for window (89) E05A 0C 19711 NumTeeth_f db 12T ; Number of teeth for wheel decoder E05B 1E 19712 MAPThresh_f db 30T ; MAP dot threshold for Accel Decel 19713 ; Enrichments *10 (KPa/Sec) 19714 E05C 00 19715 feature6_f db %00000000 ; More feature bits (92) 19716 ;VETable3b equ 1 Use VE table 3 when input low 19717 ;TargetAFR3b equ 2 Use Target AFR for VE3 if TargetAFRb:feature3 = 1 19718 ; and VETable3b:feature6 = 1 19719 ; hrd_disable 4 19720 ; wheel_old 8 19721 ; dualdizzy $10 19722 ;TractionCb equ $20 Traction control system on 19723 ;BoostDirb equ $40 Direction for boost control output, 19724 ; Increase boost = 0 Decrease boost = 1 19725 ;NoDecelBoostb equ $80 No deceleration enrichment when in boost 19726 ; (either MAP or TPSdot modes) 19727 E05D 00 19728 VE3Delay_f db 00T ; Delay for VE Table 3 to come in when 19729 ; input received. *0.1 1/10Sec 19730 RPMrate_f: E05E 00 19731 db 00T ; Fuel enrichment in mSec for 3000RPM/Sec 19732 ; increase or 5% slip if in VSS mode *0.1 E05F 64 19733 db 100T ; Fuel enrichment in mSec for 4000RPM/Sec 19734 ; increase or 15% slip if in VSS mode *0.1 E060 96 19735 db 150T ; Fuel enrichment in mSec for 6000RPM/Sec 19736 ; increase or 30% slip if in VSS mode *0.1 (96) E061 C8 19737 db 200T ; Fuel enrichment in mSec for 10000RPM/Sec 19738 ; increase or 70% slip if in VSS mode *0.1 19739 E062 02 19740 RPMthresh_f db 2T ; Threshhold for RPM change for traction 19741 ; (rpm * 1000) because it checks every 1/10 19742 ; sec and rpm = rpm*100. So 2 = 2000RPM/Sec 19743 ; threshold 19744 TractDeg_f: E063 00 19745 db 00T ; Ignition retard in Degrees for 3000RPM/Sec 19746 ; increase or 5% slip if in VSS mode *0.352 E064 38 19747 db 56T ; Ignition retard in Degrees for 4000RPM/Sec 19748 ; increase or 15% slip if in VSS mode *0.352 E065 38 19749 db 56T ; Ignition retard in Degrees for 6000RPM/Sec 19750 ; increase or 30% slip if in VSS mode *0.352 E066 55 19751 db 85T ; Ignition retard in Degrees for 10000RPM/Sec 19752 ; increase or 70% slip if in VSS mode *0.352(102) 19753 TractSpark_f: E067 00 19754 db 00T ; Spark Cut from Base number for 3000RPM/Sec 19755 ; increase or 5% slip if in VSS mode MAX 19756 ; ALLOWED 5 E068 00 19757 db 00T ; Spark Cut from Base number for 4000RPM/Sec 19758 ; increase or 15% slip if in VSS mode E069 01 19759 db 01T ; Spark Cut from Base number for 6000RPM/Sec 19760 ; increase or 30% slip if in VSS mode E06A 02 19761 db 02T ; Spark Cut from Base number for 10000RPM/Sec 19762 ; increase or 70% slip if in VSS mode (106) 19763 E06B 00 19764 BoostKnock_f db 00T ; Boost to remove from controller target when 19765 ; Knock detected (PSI) so value of MS 1 = 7KPa E06C 1E 19766 BoostKnMax_f db 30T ; Max Boost to remove when knocking in PSI so 19767 ; send 1 to MS this is 7KPa inside the code 19768 E06D 00 19769 feature7_f db %00000000 ; More feature bits (109) 19770 ;TractionNos equ 1 Turn Nos off in Traction Control if traction lost, 19771 ; only if Traction oN TractionCb:feature6 bit 6 19772 ;dwellcont equ 2 Real (crude) dwell control 19773 ;TCcycleSec equ 4 Hold traction settings for cycles || untill rpm 19774 ; stable for 0.1S only if Traction ON 19775 ; see TractionCb:feature6 bit 6 19776 ;WheelSensor equ 8 Traction control RPM Based || VSS 19777 ; only if Traction ON 19778 ; see TractionCb:feature6 bit 6 19779 ;AlphaTarAFR equ $10 speed density for target afr tables || Alpha-N 19780 ; only if Target AFR tables ON 19781 ; see TargetAFRb:feature3 bit 8 19782 ;TPSTargetAFR equ $20 0= Use Target AFR all the while || 1=Only when 19783 ; TPS above AFRTarTPS_f if Target AFR 19784 ; tables ON 19785 ; see TargetAFRb:feature3 bit 8 19786 ;idle_warmup equ $40 pwm idle warmup open loop 19787 ;idle_cl equ $80 pwm idle closed loop 19788 E06E 3C 19789 dwellcrank_f db 60T ; cranking dwell in 0.1ms E06F 28 19790 dwellrun_f db 40T ; running dwell in 0.1ms (111) 19791 19792 TractCycle_f: E070 03 19793 db 03T ; Engine cycles to hold enrichment / 19794 ; spark cut / retard for 3000RPM/Sec increase 19795 ; or 5% slip if in VSS mode E071 05 19796 db 05T ; Engine cycles to hold enrichment / 19797 ; spark cut / retard for 4000RPM/Sec increase 19798 ; or 15% slip if in VSS mode E072 08 19799 db 08T ; Engine cycles to hold enrichment / 19800 ; spark cut / retard for 6000RPM/Sec increase 19801 ; or 30% slip if in VSS mode E073 0C 19802 db 12T ; Engine cycles to hold enrichment / 19803 ; spark cut / retard for 15000RPM/Sec increase 19804 ; or 70% slip if in VSS mode 19805 E074 00 19806 feature8_f db %00000000 ; More feature bits (116) 19807 ;KPa300b: equ 1 0 = normal B+G sensor || 1 = 300 KPa sensor use. 19808 ;KPa400b: equ 2 0 = KPa300b setting || 400 KPa sensor use, 19809 ; only allowed when KPa300b = 1 19810 ;BoostTable3b: equ 4 Use boost table 3 when switch table input low 19811 ; equ 8, equ 10 used for sparks 5 & 6 19812 ;DecelMAPb: equ $20 Use TPS for Decel || Use MAP for Decel 19813 ;InterpAcelb: equ $40 Interpolate the accel enrichments down 19814 ; to a setpoint msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 160 MC68HC908GP32 User Bootloader 19815 ; equ $80 Output3 on if: Source Only || Source and 19816 ; Output1 on 19817 E075 00 19818 UDSpeedLo_f db 00T ; Min speed from the Undriven wheel for 19819 ;traction to work at. Volts *0.0196 5V=255 E076 FF 19820 UDSpeedLim_f db 255T ; Max speed from the Undriven wheel for 19821 ; traction to work at. Volts *0.0196 5V=255 E077 7D 19822 TCScaleFac_f db 125T ; Difference factor for speed inputs from 19823 ; driven and undriven inputs 19824 ; (255=100%) *0.39216 E078 19 19825 TCSlipFac_f db 25T ; Slip allowed between wheel sensors at low 19826 ; speed (255=100%) *0.39216 E079 FF 19827 AFRTarTPS_f db 255T ; TPS setpoint to go over to switch to target 19828 ; afr tables in RAW ADC (121) E07A 32 19829 idle_dc_lo db 50T ; Idle duty cycle at lower temp for 2-wire 19830 ; Fielding Idle control *1 MIn = 0 Max = 100 E07B 05 19831 TCSlipFacH_f db 5T ; Slip allowed between wheel sensors at 19832 ; high speed (255=100%) *0.39216 E07C FF 19833 LC_flatsel_f db 255T ; rpm above which arms flat shift mode E07D FF 19834 bc_max_diff db 255T ; Boost Controller max Difference in KPa E07E 00 19835 Out1Hys_f db 00T ; Hysterisis for Output1 in Raw ADC (126) E07F 00 19836 Out2Hys_f db 00T ; Hysterisis for Output2 in Raw ADC E080 37 19837 LC_flatlim db 55T ; flat shift revlimit E081 FF 19838 DecelKpa_f db 255T ; No Decel enrichment above this value in 19839 ; KPa (129) E082 00 19840 OverRunT_f db 00T ; Over Run Timer before enabling over run 19841 ; in Seconds *1 E083 FF 19842 BarCorr300_f db 255T ; Correction factor for KPA Factor for 19843 ; 300KPa sensor and 400KPa sensors only. 19844 ; 255=100% *0.39216 19845 ; (24%=GM300 28%=6300A Series and 19846 ; 78%= 6400A series) 19847 E084 00 19848 Out3Source_f db 00T ; Same as Out1Source 19849 E085 00 19850 Out3Lim_f db 00T ; Output 3 On/Off Limit as per standard MSnS E086 00 19851 TimerOut3_f db 00T ; Output 3 OFF delay timer in Seconds (134) *1 E087 00 19852 iatBoostSt_f db 00T ; Start point for boost reduction related to 19853 ; IAT when using Boost controller F -40 E088 00 19854 iatBoost_f db 00T ; Amount of IAT to remove 1 PSI from boost 19855 ; controller F, same theory as cltDeg_f E089 00 19856 tpsBooIAT_f db 00T ; TPS point to start removing boost from 19857 ; boost controller in RAW ADC 19858 E08A 00 19859 Out4Source_f db 00T ; Same as Out1Source 19860 E08B 00 19861 Out4Lim_f db 00T ; Output 4 On/Off Limit as per MSnS E08C 00 19862 LC_f_slim_f db 00T ; Retard timing above this rpm in flat shift mode E08D 00 19863 LC_f_limangle_f db 00T ; Retard timing to this in flat shift mode E08E 00 19864 spare3_f db 00T ; " E08F 05 19865 mindischg_f db 05T ; minimum discharge period for dwell 19866 ; control in mSec *0.1 E090 19 19867 idlePeriod_f db 25T ; idle period in ignition events E091 07 19868 idlekickrpm_f db 07T ; low rpm to trigger kick up of pwm idle duty E092 37 19869 idlekickdc_f db 55T ; default duty cycle 19870 E093 2D 19871 idledashdc_f db 45T ; dashpot default duty E094 1B 19872 idlemindc_f db 27T ; minimum duty cycle 19873 E095 00 19874 idle_dc_hi db 00T ; rmd Idle duty cycle at upper temp for 2-wire (warmup) E096 64 19875 idlekpa1_f db 100T ; rmd E097 64 19876 idlekpa2_f db 100T ; rmd E098 1E 19877 ikpamin1_f db 30T ; rmd E099 1E 19878 ikpamin2_f db 30T ; rmd E09A 64 19879 idlefreq_f db 100T ; rmd E09B 14 19880 delay2rpm_f db 20T ; rmd (155) E09C 0A 19881 idlePeriod2_f db 10T ; rmd (156) E09D 0F 19882 irestorerpm_f db 15T ; rmd (157) E09E 00 19883 idleclosedc_f db 0T ; rmd (158) 19884 E09F 00 19885 tachconf_f db 0T ; tach output config (159) E0A0 00 19886 Trig5_f db 0T ; wheel decoding - not used just yet (160) E0A1 00 19887 Trig6_f db 0T ; " E0A2 00 19888 Trig5ret_f db 0T ; " E0A3 00 19889 Trig6ret_f db 0T ; " 19890 19891 19892 RPMbasedrate_f: E0A4 05 19893 db 05T ; These next 4 are for adding AE based on engine rpm E0A5 14 19894 db 20T ; This is the actual engine rpm settings E0A6 23 19895 db 35T ; E0A7 37 19896 db 55T ; (167) E0A8 01 19897 RPMAQ_f2 db 01T ; Amount of fuel to add for 1st area of rpm based AE E0A9 0A 19898 db 10T ; Fuel for 2nd rpm area E0AA 0F 19899 db 15T ; Fuel for 3rd E0AB 14 19900 RPMAQL_f2: db 20T ; Fuel for 4th (171) 19901 E0AC 00 19902 n2odel_launch_f: db 00T ; delay from launch to nitrous activation E0AD 00 19903 n2odel_flat_f: db 00T ; delay from flat shift to nitrous activation E0AE 00 19904 n2oholdon_f: db 00T ; how long do extra nitrous fuel and retard hold on 19905 E0AF 00 19906 KPaCorr300_f db 00T ; KPa correction factor for 400/300KPa sensor (175) 19907 19908 tpsdotrate: E0B0 05 19909 db 05T ; These next 4 are delta points for TPSdot 19910 ; V/Sec 19911 ; these were hard coded points, now users can 19912 ; select what values 19913 ; they want where. *0.1960784 MAX=25.5 E0B1 14 19914 db 20T ; So 40 = 0.8V/0.1Sec or 8V/Sec as we check it 19915 ; every 0.1Sec E0B2 28 19916 db 40T ; E0B3 4D 19917 db 77T ; (179) 19918 mapdotrate_f: E0B4 05 19919 db 05T ; These next 4 are delta points for MAPdot 19920 ; KPa/Sec *10 so 255=2550KPa/Sec as we check it 19921 ; every 0.1Sec E0B5 0A 19922 db 10T ; E0B6 0F 19923 db 15T ; E0B7 19 19924 db 25T ; (183) 19925 MAPAQ_f: E0B8 14 19926 db 20T ; Enrichment to add in mSec for first Delta 19927 ; mapdotrate_f when in MAPdot mode *0.1 19928 ; these are all interpoled values) E0B9 32 19929 db 50T ; Enrichment to add in mSec for second Delta 19930 ; mapdotrate_f when in MAPdot mode *0.1 E0BA 69 19931 db 105T ; Enrichment to add in mSec for third Delta 19932 ; mapdotrate_f when in MAPdot mode *0.1 E0BB 96 19933 db 150T ; Enrichment to add in mSec for fourth Delta 19934 ; mapdotrate_f when in MAPdot mode *0.1 (187) 19935 TPSAQ_f1: E0BC 14 19936 db 20T ; Enrichment to add in mSec for first Delta 19937 ; tpsdotrate_f when in TPSdot mode *0.1 E0BD 32 19938 db 50T ; Enrichment to add in mSec for second Delta 19939 ; tpsdotrate_f when in TPSdot mode *0.1 E0BE 69 19940 db 105T ; Enrichment to add in mSec for third Delta ; 19941 ; tpsdotrate_f when in TPSdot mode *0.1 E0BF 96 19942 db 150T ; Enrichment to add in mSec for fourth Delta ; 19943 ; tpsdotrate_f when in TPSdot mode *0.1 19944 E0C0 5A 19945 TPSACOLD_f1 db 90T ; TPSACOLD (ms to add in when cold) *0.1 E0C1 03 19946 TPSTHRESH_f1 db 03T ; TPSTHRESH for Accel enrichment when in 19947 ; TPS mode *0.1953125 E0C2 02 19948 TPSASYNC_f1 db 02T ; TPSASYNC (accel enrich time in 1/10 19949 ; second increments) or in Enfgine Cycles. E0C3 64 19950 TPSDQ_f1 db 100T ; TPSDQ (195) msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 161 MC68HC908GP32 User Bootloader E0C4 64 19951 ACMULT_f1 db 100T ; Cold ACCELMULT E0C5 64 19952 OverRunClt_f1 db 100T ; No Over run fuel cut when below this 19953 ; coolant temp F-40 (197) E0C6 00 19954 AccelDecay_f db 00T ; This is the value in mS that the Accel 19955 ; enrichment will end up at when the timer 19956 ; has run. *0.1 19957 E0C7 00 19958 feature9_f db %00000000 ; (199) 19959 ; equ $01 NOT USED NOW 023 19960 ; equ $02 NOT USED NOW 023 19961 ; equ $04 Normal Accel | No Accel during ASE only in MAPdot mode 19962 ; equ $08 Normal Baro Correction | Use MAP for constant Baro Correction 19963 ; ONLY WORKS IN ALPHA-N MODE 19964 ;RpmAEBased equ $10 Use RPM based accel enrich if this bit is high 19965 ;Mass Air Flow use equ $20 19966 19967 ;NOTE! do not add any more data to table 0. Any more and stack may collide when in RAM. 19968 ;ends at $E0C8 19969 ;In 025x1 VE_r=$0106, so end of ram copy of data is $0106+$C8 = $1CE 19970 ; lowest observed stack was $1DB, leaving $D (13) bytes free. 19971 ; Will reserve 10 more bytes in .h for 025y, but that's it unless these data pages get 19972 ; reduced. 19973 ; That should make VE_r = $110 highest. 19974 19975 flash_table0_end: ;marker for easy lookup in lst file 19976 E100 19977 org $E100 19978 flash_table1: ; FUEL 1 12x12 Total Bytes = 144 19979 VE_f1: E100 2728292C 19980 db 39T,40T,41T,44T,44T,44T,45T,45T,45T,46T,47T,50T ; VE(0,0-11) 2C2C2D2D 2D2E2F32 E10C 2F2F3333 19981 db 47T,47T,51T,51T,50T,50T,50T,50T,51T,55T,56T,60T ; VE (1,0-11) 32323232 3337383C E118 2F2F3333 19982 db 47T,47T,51T,51T,50T,50T,50T,50T,51T,55T,56T,60T ; VE (2,0-11) 32323232 3337383C E124 34373739 19983 db 52T,55T,55T,57T,60T,61T,61T,65T,67T,70T,72T,75T ; VE (3,0-11) 3C3D3D41 4346484B E130 34373739 19984 db 52T,55T,55T,57T,60T,61T,61T,65T,67T,70T,72T,75T ; VE (4,0-11) 3C3D3D41 4346484B E13C 3B3C3C41 19985 db 59T,60T,60T,65T,66T,70T,70T,70T,72T,74T,77T,80T ; VE (5,0-11) 42464646 484A4D50 E148 3D3F4141 19986 db 61T,63T,65T,65T,68T,70T,72T,75T,77T,80T,84T,85T ; VE (6,0-11) 4446484B 4D505455 E154 4148484A 19987 db 65T,72T,72T,74T,74T,75T,75T,77T,79T,83T,89T,90T ; VE (7,0-11) 4A4B4B4D 4F53595A E160 464A4A4B 19988 db 70T,74T,74T,75T,75T,77T,77T,78T,82T,86T,95T,95T ; VE (8,0-11) 4B4D4D4E 52565F5F E16C 464A4A4B 19989 db 70T,74T,74T,75T,75T,77T,77T,78T,82T,86T,95T,95T ; VE (9,0-11) 4B4D4D4E 52565F5F E178 4B4D4F49 19990 db 75T,77T,79T,73T,82T,82T,82T,85T,87T,89T,99T,100T; VE (10,0-11) 52525255 57596364 E184 4B4D4F49 19991 db 75T,77T,79T,73T,82T,82T,82T,85T,87T,89T,99T,100T; VE (11,0-11) 52525255 57596364 19992 E190 C8 19993 EGOTEMP_f db 200T ; EGOTEMP E191 10 19994 EGOCOUNTCMP_f db 16T ; EGOCOUNTCMP E192 01 19995 EGODELTA_f db 1T ; EGODELTA E193 0F 19996 EGOLIMIT_f db 15T ; EGOLIMIT E194 9B 19997 REQ_FUEL_f1 db 155T ; REQFUEL (148) E195 04 19998 DIVIDER_f1 db 4T ; DIVIDER E196 00 19999 Alternate_f1 db 0 ; alternate or simult (single table ONLY) E197 0A 20000 INJOPEN_f1 db 10T ; INJOPEN E198 00 20001 INJOCFUEL_f1 db 0T ; INJOCFUEL NOT USED NOW !!!!! 20002 ; Kept to fill hole E199 4B 20003 INJPWM_f1 db 75T ; INJPWM E19A FF 20004 INJPWMT_f1 db 255T ; INJPWMT E19B 0C 20005 BATTFAC_f1 db 12T ; BATTFAC E19C 05 20006 rpmk_f1 db $05 ; RPMK[0] E19D DC 20007 db $DC ; RPMK[1] 20008 RPMRANGEVE_f1: E19E 05 20009 db 5T ; RPMRANGEVE[0] E19F 0A 20010 db 10T ; RPMRANGEVE[1] E1A0 0F 20011 db 15T ; RPMRANGEVE[2] E1A1 14 20012 db 20T ; RPMRANGEVE[3] E1A2 1C 20013 db 28T ; RPMRANGEVE[4] E1A3 24 20014 db 36T ; RPMRANGEVE[5] E1A4 2C 20015 db 44T ; RPMRANGEVE[6] E1A5 34 20016 db 52T ; RPMRANGEVE[7] E1A6 37 20017 db 55T ; RPMRANGEVE[8] E1A7 3C 20018 db 60T ; RPMRANGEVE[9] E1A8 3E 20019 db 62T ; RPMRANGEVE[10] E1A9 41 20020 db 65T ; RPMRANGEVE[11] 20021 KPARANGEVE_f1: E1AA 14 20022 db 20T ; KPARANGEVE[0] E1AB 1E 20023 db 30T ; KPARANGEVE[1] E1AC 28 20024 db 40T ; KPARANGEVE[2] E1AD 32 20025 db 50T ; KPARANGEVE[3] E1AE 3C 20026 db 60T ; KPARANGEVE[4] E1AF 4B 20027 db 75T ; KPARANGEVE[5] E1B0 5A 20028 db 90T ; KPARANGEVE[6] E1B1 64 20029 db 100T ; KPARANGEVE[7] E1B2 6E 20030 db 110T ; KPARANGEVE[8] E1B3 78 20031 db 120T ; KPARANGEVE[9] E1B4 82 20032 db 130T ; KPARANGEVE[10] E1B5 96 20033 db 150T ; KPARANGEVE[11] 20034 E1B6 71 20035 config11_f1 db 113T ; Config11 (originally 113T for 8 cyl) (182) E1B7 70 20036 config12_f1 db 112T ; Config12 (originally 112T for 8 injectors) E1B8 00 20037 config13_f1 db 00T ; Config13 20038 E1B9 0D 20039 EGOrpm_f db 13T ; RPMOXLIMIT E1BA EA 20040 FASTIDLEbg_f db 234T ; E1BB 1A 20041 O2targetV_f db 26T ; VOLTOXTARGET (187) 20042 flash_table1_end: 20043 E200 20044 org $E200 20045 flash_table2: ; FUEL 2 - For PW2 when in Dual Table mode, if not 20046 ; in DT mode then this whole page is ignored 20047 VE_f2: ; 12x12 Total Bytes = 144 E200 2728292C 20048 db 39T,40T,41T,44T,44T,44T,45T,45T,45T,46T,47T,50T ; VE (0,0-11) 2C2C2D2D 2D2E2F32 E20C 2F2F3333 20049 db 47T,47T,51T,51T,50T,50T,50T,50T,51T,55T,56T,60T ; VE (1,0-11) 32323232 3337383C E218 2F2F3333 20050 db 47T,47T,51T,51T,50T,50T,50T,50T,51T,55T,56T,60T ; VE (2,0-11) 32323232 3337383C E224 34373739 20051 db 52T,55T,55T,57T,60T,61T,61T,65T,67T,70T,72T,75T ; VE (3,0-11) 3C3D3D41 4346484B E230 34373739 20052 db 52T,55T,55T,57T,60T,61T,61T,65T,67T,70T,72T,75T ; VE (4,0-11) 3C3D3D41 4346484B msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 162 MC68HC908GP32 User Bootloader E23C 3B3C3C41 20053 db 59T,60T,60T,65T,66T,70T,70T,70T,72T,74T,77T,80T ; VE (5,0-11) 42464646 484A4D50 E248 3D3F4141 20054 db 61T,63T,65T,65T,68T,70T,72T,75T,77T,80T,84T,85T ; VE (6,0-11) 4446484B 4D505455 E254 4148484A 20055 db 65T,72T,72T,74T,74T,75T,75T,77T,79T,83T,89T,90T ; VE (7,0-11) 4A4B4B4D 4F53595A E260 464A4A4B 20056 db 70T,74T,74T,75T,75T,77T,77T,78T,82T,86T,95T,95T ; VE (8,0-11) 4B4D4D4E 52565F5F E26C 464A4A4B 20057 db 70T,74T,74T,75T,75T,77T,77T,78T,82T,86T,95T,95T ; VE (9,0-11) 4B4D4D4E 52565F5F E278 4B4D4F49 20058 db 75T,77T,79T,73T,82T,82T,82T,85T,87T,89T,99T,100T; VE (10,0-11) 52525255 57596364 E284 4B4D4F49 20059 db 75T,77T,79T,73T,82T,82T,82T,85T,87T,89T,99T,100T; VE (11,0-11) 52525255 57596364 20060 20061 ; Removed these as not used in the code and allows us to shrink pages - PR 20062 ;CWU_f2 db 100T 20063 ;CWH_f2 db 025T 20064 ;AWEV_f2 db 020T 20065 ;AWC_f2 db 250T 20066 ;WWU_f2: ; type=byte entries=10 total bytes=10 20067 ; db 120T,120T,115T,115T,115T,110T,105T,100T 20068 ; db 100T,100T 20069 ;TPSAQ_f2: ; type=byte entries=4 total bytes=4 20070 ; db 13T,30T,40T,40T 20071 ;TPSacold_f2 db 2T 20072 ;TPSthresh_f2 db 6T 20073 ;TPSASYNC_f2 db 10T 20074 ;TPSDQ_f2 db 20T 20075 E290 C8 20076 EGOtemp_f2 db 200T ; For second O2 sensor (feature12_f2) E291 10 20077 EGOCOUNTCMP_f2 db 16T ; NOT USED E292 01 20078 EGOdelta_f2 db 1T ; For second O2 sensor (feature12_f2) (146) E293 0A 20079 EGOlimit_f2 db 10T ; For second O2 sensor (feature12_f2) E294 9B 20080 REQ_FUEL_f2 db 155T ; (148) E295 04 20081 Divider_f2 db 4T E296 00 20082 Alternate_f2 db 0T ; NOT USED E297 0A 20083 InjOpen_f2 db 10T E298 00 20084 InjOCFuel_f2 db 0T ; NOT USED NOW !!!!! Kept to fill hole E299 64 20085 INJPWM_f2 db 100T E29A FF 20086 INJPWMT_f2 db 255T E29B 0C 20087 BATTFAC_f2 db 12T ; (155) 20088 rpmk_f2: ; type=byte entries=2 total bytes=2 E29C 05DC 20089 db $05,$DC ; (156,157) 20090 RPMRANGEVE_f2: ; type=byte entries=8 total bytes=8 E29E 050A0F14 20091 db 5T,10T,15T,20T,28T,36T,44T,52T,55T,60T,65T,70T 1C242C34 373C4146 20092 KPARANGEVE_f2: ; type=byte entries=8 total bytes=8 E2AA 141E2832 20093 db 20T,30T,40T,50T,60T,75T,90T,100T,110T,120T,130T,140T 3C4B5A64 6E78828C 20094 config11_f2: E2B6 71 20095 config21_f db 113T ; NOT USED (182) 20096 config12_f2: E2B7 70 20097 config22_f db 112T ; NOT USED 20098 config13_f2: E2B8 00 20099 config23_f db %00000000 ; (184) 20100 ; equ $02 Narrow Band | Wide Band Note: DT bank 2 only (second O2 sensor type) 20101 ;(feature12_f2) 20102 ; equ $04 Speed Density | Alpha N Note: DT bank 2 only 20103 E2B9 0D 20104 EGOrpm_f2 db 13T ; RPMOXLIMIT for second O2 sensor if used (feature12_f2) E2BA 00 20105 db 0 ; not used E2BB 1A 20106 O2targetV_f2 db 26T ; VOLTOXTARGET for second O2 sensor if used (feature12_f2) E2BC 00 20107 db 0T ; 3 Spares to fill holes for MT (188) E2BD 00 20108 db 0T E2BE 00 20109 db 0T 20110 E2BF 00 20111 feature12_f2 db %00000000 ; (191) 20112 ;SecondO2b equ 1 Second O2 sensor only for use in Dual Table 20113 ; Mode (DTmode_f bit 4) 20114 20115 flash_table2_end: 20116 E300 20117 org $E300 20118 flash_table3: ; SPARK Table 1 20119 ST_f1: ; *0.352 -28.4 Min -10 Max 80 E300 35353A46 20120 db 53T,53T,58T,70T,90T,119T,131T,131T,131T,131T,131T,131T ;(0,0-11) 5A778383 83838383 E30C 35353A46 20121 db 53T,53T,58T,70T,87T,113T,119T,119T,119T,119T,119T,119T ;(1,0-11) 57717777 77777777 E318 3A3A4046 20122 db 58T,58T,64T,70T,84T,107T,113T,113T,113T,113T,113T,113T ;(2,0-11) 546B7171 71717171 E324 3A3A4046 20123 db 58T,58T,64T,70T,81T,104T,107T,107T,107T,107T,107T,107T ;(3,0-11) 51686B6B 6B6B6B6B E330 3A3A4046 20124 db 58T,58T,64T,70T,81T,93T,101T,101T,101T,101T,101T,101T ;(4,0-11) 515D6565 65656565 E33C 3A3A4046 20125 db 58T,58T,64T,70T,81T,93T,101T,101T,101T,101T,101T,101T ;(5,0-11) 515D6565 65656565 E348 3A3A4046 20126 db 58T,58T,64T,70T,81T,93T,101T,101T,101T,101T,101T,101T ;(6,0-11) 515D6565 65656565 E354 3A3A4046 20127 db 58T,58T,64T,70T,81T,93T,101T,101T,101T,101T,101T,101T ;(7,0-11) 515D6565 65656565 E360 3A3A3D43 20128 db 58T,58T,61T,67T,78T,90T,98T,98T,98T,98T,98T,98T ;(8,0-11) 4E5A6262 62626262 E36C 3A3A3A40 20129 db 58T,58T,58T,64T,75T,87T,95T,95T,95T,95T,95T,95T ;(9,0-11) 4B575F5F 5F5F5F5F E378 3A3A373D 20130 db 58T,58T,55T,61T,72T,84T,92T,92T,92T,92T,92T,92T ;(a,0-11) 48545C5C 5C5C5C5C E384 3A3A333A 20131 db 58T,58T,51T,58T,69T,81T,81T,81T,81T,81T,81T,81T ;(b,0-11) (143) 45515151 51515151 20132 20133 RPMRANGEST_f1: E390 05070D14 20134 db 05T,07T,13T,20T,30T,40T,50T,60T,61T,62T,63T,64T 1E28323C 3D3E3F40 20135 ; RPMRANGEST[0-11] 20136 20137 KPARANGEST_f1: E39C 1E28323C 20138 db 30T,40T,50T,60T,70T,80T,90T,100T,110T,120T,130T,140T ; (last byte 167) 46505A64 6E78828C 20139 ; KPARANGEST[0-b] 20140 20141 ;; org $d3a8 ; stick them up out of the way at known values E3A8 AB 20142 TriggAngle_f db 171T ; TriggAngle (60 deg) (168) *0.352 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 163 MC68HC908GP32 User Bootloader E3A9 00 20143 FixedAngle_f db 0T ; FixedAngle *0.352 -28.4 min -10 Max 80 20144 ; THIS MUST BE -10 (0) for non fixed angle E3AA 00 20145 TrimAngle_f db 0T ; TrimAngle (NOT cleared on startup) *0.352 E3AB 38 20146 CrankAngle_f db 56T ; Cranking advance (10deg) *0.352 -28.4 20147 ; min -10 max 80 E3AC 00 20148 SparkHoldCyc_f db 0T ; SparkHoldCyc (hold spark x cycles on 20149 ; stall and restart) E3AD 04 20150 SparkConfig1_f db 4T ; SparkConfig1 (Normal trigger, trigger 20151 ; return based low speed spark) Standard MSnS E3AE 00 20152 IdleAdvance_f db 0T ; IdleAdvance *0.342 -28.4 min -10 max 80 E3AF 00 20153 IdleTPSThresh_f db 0T ; below this TPS value idle advance E3B0 00 20154 IdleRPMThresh_f db 0T ; below this RPM value idle advance (0 disables) 20155 E3B1 00 20156 spare3_177 db 0T ; spare byte as demo E3B2 00 20157 spare3_178 db 0T ; spare byte as demo E3B3 00 20158 spare3_179 db 0T ; spare byte as demo E3B4 00 20159 spare3_180 db 0T ; spare byte as demo E3B5 00 20160 spare3_181 db 0T ; spare byte as demo E3B6 00 20161 spare3_182 db 0T ; spare byte as demo E3B7 00 20162 spare3_183 db 0T ; spare byte as demo E3B8 00 20163 spare3_184 db 0T ; spare byte as demo 20164 20165 flash_table3_end: 20166 E400 20167 org $E400 20168 flash_table4: ; Spark Table 2, used when input switched 20169 ; low if selected 20170 ST_f2: ; *0.352 -28.4 Min -10 Max 80 E400 35353A46 20171 db 53T,53T,58T,70T,90T,119T,131T,131T,131T,131T,131T,131T ;(0,0-11) 5A778383 83838383 E40C 35353A46 20172 db 53T,53T,58T,70T,87T,113T,119T,119T,119T,119T,119T,119T ;(1,0-11) 57717777 77777777 E418 3A3A4046 20173 db 58T,58T,64T,70T,84T,107T,113T,113T,113T,113T,113T,113T ;(2,0-11) 546B7171 71717171 E424 3A3A4046 20174 db 58T,58T,64T,70T,81T,104T,107T,107T,107T,107T,107T,107T ;(3,0-11) 51686B6B 6B6B6B6B E430 3A3A4046 20175 db 58T,58T,64T,70T,81T,93T,101T,101T,101T,101T,101T,101T ;(4,0-11) 515D6565 65656565 E43C 3A3A4046 20176 db 58T,58T,64T,70T,81T,93T,101T,101T,101T,101T,101T,101T ;(5,0-11) 515D6565 65656565 E448 3A3A4046 20177 db 58T,58T,64T,70T,81T,93T,101T,101T,101T,101T,101T,101T ;(6,0-11) 515D6565 65656565 E454 3A3A4046 20178 db 58T,58T,64T,70T,81T,93T,101T,101T,101T,101T,101T,101T ;(7,0-11) 515D6565 65656565 E460 3A3A3D43 20179 db 58T,58T,61T,67T,78T,90T,98T,98T,98T,98T,98T,98T ;(8,0-11) 4E5A6262 62626262 E46C 3A3A3A40 20180 db 58T,58T,58T,64T,75T,87T,95T,95T,95T,95T,95T,95T ;(9,0-11) 4B575F5F 5F5F5F5F E478 3A3A373D 20181 db 58T,58T,55T,61T,72T,84T,92T,92T,92T,92T,92T,92T ;(a,0-11) 48545C5C 5C5C5C5C E484 3A3A333A 20182 db 58T,58T,51T,58T,69T,81T,81T,81T,81T,81T,81T,81T ;(b,0-11) 45515151 51515151 20183 20184 RPMRANGEST_f2: E490 05070D14 20185 db 05T,07T,13T,20T,30T,40T,50T,60T,61T,62T,63T,64T 1E28323C 3D3E3F40 20186 ; RPMRANGEST[0-b] 20187 20188 KPARANGEST_f2: E49C 1E28323C 20189 db 30T,40T,50T,60T,70T,80T,90T,100T,110T,120T,130T,140T ; KPARANGEST[0-b] 46505A64 6E78828C 20190 20191 ; Moved here to make pages smaller to get more ram - PR 20192 E4A8 78 20193 CWU_f1 db 120T ; CWU (168) E4A9 28 20194 CWH_f1 db 040T ; CWH E4AA 23 20195 AWEV_f1 db 35T ; AWEV E4AB 00 20196 SpareASE db 00T ; Was After start timer, moved it :-) PR E4AC B4 20197 WWU_f1 db 180T ; WWU (-40 F) E4AD B4 20198 db 180T ; WWU (-20 F) E4AE A0 20199 db 160T ; WWU (0 F) E4AF 96 20200 db 150T ; WWU (20 F) E4B0 87 20201 db 135T ; WWU (40 F) E4B1 7D 20202 db 125T ; WWU (60 F) E4B2 71 20203 db 113T ; WWU (80 F) E4B3 6C 20204 db 108T ; WWU (100 F) E4B4 66 20205 db 102T ; WWU (130 F) E4B5 64 20206 db 100T ; WWU (160 F) E4B6 14 20207 PRIMEP_f1 db 20T ; PRIMEP (182) 20208 20209 ; This is the cranking Table so users can select a interpolated value of 20210 ; cranking PW the same as Warmup 20211 20212 CrankPWs_f: E4B7 B4 20213 db 180T ; -40F E4B8 78 20214 db 120T ; -20F E4B9 50 20215 db 80T ; 0F E4BA 3C 20216 db 60T ; 20F E4BB 37 20217 db 55T ; 40F E4BC 32 20218 db 50T ; 60F E4BD 2D 20219 db 45T ; 80F E4BE 28 20220 db 40T ; 100F E4BF 23 20221 db 35T ; 130F E4C0 1E 20222 db 30T ; 160F (192) 20223 E4C1 10 20224 feature11_f4 db %00010000 20225 ;AlwaysPrimeb equ 1 Only fire pump if Prime pulse ON | Prime pump every time 20226 20227 ; xxxxx00x = Prime on power up (Normal) 20228 ; xxxxx10x = Prime Twice (Incase one aint enough) 20229 ; xxxxx11x = Prime once after 2 seconds (allows pump to have primed fuel lines) 20230 ;NoPrimePb: equ 8 Use Priming Table | Use Prime Pulse (primePulse_f) *023 20231 ;cltcrankb: equ $10 use coolant temp for crank pulsewidth *023 20232 ;matcrankb: equ $20 use inlet air temp for crank pulsewidth. *023 20233 ; Both bits 4 and 5 means average 20234 ;ExCrFuelb: equ $40 Are we checking the TPS to see if we want to add extra fuel 20235 ; during cranking? 20236 20237 E4C2 03 20238 CrankRPM_f db $03 ; Maximum RPM for cranking (rpm*100) E4C3 B2 20239 tpsflood_f db $B2 ; Throttle position for floodclear mode in 20240 ; RAW ADC (195) E4C4 04 20241 primePulse_f db 04T ; prime pulse if not using table (feature11_f4 $8) *023 E4C5 00 20242 ExtraCrFu_f db 00T ; Extra cranking fuel multiplier (feature11_f4 $40) (197) 20243 flash_table4_end: 20244 E500 20245 org $E500 20246 flash_table5: ; FUEL Table 3 (VE3) used when input switched low if selected 20247 VE_f3: E500 2728292C 20248 db 39T,40T,41T,44T,44T,44T,45T,45T,45T,46T,47T,50T ; VE (0,0-11) 2C2C2D2D 2D2E2F32 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 164 MC68HC908GP32 User Bootloader E50C 2F2F3333 20249 db 47T,47T,51T,51T,50T,50T,50T,50T,51T,55T,56T,60T ; VE (1,0-11) 32323232 3337383C E518 2F2F3333 20250 db 47T,47T,51T,51T,50T,50T,50T,50T,51T,55T,56T,60T ; VE (2,0-11) 32323232 3337383C E524 34373739 20251 db 52T,55T,55T,57T,60T,61T,61T,65T,67T,70T,72T,75T ; VE (3,0-11) 3C3D3D41 4346484B E530 34373739 20252 db 52T,55T,55T,57T,60T,61T,61T,65T,67T,70T,72T,75T ; VE (4,0-11) 3C3D3D41 4346484B E53C 3B3C3C41 20253 db 59T,60T,60T,65T,66T,70T,70T,70T,72T,74T,77T,80T ; VE (5,0-11) 42464646 484A4D50 E548 3D3F4141 20254 db 61T,63T,65T,65T,68T,70T,72T,75T,77T,80T,84T,85T ; VE (6,0-11) 4446484B 4D505455 E554 4148484A 20255 db 65T,72T,72T,74T,74T,75T,75T,77T,79T,83T,89T,90T ; VE (7,0-11) 4A4B4B4D 4F53595A E560 464A4A4B 20256 db 70T,74T,74T,75T,75T,77T,77T,78T,82T,86T,95T,95T ; VE (8,0-11) 4B4D4D4E 52565F5F E56C 464A4A4B 20257 db 70T,74T,74T,75T,75T,77T,77T,78T,82T,86T,95T,95T ; VE (9,0-11) 4B4D4D4E 52565F5F E578 4B4D4F49 20258 db 75T,77T,79T,73T,82T,82T,82T,85T,87T,89T,99T,100T; VE (10,0-11) 52525255 57596364 E584 4B4D4F49 20259 db 75T,77T,79T,73T,82T,82T,82T,85T,87T,89T,99T,100T; VE (11,0-11) 52525255 57596364 20260 RPMRANGEVE_f3: E590 05 20261 db 5T ; RPMRANGEVE[0] (144) E591 0A 20262 db 10T ; RPMRANGEVE[1] E592 0F 20263 db 15T ; RPMRANGEVE[2] E593 14 20264 db 20T ; RPMRANGEVE[3] E594 1C 20265 db 28T ; RPMRANGEVE[4] E595 24 20266 db 36T ; RPMRANGEVE[5] E596 2C 20267 db 44T ; RPMRANGEVE[6] E597 34 20268 db 52T ; RPMRANGEVE[7] E598 37 20269 db 55T ; RPMRANGEVE[8] E599 3C 20270 db 60T ; RPMRANGEVE[9] E59A 3E 20271 db 62T ; RPMRANGEVE[10] E59B 41 20272 db 65T ; RPMRANGEVE[11] 20273 KPARANGEVE_f3: E59C 14 20274 db 20T ; KPARANGEVE[0] (156) E59D 1E 20275 db 30T ; KPARANGEVE[1] E59E 28 20276 db 40T ; KPARANGEVE[2] E59F 32 20277 db 50T ; KPARANGEVE[3] E5A0 3C 20278 db 60T ; KPARANGEVE[4] E5A1 4B 20279 db 75T ; KPARANGEVE[5] E5A2 5A 20280 db 90T ; KPARANGEVE[6] E5A3 64 20281 db 100T ; KPARANGEVE[7] E5A4 6E 20282 db 110T ; KPARANGEVE[8] E5A5 78 20283 db 120T ; KPARANGEVE[9] E5A6 82 20284 db 130T ; KPARANGEVE[10] E5A7 96 20285 db 150T ; KPARANGEVE[11] 20286 20287 ASEVTbl_f: E5A8 1E 20288 db 30T ; -40F This is the ASE table, only used if 20289 ; $02 set in feature9_f (168) E5A9 14 20290 db 20T ; -20F this is in percentage *1 so 30 = 30% E5AA 0F 20291 db 15T ; 0F E5AB 0C 20292 db 12T ; 20F E5AC 0A 20293 db 10T ; 40F E5AD 09 20294 db 9T ; 60F E5AE 08 20295 db 8T ; 80F E5AF 07 20296 db 7T ; 100F E5B0 06 20297 db 6T ; 130F E5B1 05 20298 db 5T ; 160F (177) 20299 E5B2 FA 20300 AWC_f1 db 250T ; After Start Warmup Time E5B3 00 20301 feature10_f5 db %00000000 ; (179) 20302 ;aseIgnCount equ 1 AFTER START Enrichment Seconds || Engine Cycles^ 20303 ;ASEHoldb: equ 2 Hold ASE from decaying for a period of time determined by TimFixASE_f 20304 ;MAPHoldb: equ 4 Fixed MAP during fixed time of ASE 20305 ;cltMAPb: equ 8 Use correction in air density (cltMATcorr_f) 20306 ;CltMATCheck: equ $10 0 = Use CLT 1 = Use IAT for correction temps in table 20307 E5B4 05 20308 TimFixASE_f db 5T ; Amount of time or cycles to hold ase to fixed value (180) 20309 ; rather than decay to 0 % over the timer E5B5 55 20310 CltFixASE_f db 85T ; Coolant temp setpoint to use Fixed value ASE E5B6 3C 20311 MAPFixASE_f db 60T ; If in fixed MAP mode then hold MAP at this value during fixed ASE time 20312 20313 cltMATcorr_f: ; E5B7 64 20314 db 100T ; 7 positions for CLT related correction to (183) E5B8 64 20315 db 100T ; IAT Air Density Correction 110 = correction * 110% E5B9 64 20316 db 100T E5BA 64 20317 db 100T E5BB 64 20318 db 100T E5BC 64 20319 db 100T E5BD 64 20320 db 100T ; (189) 20321 E5BE 32 20322 RPMReduLo_f db 50T ; lowest rpm to reduce correction by (190) E5BF 64 20323 RPMReduHi_f db 100T ; Highest rpm when correction is ZERO 20324 20325 CltMATRange: E5C0 00 20326 db 0T ; -40F User defined Temp settings for Clt Related Air Dens (192) E5C1 1E 20327 db 30T ; -10F E5C2 3C 20328 db 60T ; 20F E5C3 5A 20329 db 90T ; 50F E5C4 78 20330 db 120T ; 80F E5C5 96 20331 db 150T ; 110F E5C6 B4 20332 db 180T ; 140F (198) 20333 ;NOTE! do not add any more data to table 5. Any more and stack may collide when in RAM. 20334 flash_table5_end: 20335 E600 20336 org $E600 20337 flash_table6: ; AFR Table 1 - 8x8 AFR targets for VE table 1 20338 AFR_f1: ; This is in RAW ADC so 255 = 5V from O2 sensor E600 93939393 20339 db 147T,147T,147T,147T,147T,147T,147T,147T; AFR (0,0-7) 93939393 E608 93939393 20340 db 147T,147T,147T,147T,147T,147T,147T,147T; AFR (1,0-7) 93939393 E610 93939393 20341 db 147T,147T,147T,147T,147T,147T,147T,147T; AFR (2,0-7) 93939393 E618 93939393 20342 db 147T,147T,147T,147T,147T,147T,147T,147T; AFR (3,0-7) 93939393 E620 82828282 20343 db 130T,130T,130T,130T,130T,130T,130T,130T; AFR (4,0-7) 82828282 E628 7D7D7D7D 20344 db 125T,125T,125T,125T,125T,125T,125T,125T; AFR (5,0-7) 7D7D7D7D E630 7D7D7D7D 20345 db 125T,125T,125T,125T,125T,125T,125T,125T; AFR (6,0-7) 7D7D7D7D E638 78787878 20346 db 120T,120T,120T,120T,120T,120T,120T,120T; AFR (7,0-7) 78787878 20347 20348 RPMRANGEAFR_f1: E640 05 20349 db 5T ; RPMRANGEAFR1[0] E641 0A 20350 db 10T ; RPMRANGEAFR1[1] E642 0F 20351 db 15T ; RPMRANGEAFR1[2] E643 14 20352 db 20T ; RPMRANGEAFR1[3] E644 1C 20353 db 28T ; RPMRANGEAFR1[4] E645 24 20354 db 36T ; RPMRANGEAFR1[5] msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 165 MC68HC908GP32 User Bootloader E646 32 20355 db 50T ; RPMRANGEAFR1[6] E647 3C 20356 db 60T ; RPMRANGEAFR1[7] 20357 KPARANGEAFR_f1: E648 0F 20358 db 15T ; KPARANGEAFR1[0] E649 1E 20359 db 30T ; KPARANGEAFR1[1] E64A 32 20360 db 50T ; KPARANGEAFR1[2] E64B 3C 20361 db 60T ; KPARANGEAFR1[3] E64C 5A 20362 db 90T ; KPARANGEAFR1[4] E64D 64 20363 db 100T ; KPARANGEAFR1[5] E64E 6E 20364 db 110T ; KPARANGEAFR1[6] E64F 96 20365 db 150T ; KPARANGEAFR1[7] 20366 20367 ; AFR Table 2 - 8x8 AFR targets for VE table 3 20368 ; (VE3) used when input switched low if selected 20369 20370 AFR_f2: ; This is in RAW ADC so 255 = 5V from O2 sensor E650 93939393 20371 db 147T,147T,147T,147T,147T,147T,147T,147T; AFR (0,0-7) 93939393 E658 93939393 20372 db 147T,147T,147T,147T,147T,147T,147T,147T; AFR (1,0-7) 93939393 E660 93939393 20373 db 147T,147T,147T,147T,147T,147T,147T,147T; AFR (2,0-7) 93939393 E668 93939393 20374 db 147T,147T,147T,147T,147T,147T,147T,147T; AFR (3,0-7) 93939393 E670 82828282 20375 db 130T,130T,130T,130T,130T,130T,130T,130T; AFR (4,0-7) 82828282 E678 7D7D7D7D 20376 db 125T,125T,125T,125T,125T,125T,125T,125T; AFR (5,0-7) 7D7D7D7D E680 7D7D7D7D 20377 db 125T,125T,125T,125T,125T,125T,125T,125T; AFR (6,0-7) 7D7D7D7D E688 78787878 20378 db 120T,120T,120T,120T,120T,120T,120T,120T; AFR (7,0-7) 78787878 20379 20380 RPMRANGEAFR_f2: E690 05 20381 db 5T ; RPMRANGEAF2[0] E691 0A 20382 db 10T ; RPMRANGEAF2[1] E692 0F 20383 db 15T ; RPMRANGEAF2[2] E693 14 20384 db 20T ; RPMRANGEAF2[3] E694 1C 20385 db 28T ; RPMRANGEAF2[4] E695 24 20386 db 36T ; RPMRANGEAF2[5] E696 32 20387 db 50T ; RPMRANGEAF2[6] E697 3C 20388 db 60T ; RPMRANGEAF2[7] 20389 KPARANGEAFR_f2: E698 0F 20390 db 15T ; KPARANGEAF2[0] E699 1E 20391 db 30T ; KPARANGEAF2[1] E69A 32 20392 db 50T ; KPARANGEAF2[2] E69B 3C 20393 db 60T ; KPARANGEAF2[3] E69C 5A 20394 db 90T ; KPARANGEAF2[4] E69D 64 20395 db 100T ; KPARANGEAF2[5] E69E 6E 20396 db 110T ; KPARANGEAF2[6] E69F 96 20397 db 150T ; KPARANGEAF2[7] 20398 20399 ;2nd stage of nitrous E6A0 FF 20400 Nos2Rpm_f db 255T ; rpm starts at E6A1 FF 20401 Nos2RpmMax_f db 255T ; rpm ends st E6A2 00 20402 Nos2delay_f db 0T ; delay after stage 1 E6A3 00 20403 Nos2Angle_f db 0T ; retard E6A4 00 20404 Nos2PWLo_f db 0T ; +pw at low rpm E6A5 00 20405 Nos2PWHi_f db 0T ; +pw at max rpm 20406 20407 ;oddfire wheel decoder bits - very experimental E6A6 00 20408 outaoffs_f db 0T ; offset in steps 20409 ;bit0 = 0, 22.5 ignore for now 20410 ;bit1 = 0, 45 use 0 or 45 or 90 only 20411 ;bit2 = 0, 90 E6A7 00 20412 outaoffv_f db 0T ; 0-45deg variable offset E6A8 00 20413 outboffs_f db 0T E6A9 00 20414 outboffv_f db 0T E6AA 00 20415 outcoffs_f db 0T E6AB 00 20416 outcoffv_f db 0T E6AC 00 20417 outdoffs_f db 0T E6AD 00 20418 outdoffv_f db 0T E6AE 00 20419 outeoffs_f db 0T E6AF 00 20420 outeoffv_f db 0T E6B0 00 20421 outfoffs_f db 0T E6B1 00 20422 outfoffv_f db 0T 20423 20424 flash_table6_end: 20425 20426 E700 20427 org $E700 20428 flash_table7: 20429 20430 ;boost controller, kpa target rpm vs tps 6x6 20431 bc_kpa_f: E700 64646464 20432 db 100T,100T,100T,100T,100T,100T 6464 E706 64787878 20433 db 100T,120T,120T,120T,120T,120T 7878 E70C 64787878 20434 db 100T,120T,120T,120T,120T,120T 7878 E712 64787878 20435 db 100T,120T,120T,120T,120T,120T 7878 E718 64787878 20436 db 100T,120T,120T,120T,120T,120T 7878 E71E 64787878 20437 db 100T,120T,120T,120T,120T,120T 7878 20438 20439 RPMRANGEbc_f: E724 0A141E28 20440 db 10T,20T,30T,40T,50T,70T ; RPMRANGEbc[0-5] 3246 20441 TPSRANGEbc_f: E72A 334D667F 20442 db 51T,77T,102T,127T,179T,230T ; TPSRANGEbc[0-5] B3E6 20443 20444 ;boost controller, duty cycle target rpm vs tps 20445 20446 bc_dc_f: E730 32323232 20447 db 50T,50T,50T,50T,50T,50T 3232 E736 32323232 20448 db 50T,50T,50T,50T,50T,50T 3232 E73C 32323232 20449 db 50T,50T,50T,50T,50T,50T 3232 E742 32323232 20450 db 50T,50T,50T,50T,50T,50T 3232 E748 32323232 20451 db 50T,50T,50T,50T,50T,50T 3232 E74E 32323232 20452 db 50T,50T,50T,50T,50T,50T 3232 20453 20454 RPMRANGEbc_f2: E754 0A141E28 20455 db 10T,20T,30T,40T,50T,70T ; RPMRANGEbc[0-5] 3246 20456 TPSRANGEbc_f2: E75A 334D667F 20457 db 51T,77T,102T,127T,179T,230T ; TPSRANGEbc[0-5] B3E6 20458 20459 20460 ; Second boost target table, switched over on input if selected. 20461 bc3_kpa_f: E760 64646464 20462 db 100T,100T,100T,100T,100T,100T 6464 E766 64787878 20463 db 100T,120T,120T,120T,120T,120T 7878 E76C 64787878 20464 db 100T,120T,120T,120T,120T,120T msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 166 MC68HC908GP32 User Bootloader 7878 E772 64787878 20465 db 100T,120T,120T,120T,120T,120T 7878 E778 64787878 20466 db 100T,120T,120T,120T,120T,120T 7878 E77E 64787878 20467 db 100T,120T,120T,120T,120T,120T 7878 20468 20469 RPMRANGE3bc_f: E784 0A141E28 20470 db 10T,20T,30T,40T,50T,70T ; RPMRANGE2bc[0-5] 3246 20471 TPSRANGE3bc_f: E78A 334D667F 20472 db 51T,77T,102T,127T,179T,230T ; TPSRANGE2bc[0-5] B3E6 20473 20474 ;rotary leading trailing split timing 6x6 table 20475 split_f: E790 1D585858 20476 db 29T,88T,88T,88T,88T,88T 5858 E796 1D494949 20477 db 29T,73T,73T,73T,73T,73T 4949 E79C 1D3A3A3A 20478 db 29T,58T,58T,58T,58T,58T 3A3A E7A2 1D2B2B2B 20479 db 29T,43T,43T,43T,43T,43T 2B2B E7A8 1D1D1D1D 20480 db 29T,29T,29T,29T,29T,29T 1D1D E7AE 19191919 20481 db 25T,25T,25T,25T,25T,25T 1919 20482 20483 RPMRANGEsplit_f: E7B4 06081E28 20484 db 6T,8T,30T,40T,50T,70T ; RPMRANGE2bc[0-5] 3246 20485 KPARANGEsplit_f: E7BA 28323C50 20486 db 40T,50T,60T,80T,105T,106T ; TPSRANGE2bc[0-5] 696A E7C0 00 20487 p7feat1_f: db 0T ; a page7 config byte E7C1 20488 rotary2b equ 1 ; enable/disable twin rotor mode for BIT 20489 E7C1 00 20490 fixedsplit_f: db 0T ; fixed split for testing like Fixed in spark 20491 20492 flash_table7_end: 20493 20494 ms_rf_end_f: 20495 E7C2 20496 include "boot_r12.asm" 20497 ;===================================== 20498 ; MEGASQUIRT BOOTLOADER VERSION - Dec 2001 20499 ; 20500 ; Mods by Bruce Bowling 20501 ; 20502 ; Corrected bug in BootReset 5 20503 ; 20504 ;===================================== 20505 E7C2 20506 .header 'MC68HC908GP32 User Bootloader' E7C2 20507 .base 10t E7C2 20508 .pagewidth 130 E7C2 20509 .pagelength 90 20510 ;******************************************************************************************** 20511 ;* * 20512 ;* Bootloader - MC68HC908GP32 * 20513 ;* Copyright (c) Motorola, 2001 * 20514 ;* * 20515 ;******************************************************************************************** 20516 ;* * 20517 ;* This file provides the low level assembly bootloader routine. * 20518 ;* This program has been specially tailored towards the MC68HC908GP32. * 20519 ;* * 20520 ;******************************************************************************************** 20521 ;* * 20522 ;* File name: boot.asm Current Release Level: 1.1 * 20523 ;* Last Edit Date: 07-Jun-01 Classification: ES * 20524 ;* * 20525 ;* Include Files: gp32.equ : MC68HC908GP32 MCU definitions * 20526 ;* * 20527 ;* Assembler: P&E's CASM08Z Version: 3.16 * 20528 ;* * 20529 ;* Target: MC68HC908GP32 * 20530 ;* * 20531 ;* Documentation: MC68HC908GP32/H Rev 3 * 20532 ;* Motorola Microcontroller Technical Data * msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 167 MC68HC908GP32 User Bootloader 20533 ;* * 20534 ;******************************************************************************************** 20535 ;* * 20536 ;* Author: DHJ Klotz * 20537 ;* First Release: 26-Feb-00 * 20538 ;* * 20539 ;* Update History: * 20540 ;* * 20541 ;* Rev Date Author Description of Change * 20542 ;* ------ --------- ------ ----------------------------------------------------------- * 20543 ;* ES 1.0 26-Feb-00 DHJK Initial release for HC908 Seminar 2000. * 20544 ;* ES 1.1 07-Jun-01 DHJK Improved functionality for Application Note. * 20545 ;* * 20546 ;******************************************************************************************** 20547 ;* * 20548 ;* Notes: * 20549 ;* - In order to minimize overall program size, subroutines are position within the * 20550 ;* core bootloader routine. Although this can make the program somewhat difficult * 20551 ;* to read and follow, it permits the use of relative branch opcodes. Most of * 20552 ;* these subroutines can be called from an external application program. * 20553 ;* * 20554 ;******************************************************************************************** 20555 ;* * 20556 ;* Motorola reserves the right to make changes without further notice to any product * 20557 ;* herein to improve reliability, function, or design. Motorola does not assume any * 20558 ;* liability arising out of the application or use of any product, circuit, or software * 20559 ;* described herein; neither does it convey any license under its patent rights nor the * 20560 ;* rights of others. Motorola products are not designed, intended, or authorized for * 20561 ;* use as components in systems intended for surgical implant into the body, or other * 20562 ;* applications intended to support life, or for any other application in which the * 20563 ;* failure of the Motorola product could create a situation where personal injury or * 20564 ;* death may occur. Should Buyer purchase or use Motorola products for any such * 20565 ;* intended or unauthorized application, Buyer shall indemnify and hold Motorola and * 20566 ;* its officers, employees, subsidiaries, affiliates, and distributors harmless against * 20567 ;* all claims, costs, damages, and expenses, and reasonable attorney fees arising out * 20568 ;* of, directly or indirectly, any claim of personal injury or death associated with * 20569 ;* such unintended or unauthorized use, even if such claim alleges that Motorola was * 20570 ;* negligent regarding the design or manufacture of the part. * 20571 ;* * 20572 ;* Motorola and the Motorola logo are registered trademarks of Motorola Ltd. * 20573 ;* * 20574 ;******************************************************************************************** 20575 20576 ;* Microcontroller Peripheral Equates ***************************************************** 20577 ;* 20578 20579 ; uncomment out if standalone E7C2 20580 list 20581 20582 20583 ;* Flash Memory Specifics ================================================================= 20584 ;* E7C2 20585 boot_start: equ $FB00 ; starting address of protected Bootloader E7C2 20586 flash_protect: equ {boot_start>7&$FF} ; Flash Block Protect Register value E7C2 20587 flash_page: equ 128 ; Flash Erase Page size E7C2 20588 flash_row: equ 64 ; Flash Program Row size E7C2 20589 flash_erased: equ $FF ; Flash erased state 20590 20591 20592 ;* RAM Utilization ======================================================================== 20593 ;* 0040 20594 org ram_start ; begining of RAM 20595 0040 20596 count: ds 1 ; 0040: => data counter 0041 20597 temp_sp: ds 2 ; 0041:0042 => temporary Stack Pointer storage 0043 20598 flash_first: ds 2 ; 0043:0044 => first Flash reprogram address 0045 20599 flash_last: ds 2 ; 0045:0046 => last Flash reprogram address + 1 20600 0047 20601 ram_exec: equ $01ED ; start of executable RAM space 20602 20603 20604 ;* Bootloader Customization Parameters ==================================================== 20605 ;* 0047 20606 user_scbr: equ boot_start-61 ; FAC3 => SCBR register 0047 20607 init_scbr: equ $12 ; default set SCI for 9600 kbaud 20608 0047 20609 user_config1: equ boot_start-60 ; FAC4 => CONFIG1 register 0047 20610 init_config1: equ %00000001 ; default CONFIG1 20611 0047 20612 user_config2: equ boot_start-59 ; FAC5 => CONFIG2 register 0047 20613 init_config2: equ %00000001 ; default CONFIG2 20614 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 168 MC68HC908GP32 User Bootloader 0047 20615 user_first: equ boot_start-58 ; FAC6:FAC7 => 1st application address 0047 20616 init_first: equ rom_start ; default first Flash address 20617 0047 20618 user_last: equ boot_start-56 ; FAC8:FAC9 => last application address 0047 20619 init_last: equ boot_start ; default last Flash address 20620 20621 20622 ;* Application Program Jump Vector Table ================================================== 20623 ;* 20624 ; FACA => "JMP ext" instruction (opcode $CC) 0047 20625 user_timebase: equ boot_start-54 ; FACB:FACC => user Timebase jump vector 20626 20627 ; FACD => "JMP ext" instruction (opcode $CC) 0047 20628 user_ADC: equ boot_start-51 ; FACE:FACF => user ADC jump vector 20629 20630 ; FAD0 => "JMP ext" instruction (opcode $CC) 0047 20631 user_keyboard: equ boot_start-48 ; FAD1:FAD2 => user Keyboard jump vector 20632 20633 ; FAD3 => "JMP ext" instruction (opcode $CC) 0047 20634 user_SCItx: equ boot_start-45 ; FAD4:FAD5 => user SCI transmit jump vector 20635 20636 ; FAD6 => "JMP ext" instruction (opcode $CC) 0047 20637 user_SCIrx: equ boot_start-42 ; FAD7:FAD8 => user SCI receive jump vector 20638 20639 ; FAD9 => "JMP ext" instruction (opcode $CC) 0047 20640 user_SCIerr: equ boot_start-39 ; FADA:FADB => user SCI error jump vector 20641 20642 ; FADC => "JMP ext" instruction (opcode $CC) 0047 20643 user_SPItx: equ boot_start-36 ; FADD:FADE => user SPI transmit jump vector 20644 20645 ; FADF => "JMP ext" instruction (opcode $CC) 0047 20646 user_SPIrx: equ boot_start-33 ; FAE0:FAE1 => user SPI receive jump vector 20647 20648 ; FAE2 => "JMP ext" instruction (opcode $CC) 0047 20649 user_Tim2Ov: equ boot_start-30 ; FAE3:FAE4 => user Timer 2 overflow jump vector 20650 20651 ; FAE5 => "JMP ext" instruction (opcode $CC) 0047 20652 user_Tim2Ch1: equ boot_start-27 ; FAE6:FAE7 => user Timer 2 channel 1 jump vector 20653 20654 ; FAE8 => "JMP ext" instruction (opcode $CC) 0047 20655 user_Tim2Ch0: equ boot_start-24 ; FAE9:FAEA => user Timer 2 channel 0 jump vector 20656 20657 ; FAEB => "JMP ext" instruction (opcode $CC) 0047 20658 user_Tim1Ov: equ boot_start-21 ; FAEC:FAED => user Timer 1 oveflow jump vector 20659 20660 ; FAEE => "JMP ext" instruction (opcode $CC) 0047 20661 user_Tim1Ch1: equ boot_start-18 ; FAEF:FAF0 => user Timer 1 channel 1 jump vector 20662 20663 ; FAF1 => "JMP ext" instruction (opcode $CC) 0047 20664 user_Tim1Ch0: equ boot_start-15 ; FAF2:FAF3 => user Timer 1 channel 0 jump vector 20665 20666 ; FAF4 => "JMP ext" instruction (opcode $CC) 0047 20667 user_PLL: equ boot_start-12 ; FAF5:FAF6 => user PLL jump vector 20668 20669 ; FAF7 => "JMP ext" instruction (opcode $CC) 0047 20670 user_IRQ: equ boot_start-9 ; FAF8:FAF9 => user IRQ jump vector 20671 20672 ; FAFA => "JMP ext" instruction (opcode $CC) 0047 20673 user_SWI: equ boot_start-6 ; FAFB:FAFC => user SWI jump vector 20674 20675 ; FAFD => "JMP ext" instruction (opcode $CC) 0047 20676 user_reset: equ boot_start-3 ; FAFE:FAFF => user Reset interrupt jump vector 20677 20678 20679 ;* Bootloader Program ********************************************************************* 20680 ;* 20681 0047 20682 init_stack: equ ram_exec-1 ; initialize stack pointer to before RAM routine 20683 ; 0047 20684 init_scc1: equ %01000000 ; enable SCI, 8-bits, no parity, 1 stop 0047 20685 init_scc2: equ %00001100 ; no interupts, receiver and transmitter enabled 20686 FB00 20687 org boot_start ; beginning of code 20688 20689 20690 ;* CGM Parameter Tables =================================================================== 20691 ;* 20692 ;* The following CGM parameter tables are placed here so that they are easy to access via 20693 ;* external application programs. 20694 ;* 20695 ;* 7.3728 MHz bus frequency parameters (located at address "boot_start"). 20696 ;* msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 169 MC68HC908GP32 User Bootloader 20697 bus7372800: FB00 02 20698 db $02 ; P & E FB01 C0 20699 db $C0 ; L FB02 03 20700 db $03 ; N msb FB03 84 20701 db $84 ; N lsb 20702 20703 ;* 8.003584 MHz bus frequency parameters (located at address "boot_start+4"). 20704 ;* 20705 bus8003584: FB04 02 20706 db $02 ; P & E FB05 D0 20707 db $D0 ; L FB06 03 20708 db $03 ; N msb FB07 D1 20709 db $D1 ; N lsb 20710 20711 20712 ;* Power-on Reset ========================================================================= 20713 ;* MODIFIED FOR MEGASQUIRT - Initialization code here 20714 ;* 20715 20716 BootReset: FB08 4F 20717 clra FB09 C7FFFF 20718 sta copctl FB0C 6E011E 20719 mov #%00000001,config2 FB0F 6E011F 20720 mov #%00000001,config1 FB12 450240 20721 ldhx #ram_last+1 FB15 94 20722 txs 20723 FB16 45FB00 20724 ldhx #bus7372800 ; point to 7.3728 MHz parameters FB19 AD22 20725 bsr PLLset ; change bus speed 20726 FB1B A600 20727 lda #%00000000 FB1D B705 20728 sta ddrb ; ADC Channels - inputs 20729 FB1F A670 20730 lda #%01110000 ; Set up ADC for divide by 8 and internal clock FB21 B73E 20731 sta adclk FB23 A604 20732 lda #%00000100 ; No interrupt, channel AD4 selected FB25 B73C 20733 sta adscr FB27 0F3CFD 20734 brclr coco,adscr,* ; wait until conversion complete 20735 FB2A B63D 20736 lda adr FB2C A105 20737 cmp #$05 ; Check for low voltage on divider FB2E 2529 20738 blo BootReset1 ; enter bootloader if low voltage 20739 20740 ; 20741 ; Test application reset vector. 20742 ; FB30 C6FAFE 20743 lda user_reset+1 ; get the MSB of the user reset vector FB33 A1FF 20744 cmp #flash_erased ; check if it's erased FB35 2722 20745 beq BootReset1 ; enter bootloader if erased FB37 20C4 20746 bra user_reset ; else, jump to user reset jump vector 20747 20748 20749 ;* External CGM PLL Bus Frequency Change Subroutine ======================================= 20750 ;* 20751 ;* This subroutine will program the CGM PLL to change the bus frequency in accordance with 20752 ;* the data being pointed to by X:A (which is a common implementation for pointer parameter 20753 ;* passing used by HC08 C compilers). 20754 ;* 20755 ;* C function prototype: 20756 ;* 20757 ;* void CGMChange (char parameters*); 20758 ;* 20759 ;* Calling convention: 20760 ;* 20761 ;* ldx #{parameters>8} ; get CGM parameter table address msb 20762 ;* lda #{parameters&$FF} ; get CGM parameter table address lsb 20763 ;* jsr CGMChange ; go change the bus speed 20764 ;* 20765 ;* Returns: nothing 20766 ;* 20767 ;* Changes: H:X 20768 ;* 20769 CGMChange: FB39 87 20770 psha ; save pointer lsb on stack FB3A 89 20771 pshx ; save pointer msb on stack FB3B 8A 20772 pulh ; initialize FB3C 88 20773 pulx ; H:X points to data array 20774 20775 20776 ;* Internal CGM PLL Bus Frequency Change Subroutine ======================================= 20777 ;* 20778 ;* This subroutine will program the CGM PLL to change the bus frequency in accordance with msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 170 MC68HC908GP32 User Bootloader 20779 ;* the data being pointed to by H:X. 20780 ;* 20781 ;* Calling convention: 20782 ;* 20783 ;* ldhx #parameters ; point to CGM parameter table 20784 ;* jsr PLLset ; go change the bus speed 20785 ;* 20786 ;* Returns: nothing 20787 ;* 20788 ;* Changes: H:X 20789 ;* 20790 PLLset: FB3D 1936 20791 bclr BCS,pctl ; select external reference as base clock FB3F 1B36 20792 bclr PLLON,pctl ; turn off PLL FB41 7E36 20793 mov x+,pctl ; program P & E FB43 7E3A 20794 mov x+,pmrs ; program L FB45 7E38 20795 mov x+,pmsh ; program N msb FB47 7E39 20796 mov x+,pmsl ; program N lsb FB49 1E37 20797 bset AUTO,pbwc ; enable automatic bandwidth control FB4B 1A36 20798 bset PLLON,pctl ; turn on PLL 20799 PLLwait: FB4D 0D37FD 20800 brclr LOCK,pbwc,PLLwait ; wait for PLL to lock (Note: won't simulate) FB50 1836 20801 bset BCS,pctl ; select VCO as base clock FB52 81 20802 rts ; return 20803 20804 20805 ;* PutChar Subroutine ===================================================================== 20806 ;* 20807 ;* This subroutine will output the character passed in ACC to the SCI. 20808 ;* 20809 ;* C function prototype: 20810 ;* 20811 ;* void PutChar (char data); 20812 ;* 20813 ;* Calling convention: 20814 ;* 20815 ;* lda data ; get character 20816 ;* jsr PutChar ; go output it 20817 ;* 20818 ;* Returns: nothing 20819 ;* 20820 ;* Changes: nothing 20821 ;* 20822 PutChar: FB53 0F16FD 20823 brclr SCTE,scs1,PutChar ; wait until SCI transmitter is empty FB56 B718 20824 sta scdr ; output character to the SCI FB58 81 20825 rts ; return 20826 20827 20828 ;* Power-on Reset Bootloader Entry ======================================================== 20829 ;* 20830 ;* This is where the Bootloader starts from power-on reset. 20831 ;* 20832 BootReset1: 20833 ; 20834 ; Initialize the PLL CGM for 7.3728 MHz bus speed from 32.768 kHz crystal. 20835 ; 20836 ; ldhx #bus7372800 ; point to 7.3728 MHz parameters 20837 ; bsr PLLset ; change bus speed 20838 ; 20839 ; Copy user Flash parameters into RAM. 20840 ; FB59 45FAC3 20841 ldhx #user_scbr ; point to first parameter FB5C 7E40 20842 mov x+,count ; copy user SCI baud rate FB5E 7E41 20843 mov x+,temp_sp ; copy user Configuration Register 1 FB60 7E42 20844 mov x+,temp_sp+1 ; copy user Configuration Register 2 FB62 7E43 20845 mov x+,flash_first ; copy first user Flash address MSB FB64 7E44 20846 mov x+,flash_first+1 ; copy first user Flash address LSB FB66 7E45 20847 mov x+,flash_last ; copy last user Flash address MSB FB68 7E46 20848 mov x+,flash_last+1 ; copy last user Flash address LSB FB6A 450040 20849 ldhx #count ; point to first parameter, now saved in RAM FB6D 94 20850 txs ; use SP to point to parameter list in RAM 20851 ; 20852 ; Test the user SCI baud rate. The user can override the default baud rate. 20853 ; FB6E 86 20854 pula ; get user SCBR initial data FB6F A1FF 20855 cmp #flash_erased ; check if it's erased FB71 2602 20856 bne BootReset2 ; skip if not FB73 A612 20857 lda #init_scbr ; else, force default value 20858 BootReset2: FB75 B740 20859 sta count ; save initial SCI baud rate 20860 ; msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 171 MC68HC908GP32 User Bootloader 20861 ; Program the write-once configuration registers. The user can override the defaults. 20862 ; FB77 86 20863 pula ; get user Configuration Register 1 initial data FB78 A1FF 20864 cmp #flash_erased ; check if it's erased FB7A 2602 20865 bne BootReset3 ; skip if not FB7C A601 20866 lda #init_config1 ; else, force default value 20867 BootReset3: FB7E B71F 20868 sta config1 ; initialize Configuration Register 1 20869 ; FB80 86 20870 pula ; get user Configuration Register 2 initial data FB81 A1FF 20871 cmp #flash_erased ; check if it's erased FB83 2602 20872 bne BootReset4 ; skip if not FB85 A601 20873 lda #init_config2 ; else, force default value 20874 BootReset4: FB87 B71E 20875 sta config2 ; initialize Configuration Register 2 20876 ; 20877 ; Program the first and last user Flash addresses. The user can override the defaults. 20878 ; FB89 88 20879 pulx ; get first user Flash address LSB FB8A 8A 20880 pulh ; get first user Flash address MSB FB8B 65FFFF 20881 cphx #$FFFF ; check if it's erased FB8E 2608 20882 bne BootReset5 ; skip if not FB90 A600 20883 lda #{init_first&$FF} ; else, get default first user address LSB FB92 87 20884 psha ; save it FB93 A680 20885 lda #{init_first>8} ; and get default first user address MSB FB95 87 20886 psha ; save it FB96 A702 20887 ais #2 ; move stack pointer back 20888 ; 20889 BootReset5: FB98 88 20890 pulx ; get last user Flash address LSB FB99 8A 20891 pulh ; get last user Flash address MSB FB9A 65FFFF 20892 cphx #$FFFF ; check if it's erased FB9D 2606 20893 bne BootReset6 ; skip if not 20894 ; ldx #{init_last&$FF} ; else, get default last user address LSB FB9F A600 20895 lda #{init_last&$FF} ; else, get default last user address LSB FBA1 87 20896 psha ; save it FBA2 A6FB 20897 lda #{init_last>8} ; and get default last user address MSB FBA4 87 20898 psha ; save it 20899 BootReset6: 20900 20901 20902 ;* User Bootloader Entry ================================================================== 20903 ;* 20904 ;* The user can launch the bootloader from here. 20905 ;* 20906 BootResetUser: FBA5 9B 20907 sei ; disable all interrupts FBA6 C7FFFF 20908 sta copctl ; clear the COP counter FBA9 4501ED 20909 ldhx #init_stack+1 ; initialize FBAC 94 20910 txs ; the stack pointer 20911 ; 20912 ; Initialize the PLL CGM for 7.3728 MHz bus speed from 32.768 kHz crystal. 20913 ; FBAD 45FB00 20914 ldhx #bus7372800 ; point to 7.3728 MHz parameters FBB0 AD8B 20915 bsr PLLset ; change bus speed 20916 ; 20917 ; Take over and initialize the SCI. The user can override the default baud rate. 20918 ; FBB2 4E4019 20919 mov count,scbr ; initialize SCI baud rate FBB5 6E4013 20920 mov #init_scc1,scc1 ; initialize SCI Control Register 1 FBB8 6E0C14 20921 mov #init_scc2,scc2 ; initialize SCI Control Register 2 20922 20923 20924 ;* Main Bootloader Control Loop ========================================================== 20925 ;* 20926 ;* Bootloader program supports the following commands: 20927 ;* 20928 ;* 'X' = Exit and execute user program via user reset vector 20929 ;* 'P' = Program Flash via S-Records 20930 ;* 'W' = Erase Flash (Wipe) 20931 ;* 'U' = Upgrade Flash by erasing all user space, then programming via S-Records 20932 ;* 'H' = Help 20933 ;* '?' = Help 20934 ;* 20935 ;* Note: avoid using 'A' - 'F', as these are valid S-Record characters that could get 20936 ;* misinterpreted. 20937 ;* FBBB 20938 cmd_exit: equ 'X' ; Exit command FBBB 20939 cmd_program: equ 'P' ; Program Flash command FBBB 20940 cmd_erase: equ 'W' ; Erase Flash command (Wipe) FBBB 20941 cmd_upgrade: equ 'U' ; Upgrade Flash command FBBB 20942 cmd_help: equ 'H' ; Help command msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 172 MC68HC908GP32 User Bootloader FBBB 20943 cmd_help1: equ $1F ; '?' = alternate Help command 20944 ; 20945 Boot: FBBB 45FD88 20946 ldhx #msg_hello ; point to hello message FBBE AD38 20947 bsr PrintString ; output it FBC0 CDFC6A 20948 jsr GetChar ; get a character from the SCI FBC3 A10D 20949 cmp #ascii_CR ; check for ASCII carriage return FBC5 27F4 20950 beq Boot ; just loop back if so FBC7 AD8A 20951 bsr PutChar ; else, echo character back FBC9 A4DF 20952 and #$DF ; convert to uppercase 20953 20954 20955 ;* Execute User Program Command Check ===================================================== 20956 ;* FBCB A158 20957 cmp #cmd_exit ; check for Exit command FBCD 2611 20958 bne Boot2 ; skip if not FBCF C6FAFE 20959 lda user_reset+1 ; else, get the MSB of the user reset vector FBD2 A1FF 20960 cmp #flash_erased ; check if it's erased FBD4 2703 20961 beq Boot1 ; skip if not FBD6 CCFAFD 20962 jmp user_reset ; else, jump to user reset jump vector 20963 ; 20964 ; Remain in the Bootloader if the MSB of the User Reset Jump Vector is erased. 20965 ; 20966 Boot1: FBD9 45FDE0 20967 ldhx #msg_noreset ; point to error message FBDC AD1A 20968 bsr PrintString ; output it FBDE 20DB 20969 bra Boot ; jump back to top 20970 20971 20972 ;* Erase Flash Command Check ============================================================== 20973 ;* 20974 Boot2: FBE0 A157 20975 cmp #cmd_erase ; check for Erase Flash command FBE2 2618 20976 bne Boot3 ; skip if not FBE4 AD76 20977 bsr EraseFlash ; else, go erase Flash 20978 ; 20979 ; Common Bootloader command completion points. 20980 ; 20981 BootDone: FBE6 45FDB4 20982 ldhx #msg_complete ; point to operation complete message 20983 BootDone1: FBE9 AD0D 20984 bsr PrintString ; output it 20985 BootDone2: FBEB 20CE 20986 bra Boot ; jump back to top 20987 20988 20989 ;* External PutString Subroutine ========================================================== 20990 ;* 20991 ;* This subroutine will output the null terminated string pointed to by X:A (which is a 20992 ;* common implementation for pointer parameter passing used by HC08 C compilers) to the SCI. 20993 ;* 20994 ;* C function prototype: 20995 ;* 20996 ;* void PutString (char string*); 20997 ;* 20998 ;* Calling convention: 20999 ;* 21000 ;* ldx #{string>8} ; get CGM parameter table address msb 21001 ;* lda #{string&$FF} ; get CGM parameter table address lsb 21002 ;* jsr PutString ; go change the bus speed 21003 ;* 21004 ;* Returns: nothing 21005 ;* 21006 ;* Changes: H:X 21007 ;* 21008 PutString: FBED 87 21009 psha ; save pointer lsb on stack FBEE 89 21010 pshx ; save pointer msb on stack FBEF 8A 21011 pulh ; initialize FBF0 88 21012 pulx ; H:X points to data array FBF1 2005 21013 bra PrintString ; go output string 21014 21015 21016 ;* PrintString Subroutine ================================================================= 21017 ;* 21018 ;* This subroutine will output the null teminated string pointed to by H:X to the SCI. 21019 ;* 21020 ;* Calling convention: 21021 ;* 21022 ;* ldhx #string ; point to start of string 21023 ;* jsr PrintString ; go output it 21024 ;* msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 173 MC68HC908GP32 User Bootloader 21025 ;* Returns: nothing 21026 ;* 21027 ;* Changes: H:X 21028 ;* 21029 PrintString1: FBF3 0F16FD 21030 brclr SCTE,scs1,PrintString1 ; wait until SCI transmitter is empty FBF6 7E18 21031 mov x+,scdr ; output character to the SCI and advance pointer 21032 PrintString: FBF8 7D 21033 tst ,x ; test string character FBF9 26F8 21034 bne PrintString1 ; loop back if not null FBFB 81 21035 rts ; else, return 21036 21037 21038 ;* Program Flash Command Check ============================================================ 21039 ;* 21040 Boot3: FBFC A150 21041 cmp #cmd_program ; check for Program Flash command FBFE 264A 21042 bne Boot4 ; skip if not 21043 ; FC00 AD02 21044 bsr BootProg ; go accept S19 records and program the Flash FC02 20B7 21045 bra Boot ; return to top of control loop 21046 21047 21048 ;* Program Flash Subroutine =============================================================== 21049 ;* 21050 ;* This subroutine will copy the Flash Program algorithm into RAM and execute it in 21051 ;* conjunction with the S19 record retrieval to program the required Flash pages between 21052 ;* address pointers "flash_first" and "flash_last". 21053 ;* 21054 ;* Calling convention: 21055 ;* 21056 ;* jsr BootProg ; retrieve S19 records and program Flash 21057 ;* 21058 ;* Returns: nothing 21059 ;* 21060 ;* Changes: everything 21061 ;* 21062 BootProg: FC04 45004F 21063 ldhx #ProgramRamSize ; initialize pointer 21064 BootProg1: FC07 D6FD38 21065 lda Delay-1,x ; get program from Flash FC0A D701EC 21066 sta ram_exec-1,x ; copy into RAM FC0D 5BF8 21067 dbnzx BootProg1 ; decrement pointer and loop back until done FC0F 45FDBF 21068 ldhx #msg_waiting ; point to waiting message FC12 ADE4 21069 bsr PrintString ; output it 21070 ; 21071 ; Get S-Record from host. 21072 ; 21073 BootProg2: FC14 95 21074 tsx ; get the Stack Pointer FC15 3541 21075 sthx temp_sp ; save it temporarily FC17 A7DC 21076 ais #-36 ; allocate stack space for data FC19 AD58 21077 bsr GetSRec ; get an S-Record FC1B 2625 21078 bne BootProg5 ; indicate error if S-Record is invalid FC1D 86 21079 pula ; get S-Record type FC1E A130 21080 cmp #'0' ; check for text header record type FC20 270B 21081 beq BootProg3 ; ignore and get next record FC22 A139 21082 cmp #'9' ; check for end record type FC24 270B 21083 beq BootProg4 ; indicate operation complete FC26 A131 21084 cmp #'1' ; check for data record type FC28 2618 21085 bne BootProg5 ; indicate error if S-Record is invalid 21086 ; 21087 ; Program Flash. 21088 ; FC2A CD01F8 21089 jsr {ram_exec+ProgramRam} ; execute Program Flash algorithm from RAM 21090 BootProg3: FC2D A723 21091 ais #35 ; deallocate stack space FC2F 20E3 21092 bra BootProg2 ; loop back for next S-Record 21093 ; 21094 BootProg4: FC31 A723 21095 ais #35 ; deallocate stack space FC33 0B16B0 21096 brclr SCRF,scs1,BootDone ; skip if SCI receiver is empty FC36 AD32 21097 bsr GetChar ; else, clear last ASCII carriage return from SCI FC38 0B16AB 21098 brclr SCRF,scs1,BootDone ; skip if SCI receiver is empty FC3B AD2D 21099 bsr GetChar ; else, clear last ASCII line feed from the SCI FC3D 45FDB4 21100 ldhx #msg_complete ; point to operation complete message FC40 2005 21101 bra BootProg6 ; go output it 21102 ; 21103 BootProg5: FC42 A724 21104 ais #36 ; deallocate stack space FC44 45FDCE 21105 ldhx #msg_error ; point to error message 21106 BootProg6: msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 174 MC68HC908GP32 User Bootloader FC47 ADAF 21107 bsr PrintString ; output it FC49 81 21108 rts ; return 21109 21110 21111 ;* Upgrade Flash Command Check ============================================================ 21112 ;* 21113 Boot4: FC4A A155 21114 cmp #cmd_upgrade ; check for Upgrade Flash command FC4C 2670 21115 bne Boot5 ; skip if not 21116 ; FC4E 458000 21117 ldhx #init_first ; force FC51 3543 21118 sthx flash_first ; first Flash address FC53 45FB00 21119 ldhx #init_last ; force FC56 3545 21120 sthx flash_last ; last Flash address FC58 AD02 21121 bsr EraseFlash ; go erase Flash FC5A 20A8 21122 bra BootProg ; go program Flash 21123 21124 21125 ;* Multiple Flash Page Erase Subroutine =================================================== 21126 ;* 21127 ;* This subroutine will copy the Flash Erase algorithm into RAM and execute it to erase 21128 ;* all pages between address pointers "flash_first" and "flash_last". 21129 ;* 21130 ;* Calling convention: 21131 ;* 21132 ;* ldhx #init_first ; initialize 21133 ;* sthx flash_first ; first Flash address 21134 ;* ldhx #init_last ; initialize 21135 ;* sthx flash_last ; last Flash address 21136 ;* jsr EraseFlash ; go erase flash 21137 ;* 21138 ;* Returns: nothing 21139 ;* 21140 ;* Changes: everything 21141 ;* 21142 EraseFlash: FC5C 45003B 21143 ldhx #EraseRamSize ; initialize pointer 21144 EraseFlash1: FC5F D6FD08 21145 lda MassErase-1,x ; get program from Flash FC62 D701EC 21146 sta ram_exec-1,x ; copy into RAM FC65 5BF8 21147 dbnzx EraseFlash1 ; decrement pointer and loop back until done FC67 CC01ED 21148 jmp ram_exec ; execute Flash Mass Erase algorithm from RAM 21149 21150 21151 ;* GetChar Subroutine ===================================================================== 21152 ;* 21153 ;* This subroutine will wait forever for a character to be received by the SCI and then 21154 ;* returns with that character in ACC. No error checking is performed. Note that this 21155 ;* is the primary loop where the COP counter is cleared. 21156 ;* 21157 ;* C function prototype: 21158 ;* 21159 ;* char GetChar (void); 21160 ;* 21161 ;* Calling convention: 21162 ;* 21163 ;* jsr GetChar ; get a character from the SCI 21164 ;* 21165 ;* Returns: 21166 ;* ACC= data 21167 ;* 21168 GetChar: FC6A C7FFFF 21169 sta copctl ; clear the COP counter FC6D 0B16FA 21170 brclr SCRF,scs1,GetChar ; wait forever until SCI receiver is full FC70 B618 21171 lda scdr ; get data FC72 81 21172 rts ; return 21173 21174 21175 ;* GetSRec Subroutine ===================================================================== 21176 ;* 21177 ;* This subroutine will retrieve data in S19 record format via the SCI. 21178 ;* 21179 ;* Calling convention: 21180 ;* 21181 ;* ais #-buffer_length ; allocate stack space for data 21182 ;* jsr GetSRec ; go get S-record data 21183 ;* 21184 ;* Returns: CCRZ= 1 if valid S-Record retrieved. Otherwise, CCRZ= 0. 21185 ;* S-Record Type at SP+1 (1 byte) 21186 ;* S-Record Size at SP+2 (1 byte) 21187 ;* S-Record Address at SP+3 (2 bytes) 21188 ;* S-Record Data at SP+5 (up to 32 bytes, typically) msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 175 MC68HC908GP32 User Bootloader 21189 ;* 21190 ;* | | <-sp (after local space allocation) 21191 ;* H:X-> | SRecCount | 21192 ;* | SRecChkSum | <-sp (when called) 21193 ;* | ReturnAddr msb | 21194 ;* | ReturnAddr lsb | <-sp (upon return) 21195 ;* | SRecType | 21196 ;* | SRecSize | 21197 ;* H:X-> | SRecAddr msb | 21198 ;* | SRecAddr lsb | 21199 ;* | SRecData 00 | 21200 ;* | SRecData 01 | etc.. 21201 ;* 21202 ;* Changes: everything 21203 ;* FC73 21204 SRecCount: equ 1 ; stack pointer offset for S-Record Counter FC73 21205 SRecChkSum: equ 2 ; stack pointer offset for S-Record Check Sum FC73 21206 SRecType: equ 5 ; stack pointer offset for S-Record Type FC73 21207 SRecSize: equ 6 ; stack pointer offset for S-Record Size FC73 21208 SRecAddr: equ 7 ; stack pointer offset for S-Record Address FC73 21209 SRedData: equ 8 ; stack pointer offset for S-Record Data 21210 ; 21211 GetSRec: FC73 A7FE 21212 ais #-2 ; allocate local variable space FC75 9E6F06 21213 clr SRecSize,sp ; initialize S-Record size 21214 GetSRec1: FC78 ADF0 21215 bsr GetChar ; get a character from the SCI FC7A A10D 21216 cmp #ascii_CR ; check for ASCII carriage return FC7C 2602 21217 bne GetSRec1a ; just loop back if so FC7E A60A 21218 lda #ascii_LF ; get ASCII line feed 21219 GetSRec1a: FC80 A153 21220 cmp #'S' ; check for start of record character FC82 26F4 21221 bne GetSRec1 ; loop back if not FC84 ADE4 21222 bsr GetChar ; else, get next character from the SCI FC86 A130 21223 cmp #'0' ; check for header record type FC88 27EE 21224 beq GetSRec1 ; loop back if so FC8A A139 21225 cmp #'9' ; else, check for end record type FC8C 2704 21226 beq GetSRec2 ; continue if so FC8E A131 21227 cmp #'1' ; else, check for data record type FC90 26E6 21228 bne GetSRec1 ; loop back if not 21229 GetSRec2: FC92 9EE705 21230 sta SRecType,sp ; save S-Record type FC95 AD3B 21231 bsr GetHexByte ; get the S-Record length FC97 2622 21232 bne GetSRec4 ; exit if not a valid hex byte FC99 9EE701 21233 sta SRecCount,sp ; initialize S-Record counter FC9C 9EE702 21234 sta SRecChkSum,sp ; initialize S-Record check sum FC9F A003 21235 sub #3 ; adjust for address and checksum FCA1 9EE706 21236 sta SRecSize,sp ; save S-Record size FCA4 95 21237 tsx ; use H:X as data stack frame pointer FCA5 AF06 21238 aix #{SRecAddr-1} ; adjust so pointer starts at S-Record Address 21239 GetSRec3: FCA7 AD29 21240 bsr GetHexByte ; get next S-Record hex byte FCA9 2610 21241 bne GetSRec4 ; exit if not a valid hex byte FCAB F7 21242 sta ,x ; save data in stack frame FCAC 9EEB02 21243 add SRecChkSum,sp ; add data to check sum FCAF 9EE702 21244 sta SRecChkSum,sp ; save new check sum FCB2 AF01 21245 aix #1 ; move data stack frame pointer FCB4 9E6B01EF 21246 dbnz SRecCount,sp,GetSRec3 ; loop back until all data has been received FCB8 9E6C02 21247 inc SRecChkSum,sp ; final calculation zeros check sum if it's okay 21248 GetSRec4: FCBB A702 21249 ais #2 ; deallocate local variables FCBD 81 21250 rts ; return 21251 21252 21253 ;* Help Command Response ================================================================== 21254 ;* 21255 Boot5: FCBE A148 21256 cmp #cmd_help ; check for Help command FCC0 2704 21257 beq Boot6 ; continue if so FCC2 A11F 21258 cmp #cmd_help1 ; check for alternate Help command FCC4 2606 21259 bne Boot7 ; skip if not 21260 boot6: FCC6 45FD90 21261 ldhx #msg_help ; point to Help command message FCC9 CCFBE9 21262 jmp BootDone1 ; go output it 21263 21264 21265 ;* Unknown Command Response =============================================================== 21266 ;* 21267 Boot7: FCCC 45FDD7 21268 ldhx #msg_what ; point to unknown command message FCCF CCFBE9 21269 jmp BootDone1 ; go output it 21270 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 176 MC68HC908GP32 User Bootloader 21271 21272 ;* GetHexByte Subroutine ================================================================== 21273 ;* 21274 ;* This subroutine retrieves two ASCII bytes via the SCI and converts (packs) them into one 21275 ;* hex byte, which is returned in ACC. 21276 ;* 21277 ;* Calling convention: 21278 ;* 21279 ;* jsr GetHexByte 21280 ;* 21281 ;* Returns: CCRZ= 1 if valid hex byte retrieved. Otherwise, CCRZ= 0. 21282 ;* ACC= data 21283 ;* 21284 ;* Changes: ACC 21285 ;* 21286 GetHexByte: FCD2 AD96 21287 bsr GetChar ; get msb character from the SCI FCD4 AD20 21288 bsr IsHex ; check if valid ASCII hex character FCD6 2614 21289 bne GetHexByte2 ; exit if not FCD8 AD13 21290 bsr ToHex ; convert ASCII hex character to hex value FCDA 62 21291 nsa ; swap lower nibble up FCDB 87 21292 psha ; save temporarily FCDC CDFC6A 21293 jsr GetChar ; get lsb character from the SCI FCDF AD15 21294 bsr IsHex ; check if valid ASCII hex character FCE1 2607 21295 bne GetHexByte1 ; exit if not FCE3 AD08 21296 bsr ToHex ; convert ASCII hex character to hex value FCE5 9EEB01 21297 add 1,sp ; combine msb and lsb nibbles FCE8 A500 21298 bit #0 ; CCRZ= 1 21299 GetHexByte1: FCEA A701 21300 ais #1 ; deallocate local variable 21301 GetHexByte2: FCEC 81 21302 rts ; return 21303 21304 21305 ;* ToHex Subroutine ======================================================================= 21306 ;* 21307 ;* This subroutine converts the ASCII hex value passed in ACC to a binary hex value. 21308 ;* 21309 ;* Calling convention: 21310 ;* 21311 ;* lda data 21312 ;* jsr ToHex 21313 ;* 21314 ;* Returns: ACC= data. 21315 ;* 21316 ;* Changes: ACC 21317 ;* 21318 ToHex: FCED A030 21319 sub #'0' ; adjust first by subtracting '0' FCEF A109 21320 cmp #9 ; check if value was between '0' to '9' FCF1 2302 21321 bls ToHex1 ; exit if so FCF3 A007 21322 sub #7 ; else, adjust for value between 'A' to 'F' 21323 ToHex1: FCF5 81 21324 rts ; return 21325 21326 21327 ;* IsHex Subroutine ======================================================================= 21328 ;* 21329 ;* This subroutine checks if the value passed in ACC is a valid ASCII hex character within 21330 ;* within the ranges of '0' to '9' or 'A' to 'F'. Note that the range 'a' to 'f' is not 21331 ;* checked. 21332 ;* 21333 ;* Calling convention: 21334 ;* 21335 ;* lda data 21336 ;* jsr IsHex 21337 ;* 21338 ;* Returns: CCRZ= 1 if data is a valid hex character. Otherwise, CCRZ= 0. 21339 ;* 21340 ;* Changes: nothing 21341 ;* 21342 IsHex: FCF6 A130 21343 cmp #'0' ; check value against '0' FCF8 250E 21344 blo IsntHex ; not hex if lower FCFA A139 21345 cmp #'9' ; check value against '9' FCFC 2308 21346 bls IsHex1 ; is hex if lower FCFE A141 21347 cmp #'A' ; check value against 'A' FD00 2506 21348 blo IsntHex ; not hex if lower FD02 A146 21349 cmp #'F' ; check value against 'F' FD04 2202 21350 bhi IsntHex ; not hex if higher 21351 IsHex1: FD06 A500 21352 bit #0 ; CCRZ= 1 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 177 MC68HC908GP32 User Bootloader 21353 IsntHex: FD08 81 21354 rts ; return 21355 21356 21357 ;* Flash Mass Erase Subroutine ============================================================ 21358 ;* 21359 ;* This subroutine performs multiple Page Erase operations in order to erase the application 21360 ;* space Flash memory between "flash_first" and "flash_last". This subroutine has been 21361 ;* tuned for a bus speed of 7.3728 MHz. 21362 ;* This subroutine is copied into and executed from RAM. 21363 ;* 21364 MassErase: FD09 5545 21365 ldhx flash_last ; initialize pointer to last Flash memory address FD0B 2023 21366 bra MassErase2 ; go move pointer before erasing Flash 21367 MassErase1: 21368 ; 21369 ; Set ERASE, read the Flash Block Protect Register and write any data into Flash page. 21370 ; FD0D A602 21371 lda #{ERASE} ; set ERASE control bit FD0F C7FE08 21372 sta flcr ; in Flash Control Register FD12 C6FF7E 21373 lda flbpr ; read from Flash Block Protect Register FD15 F7 21374 sta ,x ; write any data to address within page 21375 ; 21376 ; Wait for >10us, then set HVEN. 21377 ; FD16 A601 21378 lda #1 ; wait FD18 AD1F 21379 bsr delay ; for 11.7us FD1A A60A 21380 lda #{ERASE | HVEN} ; set HVEN control bit FD1C C7FE08 21381 sta flcr ; in Flash Control Register 21382 ; 21383 ; Wait for >1ms, then clear ERASE. 21384 ; FD1F A664 21385 lda #100 ; wait FD21 AD16 21386 bsr delay ; for 1.005ms FD23 A608 21387 lda #{HVEN} ; clear ERASE control bit FD25 C7FE08 21388 sta flcr ; in Flash Control Register 21389 ; 21390 ; Wait for >5us, then clear HVEN. 21391 ; FD28 A601 21392 lda #1 ; wait FD2A AD0D 21393 bsr delay ; for 11.7us FD2C 4F 21394 clra ; clear HVEN control bit FD2D C7FE08 21395 sta flcr ; in Flash Control Register 21396 ; 21397 ; Advance pointer and repeat until finished. 21398 ; 21399 MassErase2: FD30 AFC0 21400 aix #-64 ; move pointer back FD32 AFC0 21401 aix #-64 ; by one complete erase page FD34 7543 21402 cphx flash_first ; check if finished FD36 22D5 21403 bhi MassErase1 ; loop back if not 21404 ; FD38 81 21405 rts ; return 21406 21407 21408 ;* Delay Subroutine ======================================================================= 21409 ;* 21410 ;* This subroutine performs a simple software delay loop based upon the value passed in ACC. 21411 ;* The following timing calculation applies: 21412 ;* 21413 ;* delay = ((ACC * 74) + 12) (tcyc) 21414 ;* 21415 ;* Calling convention: 21416 ;* 21417 ;* lda data 21418 ;* jsr delay 21419 ;* 21420 ;* Returns: nothing 21421 ;* 21422 ;* Changes: ACC 21423 ;* 21424 Delay: FD39 87 21425 psha ; [2] save outer delay loop parameter 21426 Delay1: FD3A A616 21427 lda #22 ; [2] initialize inner delay loop counter 21428 Delay2: FD3C 4BFE 21429 dbnza Delay2 ; [3] decrement inner delay loop counter FD3E 9E6B01F8 21430 dbnz 1,sp,Delay1 ; [6] decrement outer delay loop counter FD42 86 21431 pula ; [2] deallocate local variable FD43 81 21432 rts ; [4] return 21433 FD44 21434 EraseRamSize: equ {*-MassErase} msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 178 MC68HC908GP32 User Bootloader FD44 21435 ProgramRam: equ {*-Delay} 21436 21437 21438 ;* Flash Program Subroutine =============================================================== 21439 ;* 21440 ;* This subroutine controls the Flash programming sequence. A stack frame data block is 21441 ;* passed to it in the format shown below. This subroutine has been tuned for a bus speed 21442 ;* of 7.3728 MHz. 21443 ;* This subroutine is copied into and executed from RAM. 21444 ;* 21445 ;* | | <-sp (when called) 21446 ;* | ReturnAddr msb | 21447 ;* | ReturnAddr lsb | <-sp (upon return) 21448 ;* | SRecSize | 21449 ;* | SRecAddr msb | 21450 ;* | SRecAddr lsb | 21451 ;* | SRecData 00 | 21452 ;* | SRecData 01 | etc.. 21453 ;* 21454 FlashProgram: FD44 95 21455 tsx ; get the Stack Pointer FD45 3541 21456 sthx temp_sp ; save it temporarily 21457 ; 21458 ; Get S-Record size and use the Stack Pointer as the data source pointer. 21459 ; FD47 A702 21460 ais #2 ; SP points to SRecSize FD49 86 21461 pula ; get SRecSize FD4A B740 21462 sta count ; save it temporarily 21463 ; 21464 ; Establish H:X as the destination pointer. 21465 ; FD4C 8A 21466 pulh ; get destination address msb FD4D 88 21467 pulx ; get destination address lsb 21468 21469 FlashProgram1: FD4E 7543 21470 cphx flash_first ; check against minimum address FD50 252D 21471 blo FlashProgram2 ; skip if lower FD52 7545 21472 cphx flash_last ; check against maximum address FD54 2429 21473 bhs FlashProgram2 ; skip if the same or higher 21474 ; 21475 ; Set PGM, read the Flash Block Protect Register and write anywhere in desired Flash row. 21476 ; FD56 A601 21477 lda #{PGM} ; set PGM control bit FD58 C7FE08 21478 sta flcr ; in Flash Control Register FD5B C6FF7E 21479 lda flbpr ; read from Flash Block Protect Register FD5E F7 21480 sta ,x ; write any data to first Flash address 21481 ; 21482 ; Wait for >10us, then set HVEN. 21483 ; FD5F A601 21484 lda #1 ; wait FD61 ADD6 21485 bsr delay ; for 11.7us FD63 A609 21486 lda #{PGM | HVEN} ; set HVEN control bit FD65 C7FE08 21487 sta flcr ; in Flash Control Register 21488 ; 21489 ; Wait for >5us. 21490 ; FD68 A601 21491 lda #1 ; wait FD6A ADCD 21492 bsr delay ; for 11.7us 21493 ; 21494 ; Write data to Flash and wait for 30 - 40us. 21495 ; FD6C 86 21496 pula ; get S-Record data FD6D F7 21497 sta ,x ; write data to Flash FD6E A603 21498 lda #3 ; wait FD70 ADC7 21499 bsr delay ; for 31.7us 21500 ; 21501 ; Clear PGM. 21502 ; FD72 A608 21503 lda #{HVEN} ; clear PGM FD74 C7FE08 21504 sta flcr ; in Flash Control Register 21505 ; 21506 ; Wait for >5us, then clear HVEN. 21507 ; FD77 A601 21508 lda #1 ; wait FD79 ADBE 21509 bsr delay ; for 11.7us FD7B 4F 21510 clra ; clear HVEN control bit FD7C C7FE08 21511 sta flcr ; in Flash Control Register 21512 ; 21513 ; Advance destination pointer and data counter. 21514 ; 21515 FlashProgram2: FD7F AF01 21516 aix #1 ; advance destination pointer msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 179 MC68HC908GP32 User Bootloader FD81 3B40CA 21517 dbnz count,FlashProgram1 ; decrement counter and loop back if not done. 21518 ; FD84 5541 21519 ldhx temp_sp ; restore FD86 94 21520 txs ; Stack Pointer FD87 81 21521 rts ; return 21522 FD88 21523 ProgramRamSize: equ {*-Delay} 21524 21525 21526 ;* Messages =================================================================================== 21527 ;* FD88 21528 ascii_CR: equ $0D ; ASCII carriage return FD88 21529 ascii_LF: equ $0A ; ASCII line feed 21530 ; FD88 0D0A426F 21531 msg_hello: db ascii_CR,ascii_LF,'Boot>',0 6F743E00 FD90 20202850 21532 msg_help: db ' (P)rogram (W)ipe (U)pgrade e(X)it',0 29726F67 72616D20 28572969 70652028 55297067 72616465 20652858 29697400 21533 ; FDB4 2020436F 21534 msg_complete: db ' Complete',0 6D706C65 746500 FDBF 202D2077 21535 msg_waiting: db ' - waiting ...',0 61697469 6E67202E 2E2E00 FDCE 202D2065 21536 msg_error: db ' - error',0 72726F72 00 FDD7 202D2077 21537 msg_what: db ' - what?',0 6861743F 00 FDE0 202D2052 21538 msg_noreset: db ' - Reset Vector Invalid',0 65736574 20566563 746F7220 496E7661 6C696400 21539 21540 ; 21541 ; Last location not to exceed $FDFF 21542 ; 21543 BootEnd: 21544 21545 21546 ;* Vectors ************************************************************************************ 21547 ;* FFDC 21548 org vec_timebase ; Timebase vector FFDC FACA 21549 dw user_timebase FFDE 21550 org vec_adc ; ADC vector FFDE FACD 21551 dw user_ADC FFE0 21552 org vec_kbd ; Keyboard vector FFE0 FAD0 21553 dw user_keyboard FFE2 21554 org vec_scitx ; SCI transmit vector FFE2 FAD3 21555 dw user_SCItx FFE4 21556 org vec_scirx ; SCI receive vector FFE4 FAD6 21557 dw user_SCIrx FFE6 21558 org vec_scierr ; SCI error vector FFE6 FAD9 21559 dw user_SCIerr FFE8 21560 org vec_spitx ; SPI transmit vector FFE8 FADC 21561 dw user_SPItx FFEA 21562 org vec_spirx ; SPI receive vector FFEA FADF 21563 dw user_SPIrx FFEC 21564 org vec_tim2ov ; Timer 2 overflow vector FFEC FAE2 21565 dw user_Tim2Ov FFEE 21566 org vec_tim2ch1 ; Timer 2 channel 1 vector FFEE FAE5 21567 dw user_Tim2Ch1 FFF0 21568 org vec_tim2ch0 ; Timer 2 channel 0 vector FFF0 FAE8 21569 dw user_Tim2Ch0 FFF2 21570 org vec_tim1ov ; Timer 1 oveflow vector FFF2 FAEB 21571 dw user_Tim1Ov FFF4 21572 org vec_tim1ch1 ; Timer 1 channel 1 vector FFF4 FAEE 21573 dw user_Tim1Ch1 FFF6 21574 org vec_tim1ch0 ; Timer 1 channel 0 vector FFF6 FAF1 21575 dw user_Tim1Ch0 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 180 MC68HC908GP32 User Bootloader FFF8 21576 org vec_pll ; PLL vector FFF8 FAF4 21577 dw user_PLL FFFA 21578 org vec_irq ; IRQ vector FFFA FAF7 21579 dw user_IRQ FFFC 21580 org vec_swi ; SWI vector FFFC FAFA 21581 dw user_SWI FFFE 21582 org vec_reset ; Reset vector FFFE FB08 21583 dw BootReset 21584 21585 21586 ;* Flash Block Protect Register *************************************************************** 21587 ;* FF7E 21588 org flbpr FF7E F6 21589 db flash_protect 21590 FF7F 21591 end 21592 ;check in the .lst file for how big the flash areas are by searching the variable list 21593 ;for the following. Do NOT exceed $C8 per table or stack corruption is likely FF7F 21594 flash_0_size equ {flash_table0_end-flash_table0} FF7F 21595 flash_1_size equ {flash_table1_end-flash_table1} FF7F 21596 flash_2_size equ {flash_table2_end-flash_table2} FF7F 21597 flash_3_size equ {flash_table3_end-flash_table3} FF7F 21598 flash_4_size equ {flash_table4_end-flash_table4} FF7F 21599 flash_5_size equ {flash_table5_end-flash_table5} FF7F 21600 flash_6_size equ {flash_table6_end-flash_table6} FF7F 21601 flash_7_size equ {flash_table7_end-flash_table7} 21602 21603 ****************************************************************************** 21604 ** Real Time variables sent out on RS232 port 21605 ** "R" command = all 37 Bytes 21606 ** "A" command = first 22 Bytes 21607 ****************************************************************************** 21608 * Revised by DJA to start from 0, makes more sense 21609 ** 21610 ** 0 secl 21611 ** 1 squirt 21612 ** 2 engine 21613 ** 3 baroADC 21614 ** 4 mapADC 21615 ** 5 matADC 21616 ** 6 cltADC 21617 ** 7 tpsADC 21618 ** 8 batADC 21619 ** 9 egoADC 21620 ** 10 egoCorrection 21621 ** 11 airCorrection 21622 ** 12 warmupEnrich 21623 ** 13 rpm100 21624 ** 14 pulseWidth1 21625 ** 15 accelEnrich 21626 ** 16 baroCorrection 21627 ** 17 gammaEnrich 21628 ** 18 veCurr1 21629 ** 19 pulseWidth2 21630 ** 20 veCurr2 21631 ** 21 idleDC 21632 ** 21633 ** End of "A" command RT Variables for MegaView compatability 21634 ** 21635 ** 22/23 cTime 16 bit cycle timer. 21636 ** 24 advance Spark Gauge *0.352 -28.7 Min -10 Max 80 21637 ** 25 afrtarget Raw ADC target that MS is trying to reach 21638 ** from the target table or switch point 255 = 5V. 21639 ** 26 fuelADC Raw ADC from X7 (second O2 or fuel pressure or 21640 ** VSS sensor) 21641 ** 27 egtADC Raw ADC from X6 If EGT then temp in 21642 ** F = egtADC*7.15625 21643 ** C = egtADC*3.90625 if 21644 ** VSS Volts = egtADC*0.019 21645 ** 28 CltIatAngle Spark Angle added or removed for IAT CLT temp. 21646 ** Angle = MS value*0.352 21647 ** (Angle < 45 ? Angle : -90 + Angle) 21648 ** 29 KnockAngle Spark Angle removed due to Knock System 21649 ** *0.352 21650 ** 30 egoCorrection2 Same as egocorrection, but this is for second 21651 ** O2 sensor when fitted 21652 ** 31 porta Porta raw value for displaying the I/O state 21653 ** 32 portb Portb raw value for displaying the I/O state 21654 ** 33 portc Portc raw value for displaying the I/O state 21655 ** 34 portd Portd raw value for displaying the I/O state 21656 ** 35 stackL Low byte of stack for test purposes only, no 21657 ** use to users. msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 181 MC68HC908GP32 User Bootloader 21658 ** 36 tpsLast TPS/MAP last value for MT Accel Wizard, so we 21659 ** have last and current values to give a gauge of dot 21660 **************************************************************************** FF7F 21661 end 21662 Symbol Table ACCELDECAY_F E0C6 ACCH 00C8 ACCL 00C9 ACC_DONE_LED 891A ACEL_OUTPUT3 950E ACEL_OUTPUT4 956B ACK 0002 ACKK 0002 ACMULT_F1 E0C4 ACQ 0005 AC_CHK36 CE12 AC_CHK37 CE0A ADCDONE CBB9 ADCH0 0000 ADCH1 0001 ADCH2 0002 ADCH3 0003 ADCH4 0004 ADCLK 003E ADCO 0005 ADCPTR CC0A ADCX6_IN1 939E ADCX6_IN2 9432 ADCX7_IN1 93AB ADCX7_IN2 943F ADDLONGTRIGG C8C7 ADD_TO_PWCALC 8FCF ADICLK 0004 ADIV0 0005 ADIV1 0006 ADIV2 0007 ADR 003D ADSCR 003C ADSEL 008E ADVANCE_END 9665 ADVANCING 0007 AECARRY_ONAE 895F AE_CHK 88CE AE_COMP_SHOOT_AM 8920 AE_SET 88ED AFR1_AN D33A AFR1_STEP_1 D33C AFR1_STEP_2 D35B AFR1_STEP_3 D372 AFR1_TARGETS D316 AFR2_AN D3F7 AFR2_STEP_1 D3F9 AFR2_STEP_2 D418 AFR2_STEP_3 D42F AFR2_TARGETS D3D3 AFRTARGET 0059 AFRTARTPS_F E079 AFR_F1 E600 AFR_F2 E650 AFTERAFRSET 8B34 AFTERAFRSET2 8C05 AIEN 0006 AIRCOR 004B AIRDENFACTOR F600 AIRTEMP 0108 ALED 0001 ALL_ASECOUNT 8882 ALPHATARAFR 0004 ALTCOUNT1 0086 ALTCOUNT2 0087 ALTERNATE_F1 E196 ALTERNATE_F2 E296 ALTERNATE_R 01A5 ALT_I1GE 0020 ALT_I2GE 0040 ALT_I2T2 0010 ALWAYSPRIMEB 0001 ANTI_LAG D20A ARE_WE_HIGHER D276 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 182 MC68HC908GP32 User Bootloader ASCII_CR 000D ASCII_LF 000A ASECOUNT 0083 ASEHOLDB 0002 ASEIGNCOUNTB 0001 ASETABLEB 0002 ASEVTBL_F E5A8 ASIS_SPEED C6EC AUTO 0007 AVGTOOTHH 00F4 AVGTOOTHL 00F5 AVGTTH12H 0209 AVGTTH12L 020A AVGTTH14H 0207 AVGTTH14L 0208 AWC_F1 E5B2 AWEV_F1 E4AA BARCORR300_F E083 BARO 0043 BAROCOR 0050 BAROCORCONSTB 0008 BAROFAC4115 F100 BAROFAC4250 F200 BARO_LO_CHECK 85C9 BARROHI_F E052 BARROLOW_F E053 BATT 0048 BATTFAC_F1 E19B BATTFAC_F2 E29B BATTFAC_R 01AA BATT_CORR_CALC 8D2D BATT_CORR_CALC2 8E4F BATT_CORR_PW 8D2E BC1_STEP_2 9E3E BC1_STEP_3 9E59 BC2_STEP_2 9F91 BC2_STEP_3 9FA8 BC3_KPA_F E760 BC3_STEP_2 9E9F BC3_STEP_3 9EBA BCACTCLOCK 00D4 BCACTDONE A8CC BCCLROUT B082 BCCTLCLOCK 00D5 BCDC 00CF BCDELTA 009A BCDGAIN_F E011 BCFE 0007 BCFREQDIV_F E00E BCP 009B BCPGAIN_F E010 BCS 0004 BCSETOUT B07E BCSETPOINT 0099 BCUPDATE_F E00F BC_DC_F E730 BC_ERIC 9F36 BC_KPA_F E700 BC_MAX_DIFF E07D BEND_OF_BARO 859C BHRDS B868 BKF 0001 BLOCK_NEON 8393 BLSSD AA0C BOOSTCONTROL 0000 BOOSTCUT2B 0020 BOOSTCUTB 0010 BOOSTDEC 9F5C BOOSTDIRB 0040 BOOSTDONE 9F73 BOOSTDONE_DUPE 9E0A BOOSTINC 9F64 BOOSTKNMAX_F E06C BOOSTKNOCK_F E06B BOOSTOFF B075 BOOSTON B06C BOOSTP 0003 BOOSTPOS 9F3D BOOSTP_DONE 8F50 BOOSTRAIL 9F6C BOOSTSET 9F71 BOOSTT1 9E27 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 183 MC68HC908GP32 User Bootloader BOOSTTABLE3B 0004 BOOSTZERO 9E07 BOOSTZERO2 9F70 BOOST_FIXED 9F77 BOOT FBBB BOOT1 FBD9 BOOT2 FBE0 BOOT3 FBFC BOOT4 FC4A BOOT5 FCBE BOOT6 FCC6 BOOT7 FCCC BOOTDONE FBE6 BOOTDONE1 FBE9 BOOTDONE2 FBEB BOOTEND FDF8 BOOTLOAD CE9F BOOTPROG FC04 BOOTPROG1 FC07 BOOTPROG2 FC14 BOOTPROG3 FC2D BOOTPROG4 FC31 BOOTPROG5 FC42 BOOTPROG6 FC47 BOOTRESET FB08 BOOTRESET1 FB59 BOOTRESET2 FB75 BOOTRESET3 FB7E BOOTRESET4 FB87 BOOTRESET5 FB98 BOOTRESET6 FBA5 BOOTRESETUSER FBA5 BOOT_START FB00 BOTH_TABLE1 8E98 BOTH_TABLE1JMP 8DD2 BRKA 0006 BRKE 0007 BRKH FE09 BRKL FE0A BRKSCR FE0B BSC1 CAB3 BSM C808 BSMD2 C806 BSMD4 C804 BSMD8 C802 BURNCONST D0AB BURNCOUNT 0093 BURNDST 0091 BURNSRC 008F BURN_CONT D0B2 BUS7372800 FB00 BUS8003584 FB04 B_DC 83CC B_ENABLE B0A4 B_INJFC AF1D B_INJFC2 AB8D B_SPARKFUEL 8F47 C13_BC 0008 C13_CS 0004 C13_O2 0002 C13_OF 0001 CALCBOOSTDC 9E0B CALCGAMMAE 87AE CALCPWS 878D CALCRPM 86F1 CALCRUNJMP 852C CALCRUNNINGPARAM 857D CALC_DELAY 92C2 CALC_FINAL 8D4E CALC_FINAL1DONE 8D6A CALC_FINAL2 8E70 CALC_FINAL2DONE 8E82 CALC_PWS_DONE 9018 CALC_STAGED_PW 9B5F CANT_CRANK 0003 CANT_DELAY 0004 CANT_OFF B2EE CANT_SET B2EA CARRYON_ADVANCE 9632 CARRY_LC 991B CARRY_ON_TEA 89D2 CARRY_SLIP 9943 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 184 MC68HC908GP32 User Bootloader CCNOT_ODD C68C CCOFA C638 CCOFB C646 CCOFC C654 CCOFD C662 CCOFE C670 CCOFF C67E CC_CONT C694 CD0 A2CC CD1_START A31F CD2_CONT A3F1 CD2_DONE A39E CD3_CONT A4BE CD3_DONE A46B CD4_CONT A58F CD4_DONE A53C CD5_CONT A660 CD5_DONE A60D CD_1RAIL A355 CD_1STORE A358 CD_2 A35A CD_2DD A13E CD_2RAIL A427 CD_2STORE A42A CD_3 A42C CD_3DD A0F9 CD_3RAIL A4F4 CD_3STORE A4F7 CD_4 A4F9 CD_4DD A14D CD_4RAIL A5C5 CD_4STORE A5C8 CD_5 A5CA CD_5DD A168 CD_5RAIL A696 CD_5STORE A699 CD_6 A69B CD_6DD A1AF CGMCHANGE FB39 CHARGEFD:003D A9EC CHARGEFD:0040 AB65 CHARGEFD:0044 B3EA CHARGEFD:0046 B848 CHARGEFD:004B C224 CHARGEFD:004D CA93 CHECK2VE1 8BF4 CHECK2VE3 8BF9 CHECK3 83AF CHECK4 83BD CHECK5 83CF CHECK6 83E1 CHECK7 83EF CHECK7B 842C CHECK7C 8436 CHECK8 8450 CHECK8A 8452 CHECK9 8482 CHECKBIT 0001 CHECKHIGHLIMIT 8F53 CHECKOUTPUTS 936E CHECKREVSOK 8F9D CHECKRPMSETTINGS 8E9E CHECKSOFTLIMIT 9321 CHECKVE1 8B23 CHECKVE3 8B28 CHECK_GREATER_TH CFC5 CHECK_LESS_THAN CFBD CHECK_MMS B190 CHECK_MSNS 839E CHECK_OUT_CONFIG 838B CHECK_PW2 D2F0 CHECK_RPM B084 CHECK_SPARK_LATE AA81 CHECK_SP_ADD 928A CHECK_TC_COUNTER 9967 CHECK_TXCMD CD0C CHECK_VE3_DONE D313 CHECK_VE3_NOS D30D CHECK_VE3_TABLE D301 CHKCOILCD A9A2 CHKHOLD AAAA CHKINDWELL A9A8 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 185 MC68HC908GP32 User Bootloader CHKROLL_END 9A86 CHKTRAIL B7A8 CHK_CUTS 8F75 CHK_DONE_1 AFB0 CHK_DONE_2 AFE8 CHK_DONE_2JMP AFC4 CHK_LAUNCH_LIM 8F1E CHK_O2_LAG 8B47 CHK_OUT 837D CHK_REV_CUTS 8F5C CHK_RE_ENABLE B092 CHK_ROLL 9A78 CHXF 0007 CHXIE 0006 CHXMAX 0000 CK71 841E CK72 8416 CK72B 841B CK73 840E CK74 8403 CK7C3 8445 CK7ERR 8425 CK8AERR 846D CK8BERR 8474 CK8CERR 847B CKD2SINGLE B006 CKDN2 AFF6 CKP0_DDRC CCC0 CKP0_NORM_DDRC CCBE CKP3_INV CCE1 CKP3_I_DONE CCE3 CKP7NR CD05 CKSYNC2 BDF9 CK_NEXTCYL C8D3 CK_PAGE0 CC9E CK_PAGE3 CCD6 CK_PAGE7 CCF8 CK_XLONG C8B4 CLEARRAM 8148 CLEARTIME 9881 CLEAR_DECEL 8AA1 CLEAR_TABLE CF81 CLRNSKIP 970A CLR_A_B A938 CLR_KNOCK 98CA CLR_KNOCKJMP 987B CLR_NOS_ANG D253 CLR_NOS_ANGLE D245 CLR_NOS_OUT D233 CLR_NOS_PW D2FB CLR_NOS_SYSTEM D2F9 CLR_NOS_SYSTEMJM D2BD CLR_RETARD 96A3 CLT 0046 CLT1SOURCE 9391 CLT2SOURCE 9425 CLT3SOURCE 94F4 CLT4SOURCE 9556 CLTADVANCE_F E02F CLTCRANKB 0010 CLTDEG_F E030 CLTFIXASE_F E5B5 CLTIATANGLE 005C CLTIATIGNITIONB 0004 CLTMAPB 0008 CLTMATCHECK 0010 CLTMATCORR_F E5B7 CLTMATRANGE E5C0 CLTONLYPULSE 9B11 CLT_IAT_NOFLOW 9B0E CMD_ERASE 0057 CMD_EXIT 0058 CMD_HELP 0048 CMD_HELP1 001F CMD_PROGRAM 0050 CMD_UPGRADE 0055 CN_END:003E AA7D CN_END:003F AB36 CN_END:0043 B3BB CN_END:0047 B8D9 CN_END:004A C1F2 CN_END:004E CB24 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 186 MC68HC908GP32 User Bootloader COCO 0007 COILA 0000 COILABIT 0000 COILB 0001 COILBBIT 0001 COILCBIT 0002 COILDBIT 0003 COILEBIT 0004 COILERR 0004 COILFBIT 0005 COILSEL 0068 COIL_DETECTA BD81 COIL_DETECTB BD93 CONFIG1 001F CONFIG11_F1 E1B6 CONFIG11_F2 E2B6 CONFIG11_R 01D1 CONFIG12_F1 E1B7 CONFIG12_F2 E2B7 CONFIG12_R 01D2 CONFIG13_F1 E1B8 CONFIG13_F2 E2B8 CONFIG13_R 01D3 CONFIG2 001E CONFIG21_F E2B6 CONFIG22_F E2B7 CONFIG23_F E2B8 CONFIG_ER1JMP 8523 CONFIG_ERROR 0007 CONFIG_ERROR1 852E CONF_ERR CDCC CONF_ERR2 CDD5 CONSBAR 85AE CONSBARCORB 0080 CONT_FIXASE 882C CONT_TX CE88 COOLANT 00CC COOLANTREL 8684 COOLANTTABL 86A5 COP 0005 COPCTL FFFF COUNT 0040 CPHA 0003 CPOL 0004 CRANK 0001 CRANKANGLE_F E3AB CRANKANGLE_R 01BA CRANKDWELL A098 CRANKINGDONE 9B54 CRANKINGMODE 9AA4 CRANKINGMODEPRIM 9AA7 CRANKINGPW 9AE3 CRANKINGPW2 0006 CRANKIT 8797 CRANKPWS_F E4B7 CRANKPWTABLEB 0001 CRANKRPM_F E4C2 CRPWCLT 9AFA CRPWINT 9B14 CRPWMAT 9AFE CSL_COMP 933B CSL_FLAT 9338 CTB B7B7 CTIMECOMMH 0056 CTIMECOMML 0057 CTIMEH 00BF CTIMEHCP 0200 CTIMEL 00C0 CTIMELCP 0201 CTO 0006 CTODIV 0007 CTODIVB 0080 CT_DONE B7BB CURRTTH14H 0205 CURRTTH14L 0206 CUTCHANNELS 8F8E CWH_F1 E4A9 CWU_F1 E4A8 CYCLE_CALC C617 CYL10 C812 CYL10A C798 CYL12 C838 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 187 MC68HC908GP32 User Bootloader CYL12A C79B CYL16 C858 CYL16A C79E CYL3 C7AD CYL3NC C7C3 CYL5 C7CC CYL6 C7EA CYL8 C80A CYL8A C795 CYL_INVALID C792 DCD_NO_LED C10F DC_LOW C723 DDRA 0004 DDRB 0005 DDRC 0006 DDRD 0007 DDRE 000C DD_A:0041 ABAA DD_A:0045 B42F DD_A:0048 B932 DD_A:004C C26C DD_B:0041 ABAE DD_B:0045 B433 DD_B:0048 B936 DD_B:004C C270 DD_C:0041 ABB2 DD_C:0045 B437 DD_C:0048 B93A DD_C:004C C274 DD_D:0041 ABB6 DD_D:0045 B43B DD_D:0048 B93E DD_D:004C C278 DD_END:0041 AF1C DD_END:0045 B7A1 DD_END:0048 BCA4 DD_END:004C C5DE DEAD_END 8534 DEAD_LOOP1 8556 DEAD_LOOP2 8558 DEAD_LOOP3 855A DEAD_LOOP4 856B DEAD_LOOP5 856D DEAD_LOOP6 856F DECAY_ACCEL 0088 DECELKPA_F E081 DECELMAPB 0020 DECODER_NEW BE7D DECODE_NEON BD05 DECODE_WHEEL BE12 DECODE_WHEEL2 BDDB DECRMT D08B DEC_OUTPUT3 9509 DEC_OUTPUT4 9566 DEFINATLYNO_WATE 960F DELAY FD39 DELAY1 FD3A DELAY2 FD3C DELAY2RPM_F E09B DELAYANGLE 0107 DELAY_CALC C6F8 DIVIDEND 0096 DIVIDER_F1 E195 DIVIDER_F2 E295 DIVIDER_R 01A4 DIVISOR 0098 DMARE 0005 DMATE 0004 DOBAROCORR 85B2 DOBOOSTCONTROL B064 DODWELL A9AB DONEBARO 8644 DONEBAROCORR 8626 DONEBOOSTCONTROL B084 DONE_B CD07 DONE_BYTE CE9D DONE_BYTEJMP CE4D DONE_CHECKS 8482 DONE_DECODE C107 DONE_FIXMAP CC02 DONE_LOAD CF89 DONE_RCV CDBC msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 188 MC68HC908GP32 User Bootloader DONE_ROT 8361 DONE_WITH_INTERP D009 DONT_CLR_WATER2 B022 DONT_NOS_PW1 8FE4 DONT_RESETCNT A9B7 DONT_RESETCNT2 B813 DONT_RESET_TRACT 9977 DORPMCALC 86FB DOSLS_CD AB96 DOSLS_DONE AB85 DOSLS_FD AB90 DOSLS_INV AB38 DOSPARKLSPEED AAC2 DOSQUIRT BCD0 DO_AIRDENS 8668 DO_BAR4115 8610 DO_BAR4115M 8641 DO_BAROTURBO 85D3 DO_CAL_RED1 86D2 DO_DWELL_US A0A8 DO_FAN_CHECK 957E DO_INTERP CFD0 DO_MAT_FACT 86F1 DO_NABARO 861E DO_NOS_PW1 8FDD DO_OVERRUN 95DA DO_ROTARY_DWL C9BB DO_RPM_TC 98EB DO_SECOND_EGO 8BD3 DO_SET_SPK C991 DO_TARGETS D321 DO_TARGETS2 D3DE DO_THE_EGO 8B59 DO_VE1_4_NOW 87A2 DSLSA:003E AA63 DSLSA:003F AB1C DSLSA:0043 B3A1 DSLSA:0047 B8BF DSLSA:004A C1D8 DSLSA:004E CB0A DSLSB:003E AA67 DSLSB:003F AB20 DSLSB:0043 B3A5 DSLSB:0047 B8C3 DSLSB:004A C1DC DSLSB:004E CB0E DSLSC:003E AA6B DSLSC:003F AB24 DSLSC:0043 B3A9 DSLSC:0047 B8C7 DSLSC:004A C1E0 DSLSC:004E CB12 DSLSD:003E AA6F DSLSD:003F AB28 DSLSD:0043 B3AD DSLSD:0047 B8CB DSLSD:004A C1E4 DSLSD:004E CB16 DSLSE:003E AA73 DSLSE:003F AB2C DSLSE:0043 B3B1 DSLSE:0047 B8CF DSLSE:004A C1E8 DSLSE:004E CB1A DSLSF2 C6DA DSLSF:003E AA77 DSLSF:003F AB30 DSLSF:0043 B3B5 DSLSF:0047 B8D3 DSLSF:004A C1EC DSLSF:004E CB1E DSLSX:003E AA7B DSLSX:003F AB34 DSLSX:0043 B3B9 DSLSX:0047 B8D7 DSLSX:004A C1F0 DSLSX:004E CB22 DTMODE_F E021 DTNOSB 0020 DUALDA C16A DUALDB C170 DUALDIZZYB 0010 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 189 MC68HC908GP32 User Bootloader DUALEDIS 0005 DUMMY CF9A DWELLCD 0003 DWELLCONT 0001 DWELLCRANK_F E06E DWELLDELAY1 00E8 DWELLDELAY2 00EA DWELLDELAY3 00EC DWELLDELAY4 00EE DWELLDELAY5 00F0 DWELLDELAY6 00F2 DWELLDIV_END A23A DWELLDMS 00F8 DWELLDUTY50 0006 DWELLORNOT A06A DWELLRUN_F E06F DWELLTF A04C DWELLTMPH 0096 DWELLTMPHAC 00A8 DWELLTMPHMS 009C DWELLTMPHOP 0099 DWELLTMPHP 00A0 DWELLTMPL 0097 DWELLTMPLAC 00A9 DWELLTMPLMS 009D DWELLTMPLOP 009A DWELLTMPLP 00A1 DWELLTMPX 0095 DWELLTMPXAC 00A7 DWELLTMPXMS 009B DWELLTMPXOP 0098 DWELLTMPXP 009F DWELLTV A046 DWELLUSH 00F9 DWELLUSL 00FA DWELL_CORR A09B DWELL_DUTY_CALC A0DF DWELL_LIM:0024 A311 DWELL_LIM:0025 A34A DWELL_LIM:0028 A3E3 DWELL_LIM:0029 A41C DWELL_LIM:002C A4B0 DWELL_LIM:002D A4E9 DWELL_LIM:0030 A581 DWELL_LIM:0031 A5BA DWELL_LIM:0034 A652 DWELL_LIM:0035 A68B DWELL_LIM:0038 A71C DWLLDEND:0024 A306 DWLLDEND:0025 A33F DWLLDEND:0028 A3D8 DWLLDEND:0029 A411 DWLLDEND:002C A4A5 DWLLDEND:002D A4DE DWLLDEND:0030 A576 DWLLDEND:0031 A5AF DWLLDEND:0034 A647 DWLLDEND:0035 A680 DWLLDEND:0038 A711 DWLNWCHK:0023 A2D6 DWLNWCHK:0027 A3A8 DWLNWCHK:002B A475 DWLNWCHK:002F A546 DWLNWCHK:0033 A617 DWLNWCHK:0037 A6E1 DWLNWOK:0023 A2EA DWLNWOK:0027 A3BC DWLNWOK:002B A489 DWLNWOK:002F A55A DWLNWOK:0033 A62B DWLNWOK:0037 A6F5 DWLNWRAIL:0023 A2E1 DWLNWRAIL:0027 A3B3 DWLNWRAIL:002B A480 DWLNWRAIL:002F A551 DWLNWRAIL:0033 A622 DWLNWRAIL:0037 A6EC DWLPRDCALC A1F4 DWL_OK C956 EDIS 0004 EDIS2_FIRE A846 EDIS2_FIRE_A A89B msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 190 MC68HC908GP32 User Bootloader EDISMS_F E015 EDIS_CALC 92F2 EDIS_SPEED C6A4 EFANOFFTEMP_F E04B EFANONTEMP_F E04A EGO 0049 EGOALL_DONE 8BD0 EGOALL_DONEJMP 8B57 EGOBUMP C60A EGOCORR 004A EGOCORR2 005E EGOCOUNT 0082 EGOCOUNTCMP_F E191 EGOCOUNTCMP_F2 E291 EGOCOUNTCMP_R 01A0 EGODELTA_F E192 EGODELTA_F2 E292 EGODELTA_R 01A1 EGOIGNCOUNT 0001 EGOLIM2_DONE 8C18 EGOLIM2_F E028 EGOLIM2_NEW 8C13 EGOLIMITKPA_F E027 EGOLIMIT_F E193 EGOLIMIT_F2 E293 EGOLIMIT_R 01A2 EGOLIM_DONE 8B75 EGORPM_F E1B9 EGORPM_F2 E2B9 EGOTEMP_F E190 EGOTEMP_F2 E290 EGOTEMP_R 019F EGO_2DONE 8C5F EGO_2DONEJMP 8C42 EGO_CALC 8AD5 EGO_DONE 8BBE EGTADC 005B EGT_JUMP CC19 EIDLEDASHPOT 9738 EIDLERESTORE 9736 ELSXA 0002 ELSXB 0003 ENABLEN2O D1C6 ENABLEN2O_CONT D1D1 ENABLE_THE_IRQ B18E END100TH B250 END_DTCALCS 8E4D END_DWELL A21E END_INTERPOLE D2CE END_KNOCK 98D8 END_KNOCKJMP 987E END_OF_BARO 8628 END_OF_MAIN D85B END_ROTARY_DWELL C9FF ENGINE 0042 ENHANCEDBITS 0066 ENHANCEDBITS2 0067 ENHANCEDBITS4 0069 ENHANCEDBITS5 006A ENHANCEDBITS6 006B ENSCI 0006 EN_XMIT CDB6 ERASE 0002 ERASEFLASH FC5C ERASEFLASH1 FC5F ERASERAMSIZE 003B ERRIE 0006 ERROR_EXIT A8D3 ERROR_MSG0 D4AA ERROR_MSG1 D4C5 ERROR_MSG10 D740 ERROR_MSG11 D783 ERROR_MSG12 D7C4 ERROR_MSG2 D509 ERROR_MSG3 D546 ERROR_MSG4 D588 ERROR_MSG5 D5D3 ERROR_MSG6 D61B ERROR_MSG7 D668 ERROR_MSG8 D6B7 ERROR_MSG9 D6FB ERROR_VECTOR D490 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 191 MC68HC908GP32 User Bootloader ESKIPADJUST 973F EXCRFUELB 0040 EXITSN D1C5 EXTRACRFU_F E4C5 EXTRAFUELCRANK 9ABA FAN_DONE 95A5 FAN_EXIT 957C FAN_OFF 958F FAN_ON 959B FASTIDLEBG_F E1BA FASTIDLETEMP_F E022 FASTIDLE_F E024 FASTIDLE_R 01D5 FCNITA:003E AA20 FCNITA:003F AAD9 FCNITA:0043 B35E FCNITA:0047 B87C FCNITA:004A C195 FCNITA:004E CAC7 FCNITB:003E AA26 FCNITB:003F AADF FCNITB:0043 B364 FCNITB:0047 B882 FCNITB:004A C19B FCNITB:004E CACD FCNITC:003E AA2C FCNITC:003F AAE5 FCNITC:0043 B36A FCNITC:0047 B888 FCNITC:004A C1A1 FCNITC:004E CAD3 FC_END:003D AA0C FC_END:0040 AB85 FC_END:0044 B40A FC_END:0046 B868 FC_END:004B C244 FC_END:004D CAB3 FE 0001 FEATURE1 0063 FEATURE10_F5 E5B3 FEATURE11_F4 E4C1 FEATURE12_F2 E2BF FEATURE1_F E00B FEATURE2 0064 FEATURE2_F E00C FEATURE3_F E02E FEATURE4_F E042 FEATURE5_F E04C FEATURE6_F E05C FEATURE7 0065 FEATURE7_F E06D FEATURE8_F E074 FEATURE9_F E0C7 FEIE 0001 FINALNORM D19D FINISHBIAT 9F1F FINISHED_PW_COMP 9B7D FIN_TX CE93 FIN_TXJMP CE4B FIREFD:003E AA5D FIREFD:003F AB16 FIREFD:0043 B39B FIREFD:0047 B8B9 FIREFD:004A C1D2 FIREFD:004E CB04 FIRE_ADC B1B7 FIRING1 0003 FIRING2 0005 FIXDMAP2 CBEA FIXDMAP_ASE CBDF FIXEDANGLE_F E3A9 FIXEDANGLE_R 01B8 FIXEDSPLIT_F E7C1 FIXED_FL 9043 FIXSPL_C A742 FIXSPL_FL A73F FLASHPROGRAM FD44 FLASHPROGRAM1 FD4E FLASHPROGRAM2 FD7F FLASH_0_SIZE 00C8 FLASH_1_SIZE 00BC FLASH_2_SIZE 00C0 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 192 MC68HC908GP32 User Bootloader FLASH_3_SIZE 00B9 FLASH_4_SIZE 00C6 FLASH_5_SIZE 00C7 FLASH_6_SIZE 00B2 FLASH_7_SIZE 00C2 FLASH_ERASED 00FF FLASH_FIRST 0043 FLASH_LAST 0045 FLASH_PAGE 0080 FLASH_PROTECT 00F6 FLASH_ROW 0040 FLASH_TABLE0 E000 FLASH_TABLE0_END E0C8 FLASH_TABLE1 E100 FLASH_TABLE1_END E1BC FLASH_TABLE2 E200 FLASH_TABLE2_END E2C0 FLASH_TABLE3 E300 FLASH_TABLE3_END E3B9 FLASH_TABLE4 E400 FLASH_TABLE4_END E4C6 FLASH_TABLE5 E500 FLASH_TABLE5_END E5C7 FLASH_TABLE6 E600 FLASH_TABLE6_END E6B2 FLASH_TABLE7 E700 FLASH_TABLE7_END E7C2 FLBPR FF7E FLCR FE08 FLOCKER 0076 FLOODCLEAR 9AB6 FORCE_TRAIL_OFF B7FB FUELCUT_C 8F6C FUELP 0000 FUELSPARKCUTB 0020 FUELSPARKLCB 0002 FUEL_JUMP CC0E FUEL_SPARKHARDB 0010 FUEL_SPARKHLCB 0001 FXDASEDONE 0007 FXR_C 9046 GAMMAE 0051 GAMMAE2 00DC GETCHAR FC6A GETHEXBYTE FCD2 GETHEXBYTE1 FCEA GETHEXBYTE2 FCEC GETSREC FC73 GETSREC1 FC78 GETSREC1A FC80 GETSREC2 FC92 GETSREC3 FCA7 GETSREC4 FCBB GOT_ORD_NUM CFB7 GO_INJ_FIRE A98F GO_INJ_FIRE2 A898 GO_INJ_FIRE3 A8D5 HEI7 0007 HEI7FIVE A064 HEI7ZERO A068 HEI7_SPD A055 HIGHER_ACCEL 8A56 HIGHTPS 9ADC HIGH_CONT C6F4 HIGH_SPEED C6F4 HIRES_DWELL B809 HISPDCORR C711 HRDWON 0000 HRD_CK C953 HRD_DISABLEB 0004 HRD_INV B86A HRD_OFF C951 HRD_ON C946 HRD_SET B8D9 HVEN 0008 HYBRIDALPHAN 0005 HYSTER1 93CA HYSTER2 945C IASC 0001 IAT1SOURCE 9383 IAT2SOURCE 9417 IAT3SOURCE 94E8 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 193 MC68HC908GP32 User Bootloader IAT4SOURCE 954A IATBOOSTST_F E087 IATBOOST_F E088 IATCLT_RELATED 9618 IATDANGER_F E034 IATDEG_F E032 IATPOINT_F E03D IDLE 0004 IDLEACTCHECK B04D IDLEACTCLOCK 00D3 IDLEACTDONE B061 IDLEACTOFF B05F IDLEACTON B05B IDLEACTUATOR B039 IDLEADJUST 96AA IDLEADVANCE_F E3AE IDLECLOSEDC_F E09E IDLECTLCLOCK 00D2 IDLEDASHDC_F E093 IDLEDASHPOT 974A IDLEDC 0055 IDLEDELAY 9717 IDLEDELAY2 972A IDLEDONE 97FC IDLEDONEJMP2 97CE IDLEFAST 96B9 IDLEFREQ_F E09A IDLEKICKDC_F E092 IDLEKICKRPM_F E091 IDLEKPA1_F E096 IDLEKPA2_F E097 IDLEKPACORR1 97D0 IDLEKPACORR2 97DE IDLELASTDC 00CD IDLEMINDC_F E094 IDLEON 0007 IDLEPERIOD2_F E09C IDLEPERIOD_F E090 IDLEPH 0074 IDLEPL 0075 IDLEPWM 96BF IDLERESTORE 9741 IDLERPMTHRESH_F E3B0 IDLESAVEDC 97F5 IDLESLOW 96B4 IDLESPEED 9768 IDLESPEEDCHECK 97A8 IDLETARGET 00CE IDLETEST 96F8 IDLETHRESH_F E026 IDLETOGGLE 96AD IDLETOOHIGH 97B2 IDLETOOLOW 97EC IDLETPSTHRESH_F E3AF IDLE_CL 0007 IDLE_CLOSEDLOOP 96EF IDLE_COUNT 9714 IDLE_DC_HI E095 IDLE_DC_LO E07A IDLE_DONEJMP 9712 IDLE_LOOPCOLD 96D1 IDLE_OPENLOOP 96C5 IDLE_WARMUP 0006 IGNCOUNT1 0084 IGNCOUNT2 0085 IGNORE_IAT 95F4 IKPAMIN1_F E098 IKPAMIN2_F E099 ILAD 0003 ILIE 0004 ILOP 0004 ILSOA:003D A9F2 ILSOA:0040 AB6B ILSOA:0044 B3F0 ILSOA:0046 B84E ILSOA:004B C22A ILSOA:004D CA99 ILSOB:003D A9F6 ILSOB:0040 AB6F ILSOB:0044 B3F4 ILSOB:0046 B852 ILSOB:004B C22E msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 194 MC68HC908GP32 User Bootloader ILSOB:004D CA9D ILSOC:003D A9FA ILSOC:0040 AB73 ILSOC:0044 B3F8 ILSOC:0046 B856 ILSOC:004B C232 ILSOC:004D CAA1 ILSOD:003D A9FE ILSOD:0040 AB77 ILSOD:0044 B3FC ILSOD:0046 B85A ILSOD:004B C236 ILSOD:004D CAA5 ILSOE:003D AA02 ILSOE:0040 AB7B ILSOE:0044 B400 ILSOE:0046 B85E ILSOE:004B C23A ILSOE:004D CAA9 ILSOF2 C6E5 ILSOF:003D AA06 ILSOF:0040 AB7F ILSOF:0044 B404 ILSOF:0046 B862 ILSOF:004B C23E ILSOF:004D CAAD ILSOX:003D AA0A ILSOX:0040 AB83 ILSOX:0044 B408 ILSOX:0046 B866 ILSOX:004B C242 ILSOX:004D CAB1 ILTY 0002 IMASK 0001 IMASKK 0001 INAC_CONT CE22 INCRPMER B0B2 INCRPM_CRANK B0CB INDWELL 0004 INIT_CONFIG1 0001 INIT_CONFIG2 0001 INIT_CONT 8326 INIT_CRANG 8300 INIT_EDIS 8318 INIT_FIRST 8000 INIT_LAST FB00 INIT_NO_HOLD 833D INIT_SCBR 0012 INIT_SCC1 0040 INIT_SCC2 000C INIT_STACK 01EC INIT_WHEEL 8330 INJ1 0000 INJ2 0001 INJ2DONE B036 INJECT1 0004 INJECT2 0005 INJECT_WATER AFA7 INJF1 AF4F INJF2 AF52 INJF3 AF55 INJF3JMP AFAE INJOCFUEL_F1 E198 INJOCFUEL_F2 E298 INJOCFUEL_R 01A7 INJOPEN_F1 E197 INJOPEN_F2 E297 INJOPEN_R 01A6 INJPWMT_F1 E19A INJPWMT_F2 E29A INJPWMT_R 01A9 INJPWM_F1 E199 INJPWM_F2 E299 INJPWM_R 01A8 INJ_FIRE_CTL AF4C INSPK_DONE 8352 INSPK_INV 8350 INT1 FE04 INT2 FE05 INT3 FE06 INTACC1 0094 INTACC2 0098 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 195 MC68HC908GP32 User Bootloader INTERPACELB 0040 INTERPOLE_PLUS D2A1 INTERP_PW D287 INTKBIER 001B INTKBSCR 001A INTSCR 001D INT_RAM 01ED INT_SPARK_OFF BCA6 INT_SPARK_OFFA B32E INVERTOUTONEB 0002 INVERTOUTTWOB 0004 INVLSPARKON2 C6DE INVSPARKOFF BCBB INVSPARKON2 A863 INVSPK 0006 INV_OUT2 9476 IN_A_OR_C_MODE CDFB IN_Q_MODE CE85 IN_Q_MODEJMP CE4F IN_SCI_RCV CC22 IN_SCI_TX CDE3 IN_SIGN_MODE CE7B IN_T_MODE CE80 IN_V_MODE CE70 IN_V_MV CE78 IRESTORERPM_F E09D IRQF 0003 IRQ_EXIT CBAC IRQ_EXIT2 CBB8 IRQ_LOW B1AF IRQ_MONITOR A8DB IRQ_SPARK AAA2 IRQ_SPARK_NEON AABB ISHEX FCF6 ISHEX1 FD06 ISNTHEX FD08 ISOB2 BCC5 ISOF2 BCC9 IS_MISS BEF9 ITIMEH 00AF ITIMEL 00B0 ITIMEPH 00FE ITIMEPL 00FF ITIMEPX 00FD ITIMEX 00AE ITMP00 01ED ITMP01 01EE ITMP02 01EF ITMP03 01F0 ITMP04 01F1 ITMP05 01F2 ITMP06 01F3 ITMP07 01F4 ITMP08 01F5 ITMP09 01F6 ITMP0A 01F7 ITMP0B 01F8 ITMP0C 01F9 ITMP0D 01FA ITMP0E 01FB ITMP0F 01FC ITMP10 01FD ITMP11 01FE ITMP12 01FF ITMP13 0200 ITMP14 0201 ITMP15 0202 ITMP16 0203 ITMP17 0204 ITMP18 0205 ITMP19 0206 ITMP1A 0207 ITMP1B 0208 ITMP1C 0209 ITMP1D 020A ITMP1E 020B ITMP1F 020C ITMPCOMM 020D JBOOTLOAD CDC9 JCD_4DD A135 JCD_5DD A138 JCD_6DD A13B msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 196 MC68HC908GP32 User Bootloader JCHECK_MMS B0C8 JDD_END:0041 ABB8 JDD_END:0045 B43D JDD_END:0048 B940 JDD_END:004C C27A JDECODE_WHEEL BCF9 JDECODE_WHEEL2 BCFF JINJ_FIRE_CTL AA9F JIN_SIGN_MODE CDDD JIN_T_MODE CDE0 JMCD C255 JMODE_B CD35 JMODE_BOOT CD41 JMODE_P CD3E JMODE_Q CD3B JMODE_SIGN CD44 JMODE_T CD4A JMODE_W CD38 JMODE_X CD47 JSMD2 C7A7 JSMD4 C7A4 JSMD8 C7A1 JSMT C7AA JSOD_CD_DONE B410 JWDWELL2OP:0041 ABC4 JWDWELL2OP:0045 B449 JWDWELL2OP:0048 B94C JWDWELL2OP:004C C286 JWDWELL4OP:0041 ABC1 JWDWELL4OP:0045 B446 JWDWELL4OP:0048 B949 JWDWELL4OP:004C C283 JWDWELL5OP:0041 ABBE JWDWELL5OP:0045 B443 JWDWELL5OP:0048 B946 JWDWELL5OP:004C C280 JWDWELL6OP:0041 ABBB JWDWELL6OP:0045 B440 JWDWELL6OP:0048 B943 JWDWELL6OP:004C C27D JWHEELSIM BD02 J_CSL A98B J_DONE_CD BDA3 J_HIRES_DWELL B331 J_LOST_SYNC2 BE33 J_MISS_CKDN2 C1F4 J_MISS_CKSKP C17D J_SSC C911 J_TFI_SPK A8D8 KBIE0 0000 KBIE1 0001 KBIE2 0002 KBIE3 0003 KBIE4 0004 KBIE5 0005 KBIE6 0006 KBIE7 0007 KEYF 0003 KNOCKADV 00DA KNOCKADV_F E03A KNOCKALEFT 9842 KNOCKANGLE 005D KNOCKANGLERET 0103 KNOCKBOOST 0102 KNOCKDETB 0040 KNOCKED 0007 KNOCKIN 0002 KNOCKING_STILL 9894 KNOCKKPAL_F E037 KNOCKMAX_F E03B KNOCKRET1_F E038 KNOCKRET2_F E039 KNOCKRPMLL_F E036 KNOCKRPML_F E035 KNOCKTIMLFT 00D9 KNOCKTIM_F E03C KNOCKTLEFT 9837 KNOCK_DETECTION 97FC KPA 00CB KPA300B 0001 KPA400B 0002 KPA400_READING CE51 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 197 MC68HC908GP32 User Bootloader KPA400_SET 85F5 KPACORR300_F E0AF KPADOTBOOSTB 0010 KPADOTPOS 9F4A KPADOTSETB 0080 KPAFACTOR4115 F300 KPAFACTOR4250 F400 KPALAST 00D0 KPAO2_F E040 KPARANGEAFR_F1 E648 KPARANGEAFR_F2 E698 KPARANGESPLIT_F E7BA KPARANGEST_F1 E39C KPARANGEST_F2 E49C KPARANGEST_R 01AB KPARANGEVE_F1 E1AA KPARANGEVE_F2 E2AA KPARANGEVE_F3 E59C KPARANGEVE_R 01BF KPARETARD_F E033 KPATPSOPENB 0001 KPA_ADC_CHECK CBC9 KPA_DOT_MODE B2B7 KPA_DOT_ON C608 KPA_N 00DB KPA_N_KPA 9094 LASTCHECK 9B93 LAUNCH 0003 LAUNCHCONTROL 0002 LAUNCHDONE 8F2C LAUNCHLIMIT_F E014 LAUNCHON 0006 LBATT 007B LCLT 0079 LC_FLATLIM E080 LC_FLATSEL_F E07C LC_FS 0005 LC_F_LIMANGLE_F E08D LC_F_SLIM_F E08C LC_LIMANGLE_F E02A LC_SOFT_RPM_F E02B LC_THROTTLE_F E029 LD_VE2_DONE 8DBA LD_VE_1 8C9A LD_VE_1DONE 8C9D LD_VE_2 8DB7 LED18_FAN 0006 LEGO 007C LININTERP CFB8 LIX 0098 LIX1 0094 LIX2 0095 LIY 0099 LIY1 0096 LIY2 0097 LMAP 0077 LMAT 0078 LOADCONTRIBCOMP 8CA8 LOADCONTRIBDN2 8E17 LOADCONTRIBDONE 8CF7 LOAD_MAX_MAP CE61 LOAD_TABLE CF65 LOCK 0006 LOOKUP_DONE 91AD LOOKUP_FINISHED 926B LOOPS 0007 LOSPDCORR C731 LOST_SYNC_W C082 LOWRESH 00F6 LOWRESL 00F7 LOWSPDSPK A992 LOW_CONT C6EA LOW_SPEED C6C5 LSD_A C914 LSD_B C919 LSD_C C91E LSD_D C923 LSD_DONE C903 LSD_DONE2 C905 LSD_MIN C8FE LSS2 A9A2 LSSPK_DONE AA7D msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 198 MC68HC908GP32 User Bootloader LSSPK_INV AA0E LT4_4S C76D LTPS 007A LVI 0001 LVIOUT 0007 LVISR FE0C M 0004 MAFCHECK 8CAE MAGNUS_REVLIMITE 934C MAP 0044 MAPAEN 0006 MAPAQ_F E0B8 MAPDOTRATE_F E0B4 MAPFIXASE_F E5B6 MAPHOLDB 0004 MAPSTAGED 9BAC MAPTHRESH_F E05B MASS 0004 MASSAIRFLWB 0020 MASSERASE FD09 MASSERASE1 FD0D MASSERASE2 FD30 MAT 0045 MATCRANKB 0020 MATFACTOR F700 MATREL 8686 MAXADVANCETRIM 9658 MAXADVANG_F E031 MAXPULSE 8D5C MAXPULSE2 8E7E MAX_DWELL A0A6 MAX_PWM_ALLOWED2 9B78 MBFF 8D48 MBFF2 8E6A MBOOSTPOS 9F31 MC_CD C258 MC_FD C252 MC_FD2 C24F MC_FIRE_DONE C244 MC_INV C1F7 MINDISCHG_F E08F MIN_DWELL 0005 MISC_SPARK A052 MISC_SPARK_END A845 MISS2NDB 0001 MISS_CHK C180 MISS_CHK_DONE C5DF MISS_CHK_SKIP C5E5 MISS_TPS 89B4 MMS 007D MMSDIV 00E4 MODE 0000 MODEK 0000 MODE_A CD4D MODE_AA_CONT CD57 MODE_B CC7B MODE_BOOT CDBE MODE_B_OK CC85 MODE_C CD5D MODE_P CDA6 MODE_Q CD94 MODE_R CD52 MODE_SIGN CDAD MODE_T CD9D MODE_V CD66 MODE_V2 CD84 MODE_V_F0 CD79 MODE_V_F1 CD7D MODE_V_MV CD81 MODE_W CD88 MODE_X CD8D MODF 0004 MODFEN 0002 MODRST 0002 MORE4CYL C777 MS 007E MSDONE B221 MSEC B19A MSG_COMPLETE FDB4 MSG_ERROR FDCE MSG_HELLO FD88 MSG_HELP FD90 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 199 MC68HC908GP32 User Bootloader MSG_NORESET FDE0 MSG_WAITING FDBF MSG_WHAT FDD7 MSNEON 0001 MSNS 0000 MSXA 0004 MSXB 0005 MS_DELAY D126 MS_DELAY1 D127 MS_DELAY2 D129 MS_DWELL A0B3 MS_ERASEFLASH D0E2 MS_ERASEFLASH1 D0E5 MS_ERASERAMSIZE 0031 MS_FLASHPROGRAM D131 MS_FLASHPROGRAM1 D131 MS_FLASHPROGRAM2 D160 MS_MASSERASE D100 MS_PROGRAMFLASH D0F1 MS_PROGRAMFLASH1 D0F4 MS_PROGRAMRAM 000B MS_PROGRAMRAMSIZ 004A MS_RAM_END 010F MS_RAM_SIZE 00CF MS_RAM_START 0040 MS_RF_END 01D7 MS_RF_END_F E7C2 MS_RF_SIZE 00C8 MS_RF_START 010F MS_TOTAL_RAM_SIZ 0197 MULTIFACCRANK 9B52 MULTISPARKB 0008 MULTI_IT D2D8 MV_INIT 8371 MV_MODE 0006 MV_V_EMUL CF33 M_SC1INVSPARK 0008 M_SC1LNGTRG 0001 M_SC1ODDFIRE 0010 M_SC1TIMCRNK 0004 M_SC1XLNGTRG 0002 M_TWOSTROKE 0004 N2ODEL_FLAT_F E0AD N2ODEL_LAUNCH_F E0AC N2OHOLD 010D N2OHOLDON_F E0AE N2OLAUNCHDEL 010C NBO2TYPE 8B7C NBO2TYPE2 8C1F NEG_INTERPOLE D2BF NEG_SLOPE CFFC NEIE 0002 NEW_EGOLIM 8B70 NEW_SQUIRT1 AF5B NEW_SQUIRT2 AF76 NEXTCYL 0005 NEXT_CYL_CALC 92DA NEXT_CYL_RAIL 92D2 NF 0002 NF_FLAT 9059 NF_FLAT2 92BF NILS:003E AA49 NILS:003F AB02 NILS:0043 B387 NILS:0047 B8A5 NILS:004A C1BE NILS:004E CAF0 NINVLSPARKON2 C6D3 NITROUS 0007 NITROUSANGLE 0109 NOACCELASEB 0004 NOAIRFACTORB 0040 NOASE_CHECK_ACCE 88AA NOBOOSTIAT 9F2A NODECELBOOSTB 0080 NOITX_ERR C151 NOL_TIMER B250 NONDUALDIZZY C174 NON_EDIS C61D NOPRIMEPB 0008 NORETARD 96A7 NORMAEMODE 8A50 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 200 MC68HC908GP32 User Bootloader NORMAIRDEN 86EA NORMALBASED_AE 88FC NORMAL_ADSEL CBF6 NORMAL_KPA 863C NORMASE_COUNT 8839 NORMASE_INTERP 887F NORMDECEL 8A7E NORMMAP_COUNT CBF5 NORM_OP_DDRC 8184 NORM_OUT3_CHECK 94AC NOS2ANGLE_F E6A3 NOS2DELAY_F E6A2 NOS2PWHI_F E6A5 NOS2PWLO_F E6A4 NOS2RPMMAX_F E6A1 NOS2RPM_F E6A0 NOSANGLE_F E044 NOSANTILAG 0004 NOSCLT_F E016 NOSDCOK 0000 NOSFUELHI_F E046 NOSFUELLO_F E045 NOSHIKPA_F E056 NOSIN 0001 NOSLAGSYSTEMB 0040 NOSLOWKPA_F E055 NOSPARKCARRY C895 NOSPKOFF 9A66 NOSPW 010A NOSRPMMAX_F E018 NOSRPM_F E017 NOSSYSON 0001 NOSSYSREADY 0005 NOSTPS_F E043 NOS_DONE D285 NOS_DONE_NOW D300 NOS_IP_CHECKED D216 NOS_LIN D265 NOS_PWCAL2 9011 NOTA_CARRY 963B NOTIMELEFT 9850 NOTPRIMED 84F9 NOTRPMBASED 8985 NOTSPKTIME B32D NOTTPSLAST_YET CE1A NOT_2NDMISS BF03 NOT_ANTIREV_NOS D1F6 NOT_ATMAX 98B6 NOT_DWELL_ACCEL A0D9 NOT_FIXED 904D NOT_HEI7_INIT 8378 NOT_INIT_ROT 835F NOT_LC_IN 905F NOT_MISS BF0A NOT_MISS_OK BF7B NOT_MISS_SKIP BF6B NOT_MULTI 931D NOT_NC CCF4 NOT_SPARK_TIME B7A7 NOT_ST1 926F NOT_TEMPS1 93BA NOT_TEMPS2 944C NOX_OF 8779 NO_AFRTAR_VE1 9A56 NO_AFRTAR_VE3 9A60 NO_AFR_FORVE1 D320 NO_AFR_FORVE3 D3DD NO_BOOST 9A3C NO_BOOSTKNOCK 9869 NO_BOOST_CHK 88A0 NO_BTABLE_3 9EE7 NO_BTABLE_3_J 9EB8 NO_CARRY 966E NO_CARRY_B 9EFE NO_CARRY_BARRO 85E8 NO_CRANKPW2 9B5C NO_DT_SECONDO2 8BCC NO_DWELL CA5E NO_EGO_CNT C611 NO_EGO_MSEC B19F NO_EGO_W_CHK 8ADF NO_FANON_PORTA 95A0 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 201 MC68HC908GP32 User Bootloader NO_FAN_PORTA 9594 NO_FLYBK AF72 NO_INC 9B6F NO_KPA_300 8604 NO_KPA_CHECK 8AFA NO_MISC_SPARK 9A6E NO_NITROUS 9A42 NO_NOS_STABLE2 9189 NO_ODD_FIRE 872D NO_OF_SLIP 9A0F NO_OUT3_TIMER 94E4 NO_OVERRUN 95DE NO_OVERRUN_RESET 95D1 NO_OVER_RUN 95AC NO_PERSONALITY 9040 NO_PW2_STAGING 8FFF NO_ROLLCHK BCE6 NO_RPM_THRESH 9904 NO_SPK_F 8169 NO_ST2DELAY B2A2 NO_STAGING 8FEC NO_TCACCEL 8FC6 NO_TCACCEL2 9027 NO_TC_LOSS 98F2 NO_TC_YET 9901 NO_TPSCOUNT B2B9 NO_TPS_SETAFR1 D331 NO_TPS_SETAFR2 D3EE NO_TRACTION_ON 8FAA NO_UPPER_LIM1 93FB NO_UPPER_LIM2 9493 NO_VE3 87AE NO_VE3_DELAY B29A NO_VE_TABLE_3 9A4C NO_V_LAUNCH_ON 8EF7 NO_WD_TRIG A908 NO_WD_TRIG2 BDE7 NO_WD_TRIG3 BDFF NSQ1 AF68 NSQ2 AF83 NSQ2CONT AF95 NSQ2SINGLE AF92 NUMTEETH_F E05A O2TARGETV_F E1BB O2TARGETV_F2 E2BB O2_FPADC 005A O2_IS_LEAN 8BA3 O2_IS_LEANER 8C4A O2_IS_RICH 8B8C O2_IS_RICHER 8C2D OF45 C8AE OFFSETANG 020C OFFSETSTEP 020B OFF_INJ_1 AFC6 OFF_INJ_2 B00F ONE00TH B243 ONESHOTBARRO 0007 ONESHOT_BAR 859F ONETENTH B256 ONETEN_NOTLOG B27D OP_DDRC 8186 OR 0003 ORD_TABLE_FIND CF9B ORIE 0003 ORUNKPA_F E048 ORUNRPM_F E047 ORUNTPS_F E049 OUT1DONE 9406 OUT1DONEJMP 93B8 OUT1HYS_F E07E OUT1LIM E007 OUT1OFF 93D7 OUT1ON 93E7 OUT1SOURCE E008 OUT1UPLIM_F E058 OUT1_CLR 93F7 OUT1_OUT3B 0080 OUT1_SET 9404 OUT2DONE 949E OUT2HYS_F E07F OUT2LIM E009 OUT2OFF 9469 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 202 MC68HC908GP32 User Bootloader OUT2ON 947F OUT2SOURCE E00A OUT2UPLIM_F E059 OUT2_CLR 948F OUT2_OUT3 94FF OUT2_SET 949C OUT3DONE 9515 OUT3LIM_F E085 OUT3OFF 94DB OUT3ON 9511 OUT3SOURCE_F E084 OUT3SPARKD 0004 OUT3TIMER 00E6 OUT4DONE 9570 OUT4LIM_F E08B OUT4OFF 9546 OUT4ON 956E OUT4SOURCE_F E08A OUTAOFFS_F E6A6 OUTAOFFV_F E6A7 OUTBOFFS_F E6A8 OUTBOFFV_F E6A9 OUTCOFFS_F E6AA OUTCOFFV_F E6AB OUTDOFFS_F E6AC OUTDOFFV_F E6AD OUTEOFFS_F E6AE OUTEOFFV_F E6AF OUTFOFFS_F E6B0 OUTFOFFV_F E6B1 OUTOFF_22B 0001 OUTOFF_45B 0002 OUTOFF_90B 0004 OUTPUT1 0003 OUTPUT1ON 0001 OUTPUT2 0002 OUTPUT2ON 0002 OUTPUT3 0000 OUTPUTPINS 0062 OUTPUTPINS_F E001 OVERRUN 0002 OVERRUNCLT_F1 E0C5 OVERRUNONB 0040 OVERRUNTIME 00D7 OVERRUNT_F E082 OVER_B_P_F E02C OVER_RUN 95A5 OVER_RUN_DONE 95E2 OVER_RUN_SET 0005 OVER_RUN_T 95E0 OVRF 0005 P7FEAT1_F E7C0 PAGE 0106 PAGE2 0002 PAMBIENT 00CA PASS_STORE B167 PBWC 0037 PCTL 0036 PE 0000 PEIE 0000 PEN 0001 PERSONALITY 0061 PERSONALITY_F E000 PGM 0001 PIN 0006 PIN10 0003 PIN11 0004 PLLF 0006 PLLIE 0007 PLLON 0005 PLLSET FB3D PLLWAIT FB4D PMDS 003B PMRS 003A PMSH 0038 PMSL 0039 POR 0007 PORTA 0000 PORTB 0001 PORTC 0002 PORTD 0003 PORTE 0008 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 203 MC68HC908GP32 User Bootloader POSINTERP CFE3 PRE0 0002 PRE1 0003 PRIME 850A PRIMED 0007 PRIMELATEB 0002 PRIMELATER 8502 PRIMENOW 84C9 PRIMEPULSE_F E4C4 PRIMEP_F1 E4B6 PRIMETABLE_P 84F2 PRIMETWICEB 0004 PRIME_CHECKED 9A36 PRIME_NOPRIME 84E5 PRIME_NOT_DONE 84D7 PRINTSTRING FBF8 PRINTSTRING1 FBF3 PROGRAMRAM 000B PROGRAMRAMSIZE 004F PS0 0000 PS1 0001 PS2 0002 PTAPUE 000D PTCPUE 000E PTDPUE 000F PTY 0000 PUMPPRIME 8526 PUTCHAR FB53 PUTSTRING FBED PW1 004E PW2 0053 PW2_CALC 8E85 PW2_DONE 8E80 PW2_TABLE2 8E93 PWCALC1 006E PWCALC2 006F PWMIDLE 0003 PWM_LIMIT_1 AFDC PWM_LIMIT_2 B02D PWRUN1 006C PWRUN2 006D PW_DONE 8D5E PW_STAGED 010B PZ_NWSPK CCC8 PZ_WSPK CCCC QUOTIENT 0094 R8 0007 RAILCALC D1C2 RAMSLOT1 010E RAM_EXEC 01ED RAM_LAST 023F RAM_START 0040 RE 0002 REALLY_DONE_DWEL A727 REARM_IRQ B0AE RECALCDELAY C741 REENT CFA4 REMAINDER 0094 REQ_FUEL_F1 E194 REQ_FUEL_F2 E294 REQ_FUEL_R 01A3 RESET_TC_NOW 98F5 RESET_TC_YET 9958 RESET_VL 8F16 RESTAGING 0003 RESTART_F0 B263 RESTART_F1 B270 RETARD_END 96A7 RETARD_ENDJMP 9662 RET_W C044 RET_W2 C042 REUSE_FIDLE 0000 REUSE_LED17 0001 REUSE_LED18 0002 REUSE_LED18_2 0003 REUSE_LED19 0004 REVLIMBITS 0060 REVLIMHARD 0002 REVLIMHSOFT 0001 REVLIMIT_F E006 REVLIMSOFT 0000 REVNUM D812 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 204 MC68HC908GP32 User Bootloader RE_CHECK2TARG 8BEA RE_CHECKTARG 8B19 RISE 0004 ROLL1 0000 ROLL1SET 9A76 ROLL2 0001 ROLL_NOT_HIGH 9A84 ROM_LAST FDFF ROM_START 8000 ROT2CN:003E AA3D ROT2CN:003F AAF6 ROT2CN:0043 B37B ROT2CN:0047 B899 ROT2CN:004A C1B2 ROT2CN:004E CAE4 ROT2CP:003D A9E4 ROT2CP:0040 AB5D ROT2CP:0044 B3E2 ROT2CP:0046 B840 ROT2CP:004B C21C ROT2CP:004D CA8B ROT2DN:003E AA43 ROT2DN:003F AAFC ROT2DN:0043 B381 ROT2DN:0047 B89F ROT2DN:004A C1B8 ROT2DN:004E CAEA ROT2DP:003D A9E8 ROT2DP:0040 AB61 ROT2DP:0044 B3E6 ROT2DP:0046 B844 ROT2DP:004B C220 ROT2DP:004D CA8F ROT2NEG:003E AA32 ROT2NEG:003F AAEB ROT2NEG:0043 B370 ROT2NEG:0047 B88E ROT2NEG:004A C1A7 ROT2NEG:004E CAD9 ROT2POS:003D A9D9 ROT2POS:0040 AB52 ROT2POS:0044 B3D7 ROT2POS:0046 B835 ROT2POS:004B C211 ROT2POS:004D CA80 ROTARY2 0000 ROTARY2B 0001 ROTARYFDIGN 0004 ROTARY_SET_COILC C9F9 ROTARY_SET_COILD C9FD ROTARY_SPLIT A72D ROUNDEDADVANCE 964F ROUNDEDRETARD 968F ROUNDREM D18D ROUND_SLIP_PER 9A06 RPF 0000 RPM 004D RPMAEBASED 0010 RPMAQL_F2 E0AB RPMAQ_F2 E0A8 RPMBASEDRATE_F E0A4 RPMCALCDONE 878B RPMCALCFAST 8762 RPMCALCSLOW 8731 RPMCALCZERO 878A RPMCH 0072 RPMCL 0073 RPMDOTRATE D853 RPMK_F1 E19C RPMK_F2 E29C RPMK_R 01AB RPMLAST 0104 RPMLOWBYTECHK B0A7 RPMOXLIMIT_R 01D4 RPMPH 0070 RPMPL 0071 RPMRANGE3BC_F E784 RPMRANGEAFR_F1 E640 RPMRANGEAFR_F2 E690 RPMRANGEBC_F E724 RPMRANGEBC_F2 E754 RPMRANGESPLIT_F E7B4 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 205 MC68HC908GP32 User Bootloader RPMRANGEST_F1 E390 RPMRANGEST_F2 E490 RPMRANGEST_R 019F RPMRANGEVE_F1 E19E RPMRANGEVE_F2 E29E RPMRANGEVE_F3 E590 RPMRANGEVE_R 01AD RPMRATE_F E05E RPMREDUHI_F E5BF RPMREDULO_F E5BE RPMTHRESH_F E062 RPM_THRESH 995D RQFE1 8D1A RQFE2 8E3A RQFR1 8D17 RQFR2 8E37 RS1XC:0039 A793 RS1XC:003A A7A5 RS1XC:003B A7BF RS1XC:003C A7D1 RS1XF:0039 A790 RS1XF:003A A7A2 RS1XF:003B A7BC RS1XF:003C A7CE RS1_STEP_2 A762 RS1_STEP_3 A779 RSH_R 0005 RSH_S 0004 RSM_OK A81C RST_ACCEL 8A5E RS_MULT A806 RS_STEP_1 A74B RTC_DONE B2F8 RTC_DONE2 B32A RTC_DONEJMP B2B2 RTC_RESET B31B RUNIT 879D RUNNING 0000 RWU 0001 RXOFFSET 008D SAVE_DWELL:0024 A318 SAVE_DWELL:0025 A351 SAVE_DWELL:0028 A3EA SAVE_DWELL:0029 A423 SAVE_DWELL:002C A4B7 SAVE_DWELL:002D A4F0 SAVE_DWELL:0030 A588 SAVE_DWELL:0031 A5C1 SAVE_DWELL:0034 A659 SAVE_DWELL:0035 A692 SAVE_DWELL:0038 A723 SAWH 00F4 SAWL 00F5 SAW_COUNTER B905 SAW_COUNTER2 A883 SBFCR FE03 SBK 0000 SBSR FE00 SBSW 0001 SC2DUAL CB81 SC2SINGLE CB54 SCALEFAC_F E04F SCBR 0019 SCC1 0013 SCC2 0014 SCC3 0015 SCCR_INV CAB5 SCC_HEI4 CA61 SCDR 0018 SCHED1 0002 SCHED2 0004 SCHEDULE1 CB38 SCHEDULE1A CB44 SCHEDULE2D CB97 SCHEDULE2DA CBA3 SCHEDULE2S CB6A SCHEDULE2SA CB76 SCRF 0005 SCRIE 0005 SCS1 0016 SCS2 0017 SCTE 0007 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 206 MC68HC908GP32 User Bootloader SCTIE 0007 SDD2 C8F0 SDELAYDONE C8E4 SD_1 A261 SD_2 A265 SD_3 A256 SD_4 A26E SD_5 A27B SD_6 A28A SD_DONE A299 SECH 0080 SECL 0040 SECONDO2B 0001 SECONDS B2C9 SECS B2D4 SEC_CONT B2DD SEC_FIN B2F0 SEND_DATA_NORMAL CE65 SEND_FUDGED_DATA CE63 SEND_PORTS CE69 SETAFRNORMAL 8B2B SETAFRNORMAL2 8BFC SETAFRTABLE 8B30 SETAFRTABLE2 8C01 SETAFR_UP 8B12 SETIT C99F SETIT2 C9A1 SETLSB D089 SETPWMSINGLE 81CE SET_A_CLR BD8B SET_A_DETECT BD8D SET_B_CLR BD9D SET_B_DETECT BD9F SET_EDIS2 B91E SET_FD_COILS C9F1 SET_LAUNCH 8F0B SET_SAW_ON B8EA SET_SAW_ON2 A865 SET_SPKON B344 SET_SPKON2 B347 SET_SPK_TIMER C928 SHFTLP D051 SHIFTHI_F E013 SHIFTLIGHT 0001 SHIFTLIGHT1 8EB8 SHIFTLIGHT2 8EC9 SHIFTLIGHT3 8ED6 SHIFTLIGHTDONE 8EDD SHIFTLO_F E012 SHUTIDLE 9753 SHUTIDLE2 9761 SIGNATURE D833 SIN_A A912 SIN_B A925 SIN_C A93F SIN_D A952 SIN_E A965 SIN_F A978 SKIPADJUST 9751 SKIPO2 8BBA SKIPO22 8C44 SKIPO2A 8B84 SKIPO2JMP 8B07 SKIP_ALL_O2 8B09 SKIP_CYCLE_CALC CA00 SKIP_ERR_MSG 8553 SKIP_IRQ_CHK2 A8E9 SKIP_IRQ_NEON A8F4 SKIP_LOADCCOMP2 8DD5 SKIP_LOADCONTCOM 8CB5 SKIP_ROTARY_JMP C9B8 SLD2 A7E2 SLED 0000 SLIPRATE D857 SLIP_PERCENTAGE 9A15 SLOWIDLETEMP_F E023 SLOWIDLE_F E025 SOD_CD B41B SOD_CD_DONE B7A2 SOD_NE B413 SOIN10:0021 A024 SOIN10:0042 B138 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 207 MC68HC908GP32 User Bootloader SOIN10:0049 C0D7 SOIN10:004F CF0F SOIN11:0021 A02D SOIN11:0042 B141 SOIN11:0049 C0E0 SOIN11:004F CF18 SOIN1:0021 9FF6 SOIN1:0042 B10A SOIN1:0049 C0A9 SOIN1:004F CEE1 SOIN2:0021 9FF8 SOIN2:0042 B10C SOIN2:0049 C0AB SOIN2:004F CEE3 SOIN3:0021 9FFF SOIN3:0042 B113 SOIN3:0049 C0B2 SOIN3:004F CEEA SOIN4:0021 A001 SOIN4:0042 B115 SOIN4:0049 C0B4 SOIN4:004F CEEC SOIN5:0021 A008 SOIN5:0042 B11C SOIN5:0049 C0BB SOIN5:004F CEF3 SOIN6:0021 A00A SOIN6:0042 B11E SOIN6:0049 C0BD SOIN6:004F CEF5 SOIN7:0021 A014 SOIN7:0042 B128 SOIN7:0049 C0C7 SOIN7:004F CEFF SOIN8:0021 A016 SOIN8:0042 B12A SOIN8:0049 C0C9 SOIN8:004F CF01 SOIN9:0021 A01B SOIN9:0042 B12F SOIN9:0049 C0CE SOIN9:004F CF06 SOIN:0021 9FEF SOIN:0042 B103 SOIN:0049 C0A2 SOIN:004F CEDA SOIN_DONE:0021 A02D SOIN_DONE:0042 B141 SOIN_DONE:0049 C0E0 SOIN_DONE:004F CF18 SPARE3_177 E3B1 SPARE3_178 E3B2 SPARE3_179 E3B3 SPARE3_180 E3B4 SPARE3_181 E3B5 SPARE3_182 E3B6 SPARE3_183 E3B7 SPARE3_184 E3B8 SPARE3_F E08E SPAREASE E4AB SPARK2DELAY_F E057 SPARKANGLE 0058 SPARKBITS 005F SPARKCARRY 00C3 SPARKCONFIG1_F E3AD SPARKCUT 0005 SPARKCUTBASE_F E04E SPARKCUTBNUM_F E054 SPARKCUTCNT 00D8 SPARKCUTNLC_F E04D SPARKCUTNUM_F E02D SPARKDELAYH 00B1 SPARKDELAYL 00B2 SPARKDLTH 0096 SPARKDLTL 0097 SPARKDLTX 0095 SPARKFUEL_LC 8F85 SPARKHOLDCYC_F E3AC SPARKHSPEED 0001 SPARKLSPEED 0002 SPARKOFFDONE BCCB SPARKON 0003 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 208 MC68HC908GP32 User Bootloader SPARKONDONE B40A SPARKONLEFTAH 00B3 SPARKONLEFTAL 00B4 SPARKONLEFTBH 00B5 SPARKONLEFTBL 00B6 SPARKONLEFTCH 00B7 SPARKONLEFTCL 00B8 SPARKONLEFTDH 00B9 SPARKONLEFTDL 00BA SPARKONLEFTEH 00BB SPARKONLEFTEL 00BC SPARKONLEFTFH 00BD SPARKONLEFTFL 00BE SPARKTABLE2B 0080 SPARKTARGETH 00FB SPARKTARGETL 00FC SPARKTEMPH 00C1 SPARKTEMPL 00C2 SPARKTIME B334 SPARKTIME_EXIT B7A5 SPARKTRIGG 0000 SPARK_LOOKUP 902F SPCD2 A836 SPCR 0010 SPDR 0012 SPE 0001 SPKEOPB 0008 SPKFOPB 0010 SPK_MULT C876 SPK_MULT_DIV2 C870 SPK_MULT_DIV4 C86A SPK_MULT_DIV8 C864 SPLITDELH 0100 SPLITDELL 0101 SPLIT_CALC_DONE A828 SPLIT_F E790 SPLIT_LOOKUP_DON A7D6 SPLIT_MIN B7CD SPLIT_TIMED B7D7 SPMSTR 0005 SPR0 0000 SPR1 0001 SPRF 0007 SPRIE 0007 SPSCR 0011 SPTE 0003 SPTIE 0000 SPWOM 0002 SQUIRT 0041 SQUIRTCHECK1 CB24 SQUIRTCHECK2 CB4D SQUIRTDONE1 CB4D SQUIRTDONE2 CBAC SRECADDR 0007 SRECCHKSUM 0002 SRECCOUNT 0001 SRECSIZE 0006 SRECTYPE 0005 SREDDATA 0008 SREVLIMANGLE E003 SREVLIMCTIME E005 SREVLIMDONE 936E SREVLIMHTIME E004 SREVLIMOFF 935A SREVLIMON 9360 SREVLIMONDONE 936E SREVLIMRPM E002 SREVLIMTIMELEFT 00C4 SRSR FE01 SSON_INV B3BD SST2 C931 ST1_SD 909F ST2TIMER 00DF ST2TIMER_ZERO B28C ST2_STEP_1 917C ST2_STEP_2 91B0 ST2_STEP_3 91C9 ST2_STEP_4 922A ST2_STEP_5 923F ST2_STEP_6 9254 STAGEDB 0004 STAGEDEITHER 000C msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 209 MC68HC908GP32 User Bootloader STAGEDMODEB 0008 STAGED_OFF 9BBE STAGED_ON 9BBB STAGING_2_PW 8FF5 STAGING_DONE_PW 9003 STALL B0D0 STALL_CONT B159 START 8128 STARTW 0002 START_ADC 8485 START_KNOCKTIME 98B8 STGDELTA_F E051 STGTRANS_F E050 STH 01FE STHP 00F4 STIMEB2 BCB3 STIMEF2 BCB7 STL 01FF STLP 00F5 STOP_NOS D2F7 STOREANGLE 98D5 STORECORET 86A7 STOREKNOCK 986E STORENOS D262 STORERETARDEDTRI 969E STORETPSACCEL 8A52 STORE_ADVANCE 9660 STORE_AIRCOR 86EF STORE_BOOST_REMO 98A6 STORE_DDRD 816D STORE_MOD_KPA1 8CED STORE_MOD_KPA2 8E0D STORE_PWM 81D1 STORE_SPARK 92A2 STORE_SPARK2 92C2 STORE_SPARK_ANG 92B4 STORE_TEA1 890B STR_LAUNCH 8F19 STTABLELOOKUP 9087 STX 01FD ST_F1 E300 ST_F2 E400 ST_R 010F ST_STEP_1 90A3 ST_STEP_2 90C0 ST_STEP_3 90D9 ST_STEP_4 913A ST_STEP_5 914F ST_STEP_6 9164 SUBAR FE02 SUBSECTIONLOOP 9A30 SUPERNORM D170 T1CH0H 0026 T1CH0L 0027 T1CH1H 0029 T1CH1L 002A T1CNTH 0021 T1CNTL 0022 T1MODH 0023 T1MODL 0024 T1SC 0020 T1SC0 0025 T1SC1 0028 T1SCX_NO_PWM 0010 T1SCX_PWM 001E T1TIMERGO 0052 T1TIMERSTOP 0032 T2CH0H 0031 T2CH0L 0032 T2CH1H 0034 T2CH1L 0035 T2CNTH 002C T2CNTL 002D T2CNTX 00AA T2CURRH 0203 T2CURRL 0204 T2CURRX 0202 T2LASTH 00AC T2LASTL 00AD T2LASTX 00AB T2MODH 002E T2MODL 002F msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 210 MC68HC908GP32 User Bootloader T2OVERFLOW CF8F T2PREVH 00C6 T2PREVL 00C7 T2PREVX 00C5 T2SC 002B T2SC0 0030 T2SC1 0033 T8 0006 TABLE3_BOOST 9E57 TABLE3_BOOST_J 9E88 TABLELOOKUP CF9B TABLE_ASESTUFF 8844 TACHCONF_F E09F TACHOFF_OUT3 B1ED TACHOFF_PIN10 B1F1 TACHOFF_X2 B1DD TACHOFF_X3 B1E1 TACHOFF_X4 B1E5 TACHOFF_X5 B1E9 TACHON B1F5 TACHON_OUT3 B21B TACHON_PIN10 B21F TACHON_X2 B20B TACHON_X3 B20F TACHON_X4 B213 TACHON_X5 B217 TACH_DONE C126 TACH_FULL C124 TACK 0003 TAEIGNCOUNT 0003 TAE_CALC 888F TAE_CHK_JMP 891D TAE_CHK_TIME 89EE TAE_DONE 8AD5 TAE_DONEJMP 8A54 TARGETAFR3B 0002 TARGETAFRB 0080 TBCR 001C TBIE 0002 TBIF 0007 TBON 0001 TBR0 0004 TBR1 0005 TBR2 0006 TC 0006 TCACCEL 00E1 TCANGLE 00E2 TCCYCLES 00E5 TCCYCLESEC 0002 TCIE 0006 TCSCALEFAC_F E077 TCSLIPFACH_F E07B TCSLIPFAC_F E078 TCSPARKCUT 00E3 TC_INTERPJMP 99EE TC_INTERPOLER 99A0 TDE 8A70 TDE_CHK_DONE 8AC9 TDE_CHK_FUEL_CUT 8AB3 TD_NC 929D TE 0003 TEMP_SP 0041 TENTH 007F TEXTVERSION_F D813 TFI 0006 TFIIF AF3F TFIOF AF4A TFIOUTOFF AF43 TFISPKOFF AF33 TFI_CONT C6E7 TFI_FAST AF26 TFI_SPK AF1F THERMFACTOR F500 THIS_CYL 92E4 THRESH_REACH 997A THROTTLE_CHECK 8AFC TIMEBASED AA91 TIMELEFT B2C3 TIMERGO_NO_INT 0002 TIMEROUT3_F E086 TIMERROLL A89D TIMER_DONE A8B2 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 211 MC68HC908GP32 User Bootloader TIMFIXASE_F E5B4 TLHH CA24 TL_CONT CA2E TL_HIGH CA1A TMP1 0094 TMP10 009D TMP11 009E TMP12 009F TMP13 00A0 TMP14 00A1 TMP15 00A2 TMP16 00A3 TMP17 00A4 TMP18 00A5 TMP19 00A6 TMP2 0095 TMP20 00A7 TMP21 00A8 TMP22 00A9 TMP3 0096 TMP31 00DD TMP32 00DE TMP4 0097 TMP5 0098 TMP6 0099 TMP7 009A TMP8 009B TMP9 009C TOF 0007 TOHEX FCED TOHEX1 FCF5 TOIE 0006 TOOTHLOG 0002 TOOTHL_F0 CF73 TOOTHL_F1 CF77 TOOTH_AVG BF1B TOOTH_DECODE2 BD2D TOOTH_DECODE3 BD3E TOOTH_FOUND BD52 TOOTH_LOG_SETUP CF79 TOOTH_RTI BD22 TOOTH_SYNC BD19 TOVX 0001 TOY_DLI 0007 TO_EXIT B806 TO_INV B804 TPS 0047 TPSACCEL 004F TPSACLK 0081 TPSACOLD_F1 E0C0 TPSAEN 0004 TPSAQ_F1 E0BC TPSASYNC_F1 E0C2 TPSBOOIAT_F E089 TPSDEN 0005 TPSDOTRATE E0B0 TPSDQ_F1 E0C3 TPSFLOOD_F E4C3 TPSFUELCORR 00D6 TPSFUELCUT 0089 TPSLAST 00D1 TPSO2_F E041 TPSRANGE3BC_F E78A TPSRANGEBC_F E72A TPSRANGEBC_F2 E75A TPSTARGETAFR 0005 TPSTHRESH_F1 E0C1 TPS_ACCEL_AE 89C9 TPS_COUNTER C5F6 TPS_DECELL 8A97 TPS_DOTTY 88BC TPS_DOTY 89A1 TPS_DOT_MODE B2B5 TPS_DOT_ON C606 TPS_FIRSTELEM 8908 TPS_THRESHCHECK 88E3 TRACTCYCLE_F E070 TRACTDEG_F E063 TRACTION 0000 TRACTIONCB 0020 TRACTIONNOS 0000 TRACTIONSYSTEM 98DF msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 212 MC68HC908GP32 User Bootloader TRACTION_DONE 9A30 TRACTION_DONEJMP 9955 TRACTOUT1 93E2 TRACTOUT2 947A TRACTSPARK_F E067 TRACT_OUTPUT3 9504 TRACT_OUTPUT4 9561 TRAIL_DWELL_KILL A83D TRAIL_HYS_CK A83A TRAIL_OFF A7E8 TRAIL_SIMULT A7F0 TRAIL_SPLIT A7FC TRIG1RET_F E01D TRIG1_F E019 TRIG2RET_F E01E TRIG2_F E01A TRIG3RET_F E01F TRIG3_F E01B TRIG4RET_F E020 TRIG4_F E01C TRIG5RET_F E0A2 TRIG5_F E0A0 TRIG6RET_F E0A3 TRIG6_F E0A1 TRIGGANGLE_F E3A8 TRIGGANGLE_R 01B7 TRIGGER2 0003 TRIGLOG 0003 TRIGRET 0006 TRIMANGLE_F E3AA TRIMANGLE_R 01B9 TRIM_C 927E TRIM_DONE 9292 TRIM_DONE2 92A2 TRIM_FL 927B TROLL_CK_DONE 9A9F TRST 0004 TRUE_DWELL_CALC A29C TSTOP 0005 TURBOCONST 8606 TURNALLSPARKOFF 9FDC TURN_ON_INTS 84B3 TWO_PRIMES 84C2 TX6_MV CC54 TXCNT 008A TXGOAL 008B TXINV 0005 TXMODE 008C TXMODE_5 CC3F TXMODE_6 CC47 TXMODE_7 CC57 TXMODE_8 CC5F TXMODE_9 CC67 TXMODE_9_CONT CC78 TXMODE_C CF45 TXMODE_C1 CC3C UDIVBY100 D01B UDIVROUNDINGDONE D034 UDSPEEDLIM_F E076 UDSPEEDLO_F E075 UDVD32 D035 UMUL16 D00A UMULANDDIV D00A USER_ADC FACD USER_CONFIG1 FAC4 USER_CONFIG2 FAC5 USER_FIRST FAC6 USER_IRQ FAF7 USER_KEYBOARD FAD0 USER_LAST FAC8 USER_PLL FAF4 USER_RESET FAFD USER_SCBR FAC3 USER_SCIERR FAD9 USER_SCIRX FAD6 USER_SCITX FAD3 USER_SPIRX FADF USER_SPITX FADC USER_SWI FAFA USER_TIM1CH0 FAF1 USER_TIM1CH1 FAEE USER_TIM1OV FAEB msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 213 MC68HC908GP32 User Bootloader USER_TIM2CH0 FAE8 USER_TIM2CH1 FAE5 USER_TIM2OV FAE2 USER_TIMEBASE FACA USEVE3 0006 USE_SPARK_TABLE 907E VARIABLE_DELAY C6F4 VARLAUNCHB 0002 VE1XC:0009 9C2B VE1XC:000A 9C3D VE1XC:000B 9C57 VE1XC:000C 9C69 VE1XF:0009 9C28 VE1XF:000A 9C3A VE1XF:000B 9C54 VE1XF:000C 9C66 VE1_AN 9BD9 VE1_LOOKUP 9BC1 VE1_LOOKUP_PW1 9BC6 VE1_SD 9BD5 VE1_STEP_1 9BDB VE1_STEP_2 9BFA VE1_STEP_3 9C11 VE2XC:000D 9CD1 VE2XC:000E 9CE3 VE2XC:000F 9CFD VE2XC:0010 9D0F VE2XF:000D 9CCE VE2XF:000E 9CE0 VE2XF:000F 9CFA VE2XF:0010 9D0C VE2_AN 9C7F VE2_LOOKUP 9C72 VE2_LOOKUP_PW1 9C77 VE2_STEP_1 9C81 VE2_STEP_2 9CA0 VE2_STEP_3 9CB7 VE3DELAY_F E05D VE3TIMER 00E0 VE3TIMER_ZERO B292 VE3XC:0001 90F5 VE3XC:0002 9107 VE3XC:0003 9123 VE3XC:0004 9135 VE3XF:0001 90F2 VE3XF:0002 9104 VE3XF:0003 9120 VE3XF:0004 9132 VE3_AN 9D30 VE3_LOOKUP 9D18 VE3_LOOKUP_PW1 9D1D VE3_SD 9D2C VE3_STEP_1 9D32 VE3_STEP_2 9D51 VE3_STEP_3 9D68 VE3_TABLE 87A7 VE4XC:0005 91E5 VE4XC:0006 91F7 VE4XC:0007 9213 VE4XC:0008 9225 VE4XF:0005 91E2 VE4XF:0006 91F4 VE4XF:0007 9210 VE4XF:0008 9222 VE5XC:0011 9D82 VE5XC:0012 9D94 VE5XC:0013 9DAE VE5XC:0014 9DC0 VE5XF:0011 9D7F VE5XF:0012 9D91 VE5XF:0013 9DAB VE5XF:0014 9DBD VE6XC:0050 D38C VE6XC:0051 D39E VE6XC:0052 D3B8 VE6XC:0053 D3CA VE6XF:0050 D389 VE6XF:0051 D39B VE6XF:0052 D3B5 VE6XF:0053 D3C7 VE7XC:0015 9E67 VE7XC:0016 9E6D msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 214 MC68HC908GP32 User Bootloader VE7XC:0017 9E7B VE7XC:0018 9E81 VE7XC:0054 D449 VE7XC:0055 D45B VE7XC:0056 D475 VE7XC:0057 D487 VE7XF:0015 9E64 VE7XF:0016 9E6A VE7XF:0017 9E78 VE7XF:0018 9E7E VE7XF:0054 D446 VE7XF:0055 D458 VE7XF:0056 D472 VE7XF:0057 D484 VE8XC:001D 9FB6 VE8XC:001E 9FBC VE8XC:001F 9FCA VE8XC:0020 9FD0 VE8XF:001D 9FB3 VE8XF:001E 9FB9 VE8XF:001F 9FC7 VE8XF:0020 9FCD VE9XC:0019 9EC8 VE9XC:001A 9ECE VE9XC:001B 9EDC VE9XC:001C 9EE2 VE9XF:0019 9EC5 VE9XF:001A 9ECB VE9XF:001B 9ED9 VE9XF:001C 9EDF VECURR 0052 VECURR2 0054 VEC_ADC FFDE VEC_IRQ FFFA VEC_KBD FFE0 VEC_PLL FFF8 VEC_RESET FFFE VEC_SCIERR FFE6 VEC_SCIRX FFE4 VEC_SCITX FFE2 VEC_SPIRX FFEA VEC_SPITX FFE8 VEC_SWI FFFC VEC_TIM1CH0 FFF6 VEC_TIM1CH1 FFF4 VEC_TIM1OV FFF2 VEC_TIM2CH0 FFF0 VEC_TIM2CH1 FFEE VEC_TIM2OV FFEC VEC_TIMEBASE FFDC VETABLE3B 0001 VE_F1 E100 VE_F2 E200 VE_F3 E500 VE_R 010F VE_STEP_4 9DC9 VE_STEP_5 9DDE VE_STEP_6 9DF3 VLAUNCHLIMIT 0105 VOLTOXTARGET_R 01D6 VPR0 0000 VPR1 0001 VSSTHRESH_REACH 99F0 VSSTHRESH_RJMP 999E V_MV2 CF41 WAKE 0003 WARMACCEL_COMP 8C5F WARMCOR 004C WARMUP 0003 WARMUP_OVERAE 8957 WARM_DONE_NOW 87F7 WARM_NOTDONE 87C9 WASTEDWELL:0041 ABC7 WASTEDWELL:0045 B44C WASTEDWELL:0048 B94F WASTEDWELL:004C C289 WASTED_DWELL A0E5 WATER 0005 WATER2 0004 WATERINJB 0008 WATERIPOINT_F E03E WATERIRPM_F E03F msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 215 MC68HC908GP32 User Bootloader WATER_INJECTION 95E9 WATER_INJ_DONE 9611 WATER_ON 9604 WBO2TYPE 8B86 WBO2TYPE2 8C27 WC_OP BF81 WC_OP2 BFC8 WC_OP3 BFE6 WC_WHEEL B179 WD2A180:0041 AC55 WD2A180:0045 B4DA WD2A180:0048 B9DD WD2A180:004C C317 WD2A360:0041 AC36 WD2A360:0045 B4BB WD2A360:0048 B9BE WD2A360:004C C2F8 WD2B180:0041 AC59 WD2B180:0045 B4DE WD2B180:0048 B9E1 WD2B180:004C C31B WD2B360:0041 AC3A WD2B360:0045 B4BF WD2B360:0048 B9C2 WD2B360:004C C2FC WD2END180:0041 AC5B WD2END180:0045 B4E0 WD2END180:0048 B9E3 WD2END180:004C C31D WD2END360:0041 AC3C WD2END360:0045 B4C1 WD2END360:0048 B9C4 WD2END360:004C C2FE WD2OK:0041 AC4D WD2OK:0045 B4D2 WD2OK:0048 B9D5 WD2OK:004C C30F WD2SKIP:0041 AC5B WD2SKIP:0045 B4E0 WD2SKIP:0048 B9E3 WD2SKIP:004C C31D WD2_CONT BE0D WD3A120:0041 AC05 WD3A120:0045 B48A WD3A120:0048 B98D WD3A120:004C C2C7 WD3A240:0041 AC24 WD3A240:0045 B4A9 WD3A240:0048 B9AC WD3A240:004C C2E6 WD3A360:0041 ABE6 WD3A360:0045 B46B WD3A360:0048 B96E WD3A360:004C C2A8 WD3B120:0041 AC09 WD3B120:0045 B48E WD3B120:0048 B991 WD3B120:004C C2CB WD3B240:0041 AC28 WD3B240:0045 B4AD WD3B240:0048 B9B0 WD3B240:004C C2EA WD3B360:0041 ABEA WD3B360:0045 B46F WD3B360:0048 B972 WD3B360:004C C2AC WD3C120:0041 AC0D WD3C120:0045 B492 WD3C120:0048 B995 WD3C120:004C C2CF WD3C240:0041 AC2C WD3C240:0045 B4B1 WD3C240:0048 B9B4 WD3C240:004C C2EE WD3C360:0041 ABEE WD3C360:0045 B473 WD3C360:0048 B976 WD3C360:004C C2B0 WD3END120:0041 AC0F WD3END120:0045 B494 WD3END120:0048 B997 WD3END120:004C C2D1 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 216 MC68HC908GP32 User Bootloader WD3END240:0041 AC2E WD3END240:0045 B4B3 WD3END240:0048 B9B6 WD3END240:004C C2F0 WD3END360:0041 ABF0 WD3END360:0045 B475 WD3END360:0048 B978 WD3END360:004C C2B2 WD3OK120:0041 ABFA WD3OK120:0045 B47F WD3OK120:0048 B982 WD3OK120:004C C2BC WD3OK240:0041 AC19 WD3OK240:0045 B49E WD3OK240:0048 B9A1 WD3OK240:004C C2DB WD3SKIP120:0041 AC0F WD3SKIP120:0045 B494 WD3SKIP120:0048 B997 WD3SKIP120:004C C2D1 WD4A180:0041 ACBF WD4A180:0045 B544 WD4A180:0048 BA47 WD4A180:004C C381 WD4A270:0041 ACEC WD4A270:0045 B571 WD4A270:0048 BA74 WD4A270:004C C3AE WD4A360:0041 AC6C WD4A360:0045 B4F1 WD4A360:0048 B9F4 WD4A360:004C C32E WD4A90:0041 AC99 WD4A90:0045 B51E WD4A90:0048 BA21 WD4A90:004C C35B WD4B180:0041 ACC3 WD4B180:0045 B548 WD4B180:0048 BA4B WD4B180:004C C385 WD4B270:0041 ACF0 WD4B270:0045 B575 WD4B270:0048 BA78 WD4B270:004C C3B2 WD4B360:0041 AC70 WD4B360:0045 B4F5 WD4B360:0048 B9F8 WD4B360:004C C332 WD4B90:0041 AC9D WD4B90:0045 B522 WD4B90:0048 BA25 WD4B90:004C C35F WD4C180:0041 ACC7 WD4C180:0045 B54C WD4C180:0048 BA4F WD4C180:004C C389 WD4C270:0041 ACF4 WD4C270:0045 B579 WD4C270:0048 BA7C WD4C270:004C C3B6 WD4C360:0041 AC74 WD4C360:0045 B4F9 WD4C360:0048 B9FC WD4C360:004C C336 WD4C90:0041 ACA1 WD4C90:0045 B526 WD4C90:0048 BA29 WD4C90:004C C363 WD4D180:0041 ACCB WD4D180:0045 B550 WD4D180:0048 BA53 WD4D180:004C C38D WD4D270:0041 ACF8 WD4D270:0045 B57D WD4D270:0048 BA80 WD4D270:004C C3BA WD4D360:0041 AC78 WD4D360:0045 B4FD WD4D360:0048 BA00 WD4D360:004C C33A WD4D90:0041 ACA5 WD4D90:0045 B52A msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 217 MC68HC908GP32 User Bootloader WD4D90:0048 BA2D WD4D90:004C C367 WD4END180:0041 ACCD WD4END180:0045 B552 WD4END180:0048 BA55 WD4END180:004C C38F WD4END270:0041 ACFA WD4END270:0045 B57F WD4END270:0048 BA82 WD4END270:004C C3BC WD4END360:0041 AC7A WD4END360:0045 B4FF WD4END360:0048 BA02 WD4END360:004C C33C WD4END90:0041 ACA7 WD4END90:0045 B52C WD4END90:0048 BA2F WD4END90:004C C369 WD4OK180:0041 ACB1 WD4OK180:0045 B536 WD4OK180:0048 BA39 WD4OK180:004C C373 WD4OK270:0041 ACDE WD4OK270:0045 B563 WD4OK270:0048 BA66 WD4OK270:004C C3A0 WD4OK90:0041 AC8B WD4OK90:0045 B510 WD4OK90:0048 BA13 WD4OK90:004C C34D WD4SKIP180:0041 ACCD WD4SKIP180:0045 B552 WD4SKIP180:0048 BA55 WD4SKIP180:004C C38F WD4SKIP90:0041 ACA7 WD4SKIP90:0045 B52C WD4SKIP90:0048 BA2F WD4SKIP90:004C C369 WD5A144:0041 AD68 WD5A144:0045 B5ED WD5A144:0048 BAF0 WD5A144:004C C42A WD5A216:0041 AD95 WD5A216:0045 B61A WD5A216:0048 BB1D WD5A216:004C C457 WD5A288:0041 ADC2 WD5A288:0045 B647 WD5A288:0048 BB4A WD5A288:004C C484 WD5A360:0041 AD0E WD5A360:0045 B593 WD5A360:0048 BA96 WD5A360:004C C3D0 WD5A72:0041 AD3B WD5A72:0045 B5C0 WD5A72:0048 BAC3 WD5A72:004C C3FD WD5B144:0041 AD6C WD5B144:0045 B5F1 WD5B144:0048 BAF4 WD5B144:004C C42E WD5B216:0041 AD99 WD5B216:0045 B61E WD5B216:0048 BB21 WD5B216:004C C45B WD5B288:0041 ADC6 WD5B288:0045 B64B WD5B288:0048 BB4E WD5B288:004C C488 WD5B360:0041 AD12 WD5B360:0045 B597 WD5B360:0048 BA9A WD5B360:004C C3D4 WD5B72:0041 AD3F WD5B72:0045 B5C4 WD5B72:0048 BAC7 WD5B72:004C C401 WD5C144:0041 AD70 WD5C144:0045 B5F5 WD5C144:0048 BAF8 WD5C144:004C C432 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 218 MC68HC908GP32 User Bootloader WD5C216:0041 AD9D WD5C216:0045 B622 WD5C216:0048 BB25 WD5C216:004C C45F WD5C288:0041 ADCA WD5C288:0045 B64F WD5C288:0048 BB52 WD5C288:004C C48C WD5C360:0041 AD16 WD5C360:0045 B59B WD5C360:0048 BA9E WD5C360:004C C3D8 WD5C72:0041 AD43 WD5C72:0045 B5C8 WD5C72:0048 BACB WD5C72:004C C405 WD5D144:0041 AD74 WD5D144:0045 B5F9 WD5D144:0048 BAFC WD5D144:004C C436 WD5D216:0041 ADA1 WD5D216:0045 B626 WD5D216:0048 BB29 WD5D216:004C C463 WD5D288:0041 ADCE WD5D288:0045 B653 WD5D288:0048 BB56 WD5D288:004C C490 WD5D360:0041 AD1A WD5D360:0045 B59F WD5D360:0048 BAA2 WD5D360:004C C3DC WD5D72:0041 AD47 WD5D72:0045 B5CC WD5D72:0048 BACF WD5D72:004C C409 WD5E144:0041 AD78 WD5E144:0045 B5FD WD5E144:0048 BB00 WD5E144:004C C43A WD5E216:0041 ADA5 WD5E216:0045 B62A WD5E216:0048 BB2D WD5E216:004C C467 WD5E288:0041 ADD2 WD5E288:0045 B657 WD5E288:0048 BB5A WD5E288:004C C494 WD5E360:0041 AD1E WD5E360:0045 B5A3 WD5E360:0048 BAA6 WD5E360:004C C3E0 WD5E72:0041 AD4B WD5E72:0045 B5D0 WD5E72:0048 BAD3 WD5E72:004C C40D WD5END144:0041 AD7A WD5END144:0045 B5FF WD5END144:0048 BB02 WD5END144:004C C43C WD5END216:0041 ADA7 WD5END216:0045 B62C WD5END216:0048 BB2F WD5END216:004C C469 WD5END288:0041 ADD4 WD5END288:0045 B659 WD5END288:0048 BB5C WD5END288:004C C496 WD5END360:0041 AD20 WD5END360:0045 B5A5 WD5END360:0048 BAA8 WD5END360:004C C3E2 WD5END72:0041 AD4D WD5END72:0045 B5D2 WD5END72:0048 BAD5 WD5END72:004C C40F WD5OK144:0041 AD57 WD5OK144:0045 B5DC WD5OK144:0048 BADF WD5OK144:004C C419 WD5OK216:0041 AD84 WD5OK216:0045 B609 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 219 MC68HC908GP32 User Bootloader WD5OK216:0048 BB0C WD5OK216:004C C446 WD5OK288:0041 ADB1 WD5OK288:0045 B636 WD5OK288:0048 BB39 WD5OK288:004C C473 WD5OK72:0041 AD2A WD5OK72:0045 B5AF WD5OK72:0048 BAB2 WD5OK72:004C C3EC WD5SKIP144:0041 AD7A WD5SKIP144:0045 B5FF WD5SKIP144:0048 BB02 WD5SKIP144:004C C43C WD5SKIP216:0041 ADA7 WD5SKIP216:0045 B62C WD5SKIP216:0048 BB2F WD5SKIP216:004C C469 WD5SKIP288:0041 ADD4 WD5SKIP288:0045 B659 WD5SKIP288:0048 BB5C WD5SKIP288:004C C496 WD5SKIP72:0041 AD4D WD5SKIP72:0045 B5D2 WD5SKIP72:0048 BAD5 WD5SKIP72:004C C40F WD6A120:0041 AE5A WD6A120:0045 B6DF WD6A120:0048 BBE2 WD6A120:004C C51C WD6A180:0041 AE95 WD6A180:0045 B71A WD6A180:0048 BC1D WD6A180:004C C557 WD6A240:0041 AECB WD6A240:0045 B750 WD6A240:0048 BC53 WD6A240:004C C58D WD6A300:0041 AF06 WD6A300:0045 B78B WD6A300:0048 BC8E WD6A300:004C C5C8 WD6A360:0041 ADEB WD6A360:0045 B670 WD6A360:0048 BB73 WD6A360:004C C4AD WD6A60:0041 AE26 WD6A60:0045 B6AB WD6A60:0048 BBAE WD6A60:004C C4E8 WD6B120:0041 AE5E WD6B120:0045 B6E3 WD6B120:0048 BBE6 WD6B120:004C C520 WD6B180:0041 AE99 WD6B180:0045 B71E WD6B180:0048 BC21 WD6B180:004C C55B WD6B240:0041 AECF WD6B240:0045 B754 WD6B240:0048 BC57 WD6B240:004C C591 WD6B300:0041 AF0A WD6B300:0045 B78F WD6B300:0048 BC92 WD6B300:004C C5CC WD6B360:0041 ADEF WD6B360:0045 B674 WD6B360:0048 BB77 WD6B360:004C C4B1 WD6B60:0041 AE2A WD6B60:0045 B6AF WD6B60:0048 BBB2 WD6B60:004C C4EC WD6C120:0041 AE62 WD6C120:0045 B6E7 WD6C120:0048 BBEA WD6C120:004C C524 WD6C180:0041 AE9D WD6C180:0045 B722 WD6C180:0048 BC25 WD6C180:004C C55F msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 220 MC68HC908GP32 User Bootloader WD6C240:0041 AED3 WD6C240:0045 B758 WD6C240:0048 BC5B WD6C240:004C C595 WD6C300:0041 AF0E WD6C300:0045 B793 WD6C300:0048 BC96 WD6C300:004C C5D0 WD6C360:0041 ADF3 WD6C360:0045 B678 WD6C360:0048 BB7B WD6C360:004C C4B5 WD6C60:0041 AE2E WD6C60:0045 B6B3 WD6C60:0048 BBB6 WD6C60:004C C4F0 WD6D120:0041 AE66 WD6D120:0045 B6EB WD6D120:0048 BBEE WD6D120:004C C528 WD6D180:0041 AEA1 WD6D180:0045 B726 WD6D180:0048 BC29 WD6D180:004C C563 WD6D240:0041 AED7 WD6D240:0045 B75C WD6D240:0048 BC5F WD6D240:004C C599 WD6D300:0041 AF12 WD6D300:0045 B797 WD6D300:0048 BC9A WD6D300:004C C5D4 WD6D360:0041 ADF7 WD6D360:0045 B67C WD6D360:0048 BB7F WD6D360:004C C4B9 WD6D60:0041 AE32 WD6D60:0045 B6B7 WD6D60:0048 BBBA WD6D60:004C C4F4 WD6E120:0041 AE6A WD6E120:0045 B6EF WD6E120:0048 BBF2 WD6E120:004C C52C WD6E180:0041 AEA5 WD6E180:0045 B72A WD6E180:0048 BC2D WD6E180:004C C567 WD6E240:0041 AEDB WD6E240:0045 B760 WD6E240:0048 BC63 WD6E240:004C C59D WD6E300:0041 AF16 WD6E300:0045 B79B WD6E300:0048 BC9E WD6E300:004C C5D8 WD6E360:0041 ADFB WD6E360:0045 B680 WD6E360:0048 BB83 WD6E360:004C C4BD WD6E60:0041 AE36 WD6E60:0045 B6BB WD6E60:0048 BBBE WD6E60:004C C4F8 WD6END120:0041 AE70 WD6END120:0045 B6F5 WD6END120:0048 BBF8 WD6END120:004C C532 WD6END180:0041 AEAB WD6END180:0045 B730 WD6END180:0048 BC33 WD6END180:004C C56D WD6END240:0041 AEE1 WD6END240:0045 B766 WD6END240:0048 BC69 WD6END240:004C C5A3 WD6END300:0041 AF1C WD6END300:0045 B7A1 WD6END300:0048 BCA4 WD6END300:004C C5DE WD6END360:0041 AE01 WD6END360:0045 B686 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 221 MC68HC908GP32 User Bootloader WD6END360:0048 BB89 WD6END360:004C C4C3 WD6END60:0041 AE3C WD6END60:0045 B6C1 WD6END60:0048 BBC4 WD6END60:004C C4FE WD6F120:0041 AE6E WD6F120:0045 B6F3 WD6F120:0048 BBF6 WD6F120:004C C530 WD6F180:0041 AEA9 WD6F180:0045 B72E WD6F180:0048 BC31 WD6F180:004C C56B WD6F240:0041 AEDF WD6F240:0045 B764 WD6F240:0048 BC67 WD6F240:004C C5A1 WD6F300:0041 AF1A WD6F300:0045 B79F WD6F300:0048 BCA2 WD6F300:004C C5DC WD6F360:0041 ADFF WD6F360:0045 B684 WD6F360:0048 BB87 WD6F360:004C C4C1 WD6F60:0041 AE3A WD6F60:0045 B6BF WD6F60:0048 BBC2 WD6F60:004C C4FC WD6OK120:0041 AE46 WD6OK120:0045 B6CB WD6OK120:0048 BBCE WD6OK120:004C C508 WD6OK180:0041 AE81 WD6OK180:0045 B706 WD6OK180:0048 BC09 WD6OK180:004C C543 WD6OK240:0041 AEB7 WD6OK240:0045 B73C WD6OK240:0048 BC3F WD6OK240:004C C579 WD6OK300:0041 AEF2 WD6OK300:0045 B777 WD6OK300:0048 BC7A WD6OK300:004C C5B4 WD6OK60:0041 AE12 WD6OK60:0045 B697 WD6OK60:0048 BB9A WD6OK60:004C C4D4 WD6SKIP120:0041 AE70 WD6SKIP120:0045 B6F5 WD6SKIP120:0048 BBF8 WD6SKIP120:004C C532 WD6SKIP180:0041 AEAD WD6SKIP180:0045 B732 WD6SKIP180:0048 BC35 WD6SKIP180:004C C56F WD6SKIP240:0041 AEE1 WD6SKIP240:0045 B766 WD6SKIP240:0048 BC69 WD6SKIP240:004C C5A3 WD6SKIP300:0041 AF1C WD6SKIP300:0045 B7A1 WD6SKIP300:0048 BCA4 WD6SKIP300:004C C5DE WD6SKIP60:0041 AE3C WD6SKIP60:0045 B6C1 WD6SKIP60:0048 BBC4 WD6SKIP60:004C C4FE WDNC2 BFBB WDNC3 BF92 WDNC4 BFA4 WDTH BE6C WDTL BE70 WDTLT CA37 WDTS BE6D WDWELL2OP:0041 AC31 WDWELL2OP:0045 B4B6 WDWELL2OP:0048 B9B9 WDWELL2OP:004C C2F3 WDWELL3OP:0041 ABDB msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 222 MC68HC908GP32 User Bootloader WDWELL3OP:0045 B460 WDWELL3OP:0048 B963 WDWELL3OP:004C C29D WDWELL4OP:0041 AC5E WDWELL4OP:0045 B4E3 WDWELL4OP:0048 B9E6 WDWELL4OP:004C C320 WDWELL5OP:0041 ACFD WDWELL5OP:0045 B582 WDWELL5OP:0048 BA85 WDWELL5OP:004C C3BF WDWELL6OP:0041 ADD7 WDWELL6OP:0045 B65C WDWELL6OP:0048 BB5F WDWELL6OP:004C C499 WD_2TRIG 0000 WD_2TRIGB 0001 WD_RISE A903 WD_RISE2 BDE7 WHEEL 0002 WHEEL2 0003 WHEELCOUNT 00E7 WHEELINIT 00C5 WHEELSENSOR 0003 WHEELSIM BDA6 WHEELSIMDONE BDD8 WHEEL_OLDB 0008 WHICH_IO_FIRST D205 WHLSIM 0002 WHLSIMCNT E00D WHLSIMDECODE BDAF WHLSIMRESET BDAE WHOLD 0002 WLED 0002 WSDB BDC6 WSDC BDCA WSDD BDCE WSDE BDD2 WSDF BDD6 WSPK 0003 WSP_INIT 8369 WSYNC 0001 WUE1 87BD WUE2 880C WUE2_LEDSKIP 8814 WUE3 888D WUE_CALC 87AE WUE_DONE 888F WUE_DONEJMP 8842 WWURANGE D808 WWU_F1 E4AC W_COMP BEE9 W_DECODE BE48 W_DECODE2 BEC4 W_DECODE_FALSE BE9F W_DECODE_OK BEA0 W_DEC_NOTLOG BE74 W_DEC_NOTLOGT CA3B W_HIGH BE21 W_HIGH_FAST BE3A W_LOW BE19 W_NO3 81EF W_RTI BEB1 W_STORE C0FD W_STORE2 C0FB W_TRIG1 C009 W_TRIG2 C010 W_TRIG3 C01A W_TRIG4 C024 W_TRIG5 C02E W_TRIG6 C038 W_TRIGRET1 C04F W_TRIGRET2 C055 W_TRIGRET3 C05E W_TRIGRET4 C067 W_TRIGRET5 C070 W_TRIGRET6 C079 X2_FAN 0005 XL22 C8C3 XL45 C8BB YES_ODD_FIRE 8716 ZD_A C983 msns-extra.asm Assembled with CASMW 9.3.2006 21:23:17 PAGE 223 MC68HC908GP32 User Bootloader ZD_B C987 ZD_C C98B ZD_D C98F ZERO_INTERPOLE D2CC ZERO_SLOPE D007