Address|Hex-Code| Code line | Assembler instruction -------+--------+-------------+--------------------------------------------------------------------------------------------------- 1 #include "engmem.h" 1 #include 29 # endif 30 31 #define sp r14 2 3 /* Copyright 1998 Regents University of California All Rights Reserved 4 This software is for use in the Engineering Model and Flight Model of the PSD subassembly 5 of the Integral Spacecraft. Any other use without prior authorization is forbidden */ 6 7 8 /* next definition puts low speed serial records in memory for the SEM */ 9 #define SEMLSDIAG 10 /* next definition allows configuration loading while running */ 11 /* #define LABLOAD */ 12 13 /* this starts things up in calibration mode for testing */ 14 /*#define LABMODEL */ 15 16 /* slow io definitions for memory map */ 17 #define SWROM 0x0000a0 18 #define EPROMA 0x080000 19 #define EPROMB 0x100000 20 #define RAM 0x180000 21 #define RAMINIT 0x98004c 22 #define FASTRAM 0x980020 23 #define EPROMC 0x200000 24 #define EPROMD 0x280000 25 #define FIFO 0x300000 26 /* FASTENERGY no longer b20000 because of timing problems */ 27 #define FASTAD 0x320000 28 #define FASTENERGY 0x340000 29 #define HKAD 0x380000 30 #define DFELOAD 0x390000 31 #define ANARESET 0x3a0000 32 #define CONTROL 0x3b0000 33 #define STATUS 0x3b0000 34 #define DATA151 0x3f0000 35 #define CTRL151 0x3f0004 36 37 38 /* sync word keeps changing 39 #define SYNC1 0x5a 40 #define SYNC2 0xae 41 */ 42 #define SYNC1 0xa 43 #define SYNC2 0x5 44 /* use RAM2 for program storage */ 45 #define INTRAM 0xffe000 46 /* this will sign extend into INTRAM */ 47 #define STORAGE 0xe000 48 /* this is defined with .rsect ".ram2" and the location set with a linker directive */ 49 /* use this on chip ram for the serial interrupts */ 50 #define SERIALRAML 0xfff800 51 #define SERIALRAM 0xf800 52 #define SERIALINTOP 768 53 #define SERIALOUTOFF 768 54 #define SERIALOUTBUF SERIALRAM + SERIALOUTOFF 55 #define SERIALOUTBUFL SERIALRAML + SERIALOUTOFF 56 #define SERIALINPT SERIALRAM + 0x7f0 57 #define SERIALINCNT SERIALRAM + 0x7f4 58 #define SERIALINEXP SERIALRAM + 0x7f8 59 #define SERIALINCHK SERIALRAM + 0x7fc 60 #define SERIALINCMD SERIALRAM + 0x7fe 61 #define SERIALOUTPT SERIALRAM + 0x7e0 62 #define SERIALOUTCNT SERIALRAM + 0x7e4 63 #define SERIALOUTEXP SERIALRAM + 0x7e8 64 #define SERIALOUTCHK SERIALRAM + 0x7ec 65 #define SERIALGETPT SERIALRAM + 0x7d0 66 #define SERIALGETCNT SERIALRAM + 0x7d4 67 #define SERIALOUTFIRST SERIALRAM + 0x7dc 68 #define SERIALOUTDATA SERIALRAM + 0x7d8 69 #define DUMPCHAR SERIALRAM + 0x7c3 70 #define DUMPCHARL SERIALRAML + 0x7c3 71 #define ADDTEMPL SERIALRAML + 0x7c4 72 #define SERIALDEBUG SERIALRAM + 0x7cc 73 74 /* next parameters are for communicating with semgse */ 75 #ifdef SEMLSDIAG 76 #define SERIALFLAG SERIALRAM + 0x7b0 77 #define SERIALIND SERIALRAM + 0x750 78 #define SERIALINDL SERIALRAML + 0x750 79 #define SERIALOUTD SERIALRAM + 0x780 80 #define SERIALOUTDL SERIALRAML + 0x780 81 82 83 #endif 84 #define MAXOUTCNT 36 85 86 /* constants for program */ 87 #define SOP 0x2 88 #define EOP 0x00 89 #define EOT 0x00 90 #define DPESIZE 308 91 /* pick next value to divide 8 Hz int 8 parts */ 92 #define LOOP 0x500 93 #define LOOP1 4000 94 #define LOOP2 8000 95 #define COUNTFREQ 8 96 /* ram buffer locations */ 97 #define EVENTSIZE 300 98 #define MAXEVENTS 100 99 #define MAXBUFFER 148 100 #define MAXCURVES 5 101 #define CURVESIZE 300 102 #define EVENT0 0x988000 103 #define EVENT1 EVENT0+(EVENTSIZE*2) 104 #define CURVE0 EVENT1+(EVENTSIZE*2) 105 #define CURVE1 CURVE0+(CURVESIZE*2) 106 #define LAST CURVE1+(CURVESIZE*2) 107 108 /* Error definitions */ 109 #define LOSTEVENTS 0x80 110 #define NO8HZCLK 1 111 #define BAD8HZCLK 2 112 #define NOHSL 3 113 #define BADLIBCRC 4 114 #define BADCOMMAND 5 115 #define BADSERIAL 6 116 117 /* start of circular buffer for pulses */ 118 #define PBUFFERBASE 0x9f0000 119 /* number of 256 byte buffers available */ 120 #define PBUFFERSIZE 160 121 /* number of events willing to process after 8Hz clock goes high */ 122 #define QUEROLL 10 123 124 #define STACKTOP PBUFFERBASE 125 #define STACKSIZE 512 126 #define STACKSTART (STACKTOP - STACKSIZE) 127 128 /* This line must be at the _end_ of file "engmem.h" */ 129 2 #define VERSION 230 3 4 /* Copyright 1998-2000 Regents University of California All Rights Reserved 5 This software is for use in the Engineering Model and Flight Model of the PSD subassembly 6 of the Integral Spacecraft. Any other use without prior authorization is forbidden */ 7 #ifndef ROM 8 #define TEST 9 #endif 10 #define BADID 37 #endif 38 39 _testcode: 980000 942f000e 40 r1e = pc + (testgo - _testcode -6) 980004 1ea20030 41 r2 = *r1 980008 00000000 42 nop 98000c 008fffec 43 if(ne) pcgoto _testcode 980010 00000000 44 nop 980014 0000 45 testgo: int 0,1 980016 0001 45 980018 00000000 46 nop 98001c 00000000 47 nop 980020 00000000 48 nop 980024 00000000 49 nop 980028 00000000 50 nop 51 /*#endif*/ 52 98002c 00000000 53 intstart: nop 980030 14200033 54 r1 = 0x33 /* memory B, 1 wait state */ 980034 1f81001e 55 pcw = r1 980038 00000000 56 nop 98003c a00f11c0 57 pcgoto initialize 980040 00000000 58 nop 59 swgo: 980044 a00f0c48 60 pcgoto swmode 980048 00000000 61 nop 62 initgo: 98004c a00f0dd4 63 pcgoto initcommon 980050 00000000 64 nop 65 /* the interrupt routine */ 66 lsinterrupt: 67 /* need to save registers */ 980054 1dc1e0c4 68 *r1saves = r1e 980058 1dc2e0c8 69 *r2saves = r2e 98005c 1dc3e0cc 70 *r3saves = r3e 980060 1dc4e0d0 71 *r4saves = r4e 980064 1dc5e0d4 72 *r5saves = r5e 980068 c7e10004 73 r1e = CTRL151 74 /* r1 has pointer to control register */ 98006c 1cc3ffe4 75 r3e = *SERIALOUTCNT /* see if there is supposed to be output */ 980070 1e610030 76 r1l = *r1 980074 c7e20000 77 r2e = DATA151 980078 1ae30000 78 r3 - 0 98007c 00af020c 79 if(eq) pcgoto chkinput151 980080 00000000 80 nop 980084 1be10001 81 r1 & 1 /* does UART want a character ??? */ 980088 00af0200 82 if(eq) pcgoto chkinput151 98008c 00000000 83 nop 980090 1ae30001 84 r3 - 1 /* 2nd SYNC ? */ 980094 008f0018 85 if(ne) pcgoto chkacksend 980098 00000000 86 nop 98009c 14200005 87 r1 = SYNC2 88 sendnochk: 9800a0 c7e20000 89 r2e = DATA151 9800a4 94630001 90 r3e += 1 9800a8 1f610050 91 *r2 = r1l 9800ac a00f01cc 92 pcgoto done151out 9800b0 00000000 93 nop 94 chkacksend: 9800b4 1ae30002 95 r3 - 2 /* ack/nack ??? */ 9800b8 008f003c 96 if(ne) pcgoto checkpreamble 9800bc 00000000 97 nop 9800c0 1c41fb00 98 r1l = *SERIALOUTBUF /* get NAK?ACK */ 9800c4 1c82e074 99 r2 = *starttag 9800c8 00000000 100 nop 9800cc 1ae20000 101 r2 - 0 /* normal */ 9800d0 00af0014 102 if(eq) pcgoto normalack 9800d4 00000000 103 nop 9800d8 1bc1007f 104 r1 = r1 & 0x7f /* clear msb */ 9800dc 14400000 105 r2 = 0 9800e0 1b410040 106 r1 = r1 | 0x40 /* set first flag */ 9800e4 1d82e074 107 *starttag = r2 9800e8 00000000 108 nop 109 normalack: 9800ec c7e20000 110 r2e = DATA151 9800f0 94630001 111 r3e += 1 9800f4 a00f00b8 112 pcgoto senddatachk2 9800f8 00000000 113 nop 114 checkpreamble: 9800fc 00000000 115 nop 980100 1cc4ffdc 116 r4e = *SERIALOUTFIRST 980104 00000000 117 nop 980108 18e30080 118 r3 - r4 /* are we in the preamble ? */ 98010c 018f0018 119 if(gt) pcgoto senddata 980110 00000000 120 nop 980114 9483fffd 121 r4e = r3 - 3 /* index int preamble */ 980118 dfe1ffc3 122 r1e = DUMPCHARL 98011c 00000000 123 nop 980120 98010080 124 r1e += r4 980124 a00f0080 125 pcgoto senddatchk 980128 c7e20000 126 r2e = DATA151 127 senddata: 98012c 9ae40000 128 r4e - 0 /* r4 has SERIALOUTFIRST */ 980130 00af004c 129 if(eq) pcgoto chknopreamble 980134 00000000 130 nop 980138 1cc1ffe0 131 r1e = *SERIALOUTPT 98013c 00000000 132 nop 980140 98810080 133 r1e -= r4 /* subtract preamble amount */ 980144 00000000 134 nop 980148 9a810001 135 r1e -= 1 /* fix index */ 98014c 1cc4ffd8 136 r4e = *SERIALOUTDATA 980150 00000000 137 nop 980154 18e40060 138 r4 - r3 980158 018f0044 139 if(gt) pcgoto senddata2 98015c 00000000 140 nop 980160 1cc4ffe8 141 r4e = *SERIALOUTEXP /* max count expected */ 980164 00000000 142 nop 980168 18e30080 143 r3 - r4 98016c 014f0088 144 if(ge) pcgoto last151out 980170 00000000 145 nop 146 /* else send 0's till end */ 980174 94630001 147 r3e += 1 980178 14200000 148 r1 = 0 98017c a00f0030 149 pcgoto senddatachk2 980180 00000000 150 nop 151 chknopreamble: 980184 1cc4ffe8 152 r4e = *SERIALOUTEXP /* max count expected */ 980188 c0020003 153 r2e = 3 98018c 1cc1ffe0 154 r1e = *SERIALOUTPT 980190 18e30080 155 r3 - r4 /* see if it the last one */ 980194 014f0060 156 if(ge) pcgoto last151out 980198 00000000 157 nop 98019c 98a10040 158 r1e =- r2 9801a0 00000000 159 nop 160 senddata2: 9801a4 c7e20000 161 r2e = DATA151 9801a8 98010060 162 r1e += r3 163 senddatchk: 164 /* r2 -> usart data reg, r1 -> data to send, r3 = count of out bytes */ 9801ac 94630001 165 r3e += 1 9801b0 1e610030 166 r1l = *r1 /* get data to send */ 167 senddatachk2: 9801b4 1c44ffec 168 r4l = *SERIALOUTCHK 9801b8 1f610050 169 *r2 = r1l /* into the UART */ 9801bc 19040020 170 r4 = r4 ^ r1 /* exclusive or checksum */ 171 #ifdef SEMLSDIAG 9801c0 c0050000 172 r5e = 0 9801c4 1c45ff80 173 r5l = *SERIALOUTD 9801c8 dfe2ff80 174 r2e = SERIALOUTDL 9801cc 1ae5002f 175 r5 - 0x2f /* safety control */ 9801d0 01cf000c 176 if(hi) pcgoto serodebugb1 9801d4 94a50001 177 r5e += 1 9801d8 980200a0 178 r2e += r5 9801dc 1d45ff80 179 *SERIALOUTD = r5l 9801e0 1f610050 180 *r2 = r1l 181 serodebugb1: 182 #endif 183 184 /* do some sanity chicking */ 9801e4 1ae30024 185 r3 - MAXOUTCNT 9801e8 1d44ffec 186 *SERIALOUTCHK = r4l /* save checksum */ 9801ec 018f006c 187 if(gt) pcgoto finish151out 9801f0 00000000 188 nop 9801f4 a00f0084 189 pcgoto done151out 9801f8 00000000 190 nop 191 last151out: 9801fc 018f005c 192 if(gt) pcgoto finish151out /* wait till last character is going before turning off */ 980200 00000000 193 nop 980204 1c41ffec 194 r1l = *SERIALOUTCHK 980208 c7e20000 195 r2e = DATA151 98020c 1c45e04c 196 r5l = *status 980210 94630001 197 r3e += 1 980214 1f610050 198 *r2 = r1l 980218 1b450001 199 r5 |= 1 /* set not initiated bit */ 98021c 00000000 200 nop 980220 1d45e04c 201 *status = r5l 980224 00000000 202 nop 203 /* send chksum to UART */ 204 #ifdef SEMLSDIAG 980228 c0050000 205 r5e = 0 98022c 1c45ff80 206 r5l = *SERIALOUTD 980230 dfe2ff80 207 r2e = SERIALOUTDL 980234 1ae5002f 208 r5 - 0x2f /* safety control */ 980238 01cf000c 209 if(hi) pcgoto serodebugb2 98023c 94a50001 210 r5e += 1 980240 980200a0 211 r2e += r5 980244 1d45ff80 212 *SERIALOUTD = r5l 980248 1f610050 213 *r2 = r1l 214 serodebugb2: 98024c 14a055aa 215 r5 = 0x55aa 980250 00000000 216 nop 980254 1d85ffb0 217 *SERIALFLAG = r5 /* indicate to semgse */ 218 #endif 219 980258 a00f0020 220 pcgoto done151out 98025c 00000000 221 nop 222 223 finish151out: 224 /* turn off output interrupt enable */ 225 226 /* send b4 = error clr, rcv enable (no xmit ) */ 980260 c7e10004 227 r1e = CTRL151 980264 14600096 228 r3 = 0x96 980268 1f630030 229 *r1 = r3l 98026c 1480000c 230 r4 = 12 980270 00000000 231 serlp9: nop /* write recovery time */ 980274 0c8ffff4 232 if(r4-- >= 0) pcgoto serlp9 980278 00000000 233 nop 234 98027c c0030000 235 r3e = 0 236 done151out: 980280 c7e10004 237 r1e = CTRL151 980284 1d83ffe4 238 *SERIALOUTCNT = r3 980288 1e610030 239 r1l = *r1 98028c 00000000 240 nop 241 chkinput151: 980290 1be10002 242 r1 & 2 /* input ? */ 980294 00af083c 243 if(eq) pcgoto noinput151 980298 14200000 244 r1 = 0 /* clear r1 */ 98029c 1cc3fff0 245 r3e = *SERIALINPT 9802a0 1e610050 246 r1l = *r2 247 #ifdef SEMLSDIAG 9802a4 c0050000 248 r5e = 0 9802a8 1cc2fff4 249 r2e = *SERIALINCNT 9802ac 00000000 250 nop 9802b0 1ae20001 251 r2 - 1 /* first byte */ 9802b4 008f0008 252 if(ne) pcgoto seridebug2 /* not 1st byte */ 9802b8 00000000 253 nop 9802bc 1d45ff80 254 *SERIALOUTD = r5l /* set output to 0 */ 9802c0 a00f0004 255 pcgoto seridebug1 /* set input to 0 */ 256 seridebug2: 9802c4 00000000 257 nop 9802c8 1c45ff50 258 r5l = *SERIALIND 259 seridebug1: 9802cc dfe2ff50 260 r2e = SERIALINDL 9802d0 1ae5002f 261 r5 - 0x2f /* safety control */ 9802d4 01cf000c 262 if(hi) pcgoto seridebugb3 9802d8 94a50001 263 r5e += 1 9802dc 980200a0 264 r2e += r5 9802e0 1d45ff50 265 *SERIALIND = r5l 9802e4 1f610050 266 *r2 = r1l 267 seridebugb3: 268 #endif 9802e8 1cc2fff4 269 r2e = *SERIALINCNT 9802ec 00000000 270 nop 9802f0 98030040 271 r3e += r2 /* location of input */ 272 /* check if wrap */ 9802f4 00000000 273 nop 9802f8 14420001 274 r2 += 1 /* increment count */ 9802fc 9ae30300 275 r3e - SERIALINTOP 980300 016f0004 276 if(lt) pcgoto savesin 980304 00000000 277 nop 980308 9a830300 278 r3e -= SERIALINTOP 279 savesin: 98030c dfe4f800 280 r4e = SERIALRAML 980310 00000000 281 nop 980314 98030080 282 r3e += r4 980318 00000000 283 nop 98031c 1c84fffc 284 r4 = *SERIALINCHK 980320 1d82fff4 285 *SERIALINCNT = r2 /* save the count */ 980324 19040020 286 r4 = r4 ^ r1 /* calculate checksum */ 980328 1f610070 287 *r3 = r1l /* save the data */ 98032c 1a820001 288 r2 -= 1 /* back to original count */ 980330 1d84fffc 289 *SERIALINCHK = r4 /* save the checksum */ 980334 1ae20001 290 r2 - 1 /* is this the 1st byte ? */ 980338 008f009c 291 if(ne) pcgoto not1st151 98033c 00000000 292 nop 980340 1d81fffe 293 *SERIALINCMD = r1 /* save the command */ 294 /* parse the first bye of the command to grok the length */ 980344 1ae1004b 295 r1 - 0x4b /* 'K' -- housekeeping */ 980348 00af0054 296 if(eq) pcgoto needthree 98034c 00000000 297 nop 980350 1ae10050 298 r1 - 0x50 /* 'P' -- parameter */ 980354 00af0048 299 if(eq) pcgoto needthree 980358 00000000 300 nop 98035c 1ae1004d 301 r1 - 0x4d /* 'M' -- Mode switch */ 980360 00af003c 302 if(eq) pcgoto needthree 980364 00000000 303 nop 980368 1ae10052 304 r1 - 0x52 /* 'R' software restart */ 98036c 00af0030 305 if(eq) pcgoto needthree 980370 00000000 306 nop 980374 1ae10044 307 r1 - 0x44 /* 'D' -- Memory dump */ 980378 00af0030 308 if(eq) pcgoto needsix 98037c 00000000 309 nop 980380 1ae1004c 310 r1 - 0x4c /* 'L' -- Memory load */ 980384 00af0030 311 if(eq) pcgoto needthirty 980388 00000000 312 nop 98038c 1ae10043 313 r1 - 0x43 /* 'C' -- configuration command */ 980390 00af0030 314 if(eq) pcgoto needmore /* value of command determines number needed */ 980394 00000000 315 nop 980398 1ae10049 316 r1 - 0x49 /* 'I' -- library upload */ 98039c 00af0024 317 if(eq) pcgoto needmore 9803a0 00000000 318 nop 319 /* defaults into a four byte command */ 320 needthree: 9803a4 14200004 321 r1 = 4 9803a8 a00f0020 322 pcgoto setexpect 9803ac 00000000 323 nop 324 needsix: 9803b0 14200006 325 r1 = 6 9803b4 a00f0014 326 pcgoto setexpect 9803b8 00000000 327 nop 328 needthirty: 9803bc 1420001e 329 r1 = 30 9803c0 a00f0008 330 pcgoto setexpect 9803c4 00000000 331 nop 332 needmore: 9803c8 14200000 333 r1 = 0 9803cc 00000000 334 nop 335 setexpect: 9803d0 1d81fff8 336 *SERIALINEXP = r1 9803d4 a00f06fc 337 pcgoto noinput151 /* done if 1st byte */ 9803d8 00000000 338 nop 339 not1st151: 9803dc 1c84fff8 340 r4 = *SERIALINEXP /* get max count for this command */ 9803e0 00000000 341 nop 9803e4 18e40040 342 r4 - r2 /* is this the last byte ??? */ 9803e8 00af00a0 343 if(eq) pcgoto lastinput151 9803ec 00000000 344 nop 9803f0 1ae40000 345 r4 - 0 /* see if defined */ 9803f4 008f06dc 346 if(ne) pcgoto noinput151 /* just one more datum saved */ 9803f8 00000000 347 nop 348 /* CHECK IF CONFIGURATION OR LIBRARY COMMAND */ 9803fc 1c83fffe 349 r3 = *SERIALINCMD 980400 00000000 350 nop 980404 1ae30043 351 r3 - 0x43 /* configuration */ 980408 00af0050 352 if(eq) pcgoto setconflength 98040c 00000000 353 nop 980410 1ae30049 354 r3 - 0x49 980414 008fff88 355 if(ne) pcgoto needthree /* huh -- shouldn't be here */ 980418 00000000 356 nop 357 #define MAXCONFIGL 0x06 358 /* set this parameter in conjunction with the size of library table */ 359 /* set the size for the library command */ 98041c 1ae10000 360 r1 - 0 980420 00afff7c 361 if(eq) pcgoto needthree 980424 00000000 362 nop 980428 c003000b 363 r3e = 0xb /* adjust so 0 = start of table */ 98042c 18810060 364 r1 -= r3 /* this is for 1st lib =0x0b */ 980430 1ae10006 365 r1 - MAXCONFIGL 980434 01cfff68 366 if(hi) pcgoto needthree /* out of table -- set default */ 980438 18210020 367 r1 = r1 * 2 /* index into table */ 98043c 946f06c6 368 ldmcfg: r3e = pc + (lconfigtable - ldmcfg -8) 980440 00000000 369 nop 980444 98030020 370 r3e += r1 /* r3 has the address now */ 980448 00000000 371 nop 98044c 1ea10070 372 r1 = *r3 980450 00000000 373 nop 980454 1d81fff8 374 *SERIALINEXP = r1 980458 a00f0678 375 pcgoto noinput151 /* done if 1st byte */ 98045c 00000000 376 nop 377 378 379 setconflength: 380 #define MAXCONFIGC 0x0a 381 /* set this parameter in conjunction with the size of configtable */ 382 /* set the size for the configuration command */ 980460 1ae1000a 383 r1 - MAXCONFIGC 980464 018fff38 384 if(gt) pcgoto needthree /* out of table -- set default */ 980468 18210020 385 r1 = r1 * 2 /* index into table */ 98046c 946f0680 386 dumcfg: r3e = pc + (configtable - dumcfg -8) 980470 00000000 387 nop 980474 98030020 388 r3e += r1 /* r3 has the address now */ 980478 00000000 389 nop 98047c 1ea10070 390 r1 = *r3 980480 00000000 391 nop 980484 1d81fff8 392 *SERIALINEXP = r1 980488 a00f0648 393 pcgoto noinput151 /* done if 1st byte */ 98048c 00000000 394 nop 395 lastinput151: 396 /* restart input routines -- and start response */ 980490 1c84fffc 397 r4 = *SERIALINCHK 980494 00000000 398 nop 399 /* r4 has total check -- see if its ok */ 980498 1ae40000 400 r4 - 0 /* should be zero */ 98049c 008f04c4 401 if(ne) pcgoto badchk151 9804a0 00000000 402 nop 403 /* set up output response */ 9804a4 1c42e04d 404 r2l = *(status + 1) 9804a8 1c81fffe 405 r1 = *SERIALINCMD 9804ac 1be20002 406 r2 & 0x2 /* see if in SW mode */ 9804b0 008f0128 407 if(ne) pcgoto swcommand 9804b4 00000000 408 nop 409 /* parse the command type */ 9804b8 1ae1004b 410 r1 - 0x4b /* 'K' -- housekeeping */ 9804bc 00af0388 411 if(eq) pcgoto resphkp 9804c0 00000000 412 nop 9804c4 1ae10050 413 r1 - 0x50 /* 'P' -- parameter */ 9804c8 00af021c 414 if(eq) pcgoto resp1 9804cc 00000000 415 nop 9804d0 1ae1004d 416 r1 - 0x4d /* 'M' -- Mode switch */ 9804d4 00af0190 417 if(eq) pcgoto checkmode 9804d8 00000000 418 nop 9804dc 1ae10044 419 r1 - 0x44 /* 'D' -- Memory dump */ 9804e0 00af022c 420 if(eq) pcgoto respdump 9804e4 00000000 421 nop 9804e8 1ae1004c 422 r1 - 0x4c /* 'L' -- Memory load */ 9804ec 00af0024 423 if(eq) pcgoto badcommand /* only in sw mode now */ 9804f0 00000000 424 nop 9804f4 1ae10043 425 r1 - 0x43 /* 'C' -- configuration command */ 9804f8 00af0054 426 if(eq) pcgoto confcheck /* value of command determines number needed */ 9804fc 00000000 427 nop 980500 1ae10049 428 r1 - 0x49 /* 'I' -- library load command */ 980504 00af0048 429 if(eq) pcgoto confcheck /* value of command determines number needed */ 980508 00000000 430 nop 98050c 1ae10052 431 r1 - 0x52 /* 'R' -- software restart */ 980510 00af0058 432 if(eq) pcgoto checkrestart 980514 00000000 433 nop 434 /* unparsed command */ 435 badcommand: 436 /* set error flag */ 980518 1c44fb3c 437 r4l = *herrorcnt 98051c 14a00005 438 r5 = BADCOMMAND 980520 14840001 439 r4 += 1 980524 1d45fb3d 440 *herrortype = r5l 980528 1d44fb3c 441 *herrorcnt = r4l 442 /* set status bit to indicate error */ 98052c 1c42e04d 443 r2l = *(status + 1) 980530 00000000 444 nop 980534 1b420080 445 r2 |= 0x80 /* set error indicator */ 980538 00000000 446 nop 98053c 1d42e04d 447 *(status + 1) = r2l 448 980540 c0040000 449 r4e = 0 980544 14200002 450 r1 = 0x2 /* Bad command */ 980548 1dc4ffdc 451 *SERIALOUTFIRST = r4e /* only ACK/NACK response */ 98054c a00f041c 452 pcgoto flushinput 980550 00000000 453 nop 454 confcheck: 455 /* check to make sure we are in configuration mode */ 980554 1c84e050 456 r4 = *state 980558 00000000 457 nop 98055c 1ae40001 458 r4 - 1 /* configuration mode */ 459 #ifndef LABLOAD 980560 008fffb0 460 if(ne) pcgoto badcommand 980564 00000000 461 nop 462 #endif 980568 a00f017c 463 pcgoto resp1 98056c 00000000 464 nop 465 checkrestart: 466 /* check to make sure we are in configuration mode */ 980570 1c84e050 467 r4 = *state 980574 00000000 468 nop 980578 1ae40001 469 r4 - 1 /* configuration mode */ 98057c 008fff94 470 if(ne) pcgoto badcommand 980580 00000000 471 nop 980584 1cc3fff0 472 r3e = *SERIALINPT 980588 00000000 473 nop 98058c 94630002 474 r3e += 2 /* index to destination mode */ 980590 dfe1f800 475 r1e = SERIALRAML 476 /* check for wrappage */ 980594 1ae30300 477 r3 - SERIALINTOP 980598 016f0004 478 if(lt) pcgoto checkrestart2 98059c 00000000 479 nop 9805a0 9a830300 480 r3e -= SERIALINTOP 481 checkrestart2: 9805a4 c0020000 482 r2e = 0 9805a8 98010060 483 r1e += r3 9805ac 00000000 484 nop 9805b0 1e620030 485 r2l = *r1 /* get 2nd byte */ 9805b4 00000000 486 nop 9805b8 1ae2004d 487 r2 - 0x4d /* 'M' enter sw mode */ 9805bc 008fff54 488 if(ne) pcgoto badcommand 9805c0 00000000 489 nop 490 /* set status bit to indicate sw mode */ 9805c4 1c42e04d 491 r2l = *(status + 1) 9805c8 00000000 492 nop 9805cc 1b420002 493 r2 |= 0x2 /* set sw indicator */ 9805d0 00000000 494 nop 9805d4 1d42e04d 495 *(status + 1) = r2l 9805d8 a00f010c 496 pcgoto resp1 9805dc 00000000 497 nop 498 swcommand: 499 /* parse the command type */ 9805e0 1ae10044 500 r1 - 0x44 /* 'D' -- Memory dump */ 9805e4 00af0128 501 if(eq) pcgoto respdump 9805e8 00000000 502 nop 9805ec 1ae1004c 503 r1 - 0x4c /* 'L' -- Memory load */ 9805f0 00afff5c 504 if(eq) pcgoto confcheck 9805f4 00000000 505 nop 9805f8 1ae10052 506 r1 - 0x52 /* 'R' -- software restart */ 9805fc 008fff14 507 if(ne) pcgoto badcommand 980600 00000000 508 nop 980604 1cc3fff0 509 r3e = *SERIALINPT 980608 00000000 510 nop 98060c 94630002 511 r3e += 2 /* index to destination mode */ 980610 dfe1f800 512 r1e = SERIALRAML 513 /* check for wrappage */ 980614 1ae30300 514 r3 - SERIALINTOP 980618 016f0004 515 if(lt) pcgoto checkrestart3 98061c 00000000 516 nop 980620 9a830300 517 r3e -= SERIALINTOP 518 checkrestart3: 980624 c0020000 519 r2e = 0 980628 98010060 520 r1e += r3 98062c 00000000 521 nop 980630 1e620030 522 r2l = *r1 /* get 2nd byte */ 980634 00000000 523 nop 980638 1ae20049 524 r2 - 0x49 /* 'I' -- software init flight2 */ 98063c 00af00a8 525 if(eq) pcgoto resp1 980640 00000000 526 nop 980644 1ae20052 527 r2 - 0x52 /* second R */ 980648 008ffec8 528 if(ne) pcgoto badcommand 98064c 00000000 529 nop 530 531 /* clear sw bit in status */ 980650 1c42e04d 532 r2l = *(status + 1) 980654 00000000 533 nop 980658 1bc200fd 534 r2 &= 0xfd /* clear sw indicator */ 98065c 00000000 535 nop 980660 1d42e04d 536 *(status + 1) = r2l 980664 a00f0080 537 pcgoto resp1 980668 00000000 538 nop 539 540 541 checkmode: 98066c 1cc3fff0 542 r3e = *SERIALINPT 980670 00000000 543 nop 980674 94630002 544 r3e += 2 /* index to destination mode */ 980678 dfe1f800 545 r1e = SERIALRAML 546 /* check for wrappage */ 98067c 1ae30300 547 r3 - SERIALINTOP 980680 016f0004 548 if(lt) pcgoto checkmode2 980684 00000000 549 nop 980688 9a830300 550 r3e -= SERIALINTOP 551 checkmode2: 98068c c0020000 552 r2e = 0 980690 98010060 553 r1e += r3 980694 00000000 554 nop 980698 1e620030 555 r2l = *r1 /* get dest mode */ 98069c 1c83e050 556 r3 = *state 9806a0 1ae20059 557 r2 - 0x59 /* 'Y' go to stand-by */ 9806a4 008f0014 558 if(ne) pcgoto checkmode3 9806a8 00000000 559 nop 9806ac 1ae30000 560 r3 - 0 /* already in stand-by ? */ 9806b0 00affe60 561 if(eq) pcgoto badcommand 9806b4 00000000 562 nop 9806b8 a00f002c 563 pcgoto resp1 /* yup */ 9806bc 00000000 564 nop 565 checkmode3: 9806c0 1ae20058 566 r2 - 0x58 /* 'X' go to config */ 9806c4 008f0014 567 if(ne) pcgoto checkmode4 9806c8 00000000 568 nop 9806cc 1ae30001 569 r3 - 1 /* already in config mode ? */ 9806d0 00affe40 570 if(eq) pcgoto badcommand 9806d4 00000000 571 nop 9806d8 a00f000c 572 pcgoto resp1 /* ok */ 9806dc 00000000 573 nop 574 checkmode4: 9806e0 1ae30001 575 r3 - 1 /* otherwise must be in config state to go anywhere */ 9806e4 008ffe2c 576 if(ne) pcgoto badcommand 9806e8 00000000 577 nop 578 /* fall through to resp1 */ 579 resp1: 9806ec 14200080 580 r1 = 0x80 9806f0 1d41fb00 581 *SERIALOUTBUF = r1l /* save ACK/NAK here */ 9806f4 c0040003 582 r4e = 3 /* 1 byte response */ 9806f8 dfe2fb01 583 r2e = SERIALOUTBUFL + 1 9806fc c0010000 584 r1e = 0 980700 00000000 585 nop 980704 1dc1ffdc 586 *SERIALOUTFIRST = r1e 980708 1dc1ffd8 587 *SERIALOUTDATA = r1e 98070c a00f028c 588 pcgoto restart151 980710 00000000 589 nop 590 respdump: 591 /* check to make sure we are in configuration mode */ 980714 1c84e050 592 r4 = *state 980718 00000000 593 nop 98071c 1ae40001 594 r4 - 1 /* configuration mode */ 980720 00af000c 595 if(eq) pcgoto respdump1 980724 00000000 596 nop 980728 1ae40003 597 r4 - 3 /* allowed in diagnostic mode */ 98072c 008ffde4 598 if(ne) pcgoto badcommand 980730 00000000 599 nop 600 /* calculate the dump address */ 601 respdump1: 980734 1cc3fff0 602 r3e = *SERIALINPT 980738 dfe4ffc3 603 r4e = DUMPCHARL 98073c c0020000 604 r2e = 0 980740 1f610097 605 *r4++ = r1l /* save "D" */ 980744 1dc2e0c0 606 *addtemp = r2e 980748 94630002 607 r3e += 2 /* index to start of dump address */ 98074c dfe1f800 608 r1e = SERIALRAML 609 /* check for wrappage */ 980750 1ae30300 610 r3 - SERIALINTOP 980754 016f0004 611 if(lt) pcgoto respdump2 980758 00000000 612 nop 98075c 9a830300 613 r3e -= SERIALINTOP 614 respdump2: 980760 00000000 615 nop 980764 98010060 616 r1e += r3 980768 00000000 617 nop 98076c 1e620030 618 r2l = *r1 /* get msb */ 980770 00000000 619 nop 980774 1d42e0c2 620 *(addtemp + 2) = r2l 980778 1f620097 621 *r4++ = r2l 98077c 94630001 622 r3e += 1 980780 dfe1f800 623 r1e = SERIALRAML 624 /* check for wrappage */ 980784 1ae30300 625 r3 - SERIALINTOP 980788 016f0004 626 if(lt) pcgoto respdump3 98078c 00000000 627 nop 980790 9a830300 628 r3e -= SERIALINTOP 629 respdump3: 980794 00000000 630 nop 980798 98010060 631 r1e += r3 98079c 00000000 632 nop 9807a0 1e620030 633 r2l = *r1 /* get midb */ 9807a4 00000000 634 nop 9807a8 1d42e0c1 635 *(addtemp + 1) = r2l 9807ac 1f620097 636 *r4++ = r2l 9807b0 94630001 637 r3e += 1 9807b4 dfe1f800 638 r1e = SERIALRAML 639 /* check for wrappage */ 9807b8 1ae30300 640 r3 - SERIALINTOP 9807bc 016f0004 641 if(lt) pcgoto respdump4 9807c0 00000000 642 nop 9807c4 9a830300 643 r3e -= SERIALINTOP 644 respdump4: 9807c8 00000000 645 nop 9807cc 98010060 646 r1e += r3 9807d0 00000000 647 nop 9807d4 1e620030 648 r2l = *r1 /* get lsb */ 9807d8 00000000 649 nop 9807dc 1d42e0c0 650 *addtemp = r2l 9807e0 1f620097 651 *r4++ = r2l 9807e4 94630001 652 r3e += 1 9807e8 dfe1f800 653 r1e = SERIALRAML 654 /* check for wrappage */ 9807ec 1ae30300 655 r3 - SERIALINTOP 9807f0 016f0004 656 if(lt) pcgoto respdump5 9807f4 00000000 657 nop 9807f8 9a830300 658 r3e -= SERIALINTOP 659 respdump5: 9807fc c0020000 660 r2e = 0 980800 98010060 661 r1e += r3 980804 00000000 662 nop 980808 1e620030 663 r2l = *r1 /* amount to send */ 98080c 00000000 664 nop 980810 1f620097 665 *r4++ = r2l 980814 1ae20018 666 r2 - 24 980818 01af0004 667 if(le) pcgoto dumpaddok 98081c 00000000 668 nop 980820 c0020018 669 r2e = 24 670 dumpaddok: 980824 c0030007 671 r3e = 7 /* fix SEM bug */ 980828 94420008 672 r2e += 8 /* include address et al in data count */ 98082c 1dc3ffdc 673 *SERIALOUTFIRST = r3e 980830 1dc2ffd8 674 *SERIALOUTDATA = r2e 980834 c0010080 675 r1e = 0x80 980838 1cc2e0c0 676 r2e = *addtemp 98083c 1d41fb00 677 *SERIALOUTBUF = r1l /* save ACK/NAK here */ 980840 c0040021 678 r4e = 33 980844 a00f0154 679 pcgoto restart151 980848 00000000 680 nop 681 682 resphkp: 98084c c0010003 683 r1e = 3 980850 1cc3fff0 684 r3e = *SERIALINPT 980854 1dc1ffdc 685 *SERIALOUTFIRST = r1e 980858 94630002 686 r3e += 2 /* bypass count, command type */ 98085c dfe1f800 687 r1e = SERIALRAML 688 /* check for wrappage */ 980860 1ae30300 689 r3 - SERIALINTOP 980864 016f0004 690 if(lt) pcgoto resphkp2 980868 00000000 691 nop 98086c 9a830300 692 r3e -= SERIALINTOP 693 resphkp2: 980870 98010060 694 r1e += r3 980874 00000000 695 nop 980878 1e610030 696 r1l = *r1 /* get the ID */ 98087c 00000000 697 nop 980880 1d41ffc3 698 *DUMPCHAR = r1l 980884 1ae10000 699 r1 - 0 /* is this just status */ 980888 008f0024 700 if(ne) pcgoto sendhkp 98088c 00000000 701 nop 980890 c0040006 702 r4e = 6 980894 14200080 703 r1 = 0x80 /* ok response */ 980898 1dc4ffd8 704 *SERIALOUTDATA = r4e 98089c 00000000 705 nop 9808a0 c0040007 706 r4e = 7 /* 4 bytes to send */ 9808a4 1d41fb00 707 *SERIALOUTBUF = r1l /* save ACK/NAK here */ 9808a8 dfe2e04c 708 r2e = status 9808ac a00f00ec 709 pcgoto restart151 9808b0 00000000 710 nop 711 sendhkp: 9808b4 1ae1000a 712 r1 - 0xa /* echo config command ? */ 9808b8 018f0050 713 if(gt) pcgoto sendhkp1 9808bc 00000000 714 nop 9808c0 18210020 715 r1 = r1 * 2 /* index into table */ 9808c4 946f024e 716 sencfg: r3e = pc + (configindex - sencfg -8) 9808c8 00000000 717 nop 9808cc 98030020 718 r3e += r1 /* r3 has the address now */ 9808d0 00000000 719 nop 9808d4 1ea40070 720 r4 = *r3 /* r1 has the offset into the array */ 9808d8 dfe2e128 721 r2e = detenb1 9808dc 98020080 722 r2e += r4 /* r2e has address of daa to send */ 9808e0 946f020c 723 lencfg: r3e = pc + (configtable - lencfg -8) 9808e4 00000000 724 nop 9808e8 98030020 725 r3e += r1 /* r3 has the address now */ 9808ec 00000000 726 nop 9808f0 1ea40070 727 r4 = *r3 /* r1 has the length of the command */ 9808f4 00000000 728 nop 9808f8 1dc4ffd8 729 *SERIALOUTDATA = r4e 9808fc 14200080 730 r1 = 0x80 980900 94840001 731 r4e += 1 /* bytes to go */ 980904 1d41fb00 732 *SERIALOUTBUF = r1l /* save ACK/NAK here */ 980908 a00f0090 733 pcgoto restart151 98090c 00000000 734 nop 735 736 sendhkp1: 980910 1ae10012 737 r1 - 0x12 /* in forbidden range ? */ 980914 016ffbfc 738 if(lt) pcgoto badcommand 980918 00000000 739 nop 98091c 1ae1001c 740 r1 - 0x1c /* in correct range ?? */ 980920 018ffbf0 741 if(gt) pcgoto badcommand 980924 00000000 742 nop 980928 9a810012 743 r1e -= 0x12 /* calculate index into housekeeping */ 98092c dfe2fb20 744 r2e = hkpdata 980930 98030a01 745 r3e = r1 980934 98210020 746 r1e = r1*2 980938 98010060 747 r1e += r3 /* times 3 */ 98093c 98210020 748 r1e = r1*2 980940 98210020 749 r1e = r1*2 /* times 12 */ 980944 98210020 750 r1e = r1*2 /* times 24 arrrrrrggggghhhh */ 980948 c004001c 751 r4e = 28 98094c 98020020 752 r2e += r1 980950 1dc4ffd8 753 *SERIALOUTDATA = r4e 980954 14200080 754 r1 = 0x80 980958 c004001d 755 r4e = 29 /* 28 bytes to go */ 98095c 1d41fb00 756 *SERIALOUTBUF = r1l /* save ACK/NAK here */ 980960 a00f0038 757 pcgoto restart151 980964 00000000 758 nop 759 badchk151: 760 /* flush data buffer */ 980968 1d84ffcc 761 *SERIALDEBUG = r4 98096c c0010001 762 r1e = 0x1 /* CS error */ 763 flushinput: 980970 00000000 764 nop 980974 c0040000 765 r4e = 0 980978 00000000 766 nop 98097c 1dc4fff4 767 *SERIALINCNT = r4e 980980 1dc4fff8 768 *SERIALINEXP = r4e 980984 1d41fb00 769 *SERIALOUTBUF = r1l /* save ACK/NAK here */ 980988 c0040003 770 r4e = 3 /* 1 byte response */ 98098c c0010000 771 r1e = 0 980990 00000000 772 nop 980994 1dc1ffdc 773 *SERIALOUTFIRST = r1e 980998 1dc1ffd8 774 *SERIALOUTDATA = r1e 98099c dfe2fb01 775 r2e = SERIALOUTBUFL + 1 776 777 /* assumptions here */ 778 /* SERIALOUTBUF contains the ACK/NAK byte */ 779 /* r4e has the number of bytes in the response */ 780 /* r2e points to the data to send after the ACK/NAK */ 781 /* r1,r3 are scratch, the rest untouched */ 782 783 restart151: 784 /* this code will enable ls output buffer according 785 to latest CNES spec (no output on unused port) --> cannot select until receive character 786 since selection is now based on low speed clock */ 9809a0 1c81e2d2 787 r1 = *dfeselect 9809a4 c7e30004 788 r3e = CTRL151 9809a8 1ae10000 789 r1 - 0 9809ac 008f0068 790 if(ne) pcgoto start151out 9809b0 00000000 791 nop 9809b4 1c81e064 792 r1 = *softcontrol 9809b8 1e630070 793 r3l = *r3 /* get USART status */ 9809bc 1bc1ffbf 794 r1 = r1 & 0xffbf /* mask off select bit */ 9809c0 1be30080 795 r3 & 0x80 /* DSR on 8 Hz A */ 9809c4 00af0034 796 if(eq) pcgoto setdfeB 9809c8 00000000 797 nop 9809cc 14600040 798 r3 = 0x40 9809d0 00000000 799 nop 9809d4 19410060 800 r1 = r1 | r3 9809d8 00000000 801 nop 9809dc 1d81e064 802 *softcontrol = r1 9809e0 c7630000 803 r3e = CONTROL 9809e4 1fa10070 804 *r3 = r1 9809e8 00000000 805 nop 9809ec 14600001 806 r3 = 1 9809f0 00000000 807 nop 9809f4 1d83e2d2 808 *dfeselect = r3 9809f8 a00f001c 809 pcgoto start151out 9809fc 00000000 810 nop 811 setdfeB: 980a00 c7630000 812 r3e = CONTROL 980a04 1d81e064 813 *softcontrol = r1 980a08 1fa10070 814 *r3 = r1 980a0c 00000000 815 nop 980a10 14600002 816 r3 = 2 980a14 00000000 817 nop 980a18 1d83e2d2 818 *dfeselect = r3 819 start151out: 820 /* start the output going -- reenter hunt for sync */ 821 /* use TRS to control CTS */ 980a1c c7e30004 822 r3e = CTRL151 980a20 14200093 823 r1 = 0x93 /* enable output */ /* flight2 */ 980a24 00000000 824 nop /* order changed here*/ /* flight2 */ 980a28 1f610070 825 *r3 = r1l 980a2c 00000000 826 nop 980a30 c7e30000 827 r3e = DATA151 980a34 1420000a 828 r1 = SYNC1 /* 1st sync byte */ 980a38 00000000 829 nop 980a3c 1f610070 830 *r3 = r1l /* send it */ 980a40 00000000 831 nop 980a44 14200008 832 r1 = 8 980a48 00000000 833 serlpa: nop /* write recovery time */ 980a4c 0c2ffff4 834 if(r1-- >= 0) pcgoto serlpa 980a50 00000000 835 nop 980a54 c7e30004 836 r3e = CTRL151 980a58 142000b3 837 r1 = 0xb3 /* enable output + RTS */ /* flight2 */ 980a5c 00000000 838 nop /* flight2 */ 980a60 1f610070 839 *r3 = r1l /* flight2 */ 980a64 00000000 840 nop /* flight2 */ 980a68 c0010000 841 r1e = 0 980a6c 00000000 842 nop 980a70 1dc1ffec 843 *SERIALOUTCHK = r1e 980a74 1dc4ffe8 844 *SERIALOUTEXP = r4e /* number of bytes */ 980a78 c0010001 845 r1e = 1 980a7c 1dc2ffe0 846 *SERIALOUTPT = r2e /* data buffer */ 980a80 1dc1ffe4 847 *SERIALOUTCNT = r1e 848 /* readjust the pointers for new input */ 980a84 1c81fff8 849 r1 = *SERIALINEXP 980a88 1cc3fff0 850 r3e = *SERIALINPT 980a8c dfe4f800 851 r4e = SERIALRAML 980a90 00000000 852 nop 980a94 98040060 853 r4e += r3 980a98 00000000 854 nop 980a9c 1f610090 855 *r4 = r1l 980aa0 00000000 856 nop 980aa4 1cc4fff0 857 r4e = *SERIALINPT 980aa8 1cc3fff4 858 r3e = *SERIALINCNT 980aac c0010001 859 r1e = 1 /* start with space for count byte */ 980ab0 98040060 860 r4e += r3 /* add the data present */ 980ab4 1dc1fff4 861 *SERIALINCNT = r1e 862 /* check the pointer to see if its time to wrap */ 980ab8 9ae40300 863 r4e - SERIALINTOP 980abc 016f0004 864 if(lt) pcgoto wrapinput 980ac0 00000000 865 nop 980ac4 9a840300 866 r4e -= SERIALINTOP 867 wrapinput: 980ac8 c0010000 868 r1e = 0 980acc 1dc4fff0 869 *SERIALINPT = r4e 980ad0 1dc1fff8 870 *SERIALINEXP = r1e /* clear buffer and check sum */ 980ad4 1d81fffc 871 *SERIALINCHK = r1 872 873 noinput151: 980ad8 1cc1e0c4 874 r1e = *r1saves 980adc 1cc2e0c8 875 r2e = *r2saves 980ae0 1cc3e0cc 876 r3e = *r3saves 980ae4 1cc4e0d0 877 r4e = *r4saves 980ae8 1cc5e0d4 878 r5e = *r5saves 980aec 003e0000 879 ireturn 980af0 00000000 880 nop 881 configtable: 980af4 0004 882 int 4 /* 00 --*/ 980af6 000c 883 int 12 /* 01 --*/ 980af8 0018 884 int 24 /* 02 --*/ 980afa 0018 885 int 24 /* 03 --*/ 980afc 0018 886 int 24 /* 04 --*/ 980afe 0018 887 int 24 /* 05 --*/ 980b00 000c 888 int 12 /* 06 --*/ 980b02 001e 889 int 30 /* 07 --*/ 980b04 001e 890 int 30 /* 08 --*/ 980b06 001e 891 int 30 /* 09 --*/ 980b08 0008 892 int 8 /* 0a --*/ 893 lconfigtable: 980b0a 0016 894 int 22 /* 0b --*/ 980b0c 0022 895 int 34 /* 0c --*/ 980b0e 0022 896 int 34 /* 0d --*/ 980b10 0022 897 int 34 /* 0e --*/ 980b12 0022 898 int 34 /* 0f --*/ 980b14 0022 899 int 34 /* 10 --*/ 980b16 0022 900 int 34 /* 11 --*/ 980b18 0004 901 int 4 /* 12 --*/ 902 configindex: 980b1a 0000 903 int 0 /* 00 --*/ 980b1c 0000 904 int 0 /* 01 --*/ 980b1e 0008 905 int 8 /* 02 --*/ 980b20 001c 906 int 28 /* 03 --*/ 980b22 0030 907 int 48 /* 04 --*/ 980b24 0044 908 int 68 /* 05 --*/ 980b26 0058 909 int 88 /* 06 --*/ 980b28 0060 910 int 96 /* 07 --*/ 980b2a 007a 911 int 122 /* 08 --*/ 980b2c 0094 912 int 148 /* 09 --*/ 980b2e 00ae 913 int 174 /* 0a --*/ 914 915 916 .align 4 917 /* if there is a bad interrupt, disable unused interrupt enables */ 918 badinterrupt: 980b30 1dc1e0bc 919 *r1save = r1e 980b34 1e81001e 920 r1 = pcw 980b38 00000000 921 nop 980b3c 1bc187ff 922 r1 = r1 & 0x87ff /* data + serial interrupt */ 980b40 00000000 923 nop 980b44 1f81001e 924 pcw = r1 980b48 00000000 925 nop 980b4c 1cc1e0bc 926 r1e = *r1save 980b50 003e0000 927 ireturn 980b54 00000000 928 nop 929 930 /* the interrupt vector table */ 931 980b58 a00f2000 932 itable: pcgoto getpulse 980b5c 00000000 933 nop 980b60 bfefffc8 934 pcgoto badinterrupt 980b64 00000000 935 nop 980b68 bfefffc0 936 pcgoto badinterrupt 980b6c 00000000 937 nop 980b70 bfefffb8 938 pcgoto badinterrupt 980b74 00000000 939 nop 980b78 bfefffb0 940 pcgoto badinterrupt 980b7c 00000000 941 nop 980b80 bfeff4cc 942 pcgoto lsinterrupt 980b84 00000000 943 nop 944 /* gets the next command -- r1 = 1 if there is a command , r1 = 0 if not */ 945 getnextcommand: 980b88 1cc2ffd0 946 r2e = *SERIALGETPT 980b8c 1cc3fff0 947 r3e = *SERIALINPT 980b90 1e610050 948 r1l = *r2 980b94 18840843 949 r4 = r3 - r2 980b98 00af0098 950 if(eq) pcgoto gcmdend 980b9c 00000000 951 nop 980ba0 018f0004 952 if(gt) pcgoto havecmd 980ba4 00000000 953 nop 980ba8 14840300 954 r4 += SERIALINTOP 955 havecmd: 980bac dfe3f800 956 r3e = SERIALRAML 980bb0 c0050000 957 r5e = 0 980bb4 98030040 958 r3e += r2 980bb8 00000000 959 nop 980bbc 1e650070 960 r5l = *r3 /* count to move */ 980bc0 dfe7e020 961 r7e = nextcmd 980bc4 1ae50026 962 r5 - 0x26 /* too much */ 980bc8 014f0074 963 if(ge) pcgoto nastycommand 980bcc 1f6500f7 964 *r7++ = r5l 980bd0 00000000 965 nop 980bd4 1a850001 966 r5 -= 1 967 cmdgetlp: 980bd8 dfe3f800 968 r3e = SERIALRAML 980bdc 94420001 969 r2e += 1 980be0 00000000 970 nop 980be4 1ae20300 971 r2 - SERIALINTOP 980be8 016f0008 972 if(lt) pcgoto cmdrange 980bec 00000000 973 nop 980bf0 9a820300 974 r2e -= SERIALINTOP 980bf4 00000000 975 nop 976 cmdrange: 980bf8 98030040 977 r3e += r2 /* address if input */ 980bfc 00000000 978 nop 980c00 1e610077 979 r1l = *r3++ 980c04 00000000 980 nop 980c08 1f6100f7 981 *r7++ = r1l 980c0c 0cafffc4 982 if(r5-- >= 0) pcgoto cmdgetlp 980c10 00000000 983 nop 980c14 1c83e07c 984 r3 = *commandcount 980c18 c0010001 985 r1e = 1 980c1c 14630001 986 r3 += 1 980c20 1dc2ffd0 987 *SERIALGETPT = r2e 980c24 1d83e07c 988 *commandcount = r3 /* increment command count */ 980c28 1d03fb30 989 *hcommandcount = r3h 980c2c 1d43fb31 990 *(hcommandcount + 1) = r3l 980c30 00340000 991 return(r18) 980c34 00000000 992 nop 993 gcmdend: 980c38 c0010000 994 r1e = 0 980c3c 00340000 995 return(r18) 980c40 00000000 996 nop 997 nastycommand: 980c44 dfe1ff30 998 r1e = 0xffff30 /* just to debug */ 980c48 1cc2ffd0 999 r2e = *SERIALGETPT 980c4c 1cc3fff0 1000 r3e = *SERIALINPT 980c50 1fa50037 1001 *r1++ = r5 980c54 1fa20037 1002 *r1++ = r2 980c58 1fa30037 1003 *r1++ = r3 1004 /* set error flag */ 980c5c 1c44fb3c 1005 r4l = *herrorcnt 980c60 14a00006 1006 r5 = BADSERIAL 980c64 c0010000 1007 r1e = 0 980c68 14840001 1008 r4 += 1 980c6c 1d45fb3d 1009 *herrortype = r5l 980c70 1d44fb3c 1010 *herrorcnt = r4l 1011 /* set status bit to indicate error */ 980c74 1c42e04d 1012 r2l = *(status + 1) 980c78 00000000 1013 nop 980c7c 1b4200c0 1014 r2 |= 0xc0 /* set error indicator */ 980c80 00000000 1015 nop 980c84 1d42e04d 1016 *(status + 1) = r2l 980c88 1dc3ffd0 1017 *SERIALGETPT = r3e /* restore sanity */ 980c8c 00340000 1018 return(r18) 980c90 00000000 1019 nop 1020 1021 1022 /* Mode parser for sw only... enters with r15 pointing to return address (dumi... in main program) */ 1023 swmode: 980c94 14200033 1024 r1 = 0x33 /* memory B, 1 wait state */ 980c98 1f81001e 1025 pcw = r1 /* turn off interrupts */ 1026 /* set local interrupt vector */ 980c9c 97affeb4 1027 dumi2: r22e = pc + (itable - dumi2 - 8) /* set the interrupt vector */ 980ca0 00000000 1028 nop 980ca4 1e81001e 1029 r1 = pcw 980ca8 00000000 1030 nop 980cac 1b410400 1031 r1 = r1 | 0x400 /* serial interrupt only */ 980cb0 00000000 1032 nop 980cb4 1f81001e 1033 pcw = r1 980cb8 00000000 1034 nop 1035 1036 /* primitive command parser just for sw mode */ 1037 swcommandloop: 980cbc 128ffec4 1038 pccall getnextcommand(r18) 980cc0 00000000 1039 nop 980cc4 1ae10000 1040 r1 - 0 /* see if there is one */ 980cc8 008f0034 1041 if(ne) pcgoto swcommandparse 980ccc 00000000 1042 nop 980cd0 1cc2ffd0 1043 r2e = *SERIALGETPT 980cd4 1cc3fff0 1044 r3e = *SERIALINPT 980cd8 00000000 1045 nop 980cdc 18e30040 1046 r3 - r2 980ce0 008fffd4 1047 if(ne) pcgoto swcommandloop 980ce4 00000000 1048 nop 980ce8 1c45e04c 1049 r5l = *status 980cec 00000000 1050 nop 980cf0 1bc500fe 1051 r5 &= 0xfe /* clear not initiated bit */ 980cf4 00000000 1052 nop 980cf8 1d45e04c 1053 *status = r5l 980cfc bfefffb8 1054 pcgoto swcommandloop 980d00 00000000 1055 nop 1056 swcommandparse: 980d04 1c45e04c 1057 r5l = *status 980d08 00000000 1058 nop 980d0c 1b450001 1059 r5 |= 1 /* set not initiated bit */ 980d10 00000000 1060 nop 980d14 1d45e04c 1061 *status = r5l 980d18 c0010000 1062 r1e = 0 980d1c c0020000 1063 r2e = 0 980d20 1c41e021 1064 r1l = *(nextcmd + 1) /* get the command type */ 980d24 1c42e022 1065 r2l = *(nextcmd + 2) /* the following byte */ 980d28 00000000 1066 nop /* flight2 */ 980d2c 1d42fb33 1067 *(commandtype +1) = r2l /* flight2 */ 980d30 1d41fb32 1068 *commandtype = r1l /* flight2 */ 1069 /* only command to parse is leaving sw mode */ 980d34 1ae10052 1070 r1 - 0x52 /* 'R' */ 980d38 008f0038 1071 if(ne) pcgoto swloadcheck /* check memory load */ 980d3c 00000000 1072 nop 980d40 1ae20049 1073 r2 - 0x49 /* 'I' */ 980d44 00af00a8 1074 if(eq) pcgoto swinitialize /* software initialization flight2 */ 980d48 00000000 1075 nop 980d4c 1ae20052 1076 r2 - 0x52 /* 'R' */ 980d50 008f0094 1077 if(ne) pcgoto swcommanderror /* if dont know dont do anything */ 980d54 00000000 1078 nop 1079 1080 /* set up the return to the main program */ 980d58 14200033 1081 r1 = 0x33 /* memory B, 1 wait state */ 980d5c 1f81001e 1082 pcw = r1 /* turn off interrupts */ 980d60 98140a11 1083 r18e = r15 /* return address */ 980d64 1cd9f05c 1084 r21e = *Crestart 980d68 00000000 1085 nop 980d6c 1dd4f070 1086 *Jtemp = r18e /* debugging */ 980d70 a0190000 1087 goto r21 /* (r18) used for return */ 1088 /* if Crestart is not changed just goes back to program loop */ 980d74 00000000 1089 nop 1090 swloadcheck: 980d78 1ae1004c 1091 r1 - 0x4c /* 'L' */ 980d7c 008f0068 1092 if(ne) pcgoto swcommanderror /* if dont know dont do anything */ 980d80 00000000 1093 nop 1094 /* load the memory */ 980d84 c0020000 1095 r2e = 0 980d88 1420e022 1096 r1 = nextcmd + 2 980d8c 1d42e093 1097 *(addtempl + 3) = r2l 980d90 00000000 1098 nop 980d94 1e620037 1099 r2l = *r1++ /* get msb */ 980d98 00000000 1100 nop 980d9c 1d42e092 1101 *(addtempl + 2) = r2l 980da0 00000000 1102 nop 980da4 1e620037 1103 r2l = *r1++ /* get midb */ 980da8 00000000 1104 nop 980dac 1d42e091 1105 *(addtempl + 1) = r2l 980db0 00000000 1106 nop 980db4 1e620037 1107 r2l = *r1++ /* get lsb */ 980db8 c0030000 1108 r3e = 0 980dbc 1d42e090 1109 *addtempl = r2l 980dc0 1e630037 1110 r3l = *r1++ /* get bytecount */ 980dc4 1cc2e090 1111 r2e = *addtempl /* load address */ 1112 1113 /* general routine to move the command data to its destination */ 1114 /* r3 has move count, r2e has destination address , r1e has source address */ 1115 980dc8 1ae30000 1116 r3 - 0 980dcc 01affee8 1117 if(le) pcgoto swcommandloop /* if byte count is 0, forget it */ 980dd0 00000000 1118 nop 980dd4 1a830002 1119 r3 -= 2 /* adjust for looping */ 1120 swloadloop: 980dd8 1e650037 1121 r5l = *r1++ 980ddc 00000000 1122 nop 980de0 1f650057 1123 *r2++ = r5l 980de4 0c6fffec 1124 if(r3-->=0) pcgoto swloadloop 980de8 00000000 1125 nop 1126 1127 swcommanderror: 980dec bfeffec8 1128 pcgoto swcommandloop 980df0 00000000 1129 nop 1130 1131 swinitialize: 980df4 c30d0000 1132 r13e = RAM 980df8 c00c005c 1133 r12e = 0x05c 980dfc 15604000 1134 r11 = 0x4000 1135 moveloopsw: 980e00 1eaa0197 1136 r10 = *r12++ 980e04 00000000 1137 nop 980e08 1faa01b7 1138 *r13++ = r10 980e0c 0d6fffec 1139 if (r11-- >= 0) pcgoto moveloopsw 980e10 00000000 1140 nop 980e14 d3cefe00 1141 r14e = STACKSTART /* set the stack */ 1142 980e18 f314004c 1143 call RAMINIT(r18) 980e1c 00000000 1144 nop 1145 1146 980e20 bfeffe94 1147 pcgoto swcommandloop 980e24 00000000 1148 nop 1149 1150 1151 1152 1153 initcommon: 1154 /* initialize variables */ 980e28 14400000 1155 r2 = 0 980e2c 1d82e070 1156 *fasthold = r2 980e30 1d82e068 1157 *eightstatus = r2 980e34 1d82e06e 1158 *bufferno = r2 1159 /* start with no data */ 980e38 1d82e054 1160 *events0 = r2 980e3c 1d82e056 1161 *events1 = r2 980e40 1d82e058 1162 *curves0 = r2 980e44 1d82e05a 1163 *curves1 = r2 980e48 d3018000 1164 r1e = EVENT0 980e4c d3028258 1165 r2e = EVENT1 980e50 1dc1e000 1166 *eventbuffer0 = r1e 980e54 1dc2e004 1167 *eventbuffer1 = r2e 980e58 14800000 1168 r4 = 0 /* ident flag */ 980e5c 00000000 1169 nop 980e60 1d84e078 1170 *id = r4 980e64 d30184b0 1171 r1e = CURVE0 980e68 d3028708 1172 r2e = CURVE1 980e6c 1dc1e008 1173 *curvebuffer0 = r1e 980e70 1dc2e00c 1174 *curvebuffer1 = r2e 980e74 14400000 1175 r2 = 0 980e78 1d82e05c 1176 *sendcount = r2 980e7c 1d82e05e 1177 *loopcount = r2 1178 /* 1179 Initialize Serial IOC register 1180 Bits Field Value Function 1181 0 ASY 1 Sync Internal (N.A.) 1182 1 BC 1 use OCK for sync clock (N.A.) 1183 3,2 SLEN 00 freq ratio on-chip SY -- not used 1184 4 AIC 0 ICK external (connected to OCLK and generated there) 1185 5 AIL 0 ILD is external (from synchronized control register) 1186 7,6 ILEN 11 Serial input 32 bits after ILD 1187 8 AOC 1 OCK generated internally 1188 9 AOL 0 ILD is external (as AIL) 1189 11,10 OLEN 11 32 bit output 1190 12 SAN 0 clear sanity ? 1191 15-13 DMA 000 no DMA 1192 16 IN 1 MSB first on input (order of Hen3ry's counters) 1193 17 OUT 0 LSB first on output -- lowest 19 bits control channel on/off 1194 18 CKI 1 CKI/24 = 1.666 MHz 1195 19 O24 0 OLEN determines length 1196 20 DSZ 0 DMA size (N.A.) 1197 */ 980e80 14400000 1198 r2 = 0 980e84 00000000 1199 nop 980e88 1d82e06a 1200 *analogcount = r2 980e8c 17650dc3 1201 ioc = 0x050dc3 1202 1203 1204 /* anacntl -- Analog control bits 1205 Bits Field Value Function 1206 0-18 CHON 0 0 turns on channel, 1 disables it 1207 19-21 TRIG 0 Front end trigger level..0 is least sensitive, 7 most sensitive 1208 22-24 LLD 7 LLD threshold , 0 is lowest, 7 is highest.. use 7 for lab to minimize low energy events 1209 25-27 TIME 1 Time window for LLD to fire.0 = 300 ns,1 = 460 ns,2=610 ns,4 = 940ns,7 = 1500 ns(accept any) 1210 28 GAIN 0 1 Drops system gain factor of 3 1211 29-31 unused 1212 */ 980e90 14400000 1213 r2 = 0 /* bit on is disable channel */ 980e94 dfe1e060 1214 r1e = anacntl 980e98 dfe4e128 1215 r4e = detenb1 980e9c dfe5e12c 1216 r5e = detenb2 980ea0 00000000 1217 nop 980ea4 00000000 1218 nop 980ea8 1fa20037 1219 *r1++ = r2 980eac 1fa20097 1220 *r4++ = r2 980eb0 1fa200b7 1221 *r5++ = r2 980eb4 00000000 1222 nop 980eb8 144002a0 1223 r2 = 0x02a0 /* high byte of anactl */ 980ebc 00000000 1224 nop 980ec0 1fa20030 1225 *r1 = r2 980ec4 1fa20090 1226 *r4 = r2 980ec8 1fa200b0 1227 *r5 = r2 980ecc 00000000 1228 nop 1229 tellloop: 1230 /* pcgoto tellloop */ 980ed0 00000000 1231 nop 1232 1233 /* initialize more program parameters */ 980ed4 c0010000 1234 r1e = 0 980ed8 144000e6 1235 r2 = VERSION 980edc 1d81e2d0 1236 *quecount = r1 980ee0 1d82e052 1237 *version = r2 1238 /* initialize circular buffer parameters */ 1239 /* 256 * 256 = 65k buffer */ 980ee4 146000a0 1240 r3 = PBUFFERSIZE 980ee8 d3e20000 1241 r2e = PBUFFERBASE 980eec 1d83e082 1242 *pulsemax = r3 980ef0 1d81e07e 1243 *pulsewrite = r1 980ef4 1dc2e084 1244 *pulsebase = r2e 980ef8 1d81e080 1245 *pulseread = r1 1246 /* sample buffer pointer not used as pointer to collection buffer */ 980efc 1dc2e018 1247 *samplebuffer1 = r2e 980f00 1dc2e01c 1248 *samplebuffer2 = r2e 980f04 14200134 1249 r1 = DPESIZE 980f08 1d81e066 1250 *hssize = r1 980f0c 14402000 1251 r2 = 0x2000 /* every 2 seconds */ 980f10 14200005 1252 r1 = 5 /* 5 per 8 hz = max */ 980f14 1d82e1d6 1253 *rate_control = r2 980f18 1d81e1d8 1254 *(rate_control + 2) = r1 1255 /* initialize energy thresholds */ 980f1c dfe2e0dc 1256 r2e = energythresh 980f20 dfe4e130 1257 r4e = low_threshold 980f24 dfe5e158 1258 r5e = high_threshold 1259 /* 1st low_threshold entry is now quesize */ 980f28 14200100 1260 r1 = 0x0100 /* safe */ 980f2c 14600000 1261 r3 = 0 /* new definition eliminates global threshold */ /* flight2 */ 980f30 1d83e0da 1262 *(globalthresh + 2) = r3 980f34 1d81e0d8 1263 *globalthresh = r1 /* really quesize */ 980f38 1f210097 1264 *r4++ = r1h 980f3c 1f610097 1265 *r4++ = r1l 980f40 1f2300b7 1266 *r5++ = r3h 980f44 1f6300b7 1267 *r5++ = r3l 980f48 1420000a 1268 r1 = 10 /* lower threshold to start */ 980f4c 146001ff 1269 r3 = 511 /* upper thresh to start */ 980f50 15600011 1270 r11 = 19 - 2 1271 threshstart: 980f54 1fa10057 1272 *r2++ = r1 980f58 1fa30057 1273 *r2++ = r3 980f5c 1f210097 1274 *r4++ = r1h 980f60 1f610097 1275 *r4++ = r1l 980f64 1f2300b7 1276 *r5++ = r3h 980f68 1f6300b7 1277 *r5++ = r3l 980f6c 0d6fffe0 1278 if(r11-- >= 0) pcgoto threshstart 980f70 00000000 1279 nop 1280 /* clear the library upload table */ 980f74 dfe3fd30 1281 r3e = libloadchkB 980f78 14a00005 1282 r5 = 5 980f7c 14c00000 1283 r6 = 0 1284 /* clear the check table */ 1285 libloadclr: 980f80 1fa60077 1286 *r3++ = r6 980f84 0caffff4 1287 if(r5-- >= 0) pcgoto libloadclr 980f88 00000000 1288 nop 1289 /* clear the config load table */ 980f8c dfe3fd40 1290 r3e = configchk1 980f90 14a00008 1291 r5 = 8 1292 configloadclr: 980f94 1fa60077 1293 *r3++ = r6 980f98 0caffff4 1294 if(r5-- >= 0) pcgoto configloadclr 980f9c 00000000 1295 nop 1296 /* clear the housekeeping data */ 980fa0 dfe3fb20 1297 r3e = hkpdata 980fa4 14a00082 1298 r5 = 130 1299 hkpclr: 980fa8 1fa60077 1300 *r3++ = r6 980fac 0caffff4 1301 if(r5-- >= 0) pcgoto hkpclr 980fb0 00000000 1302 nop 1303 /* clear the rate history */ 980fb4 dfe3e1de 1304 r3e = countarray 980fb8 14a0003e 1305 r5 = 64 - 2 1306 countclr: 980fbc 1fa60077 1307 *r3++ = r6 980fc0 0caffff4 1308 if(r5-- >= 0) pcgoto countclr 980fc4 00000000 1309 nop 1310 /* clear the channel rates */ 980fc8 dfe3e25e 1311 r3e = rawrates 980fcc 14a00011 1312 r5 = 19 - 2 1313 ratesclr: 980fd0 1fa60077 1314 *r3++ = r6 980fd4 0caffff4 1315 if(r5-- >= 0) pcgoto ratesclr 980fd8 00000000 1316 nop 1317 /* clear the selection stats */ 980fdc dfe3e284 1318 r3e = rawstats 980fe0 14a00024 1319 r5 = 38 - 2 1320 statsclr: 980fe4 1fa60077 1321 *r3++ = r6 980fe8 0caffff4 1322 if(r5-- >= 0) pcgoto statsclr 980fec 00000000 1323 nop 980ff0 944f0388 1324 jdum1: r2e = pc + (mainloop - jdum1 - 8) 980ff4 00000000 1325 nop 980ff8 1dc2f008 1326 *Jmain = r2e 980ffc 00000000 1327 nop 981000 944f0388 1328 jdum2: r2e = pc + (commandchk - jdum2 - 8) 981004 00000000 1329 nop 981008 1dc2f00c 1330 *Jcommandchk = r2e 98100c 00000000 1331 nop 981010 944f0568 1332 jdum3: r2e = pc + (modecommand - jdum3 - 8) 981014 00000000 1333 nop 981018 1dc2f010 1334 *Jmodecommand = r2e 98101c 00000000 1335 nop 981020 944f06c0 1336 jdum4: r2e = pc + (configcommand - jdum4 - 8) 981024 00000000 1337 nop 981028 1dc2f014 1338 *Jconfigcommand = r2e 98102c 00000000 1339 nop 981030 944f09b4 1340 jdum5: r2e = pc + (librarycommand - jdum5 - 8) 981034 00000000 1341 nop 981038 1dc2f020 1342 *Jlibrarycommand = r2e 98103c 00000000 1343 nop 981040 944f0c1c 1344 jdum6: r2e = pc + (commanddone - jdum6 - 8) 981044 00000000 1345 nop 981048 1dc2f028 1346 *Jcommanddone = r2e 98104c 00000000 1347 nop 981050 944f0c4c 1348 jdum7: r2e = pc + (check8hz - jdum7 - 8) 981054 00000000 1349 nop 981058 1dc2f02c 1350 *Jcheck8hz = r2e 98105c 00000000 1351 nop 981060 944f088c 1352 jdum8: r2e = pc + (paramcommand - jdum8 - 8) 981064 00000000 1353 nop 981068 1dc2f018 1354 *Jparamcommand = r2e 98106c 00000000 1355 nop 981070 944f088c 1356 jdum9: r2e = pc + (loadcommand - jdum9 - 8) 981074 00000000 1357 nop 981078 1dc2f01c 1358 *Jloadcommand = r2e 98107c 00000000 1359 nop 981080 944f0954 1360 jdum10: r2e = pc + (dumpcommand - jdum10 - 8) 981084 00000000 1361 nop 981088 1dc2f024 1362 *Jdumpcommand = r2e 98108c 00000000 1363 nop 981090 944f1078 1364 jdum11: r2e = pc + (eightlows - jdum11 - 8) 981094 00000000 1365 nop 981098 1dc2f030 1366 *Jeightlows = r2e 98109c 00000000 1367 nop 9810a0 944f0d88 1368 jdum12: r2e = pc + (eighthighs - jdum12 - 8) 9810a4 00000000 1369 nop 9810a8 1dc2f034 1370 *Jeighthighs = r2e 9810ac 00000000 1371 nop 9810b0 944f112c 1372 jdum13: r2e = pc + (flushevents - jdum13 - 8) 9810b4 00000000 1373 nop 9810b8 1dc2f038 1374 *Jflushevents = r2e 9810bc 00000000 1375 nop 9810c0 944f123c 1376 jdum14: r2e = pc + (fifooutput - jdum14 - 8) 9810c4 00000000 1377 nop 9810c8 1dc2f03c 1378 *Jfifooutput = r2e 9810cc 00000000 1379 nop 9810d0 944f0cec 1380 jdum15: r2e = pc + (eightdone - jdum15 - 8) 9810d4 00000000 1381 nop 9810d8 1dc2f040 1382 *Jeightdone = r2e 9810dc 00000000 1383 nop 9810e0 944f1514 1384 jdum16: r2e = pc + (adcheck - jdum16 - 8) 9810e4 00000000 1385 nop 9810e8 1dc2f044 1386 *Jadcheck = r2e 9810ec 00000000 1387 nop 9810f0 944f1664 1388 jdum17: r2e = pc + (saveshape - jdum17 - 8) 9810f4 00000000 1389 nop 9810f8 1dc2f048 1390 *Jsaveshape = r2e 9810fc 00000000 1391 nop 981100 944f1818 1392 jdum18: r2e = pc + (eventdone - jdum18 - 8) 981104 00000000 1393 nop 981108 1dc2f04c 1394 *Jeventdone = r2e 98110c 00000000 1395 nop 1396 1397 /* Initialize the call table */ 1398 981110 944f05a0 1399 cdum1: r2e = pc + (opermodeinit - cdum1 - 8) 981114 00000000 1400 nop 981118 1dc2f050 1401 *Copermodeinit = r2e 98111c 00000000 1402 nop 981120 944f059c 1403 cdum2: r2e = pc + (calibmodeinit - cdum2 - 8) 981124 00000000 1404 nop 981128 1dc2f054 1405 *Ccalibmodeinit = r2e 98112c 00000000 1406 nop 981130 944f0598 1407 cdum3: r2e = pc + (diagmodeinit - cdum3 - 8) 981134 00000000 1408 nop 981138 1dc2f058 1409 *Cdiagmodeinit = r2e 98113c 00000000 1410 nop 981140 944f17e8 1411 cdum4: r2e = pc + (statcollect - cdum4 - 8) 981144 00000000 1412 nop 981148 1dc2f060 1413 *Cstatcollect = r2e 98114c 00000000 1414 nop 981150 944f1838 1415 cdum5: r2e = pc + (eventroutine - cdum5 - 8) 981154 00000000 1416 nop 981158 1dc2f064 1417 *Ceventroutine = r2e 98115c 00000000 1418 nop 981160 944f0574 1419 cdum6: r2e = pc + (restart - cdum6 - 8) 981164 00000000 1420 nop 981168 1dc2f05c 1421 *Crestart = r2e 98116c 00000000 1422 nop 981170 944f1c40 1423 cdum7: r2e = pc + (compress - cdum7 - 8) 981174 00000000 1424 nop 981178 1dc2f068 1425 *Ccompress = r2e 98117c 00000000 1426 nop 981180 98020a0e 1427 r2e = r14 981184 95ce0004 1428 r14e = r14 + 4 981188 1ff40050 1429 *r2 = r18e 1430 /* Call Toms routine to initialize the analysis routines */ 98118c 128f2028 1431 pccall analinit(r18) 981190 00000000 1432 nop 981194 944f1fc8 1433 deflibdum: r2e = pc + (def_lib_control - deflibdum - 8) 981198 dfe3e188 1434 r3e = library_control 98119c 14800025 1435 r4 = 39 - 2 1436 deflibmove: 9811a0 1ea50057 1437 r5 = *r2++ 9811a4 00000000 1438 nop 9811a8 1fa50077 1439 *r3++ = r5 9811ac 0c8fffec 1440 if(r4-- >= 0) pcgoto deflibmove 9811b0 00000000 1441 nop 9811b4 944f1ff6 1442 r2e = pc + (def_ad_offsets - . - 8) 9811b8 dfe3e180 1443 r3e = ad_offsets 9811bc 14800002 1444 r4 = 4 - 2 1445 defadmove: 9811c0 1ea50057 1446 r5 = *r2++ 9811c4 00000000 1447 nop 9811c8 1fa50077 1448 *r3++ = r5 9811cc 0c8fffec 1449 if(r4-- >= 0) pcgoto defadmove 9811d0 00000000 1450 nop 1451 /* Give Tom a call to calculate correlation coefficients */ 9811d4 128f20d4 1452 pccall correlate(r18) 9811d8 00000000 1453 nop 1454 9811dc 962f0178 1455 cdumr2: r15e = pc + (dumi - cdumr2 - 8) /* come back to dumi to reset the system */ 9811e0 00000000 1456 nop 9811e4 1dd1f06c 1457 *Jswreturn = r15e 1458 9811e8 98020a0e 1459 r2e = r14 9811ec 9a820004 1460 r2e = r2 -4 9811f0 00000000 1461 nop 9811f4 1ef40050 1462 r18e = *r2 9811f8 9a8e0004 1463 r14e = r14 -4 9811fc 00340000 1464 return(r18) 981200 00000000 1465 nop 1466 1467 1468 initialize: 981204 1d82e07a 1469 *eightcount = r2 981208 14200040 1470 r1 = 0x40 98120c c7620000 1471 r2e = CONTROL 981210 1d81e064 1472 *softcontrol = r1 981214 1fa10050 1473 *r2 = r1 1474 1475 /* initialize serial chip -- needs 6 5Mhz clocks bewteen writes */ 1476 981218 14400000 1477 r2 = 0 1478 98121c 14600040 1479 r3 = 0x40 1480 /* send 0,0,0,0x40 to force reset state */ 981220 c7e10004 1481 r1e = CTRL151 981224 00000000 1482 nop 981228 1f620030 1483 *r1 = r2l 98122c 1480000c 1484 r4 = 12 1485 981230 00000000 1486 serlp1: nop /* write recovery time */ 981234 0c8ffff4 1487 if(r4-- >= 0) pcgoto serlp1 981238 00000000 1488 nop 98123c 1f620030 1489 *r1 = r2l 981240 1480000c 1490 r4 = 12 981244 00000000 1491 serlp2: nop /* write recovery time */ 981248 0c8ffff4 1492 if(r4-- >= 0) pcgoto serlp2 98124c 00000000 1493 nop 981250 1f620030 1494 *r1 = r2l 981254 1480000c 1495 r4 = 12 981258 00000000 1496 serlp3: nop /* write recovery time */ 98125c 0c8ffff4 1497 if(r4-- >= 0) pcgoto serlp3 981260 00000000 1498 nop 981264 1f630030 1499 *r1 = r3l 981268 1440000c 1500 r2 = 0xc 98126c 1480000c 1501 r4 = 12 981270 00000000 1502 serlp4: nop /* write recovery time */ 981274 0c8ffff4 1503 if(r4-- >= 0) pcgoto serlp4 981278 00000000 1504 nop 1505 1506 /* send 0c = 2 syncs,internal detect,no parity 8 bit */ 98127c 1f620030 1507 *r1 = r2l 981280 1460000a 1508 r3 = SYNC1 981284 1480000c 1509 r4 = 12 981288 00000000 1510 serlp5: nop /* write recovery time */ 98128c 0c8ffff4 1511 if(r4-- >= 0) pcgoto serlp5 981290 00000000 1512 nop 1513 /* 1st sync character */ 981294 1f630030 1514 *r1 = r3l 981298 14400005 1515 r2 = SYNC2 98129c 1480000c 1516 r4 = 12 9812a0 00000000 1517 serlp6: nop /* write recovery time */ 9812a4 0c8ffff4 1518 if(r4-- >= 0) pcgoto serlp6 9812a8 00000000 1519 nop 9812ac 1f620030 1520 *r1 = r2l /* 2nd sync character */ 9812b0 14600094 1521 r3 = 0x94 9812b4 1480000c 1522 r4 = 12 9812b8 00000000 1523 serlp7: nop /* write recovery time */ 9812bc 0c8ffff4 1524 if(r4-- >= 0) pcgoto serlp7 9812c0 00000000 1525 nop 1526 1527 /* send 94 = error clr, rcv enable (no xmit ) */ 1528 /* dtr turns on transceivers... wait until a character is received to enable it */ 9812c4 1f630030 1529 *r1 = r3l 9812c8 1480000c 1530 r4 = 12 9812cc 00000000 1531 serlp8: nop /* write recovery time */ 9812d0 0c8ffff4 1532 if(r4-- >= 0) pcgoto serlp8 9812d4 00000000 1533 nop 1534 /* initialize serial parameters */ 9812d8 c0010000 1535 r1e = 0 9812dc dfe3fb00 1536 r3e = SERIALOUTBUFL 9812e0 1dc1fff0 1537 *SERIALINPT = r1e 9812e4 1dc3ffe0 1538 *SERIALOUTPT = r3e 9812e8 c0020001 1539 r2e = 1 /* skip the count byte */ 9812ec 1dc1fff8 1540 *SERIALINEXP = r1e 9812f0 1dc1fffc 1541 *SERIALINCHK = r1e 9812f4 1dc2fff4 1542 *SERIALINCNT = r2e 9812f8 1dc1ffe4 1543 *SERIALOUTCNT = r1e 9812fc 1dc1ffe8 1544 *SERIALOUTEXP = r1e 981300 1dc1ffec 1545 *SERIALOUTCHK = r1e 981304 1dc1ffdc 1546 *SERIALOUTFIRST = r1e 981308 1dc1ffd8 1547 *SERIALOUTDATA = r1e 98130c 1dc1ffd0 1548 *SERIALGETPT = r1e 1549 981310 d3cefe00 1550 r14e = STACKSTART /* set the stack */ 1551 981314 128ffb0c 1552 pccall initcommon(r18) 981318 00000000 1553 nop 1554 98131c c0010000 1555 r1e = 0 981320 14400001 1556 r2 = 1 981324 1d41e020 1557 *nextcmd = r1l 981328 1d81e07c 1558 *commandcount = r1 98132c 1d82e074 1559 *starttag = r2 /* non zero for first LSL ack */ 981330 1d81fb3c 1560 *herrorcnt = r1 981334 1d81e072 1561 *partevent = r1 981338 1d81e2d2 1562 *dfeselect = r1 98133c c0030100 1563 r3e = 0x0100 /* status #2 = 0x1 for eng model */ 981340 14400000 1564 r2 =0 1568 #endif 981344 1dc3e04c 1569 *status = r3e 981348 1d82e050 1570 *state = r2 1571 1572 /*Initialize the jump table */ 98134c 944ff804 1573 jdumi: r2e = pc + (itable - jdumi - 8) /* save the the interrupt vector */ 981350 00000000 1574 nop 981354 1dc2f000 1575 *Jintvec = r2e 981358 00000000 1576 nop 1577 1578 98135c 97aff7f4 1579 dumi: r22e = pc + (itable - dumi - 8) /* set the interrupt vector */ 981360 00000000 1580 nop 981364 c74d0000 1581 r13e = ANARESET 981368 1e81001e 1582 r1 = pcw 98136c 1fa901b0 1583 *r13 = r9 981370 1b418400 1584 r1 = r1 | 0x8400 /* data + serial interrupt */ 981374 00000000 1585 nop 981378 1f81001e 1586 pcw = r1 98137c 00000000 1587 nop 1588 1589 1590 mainloop: 981380 1cd9f00c 1591 r21e = *Jcommandchk 981384 00000000 1592 nop 981388 a0190000 1593 goto r21 98138c 00000000 1594 nop 1595 1596 1597 commandchk: 981390 128ff7f0 1598 pccall getnextcommand(r18) 981394 00000000 1599 nop 981398 1ae10000 1600 r1 - 0 /* see if there is one */ 98139c 008f0040 1601 if(ne) pcgoto commandparse 9813a0 00000000 1602 nop 9813a4 1cc2ffd0 1603 r2e = *SERIALGETPT 9813a8 1cc3fff0 1604 r3e = *SERIALINPT 9813ac 00000000 1605 nop 9813b0 18e30040 1606 r3 - r2 9813b4 008f0014 1607 if(ne) pcgoto notallinitiatedc 9813b8 00000000 1608 nop 9813bc 1c45e04c 1609 r5l = *status 9813c0 00000000 1610 nop 9813c4 1bc500fe 1611 r5 &= 0xfe /* clear not initiated bit */ 9813c8 00000000 1612 nop 9813cc 1d45e04c 1613 *status = r5l 1614 notallinitiatedc: 9813d0 00000000 1615 nop 9813d4 1cd9f02c 1616 r21e = *Jcheck8hz 9813d8 00000000 1617 nop 9813dc a0190000 1618 goto r21 9813e0 00000000 1619 nop 1620 1621 commandparse: 1622 /* interpret any commands that have come in */ 9813e4 1c45e04c 1623 r5l = *status 9813e8 00000000 1624 nop 9813ec 1b450001 1625 r5 |= 1 /* set not initiated bit */ 9813f0 00000000 1626 nop 9813f4 1d45e04c 1627 *status = r5l 9813f8 c0010000 1628 r1e = 0 9813fc c0020000 1629 r2e = 0 981400 1c41e021 1630 r1l = *(nextcmd + 1) /* get the command type */ 981404 1c42e022 1631 r2l = *(nextcmd + 2) /* the following byte */ 981408 1ae1004b 1632 r1 - 0x4b /* 'K' housekeeping or status -- dont include in hkp status*/ 98140c 00af0008 1633 if(eq) pcgoto nocmdreport 981410 00000000 1634 nop 981414 1d42fb33 1635 *(commandtype +1) = r2l 981418 1d41fb32 1636 *commandtype = r1l 1637 nocmdreport: 98141c 1c42e020 1638 r2l = *nextcmd 981420 1ae1004d 1639 r1 - 0x4d /* Mode command */ 981424 008f0010 1640 if(ne) pcgoto mainchkhkp 981428 00000000 1641 nop 98142c 1cd9f010 1642 r21e = *Jmodecommand 981430 00000000 1643 nop 981434 a0190000 1644 goto r21 981438 00000000 1645 nop 1646 mainchkhkp: 98143c 1ae1004b 1647 r1 - 0x4b /* 'K' housekeeping or status */ 981440 008f0040 1648 if(ne) pcgoto mainchkcfg 981444 00000000 1649 nop 981448 1c44e022 1650 r4l = *(nextcmd + 2) 98144c 00000000 1651 nop 981450 1ae40013 1652 r4 - 0x13 /* housekeeping 0x13 reads the errors */ 981454 008f0018 1653 if(ne) pcgoto noerrorrst 981458 00000000 1654 nop 98145c 1c42e04d 1655 r2l = *(status + 1) 981460 00000000 1656 nop 981464 1bc2007f 1657 r2 &= 0x7f /* clear error indicator */ 981468 00000000 1658 nop 98146c 1d42e04d 1659 *(status + 1) = r2l 981470 00000000 1660 nop 1661 noerrorrst: 981474 00000000 1662 nop 981478 1cd9f028 1663 r21e = *Jcommanddone 98147c 00000000 1664 nop 981480 a0190000 1665 goto r21 /* nothing to do in foreground loop for now */ 981484 00000000 1666 nop 1667 mainchkcfg: 981488 1ae10043 1668 r1 - 0x43 /* 'C' configuration command */ 98148c 008f0010 1669 if(ne) pcgoto mainchkparam 981490 00000000 1670 nop 981494 1cd9f014 1671 r21e = *Jconfigcommand 981498 00000000 1672 nop 98149c a0190000 1673 goto r21 9814a0 00000000 1674 nop 1675 mainchkparam: 9814a4 1ae10050 1676 r1 - 0x50 /* 'P' single parameter */ 9814a8 008f0010 1677 if(ne) pcgoto mainchkload 9814ac 00000000 1678 nop 9814b0 1cd9f018 1679 r21e = *Jparamcommand 9814b4 00000000 1680 nop 9814b8 a0190000 1681 goto r21 9814bc 00000000 1682 nop 1683 mainchkload: 9814c0 1ae1004c 1684 r1 - 0x4c /* 'L' memory load command */ 9814c4 008f0010 1685 if(ne) pcgoto mainchkdump 9814c8 00000000 1686 nop 9814cc 1cd9f01c 1687 r21e = *Jloadcommand 9814d0 00000000 1688 nop 9814d4 a0190000 1689 goto r21 9814d8 00000000 1690 nop 1691 mainchkdump: 9814dc 1ae10044 1692 r1 - 0x44 /* 'D' memory dump command */ 9814e0 008f0010 1693 if(ne) pcgoto mainchklib 9814e4 00000000 1694 nop 9814e8 1cd9f024 1695 r21e = *Jdumpcommand 9814ec 00000000 1696 nop 9814f0 a0190000 1697 goto r21 9814f4 00000000 1698 nop 1699 mainchklib: 9814f8 00000000 1700 nop 9814fc 1ae10049 1701 r1 - 0x49 /* 'I' library upload command */ 981500 008f0010 1702 if(ne) pcgoto mainchkreset 981504 00000000 1703 nop 981508 1cd9f020 1704 r21e = *Jlibrarycommand 98150c 00000000 1705 nop 981510 a0190000 1706 goto r21 981514 00000000 1707 nop 1708 mainchkreset: 981518 1ae10052 1709 r1 - 0x52 /* 'R' */ 98151c 008f0024 1710 if(ne) pcgoto maincommanderror /* if dont know dont do anything */ 981520 00000000 1711 nop 981524 962ffe30 1712 cdumr: r15e = pc + (dumi - cdumr - 8) /* come back to dumi to reset the system */ 981528 00000000 1713 nop 98152c 1dd1f06c 1714 *Jswreturn = r15e 1715 /* pcgoto swgo*/ /* this could be absolute rom call.... */ 981530 a00000a0 1716 goto SWROM /* ok do it in ROM */ 981534 00000000 1717 nop 981538 1cd9f028 1718 r21e = *Jcommanddone 98153c 00000000 1719 nop 981540 a0190000 1720 goto r21 981544 00000000 1721 nop 1722 1723 maincommanderror: 1724 /* set error flag */ 981548 1c44fb3c 1725 r4l = *herrorcnt 98154c 14a00005 1726 r5 = BADCOMMAND 981550 14840001 1727 r4 += 1 981554 1d45fb3d 1728 *herrortype = r5l 981558 1d44fb3c 1729 *herrorcnt = r4l 1730 /* set status bit to indicate error */ 98155c 1c42e04d 1731 r2l = *(status + 1) 981560 00000000 1732 nop 981564 1b420080 1733 r2 |= 0x80 /* set error indicator */ 981568 00000000 1734 nop 98156c 1d42e04d 1735 *(status + 1) = r2l 981570 1cd9f028 1736 r21e = *Jcommanddone 981574 00000000 1737 nop 981578 a0190000 1738 goto r21 98157c 00000000 1739 nop 1740 1741 modecommand: 1742 981580 1c41e022 1743 r1l = *(nextcmd + 2) /* Mode command ID */ 981584 00000000 1744 nop 981588 1ae10053 1745 r1 - 0x53 /* 'S' */ 98158c 008f0034 1746 if(ne) pcgoto mainchkstop 981590 00000000 1747 nop 1748 1749 /* do initialization for operation command */ 981594 dfe4e128 1750 r4e = detenb1 981598 dfe5e060 1751 r5e = anacntl 98159c 1ea60097 1752 r6 = *r4++ 9815a0 1ea70090 1753 r7 = *r4 9815a4 1fa600b7 1754 *r5++ = r6 9815a8 1fa700b0 1755 *r5 = r7 1756 9815ac 1cd9f050 1757 r21e = *Copermodeinit 9815b0 00000000 1758 nop 9815b4 12990000 1759 call r21(r18) 9815b8 00000000 1760 nop 1761 1762 9815bc 14200002 1763 r1 = 2 /* go to operational */ 9815c0 a00f00b0 1764 pcgoto setmode 9815c4 00000000 1765 nop 1766 mainchkstop: 9815c8 1ae10058 1767 r1 - 0x58 /* 'X' */ 9815cc 008f000c 1768 if(ne) pcgoto mainchkcal 9815d0 00000000 1769 nop 9815d4 14200001 1770 r1 = 1 /* go to configuration */ 9815d8 a00f0098 1771 pcgoto setmode 9815dc 00000000 1772 nop 1773 mainchkcal: 9815e0 1ae10043 1774 r1 - 0x43 /* 'C' */ 9815e4 008f0034 1775 if(ne) pcgoto mainchkstby 9815e8 00000000 1776 nop 1777 /* do initialization for calibration command */ 9815ec dfe4e128 1778 r4e = detenb1 9815f0 dfe5e060 1779 r5e = anacntl 9815f4 1ea60097 1780 r6 = *r4++ 9815f8 1ea70090 1781 r7 = *r4 9815fc 1fa600b7 1782 *r5++ = r6 981600 1fa700b0 1783 *r5 = r7 1784 981604 1cd9f054 1785 r21e = *Ccalibmodeinit 981608 00000000 1786 nop 98160c 12990000 1787 call r21(r18) 981610 00000000 1788 nop 1789 981614 14200004 1790 r1 = 4 /* go to cal */ 981618 a00f0058 1791 pcgoto setmode 98161c 00000000 1792 nop 1793 mainchkstby: 981620 1ae10059 1794 r1 - 0x59 /* 'Y' */ 981624 008f000c 1795 if(ne) pcgoto mainchkdiag 981628 00000000 1796 nop 98162c 14200000 1797 r1 = 0 /* goto standby */ 981630 a00f0040 1798 pcgoto setmode 981634 00000000 1799 nop 1800 mainchkdiag: 981638 1ae10044 1801 r1 - 0x44 /* 'D' */ 98163c 008fff04 1802 if(ne) pcgoto maincommanderror 981640 00000000 1803 nop 1804 /* do initialization for diagnostic command */ 981644 dfe4e12c 1805 r4e = detenb2 981648 dfe5e060 1806 r5e = anacntl 98164c 1ea60097 1807 r6 = *r4++ 981650 1ea70090 1808 r7 = *r4 981654 1fa600b7 1809 *r5++ = r6 981658 1fa700b0 1810 *r5 = r7 98165c 1cd9f058 1811 r21e = *Cdiagmodeinit 981660 00000000 1812 nop 981664 12990000 1813 call r21(r18) 981668 00000000 1814 nop 1815 98166c 14200003 1816 r1 = 3 /* go to diagnostic */ 981670 a00f0000 1817 pcgoto setmode 981674 00000000 1818 nop 1819 1820 setmode: 1821 /* r1 has the mode to go to */ 981678 1d81e050 1822 *state = r1 98167c 1c42e04c 1823 r2l = *status 981680 18210020 1824 r1 = r1*2 981684 1bc2001f 1825 r2 &= 0x1f 981688 18210020 1826 r1 = r1*2 98168c 18210020 1827 r1 = r1*2 981690 18210020 1828 r1 = r1*2 981694 18210020 1829 r1 = r1*2 981698 00000000 1830 nop 98169c 19420020 1831 r2 |= r1 /* add in new state */ 9816a0 00000000 1832 nop 9816a4 1d42e04c 1833 *status = r2l 9816a8 1cd9f028 1834 r21e = *Jcommanddone 9816ac 00000000 1835 nop 9816b0 a0190000 1836 goto r21 9816b4 00000000 1837 nop 1838 1839 /* extra stuff to do when going into these modes */ 1840 1841 opermodeinit: 9816b8 00000000 1842 nop 9816bc 00340000 1843 return(r18) 9816c0 00000000 1844 nop 1845 calibmodeinit: 9816c4 00000000 1846 nop 9816c8 00340000 1847 return(r18) 9816cc 00000000 1848 nop 1849 diagmodeinit: 9816d0 00000000 1850 nop 9816d4 00340000 1851 return(r18) 9816d8 00000000 1852 nop 1853 restart: 9816dc 00000000 1854 nop 9816e0 00340000 1855 return(r18) 9816e4 00000000 1856 nop 1857 1858 configcommand: 1859 /* configuration commands here */ 9816e8 c0040000 1860 r4e = 0 9816ec 1420e023 1861 r1 = nextcmd + 3 /* point to 1st data byte */ 9816f0 1c44e022 1862 r4l = *(nextcmd + 2) /* Configuration command ID */ 9816f4 00000000 1863 nop 9816f8 1ae40001 1864 r4 - 1 /* Detector enables ? */ 9816fc 008f0084 1865 if(ne) pcgoto configthresh 981700 00000000 1866 nop 981704 1d84fd40 1867 *configchk1 = r4 1868 /* always want this */ 981708 98050a01 1869 r5e = r1 98170c dfe2e060 1870 r2e = anacntl 981710 1e6400b7 1871 r4l = *r5++ 981714 00000000 1872 nop 981718 1f640057 1873 *r2++ = r4l 98171c 00000000 1874 nop 981720 1e6400b7 1875 r4l = *r5++ 981724 00000000 1876 nop 981728 1f640057 1877 *r2++ = r4l 98172c 00000000 1878 nop 981730 1e6400b7 1879 r4l = *r5++ 981734 00000000 1880 nop 981738 1f640057 1881 *r2++ = r4l 98173c 00000000 1882 nop 981740 1e6400b7 1883 r4l = *r5++ 981744 00000000 1884 nop 981748 1f640057 1885 *r2++ = r4l 98174c 00000000 1886 nop 981750 1e6400b7 1887 r4l = *r5++ 981754 00000000 1888 nop 1889 981758 14600002 1890 r3 = 2 /* byte count to move */ 98175c dfe2e128 1891 r2e = detenb1 1892 detloadloop: 981760 1e640037 1893 r4l = *r1++ 981764 00000000 1894 nop 981768 1f640057 1895 *r2++ = r4l 98176c 0c6fffec 1896 if(r3-->=0) pcgoto detloadloop 981770 00000000 1897 nop 981774 dfe2e12c 1898 r2e = detenb2 981778 14600004 1899 r3 = 4 98177c 14800001 1900 r4 = 1 /* restore for commandload check */ 981780 a00f01c0 1901 pcgoto commandload 981784 00000000 1902 nop 1903 configthresh: 981788 1ae40006 1904 r4 - 6 /* A/D offsets */ 98178c 00af00d4 1905 if(eq) pcgoto adoffload 981790 00000000 1906 nop 981794 018f00e0 1907 if(gt) pcgoto libcntload 981798 00000000 1908 nop 98179c 1ae40004 1909 r4 - 4 9817a0 00af0034 1910 if(eq) pcgoto configthresh4 9817a4 00000000 1911 nop 9817a8 018f003c 1912 if(gt) pcgoto configthresh5 9817ac 00000000 1913 nop 9817b0 1ae40003 1914 r4 - 3 9817b4 00af0010 1915 if(eq) pcgoto configthresh3 9817b8 00000000 1916 nop 9817bc 1d84fd42 1917 *configchk2 = r4 9817c0 dfe7e0d8 1918 r7e = globalthresh /* our real destination */ 9817c4 a00f002c 1919 pcgoto configthreshcmn 9817c8 00000000 1920 nop 1921 configthresh3: 9817cc 1d84fd44 1922 *configchk3 = r4 9817d0 dfe7e100 1923 r7e = globalthresh + 40 /* our real destination */ 9817d4 a00f001c 1924 pcgoto configthreshcmn 9817d8 00000000 1925 nop 1926 configthresh4: 9817dc 1d84fd46 1927 *configchk4 = r4 9817e0 dfe7e0da 1928 r7e = globalthresh + 2 /* our real destination */ 9817e4 a00f000c 1929 pcgoto configthreshcmn 9817e8 00000000 1930 nop 1931 configthresh5: 9817ec 1d84fd48 1932 *configchk5 = r4 9817f0 dfe7e102 1933 r7e = globalthresh + 42 /* our real destination */ 9817f4 00000000 1934 nop 1935 1936 configthreshcmn: 9817f8 18050a04 1937 r5 = r4 9817fc 9a840002 1938 r4e -= 2 /* adjust index */ 981800 00000000 1939 nop 981804 18240080 1940 r4 = r4*2 981808 18240080 1941 r4 = r4*2 98180c 00000000 1942 nop 981810 98030a04 1943 r3e = r4 981814 18240080 1944 r4 = r4*2 981818 18240080 1945 r4 = r4*2 98181c 00000000 1946 nop 981820 98030080 1947 r3e += r4 /* *16 + *4 = *20 */ 981824 00000000 1948 nop 981828 dfe2e130 1949 r2e = low_threshold 98182c 00000000 1950 nop 981830 98020060 1951 r2e += r3 /* index into thresholds */ 981834 18040a05 1952 r4 = r5 /* restore for commandload check */ 1953 1954 /* r3 has move count, r2e has destination address , r1e has source address */ 981838 14600008 1955 r3 = 10 - 2 /* adjust for looping */ 1956 threshloadloop: 98183c 1e650037 1957 r5l = *r1++ 981840 1e660037 1958 r6l = *r1++ 981844 1f650057 1959 *r2++ = r5l 981848 1f6600f7 1960 *r7++ = r6l /* byte swap */ 98184c 1f6500f7 1961 *r7++ = r5l 981850 1f660057 1962 *r2++ = r6l 981854 94e70002 1963 r7e += 2 /* skip next 2.. for different ordering */ 981858 0c6fffdc 1964 if(r3-->=0) pcgoto threshloadloop 98185c 00000000 1965 nop 981860 a00f0124 1966 pcgoto cloaddone 981864 00000000 1967 nop 1968 adoffload: 981868 dfe2e180 1969 r2e = ad_offsets 98186c 14600008 1970 r3 = 8 981870 1d84fd4a 1971 *configchk6 = r4 981874 a00f00cc 1972 pcgoto commandload 981878 00000000 1973 nop 1974 libcntload: 98187c 1460001a 1975 r3 = 26 981880 1ae40007 1976 r4 - 7 981884 008f0010 1977 if(ne) pcgoto libcntload2 981888 00000000 1978 nop 98188c 1d84fd4c 1979 *configchk7 = r4 981890 dfe2e188 1980 r2e = library_control 981894 a00f00ac 1981 pcgoto commandload 981898 00000000 1982 nop 1983 libcntload2: 98189c 1ae40008 1984 r4 - 8 9818a0 008f0010 1985 if(ne) pcgoto libcntload3 9818a4 00000000 1986 nop 9818a8 1d84fd4e 1987 *configchk8 = r4 9818ac dfe2e1a2 1988 r2e = library_control + 26 9818b0 a00f0090 1989 pcgoto commandload 9818b4 00000000 1990 nop 1991 libcntload3: 9818b8 1ae40009 1992 r4 - 9 9818bc 008f0010 1993 if(ne) pcgoto transrate 9818c0 00000000 1994 nop 9818c4 1d84fd50 1995 *configchk9 = r4 9818c8 dfe2e1bc 1996 r2e = library_control + 52 9818cc a00f0074 1997 pcgoto commandload 9818d0 00000000 1998 nop 1999 transrate: 9818d4 1ae4000a 2000 r4 - 10 9818d8 008ffc68 2001 if(ne) pcgoto maincommanderror 9818dc 00000000 2002 nop 9818e0 dfe2e1d6 2003 r2e = rate_control 9818e4 14600008 2004 r3 = 8 9818e8 1d84fd52 2005 *configchkA = r4 9818ec a00f0054 2006 pcgoto commandload 9818f0 00000000 2007 nop 2008 2009 2010 2011 paramcommand: 2012 /* Any special parameters get parsed here */ 9818f4 1cd9f028 2013 r21e = *Jcommanddone 9818f8 00000000 2014 nop 9818fc a0190000 2015 goto r21 981900 00000000 2016 nop 2017 2018 loadcommand: 2019 /* load the memory */ 981904 c0020000 2020 r2e = 0 981908 1420e022 2021 r1 = nextcmd + 2 98190c 1d42e093 2022 *(addtempl + 3) = r2l 981910 00000000 2023 nop 981914 1e620037 2024 r2l = *r1++ /* get msb */ 981918 00000000 2025 nop 98191c 1d42e092 2026 *(addtempl + 2) = r2l 981920 00000000 2027 nop 981924 1e620037 2028 r2l = *r1++ /* get midb */ 981928 00000000 2029 nop 98192c 1d42e091 2030 *(addtempl + 1) = r2l 981930 00000000 2031 nop 981934 1e620037 2032 r2l = *r1++ /* get lsb */ 981938 c0030000 2033 r3e = 0 98193c 1d42e090 2034 *addtempl = r2l 981940 1e630037 2035 r3l = *r1++ /* get bytecount */ 981944 1cc2e090 2036 r2e = *addtempl /* load address */ 2037 2038 /* general routine to move the command data to its destination */ 2039 /* r3 has move count, r2e has destination address , r1e has source address */ 2040 commandload: 981948 1ae30000 2041 r3 - 0 98194c 01af0038 2042 if(le) pcgoto cloaddone /* if byte count is 0, forget it */ 981950 00000000 2043 nop 981954 1a830002 2044 r3 -= 2 /* adjust for looping */ 2045 loadloop: 981958 1e650037 2046 r5l = *r1++ 98195c 00000000 2047 nop 981960 1f650057 2048 *r2++ = r5l 981964 0c6fffec 2049 if(r3-->=0) pcgoto loadloop 981968 00000000 2050 nop 2051 /* r4 has the command -- check if 7,8, or 9 */ 98196c 1ae40007 2052 r4 - 7 981970 016f0014 2053 if( lt) pcgoto cloaddone 981974 00000000 2054 nop 981978 1ae40009 2055 r4 - 9 98197c 018f0008 2056 if(gt) pcgoto cloaddone 981980 00000000 2057 nop 2058 /* see if they all have been loaded */ 2059 /* r5 = *configchk7 2060 r6 = *configchk8 2061 r7 = *configchk9 2062 r5 - 0 2063 if(eq) pcgoto cloaddone 2064 nop 2065 r6 - 0 2066 if(eq) pcgoto cloaddone 2067 nop 2068 r7 - 0 2069 if(eq) pcgoto cloaddone 2070 nop */ 2071 /* Give Tom a call to calculate correlation coefficients */ 981984 128f1924 2072 pccall correlate(r18) 981988 00000000 2073 nop 2074 cloaddone: 2075 /* check if all parameters are loaded */ 98198c 00000000 2076 nop 981990 dfe2fd40 2077 r2e = configchk1 981994 14a00008 2078 r5 = 10 -2 2079 cfaloadloop: 981998 1ea10057 2080 r1 = *r2++ 98199c 00000000 2081 nop 9819a0 1ae10000 2082 r1 - 0 9819a4 00af0020 2083 if(eq) pcgoto noconfig 9819a8 00000000 2084 nop 9819ac 0cafffe4 2085 if(r5-- >= 0) pcgoto cfaloadloop 9819b0 00000000 2086 nop 9819b4 1c42e04d 2087 r2l = *(status + 1) 9819b8 00000000 2088 nop 9819bc 1bc200fe 2089 r2 &= 0xfe /* clear noconfig indicator */ 9819c0 00000000 2090 nop 9819c4 1d42e04d 2091 *(status + 1) = r2l 9819c8 00000000 2092 nop 2093 noconfig: 9819cc 1cd9f028 2094 r21e = *Jcommanddone 9819d0 00000000 2095 nop 9819d4 a0190000 2096 goto r21 9819d8 00000000 2097 nop 2098 2099 dumpcommand: 2100 /* already done in interrupt routine */ 9819dc 1cd9f028 2101 r21e = *Jcommanddone 9819e0 00000000 2102 nop 9819e4 a0190000 2103 goto r21 9819e8 00000000 2104 nop 2105 2106 librarycommand: 2107 /* library upload commands here */ 9819ec c0040000 2108 r4e = 0 9819f0 1420e023 2109 r1 = nextcmd + 3 /* point to 1st data byte */ 9819f4 1c44e022 2110 r4l = *(nextcmd + 2) /* Configuration command ID */ 9819f8 00000000 2111 nop 9819fc 1ae4000b 2112 r4 -0xb 981a00 008f0070 2113 if(ne) pcgoto libchkc 981a04 00000000 2114 nop 2115 /* set status bit to indicate libload mode */ 981a08 1c42e04d 2116 r2l = *(status + 1) /* flight2 */ 981a0c 00000000 2117 nop /* flight2 */ 981a10 1b420004 2118 r2 |= 0x4 /* set libload indicator */ /* flight2 */ 981a14 00000000 2119 nop /* flight2 */ 981a18 1d42e04d 2120 *(status + 1) = r2l /* flight2 */ 981a1c dfe3fd30 2121 r3e = libloadchkB /* flight2 */ 981a20 14a00005 2122 r5 = 5 /* flight2 */ 981a24 14c00000 2123 r6 = 0 /* flight2 */ 2124 /* clear the check table */ /* flight2 */ 2125 libstartclr: /* flight2 */ 981a28 1fa60077 2126 *r3++ = r6 /* flight2 */ 981a2c 0caffff4 2127 if(r5-- >= 0) pcgoto libstartclr /* flight2 */ 981a30 00000000 2128 nop /* flight2 */ 981a34 1e670037 2129 r7l = *r1++ /* Load detector number */ 981a38 1e680037 2130 r8l = *r1++ /* Load curve number */ 981a3c 1e690037 2131 r9l = *r1++ /* Load the set number */ 981a40 1d87fc28 2132 *libloaddetector = r7 981a44 1d89fc2a 2133 *libloadset = r9 981a48 1e670037 2134 r7l = *r1++ 981a4c 1d88fc2c 2135 *libloadcurve = r8 981a50 1e680037 2136 r8l = *r1++ 981a54 1d87fc2e 2137 *libloadlength = r7 981a58 1e690037 2138 r9l = *r1++ 981a5c 1d48fd3f 2139 *(libloadCRC +1) = r8l /* CRC is Byte swapped */ 981a60 1d49fd3e 2140 *libloadCRC = r9l 981a64 dfe2fd30 2141 r2e = libloadchkB 981a68 dfe3fc30 2142 r3e = libloadB 981a6c 14a00002 2143 r5 = 4 - 2 981a70 a00f00bc 2144 pcgoto libmovecommon 981a74 00000000 2145 nop 2146 2147 libchkc: 981a78 1ae4000c 2148 r4 -0xc 981a7c 008f0014 2149 if(ne) pcgoto libchkd 981a80 00000000 2150 nop 981a84 dfe2fd32 2151 r2e = libloadchkC 981a88 dfe3fc40 2152 r3e = libloadC 981a8c 14a00008 2153 r5 = 10 - 2 981a90 a00f009c 2154 pcgoto libmovecommon 981a94 00000000 2155 nop 2156 libchkd: 981a98 1ae4000d 2157 r4 -0xd 981a9c 008f0014 2158 if(ne) pcgoto libchke 981aa0 00000000 2159 nop 981aa4 dfe2fd34 2160 r2e = libloadchkD 981aa8 dfe3fc68 2161 r3e = libloadD 981aac 14a00008 2162 r5 = 10 - 2 981ab0 a00f007c 2163 pcgoto libmovecommon 981ab4 00000000 2164 nop 2165 libchke: 981ab8 1ae4000e 2166 r4 -0xe 981abc 008f0014 2167 if(ne) pcgoto libchkf 981ac0 00000000 2168 nop 981ac4 dfe2fd36 2169 r2e = libloadchkE 981ac8 dfe3fc90 2170 r3e = libloadE 981acc 14a00008 2171 r5 = 10 - 2 981ad0 a00f005c 2172 pcgoto libmovecommon 981ad4 00000000 2173 nop 2174 libchkf: 981ad8 1ae4000f 2175 r4 -0xf 981adc 008f0014 2176 if(ne) pcgoto libchk10 981ae0 00000000 2177 nop 981ae4 dfe2fd38 2178 r2e = libloadchkF 981ae8 dfe3fcb8 2179 r3e = libloadF 981aec 14a00008 2180 r5 = 10 - 2 981af0 a00f003c 2181 pcgoto libmovecommon 981af4 00000000 2182 nop 2183 libchk10: 981af8 1ae40010 2184 r4 -0x10 981afc 008f0014 2185 if(ne) pcgoto libchk11 981b00 00000000 2186 nop 981b04 dfe2fd3a 2187 r2e = libloadchk10 981b08 dfe3fce0 2188 r3e = libload10 981b0c 14a00008 2189 r5 = 10 - 2 981b10 a00f001c 2190 pcgoto libmovecommon 981b14 00000000 2191 nop 2192 libchk11: 981b18 1ae40011 2193 r4 -0x11 981b1c 008ffa24 2194 if(ne) pcgoto maincommanderror 981b20 00000000 2195 nop 981b24 dfe2fd3c 2196 r2e = libloadchk11 981b28 dfe3fd08 2197 r3e = libload11 981b2c 14a00008 2198 r5 = 10 - 2 981b30 00000000 2199 nop 2200 libmovecommon: 981b34 c0060000 2201 r6e = 0 /* for CRC */ 981b38 980a0a02 2202 r10e = r2 2203 libmoveloop: 981b3c 1e670037 2204 r7l = *r1++ 981b40 1e680037 2205 r8l = *r1++ 981b44 1e690037 2206 r9l = *r1++ 981b48 1f670077 2207 *r3++ = r7l 981b4c 180600e0 2208 r6 += r7 981b50 1f680077 2209 *r3++ = r8l 981b54 18060100 2210 r6 += r8 981b58 14e00000 2211 r7 = 0 981b5c 1f690077 2212 *r3++ = r9l 981b60 18060120 2213 r6 += r9 981b64 1f670077 2214 *r3++ = r7l 981b68 0cafffcc 2215 if(r5-- >= 0 )pcgoto libmoveloop 981b6c 00000000 2216 nop 981b70 1b464000 2217 r6 |= 0x4000 /* make sure its non zero */ 981b74 00000000 2218 nop 981b78 1fa60050 2219 *r2 = r6 981b7c dfe3fd30 2220 r3e = libloadchkB 981b80 14a00005 2221 r5 = 5 981b84 14e00000 2222 r7 = 0 2223 /* see if check table is full and sum partial sums */ 2224 libfilledchk: 981b88 1ea60077 2225 r6 = *r3++ 981b8c 00000000 2226 nop 981b90 1ae60000 2227 r6 - 0 981b94 00af0088 2228 if(eq) pcgoto libcommanddone 981b98 1bc63fff 2229 r6 &= 0x3fff 981b9c 00000000 2230 nop 981ba0 180700c0 2231 r7 += r6 981ba4 0cafffdc 2232 if(r5-- >= 0) pcgoto libfilledchk 981ba8 00000000 2233 nop 2234 /* here if library completely sent */ 981bac dfe3fd30 2235 r3e = libloadchkB 981bb0 14a00005 2236 r5 = 5 981bb4 14c00000 2237 r6 = 0 2238 /* clear the check table */ 2239 libfilledclr: 981bb8 1fa60077 2240 *r3++ = r6 981bbc 0caffff4 2241 if(r5-- >= 0) pcgoto libfilledclr 981bc0 00000000 2242 nop 2243 /* clear libload bit in status */ 981bc4 1c42e04d 2244 r2l = *(status + 1) /* flight2 */ 981bc8 00000000 2245 nop /* flight2 */ 981bcc 1bc200fb 2246 r2 &= 0xfb /* clear libload indicator */ /* flight2 */ 981bd0 00000000 2247 nop /* flight2 */ 981bd4 1d42e04d 2248 *(status + 1) = r2l /* flight2 */ 2249 981bd8 1c86fd3e 2250 r6 = *libloadCRC 981bdc 00000000 2251 nop 981be0 18e700c0 2252 r7 - r6 /* checksums the same */ 981be4 008f0048 2253 if(ne) pcgoto badlibload 981be8 00000000 2254 nop 2255 /* turn off data collection for eeprom write */ 981bec 1e82001e 2256 r2 = pcw 981bf0 00000000 2257 nop 981bf4 1bc207ff 2258 r2 = r2 & 0x7ff /* serial interrupt */ 981bf8 00000000 2259 nop 981bfc 1f82001e 2260 pcw = r2 2261 2262 /* call Toms routine to add this library */ 981c00 128f1c1c 2263 pccall addlibrary(r18) 981c04 00000000 2264 nop 2265 /* reenable data collection */ 981c08 c74d0000 2266 r13e = ANARESET 981c0c 1e82001e 2267 r2 = pcw 981c10 1fa901b0 2268 *r13 = r9 981c14 00000000 2269 nop 981c18 1b428400 2270 r2 = r2 | 0x8400 /* data + serial interrupt */ 981c1c 00000000 2271 nop 981c20 1f82001e 2272 pcw = r2 2273 2274 libcommanddone: 981c24 1cd9f028 2275 r21e = *Jcommanddone 981c28 00000000 2276 nop 981c2c a0190000 2277 goto r21 981c30 00000000 2278 nop 2279 badlibload: 981c34 1c44fb3c 2280 r4l = *herrorcnt 981c38 14a00004 2281 r5 = BADLIBCRC 981c3c 14840001 2282 r4 += 1 981c40 1d45fb3d 2283 *herrortype = r5l 981c44 1d44fb3c 2284 *herrorcnt = r4l 2285 /* set status bit to indicate error */ 981c48 1c42e04d 2286 r2l = *(status + 1) 981c4c 00000000 2287 nop 981c50 1b420080 2288 r2 |= 0x80 /* set error indicator */ 981c54 00000000 2289 nop 981c58 1d42e04d 2290 *(status + 1) = r2l 981c5c bfefffc0 2291 pcgoto libcommanddone 981c60 00000000 2292 nop 2293 2294 commanddone: 981c64 1cc2ffd0 2295 r2e = *SERIALGETPT 981c68 1cc3fff0 2296 r3e = *SERIALINPT 981c6c 00000000 2297 nop 981c70 18e30040 2298 r3 - r2 981c74 008f0014 2299 if(ne) pcgoto notallinitiated 981c78 00000000 2300 nop 981c7c 1c45e04c 2301 r5l = *status 981c80 00000000 2302 nop 981c84 1bc500fe 2303 r5 &= 0xfe /* clear not initiated bit */ 981c88 00000000 2304 nop 981c8c 1d45e04c 2305 *status = r5l 2306 notallinitiated: 981c90 00000000 2307 nop 981c94 1cd9f02c 2308 r21e = *Jcheck8hz 981c98 00000000 2309 nop 981c9c a0190000 2310 goto r21 981ca0 00000000 2311 nop 2312 2313 /* check the status of the 8HZ clock */ 2314 check8hz: 981ca4 c7610000 2315 main1: r1e = STATUS 981ca8 1ea20030 2316 r2 = *r1 981cac 00000000 2317 nop 981cb0 1be28000 2318 r2 & 0x8000 /* 8 HZ bit */ 981cb4 008f00a8 2319 if(ne) pcgoto eighthigh 981cb8 00000000 2320 nop 981cbc 1ea20030 2321 r2 = *r1 981cc0 00000000 2322 nop 981cc4 1be28000 2323 r2 & 0x8000 /* 8 HZ bit */ 981cc8 008f0038 2324 if(ne) pcgoto eightweirdl /* make sure this is really true */ 981ccc 00000000 2325 nop 981cd0 1ea20030 2326 r2 = *r1 981cd4 00000000 2327 nop 981cd8 1be28000 2328 r2 & 0x8000 /* 8 HZ bit */ 981cdc 008f0024 2329 if(ne) pcgoto eightweirdl /* make sure this is really true */ 981ce0 00000000 2330 nop 981ce4 1c82e068 2331 r2 = *eightstatus /* 8HZ is low, check if this is a change */ 981ce8 00000000 2332 nop 981cec 1be2ffff 2333 r2 & 0xffff /* was it already set high */ 981cf0 00af00bc 2334 if(eq) pcgoto eightsame /* remains low */ 981cf4 00000000 2335 nop 981cf8 1cd9f030 2336 r21e = *Jeightlows 981cfc 00000000 2337 nop 981d00 a0190000 2338 goto r21 981d04 00000000 2339 nop 2340 eightweirdl: 981d08 1ea20030 2341 r2 = *r1 981d0c 00000000 2342 nop 981d10 1be28000 2343 r2 & 0x8000 /* 8 HZ bit */ 981d14 008f0098 2344 if(ne) pcgoto eightsame /* stays high */ 981d18 00000000 2345 nop 2346 /* error except if seen right on 8 Hz edge */ 2347 eighterror: 981d1c 1c44fb3c 2348 r4l = *herrorcnt 981d20 14a00002 2349 r5 = BAD8HZCLK 981d24 14840001 2350 r4 += 1 981d28 1d45fb3d 2351 *herrortype = r5l 981d2c 1d44fb3c 2352 *herrorcnt = r4l 981d30 1c42e04d 2353 r2l = *(status + 1) 981d34 00000000 2354 nop 981d38 1b420080 2355 r2 |= 0x80 /* set error indicator */ 981d3c 00000000 2356 nop 981d40 1d42e04d 2357 *(status + 1) = r2l 981d44 a00f0068 2358 pcgoto eightsame 981d48 00000000 2359 nop 2360 eightweirdh: 981d4c 1ea20030 2361 r2 = *r1 981d50 00000000 2362 nop 981d54 1be28000 2363 r2 & 0x8000 /* 8 HZ bit */ 981d58 00af0054 2364 if(eq) pcgoto eightsame 981d5c 00000000 2365 nop 981d60 bfefffb4 2366 pcgoto eighterror 2367 eighthigh: 981d64 00000000 2368 nop 981d68 1ea20030 2369 r2 = *r1 981d6c 00000000 2370 nop 981d70 1be28000 2371 r2 & 0x8000 /* 8 HZ bit */ 981d74 00afffd0 2372 if(eq) pcgoto eightweirdh /* double check */ 981d78 00000000 2373 nop 981d7c 1ea20030 2374 r2 = *r1 981d80 00000000 2375 nop 981d84 1be28000 2376 r2 & 0x8000 /* 8 HZ bit */ 981d88 00afffbc 2377 if(eq) pcgoto eightweirdh /* double check */ 981d8c 00000000 2378 nop 981d90 1c82e068 2379 r2 = *eightstatus /* 8HZ is low, check if this is a change */ 981d94 00000000 2380 nop 981d98 1be2ffff 2381 r2 & 0xffff /* was it already set high */ 981d9c 008f0010 2382 if(ne) pcgoto eightsame /* remains high */ 981da0 00000000 2383 nop 981da4 1cd9f034 2384 r21e = *Jeighthighs 981da8 00000000 2385 nop 981dac a0190000 2386 goto r21 981db0 00000000 2387 nop 2388 eightsame: 981db4 1cd9f040 2389 r21e = *Jeightdone 981db8 00000000 2390 nop 981dbc a0190000 2391 goto r21 981dc0 00000000 2392 nop 2393 eightdone: 2394 /* if there is no 8 Hz clock, fake one to update housekeeping, etc */ 981dc4 1c82e05e 2395 r2 = *loopcount 981dc8 00000000 2396 nop 981dcc 1ae2fffe 2397 r2 - 0xfffe 981dd0 01ef0044 2398 if(ls) pcgoto startdfe 981dd4 00000000 2399 nop 981dd8 1c82e068 2400 r2 = *eightstatus /* change 8 Hz status */ 981ddc 00000000 2401 nop 981de0 1be2ffff 2402 r2 & 0xffff /* clock high */ 981de4 00af0044 2403 if(eq) pcgoto forcehigh 981de8 00000000 2404 nop 981dec 1c44fb3c 2405 r4l = *herrorcnt 981df0 14a00001 2406 r5 = NO8HZCLK 981df4 14840001 2407 r4 += 1 981df8 1d45fb3d 2408 *herrortype = r5l 981dfc 1d44fb3c 2409 *herrorcnt = r4l 981e00 1c42e04d 2410 r2l = *(status + 1) 981e04 00000000 2411 nop 981e08 1b420080 2412 r2 |= 0x80 /* set error indicator */ 981e0c 00000000 2413 nop 981e10 1d42e04d 2414 *(status + 1) = r2l 2415 981e14 a00f02f4 2416 pcgoto forcelow 981e18 00000000 2417 nop 2418 /* dont enable the DFE interface unless in operational mode */ 2419 startdfe: 2420 981e1c 00000000 2421 nop 981e20 1cd9f044 2422 r21e = *Jadcheck 981e24 00000000 2423 nop 981e28 a0190000 2424 goto r21 981e2c 00000000 2425 nop 2426 2427 eighthighs: 2428 forcehigh: 981e30 1440ffff 2429 r2 = 0xffff 981e34 1d82e068 2430 *eightstatus = r2 981e38 1c82e07a 2431 r2 = *eightcount 981e3c c7010000 2432 r1e = HKAD 981e40 1a820001 2433 r2 -= 1 981e44 1ea30030 2434 r3 = *r1 981e48 1bc20007 2435 r2 = r2 & 0x7 981e4c 18220040 2436 r2 = r2 * 2 981e50 dfe1fb20 2437 r1e = addata 981e54 98010040 2438 r1e += r2 981e58 00000000 2439 nop 981e5c 1c82e07a 2440 r2 = *eightcount 981e60 1f230037 2441 *r1++ = r3h 981e64 1bc20007 2442 r2 = r2 & 0x7 981e68 1f630030 2443 *r1 = r3l 2444 /* load the A/D input source */ 981e6c 1c83e064 2445 r3 = *softcontrol 981e70 00000000 2446 nop 981e74 1bc3fff8 2447 r3 = r3 & 0xfff8 2448 /* r3 = r3 &0xfff7 debugging */ 981e78 19430040 2449 r3 = r3 | r2 981e7c c7610000 2450 r1e = CONTROL 981e80 1b430010 2451 r3 |= 0x10 981e84 1d83e064 2452 *softcontrol = r3 981e88 1fa30030 2453 *r1 = r3 981e8c 1c82e07a 2454 r2 = *eightcount 981e90 00000000 2455 nop 981e94 1be20007 2456 r2 & 0x7 981e98 008fff14 2457 if(ne) pcgoto eightsame 981e9c 00000000 2458 nop 981ea0 1c86e048 2459 r6 = *anaresult 981ea4 1c87e04a 2460 r7 = *(anaresult + 2) 981ea8 dfe5e048 2461 r5e = anaresult 981eac 00000000 2462 nop 981eb0 1de400b0 2463 *r5 = ibufe 981eb4 1be20008 2464 r2 & 8 981eb8 00af0048 2465 if(eq) pcgoto eightrchk 981ebc 00000000 2466 nop 981ec0 1c88e048 2467 r8 = *anaresult 981ec4 1c89e04a 2468 r9 = *(anaresult + 2) 981ec8 198600c0 2469 r6 = r6 >> 1 981ecc 198700e0 2470 r7 = r7 >> 1 981ed0 19880100 2471 r8 = r8 >> 1 981ed4 19890120 2472 r9 = r9 >> 1 981ed8 18060100 2473 r6 = r6 + r8 981edc 18070120 2474 r7 = r7 + r9 981ee0 19830040 2475 r3 = r2 >> 1 981ee4 19830060 2476 r3 = r3 >> 1 981ee8 1bc3007c 2477 r3 = r3 & 0x7c /* index into array of 32 longs*/ 981eec dfe8e1de 2478 r8e = countarray 981ef0 98080060 2479 r8e += r3 981ef4 00000000 2480 nop 981ef8 1fa60117 2481 *r8++ = r6 981efc 1fa70110 2482 *r8 = r7 /* save rates */ 981f00 bfeffeac 2483 pcgoto eightsame 981f04 00000000 2484 nop 2485 eightrchk: 981f08 1be201f0 2486 r2 & 0x1f0 /* 8hz on 64 sec boundary ? */ 981f0c 008ffea0 2487 if(ne) pcgoto eightsame 981f10 00000000 2488 nop 981f14 dfe8e1de 2489 r8e = countarray /* last 64 seconds worth */ 981f18 dfe7fb78 2490 r7e = rate_history 981f1c 1520001e 2491 r9 = 30 2492 ratemove: 981f20 1ea50117 2493 r5 = *r8++ 981f24 1ea60117 2494 r6 = *r8++ 981f28 00000000 2495 nop 981f2c 1f2600f7 2496 *r7++ = r6h 981f30 1f6600f7 2497 *r7++ = r6l 981f34 1f2500f7 2498 *r7++ = r5h 981f38 1f6500f7 2499 *r7++ = r5l 981f3c 0d2fffdc 2500 if( r9-- >=0) pcgoto ratemove 981f40 00000000 2501 nop 981f44 dfe8e25e 2502 r8e = rawrates 981f48 dfe7fb3e 2503 r7e = chan_rates 981f4c 15200011 2504 r9 = 19 - 2 981f50 14600000 2505 r3 = 0 2506 chanratemove: 981f54 1ea50110 2507 r5 = *r8 981f58 00000000 2508 nop 2509 /* do 16 bit -> 3 + 5 compression */ 981f5c 1be5f000 2510 r5 & 0xf000 981f60 00af0044 2511 if(eq) pcgoto lower35a 981f64 14808000 2512 r4 = 0x8000 981f68 1be5e000 2513 r5 & 0xe000 981f6c 00af0080 2514 if(eq) pcgoto done53a 981f70 00000000 2515 nop 981f74 198500a0 2516 r5 = r5 >> 1 981f78 1480a000 2517 r4 = 0xa000 981f7c 1be5e000 2518 r5 & 0xe000 981f80 00af006c 2519 if(eq) pcgoto done53a 981f84 00000000 2520 nop 981f88 198500a0 2521 r5 = r5 >> 1 981f8c 1480c000 2522 r4 = 0xc000 981f90 1be5e000 2523 r5 & 0xe000 981f94 00af0058 2524 if(eq) pcgoto done53a 981f98 00000000 2525 nop 981f9c 198500a0 2526 r5 = r5 >> 1 981fa0 1480e000 2527 r4 = 0xe000 981fa4 a00f0048 2528 pcgoto done53a 981fa8 00000000 2529 nop 2530 lower35a: 981fac 182500a0 2531 r5 = r5 * 2 981fb0 14806000 2532 r4 = 0x6000 981fb4 1be5f000 2533 r5 & 0xf000 981fb8 008f0034 2534 if(ne) pcgoto done53a 981fbc 00000000 2535 nop 981fc0 182500a0 2536 r5 = r5 * 2 981fc4 14804000 2537 r4 = 0x4000 981fc8 1be5f000 2538 r5 & 0xf000 981fcc 008f0020 2539 if(ne) pcgoto done53a 981fd0 00000000 2540 nop 981fd4 182500a0 2541 r5 = r5 * 2 981fd8 14802000 2542 r4 = 0x2000 981fdc 1be5f000 2543 r5 & 0xf000 981fe0 008f000c 2544 if(ne) pcgoto done53a 981fe4 00000000 2545 nop 981fe8 182500a0 2546 r5 = r5 * 2 981fec 14800000 2547 r4 = 0x0000 981ff0 00000000 2548 nop 2549 done53a: 981ff4 19450080 2550 r5 |= r4 /* combine exponent and mantissa */ 2551 981ff8 1fa30110 2552 *r8 = r3 981ffc 1fa30117 2553 *r8++ = r3 /* override any interrupt conflict */ 982000 1f2500f7 2554 *r7++ = r5h 982004 0d2fff48 2555 if( r9-- >= 0) pcgoto chanratemove 982008 00000000 2556 nop 98200c dfe8e284 2557 r8e = rawstats 982010 dfe7fb52 2558 r7e = sel_stats 982014 15200024 2559 r9 = 38 - 2 982018 14600000 2560 r3 = 0 2561 statmove: 98201c 1ea50110 2562 r5 = *r8 982020 00000000 2563 nop 2564 /* do 16 bit -> 3 + 5 compression */ 982024 1be5f000 2565 r5 & 0xf000 982028 00af0044 2566 if(eq) pcgoto lower35b 98202c 14808000 2567 r4 = 0x8000 982030 1be5e000 2568 r5 & 0xe000 982034 00af0080 2569 if(eq) pcgoto done53b 982038 00000000 2570 nop 98203c 198500a0 2571 r5 = r5 >> 1 982040 1480a000 2572 r4 = 0xa000 982044 1be5e000 2573 r5 & 0xe000 982048 00af006c 2574 if(eq) pcgoto done53b 98204c 00000000 2575 nop 982050 198500a0 2576 r5 = r5 >> 1 982054 1480c000 2577 r4 = 0xc000 982058 1be5e000 2578 r5 & 0xe000 98205c 00af0058 2579 if(eq) pcgoto done53b 982060 00000000 2580 nop 982064 198500a0 2581 r5 = r5 >> 1 982068 1480e000 2582 r4 = 0xe000 98206c a00f0048 2583 pcgoto done53b 982070 00000000 2584 nop 2585 lower35b: 982074 182500a0 2586 r5 = r5 * 2 982078 14806000 2587 r4 = 0x6000 98207c 1be5f000 2588 r5 & 0xf000 982080 008f0034 2589 if(ne) pcgoto done53b 982084 00000000 2590 nop 982088 182500a0 2591 r5 = r5 * 2 98208c 14804000 2592 r4 = 0x4000 982090 1be5f000 2593 r5 & 0xf000 982094 008f0020 2594 if(ne) pcgoto done53b 982098 00000000 2595 nop 98209c 182500a0 2596 r5 = r5 * 2 9820a0 14802000 2597 r4 = 0x2000 9820a4 1be5f000 2598 r5 & 0xf000 9820a8 008f000c 2599 if(ne) pcgoto done53b 9820ac 00000000 2600 nop 9820b0 182500a0 2601 r5 = r5 * 2 9820b4 14800000 2602 r4 = 0x0000 9820b8 00000000 2603 nop 2604 done53b: 9820bc 19450080 2605 r5 |= r4 /* combine exponent and mantissa */ 9820c0 1fa30117 2606 *r8++ = r3 9820c4 1f2500f7 2607 *r7++ = r5h 9820c8 0d2fff4c 2608 if( r9-- >= 0) pcgoto statmove 9820cc 00000000 2609 nop 9820d0 1c83e064 2610 r3 = *softcontrol 9820d4 1c84e060 2611 r4 = *anacntl 9820d8 1c85e062 2612 r5 = *(anacntl + 2) 9820dc 1d03fc1e 2613 *hsoftcontrol = r3h 9820e0 1d43fc1f 2614 *(hsoftcontrol + 1) = r3l 9820e4 1d44fc20 2615 *hanacntl = r4l /* flight2 */ 9820e8 1d04fc21 2616 *(hanacntl + 1) = r4h /* flight2 */ 9820ec 1d45fc22 2617 *(hanacntl + 2) = r5l /* flight2 */ 9820f0 1d05fc23 2618 *(hanacntl + 3) = r5h /* flight2 */ 9820f4 1c85e2d0 2619 r5 = *quecount 9820f8 14800000 2620 r4 = 0 9820fc 1d05fc24 2621 *hquecount = r5h 982100 1d45fc25 2622 *(hquecount + 1) = r5l 982104 1d84e2d0 2623 *quecount = r4 982108 bfeffca4 2624 pcgoto eightsame 98210c 00000000 2625 nop 2626 eightlows: 2627 forcelow: 982110 14400000 2628 r2 = 0 982114 00000000 2629 nop 982118 1d82e068 2630 *eightstatus = r2 2631 /* here if a 0 -> 1 transition on the 8HZ clock */ 98211c 14400000 2632 r2 = 0 2633 /* initialize fake parameters */ 982120 1d82e05c 2634 *sendcount = r2 982124 1d82e05e 2635 *loopcount = r2 2636 2637 2638 2639 /* switch collection buffers and fill fifo */ 982128 1c82e064 2640 r2 = *softcontrol 98212c 1c81e050 2641 r1 = *state 982130 1bc200df 2642 r2 = r2 & 0xdf /* DFE off if in standby or config */ 982134 1ae10000 2643 r1 - 0 /* standby */ 982138 00af0010 2644 if(eq) pcgoto ffreset 98213c 00000000 2645 nop 982140 1ae10001 2646 r1 - 1 /* config */ 982144 00af0004 2647 if(eq) pcgoto ffreset 982148 00000000 2648 nop 98214c 1b420020 2649 r2 = r2 | 0x20 /* reenable DFE */ 2650 ffreset: 982150 c7610000 2651 r1e = CONTROL 982154 1bc2ff7f 2652 r2 = r2 & 0xff7f /* reset fifo , disable interface*/ 982158 1fa20030 2653 *r1 = r2 98215c 1b420080 2654 r2 = r2 | 0x80 /* reenable it */ 982160 00000000 2655 nop 982164 1fa20030 2656 *r1 = r2 982168 1d82e064 2657 *softcontrol = r2 98216c c7030000 2658 r3e = HKAD 2659 982170 1fa30070 2660 *r3 = r3 982174 1c84e06a 2661 r4 = *analogcount 982178 1c82e07a 2662 r2 = *eightcount 98217c 14840001 2663 r4 += 1 982180 180202e0 2664 r2 = r2 + 1 2665 /* update housekeeping parameters */ 982184 1c85e06c 2666 r5 = *lastid /* flight2 */ 982188 1d02fb36 2667 *heightcount = r2h 98218c 1d42fb37 2668 *(heightcount + 1) = r2l 982190 1d05fb34 2669 *hid = r5h 982194 1d45fb35 2670 *(hid + 1) = r5l 982198 1be20007 2671 r2 & 7 /* flight2 */ 98219c 008f0018 2672 if(ne) pcgoto saveanacnt 9821a0 1d82e07a 2673 *eightcount = r2 2674 9821a4 14800000 2675 r4 = 0 2676 /* exchange data with the Analog board */ 9821a8 1c83e064 2677 r3 = *softcontrol 9821ac c7610000 2678 r1e = CONTROL 9821b0 1bc3ffef 2679 r3 = r3 & 0xffef 9821b4 1fa30030 2680 *r1 = r3 9821b8 1d83e064 2681 *softcontrol = r3 2682 saveanacnt: 9821bc 1d84e06a 2683 *analogcount = r4 9821c0 1be20007 2684 r2 & 7 9821c4 008f0008 2685 if(ne) pcgoto noanaset 9821c8 00000000 2686 nop 9821cc dfe5e060 2687 r5e = anacntl 9821d0 1ce500b0 2688 obufe = *r5 2689 noanaset: 9821d4 1cd9f038 2690 r21e = *Jflushevents 9821d8 00000000 2691 nop 9821dc a0190000 2692 goto r21 9821e0 00000000 2693 nop 2694 /* make sure event reporting is consistent with data cycle */ 2695 /* Discard events we cant process */ 2696 flushevents: 9821e4 14200001 2697 r1 = 1 9821e8 1d81e070 2698 *fasthold = r1 /* allow only 1 pulse in fast channel until fifo is out */ 9821ec 14200000 2699 r1 = 0 9821f0 1d81e076 2700 *queflush = r1 2701 quehandle: 9821f4 1c43e130 2702 r3l = *quesize 9821f8 1c82e07a 2703 r2 = *eightcount 9821fc 18e30020 2704 r3 - r1 982200 01af00b8 2705 if(le) pcgoto quedump 982204 00000000 2706 nop 2707 /* get the address of the next raw pulse */ 982208 1c09e080 2708 r9h = *pulseread 98220c 1c87e080 2709 r7 = *pulseread 982210 1d89e088 2710 *pulseadd = r9 982214 1c88e07e 2711 r8 = *pulsewrite 982218 1c49e081 2712 r9l = *(pulseread + 1) 98221c 18e70100 2713 r7 - r8 982220 00af00cc 2714 if(eq) pcgoto quedone 982224 1d89e08a 2715 *(pulseadd+2) = r9 982228 1ccce084 2716 r12e = *pulsebase 98222c 1cc9e088 2717 r9e = *pulseadd 982230 14e70001 2718 r7 += 1 982234 1c88e082 2719 r8 = *pulsemax 982238 980c0120 2720 r12e += r9 /* points to the next read buffer */ 98223c 00000000 2721 nop 982240 1ea10190 2722 r1 = *r12 /* get the value of eightcount */ 982244 00000000 2723 nop 982248 18e10040 2724 r1 - r2 98224c 00af00a0 2725 if(eq) pcgoto quedone 982250 00000000 2726 nop 982254 18e70100 2727 r7 - r8 /* wraparound ?? */ 982258 016f0004 2728 if(lt) pcgoto noreadwrapa 98225c 1dcce014 2729 *rawpointer = r12e 982260 14e00000 2730 r7 = 0 2731 noreadwrapa: 982264 15000040 2732 r8 = 0x40 /* offset to data */ 982268 1d87e080 2733 *pulseread = r7 98226c 980c0100 2734 r12e += r8 982270 00000000 2735 nop 982274 1dcce010 2736 *rawevent = r12e 2737 /* here is where the analysis routine gets called */ 2738 /* This is Tom's call :) */ 982278 128f1ef0 2739 pccall anal(r18) 98227c 00000000 2740 nop 982280 1cd9f060 2741 r21e = *Cstatcollect 982284 00000000 2742 nop 982288 12990000 2743 call r21(r18) 98228c 00000000 2744 nop 982290 1cd9f064 2745 r21e = *Ceventroutine 982294 00000000 2746 nop 982298 12990000 2747 call r21(r18) 98229c 00000000 2748 nop 9822a0 1c81e076 2749 r1 = *queflush 9822a4 00000000 2750 nop 9822a8 14210001 2751 r1 += 1 9822ac 00000000 2752 nop 9822b0 1d81e076 2753 *queflush = r1 2754 /* see if we have reached the limit */ 9822b4 1ae1000a 2755 r1 - QUEROLL 9822b8 01afff34 2756 if(le) pcgoto quehandle 9822bc 00000000 2757 nop 2758 /* just dump the rest */ 2759 quedump: 9822c0 1c87e080 2760 r7 = *pulseread 9822c4 1c88e07e 2761 r8 = *pulsewrite 9822c8 00000000 2762 nop 9822cc 1d88e080 2763 *pulseread = r8 9822d0 1d88e080 2764 *pulseread = r8 9822d4 1c85e082 2765 r5 = *pulsemax 9822d8 188800e0 2766 r8 -= r7 9822dc 1808b4a0 2767 if(lt) r8 += r5 9822e0 1c82e2d0 2768 r2 = *quecount 9822e4 00000000 2769 nop 9822e8 14420001 2770 r2 += 1 /* keep track of thrown away events */ 9822ec 00000000 2771 nop 9822f0 1d82e2d0 2772 *quecount = r2 2773 quedone: 9822f4 1cd9f03c 2774 r21e = *Jfifooutput 9822f8 00000000 2775 nop 9822fc a0190000 2776 goto r21 982300 00000000 2777 nop 2778 2779 /* send the HSL data to the fifo */ 2780 fifooutput: 982304 c60a0000 2781 r10e = FIFO 2782 /* check for state before filling fifo */ 982308 1c82e050 2783 r2 = *state 98230c 00000000 2784 nop 982310 1ae20000 2785 r2 - 0 /* standby */ 982314 00af000c 2786 if(eq) pcgoto fillff 982318 00000000 2787 nop 98231c 1ae20001 2788 r2 - 1 /* config */ 982320 008f003c 2789 if(ne) pcgoto operfill 982324 00000000 2790 nop 2791 fillff: 982328 1440ffff 2792 r2 = 0xffff 98232c 00000000 2793 nop 982330 1fa20150 2794 *r10 = r2 /* no output */ 982334 1c81e06e 2795 r1 = *bufferno /* which buffer */ 982338 00000000 2796 nop 98233c 1be1ffff 2797 r1 & 0xffff /* is it buffer 1 */ 982340 008f000c 2798 if(ne) pcgoto fifo1n 982344 1420ffff 2799 r1 = 0xffff 982348 1d81e06e 2800 *bufferno = r1 98234c a00f0204 2801 pcgoto clear0 982350 00000000 2802 nop 2803 fifo1n: 982354 14200000 2804 r1 = 0 982358 1d81e06e 2805 *bufferno = r1 98235c a00f01f4 2806 pcgoto clear0 982360 00000000 2807 nop 2808 operfill: 982364 1c81e06e 2809 r1 = *bufferno /* which buffer */ 982368 14400002 2810 r2 = SOP 98236c 1fa20150 2811 *r10 = r2 982370 1fa20150 2812 *r10 = r2 982374 1fa20150 2813 *r10 = r2 /* 3 SOPs to start */ 982378 1be1ffff 2814 r1 & 0xffff /* is it buffer 1 */ 98237c 008f00b8 2815 if(ne) pcgoto fifo1 982380 1420ffff 2816 r1 = 0xffff 982384 1d81e06e 2817 *bufferno = r1 982388 1c02e054 2818 r2h = *events0 98238c 1c41e058 2819 r1l = *curves0 982390 00000000 2820 nop 982394 19420020 2821 r2 = r2 | r1 982398 00af0140 2822 if(eq) pcgoto sendnothing 98239c 00000000 2823 nop 9823a0 1fa20150 2824 *r10 = r2 /* send event & curve numbers */ 2825 /* timing debug */ 9823a4 1c82e064 2826 r2 = *softcontrol 9823a8 c7610000 2827 r1e = CONTROL 9823ac 1b420008 2828 r2 = r2 | 8 9823b0 1fa20030 2829 *r1 = r2 9823b4 1c81e054 2830 r1 = *events0 9823b8 1ccbe000 2831 r11e = *eventbuffer0 9823bc 18210020 2832 r1 = r1*2 9823c0 00000000 2833 nop 9823c4 18080a01 2834 r8 = r1 9823c8 18030ae8 2835 r3 = r8 +1 /* add event/curve data to total */ 9823cc 188102e0 2836 r1 = r1 - 1 9823d0 016f0018 2837 if(lt) pcgoto shapes0snd 9823d4 188102e0 2838 r1 = r1 - 1 /* adjust for branch latency */ 2839 event0lp: 9823d8 1ea20177 2840 r2 = *r11++ 9823dc 0c2ffff4 2841 if( r1-- >= 0) pcgoto event0lp 9823e0 1fa20150 2842 *r10 = r2 2843 /* timing debug */ 9823e4 1c82e064 2844 r2 = *softcontrol 9823e8 c7610000 2845 r1e = CONTROL 9823ec 1fa20030 2846 *r1 = r2 2847 shapes0snd: 2848 sizeld1: 9823f0 946f0a50 2849 r3e = pc + (sizetable - sizeld1 - 8) 2850 9823f4 1c81e058 2851 r1 = *curves0 9823f8 00000000 2852 nop 9823fc 98030020 2853 r3e += r1 982400 98030020 2854 r3e += r1 982404 00000000 2855 nop 982408 1ea10070 2856 r1 = *r3 98240c 00000000 2857 nop 982410 18080020 2858 r8 = r8 + r1 /* r8 has total of events and shapes */ 2859 982414 18030a01 2860 r3 = r1 /* save amt of curve data */ 982418 1ccbe008 2861 r11e = *curvebuffer0 98241c 188102e0 2862 r1 = r1 - 1 982420 016f00c8 2863 if(lt) pcgoto eightfinish 982424 188102e0 2864 r1 = r1 - 1 /* adjust for branch latency */ 2865 curve0lp: 982428 1ea20177 2866 r2 = *r11++ 98242c 0c2ffff4 2867 if( r1-- >= 0) pcgoto curve0lp 982430 1fa20150 2868 *r10 = r2 982434 a00f00b4 2869 pcgoto eightfinish 982438 00000000 2870 nop 2871 /* r2 has the SOP to send */ 2872 fifo1: 98243c 14200000 2873 r1 = 0 982440 00000000 2874 nop 982444 1d81e06e 2875 *bufferno = r1 982448 1c02e056 2876 r2h = *events1 98244c 1c41e05a 2877 r1l = *curves1 982450 00000000 2878 nop 982454 19420020 2879 r2 = r2 | r1 982458 00af0080 2880 if(eq) pcgoto sendnothing 98245c 00000000 2881 nop 982460 1fa20150 2882 *r10 = r2 /* send event & curve numbers */ 982464 1c81e056 2883 r1 = *events1 982468 1ccbe004 2884 r11e = *eventbuffer1 98246c 18210020 2885 r1 = r1 * 2 982470 00000000 2886 nop 982474 18080a01 2887 r8 = r1 982478 18030ae8 2888 r3 = r8 +1 /* add event/curve data to total */ 98247c 188102e0 2889 r1 = r1 - 1 982480 016f000c 2890 if(lt) pcgoto shapes1snd 982484 188102e0 2891 r1 = r1 - 1 /* adjust for branch latency */ 2892 event1lp: 982488 1ea20177 2893 r2 = *r11++ 98248c 0c2ffff4 2894 if( r1-- >= 0) pcgoto event1lp 982490 1fa20150 2895 *r10 = r2 2896 shapes1snd: 2897 sizeld2: 982494 946f09ac 2898 r3e = pc + (sizetable - sizeld2 - 8) 2899 982498 1c81e05a 2900 r1 = *curves1 98249c 00000000 2901 nop 9824a0 98030020 2902 r3e += r1 9824a4 98030020 2903 r3e += r1 9824a8 00000000 2904 nop 9824ac 1ea10070 2905 r1 = *r3 9824b0 00000000 2906 nop 9824b4 18080020 2907 r8 = r8 + r1 /* r8 has total of events and shapes */ 2908 9824b8 18030a01 2909 r3 = r1 /* save amt of curve data */ 9824bc 1ccbe00c 2910 r11e = *curvebuffer1 9824c0 188102e0 2911 r1 = r1 - 1 9824c4 016f0024 2912 if(lt) pcgoto eightfinish 9824c8 188102e0 2913 r1 = r1 - 1 /* adjust for branch latency */ 2914 curve1lp: 9824cc 1ea20177 2915 r2 = *r11++ 9824d0 0c2ffff4 2916 if( r1-- >= 0) pcgoto curve1lp 9824d4 1fa20150 2917 *r10 = r2 9824d8 a00f0010 2918 pcgoto eightfinish 9824dc 00000000 2919 nop 2920 2921 /* fix for backward searching DPE code when 0 events and 0 curves */ 2922 sendnothing: 9824e0 14400000 2923 r2 = EOP 9824e4 15000000 2924 r8 = 0 9824e8 a00f0010 2925 pcgoto sendeop 9824ec 00000000 2926 nop 2927 2928 eightfinish: 9824f0 14400000 2929 r2 = EOP 9824f4 180802e0 2930 r8 = r8 + 1 /* dropped the extra number word */ 9824f8 00000000 2931 nop 9824fc 19420100 2932 r2 = r2 | r8 /* include # transferred */ 2933 sendeop: 982500 00000000 2934 nop 982504 1fa20150 2935 *r10 = r2 982508 1fa20150 2936 *r10 = r2 98250c 1fa20150 2937 *r10 = r2 /* 3 EOPs */ 982510 1c81e066 2938 r1 = *hssize /* number of words to send to DPE on high speed link */ 982514 00000000 2939 nop 982518 1a81000b 2940 r1 -= 11 /* adjust for loop,SOPs,EOPs,EOT */ 98251c 18810100 2941 r1 = r1 - r8 982520 016f000c 2942 if(lt) pcgoto finish2 982524 14400000 2943 r2 = 0 2944 finishlp: 982528 1fa20150 2945 *r10 = r2 98252c 0c2ffff4 2946 if(r1-- >= 0) pcgoto finishlp 982530 00000000 2947 nop 2948 finish2: 982534 15080006 2949 r8 = r8 + 6 /* include SOPs & EOPs */ 982538 14400000 2950 r2 = EOT 98253c 00000000 2951 nop 982540 19420100 2952 r2 = r2 | r8 982544 00000000 2953 nop 982548 1fa20150 2954 *r10 = r2 98254c 1fa20150 2955 *r10 = r2 982550 1fa20150 2956 *r10 = r2 /* 3 final EOTs */ 982554 00000000 2957 nop 2958 /* clear the eventand curve counts */ 2959 clear0: 982558 1c81e06e 2960 r1 = *bufferno 98255c 14400000 2961 r2 = 0 982560 1be1ffff 2962 r1 & 0xffff 982564 00af0020 2963 if(eq) pcgoto clear1 982568 00000000 2964 nop 2965 98256c 1c81e054 2966 r1 = *events0 982570 1c83e058 2967 r3 = *curves0 982574 1d41fb38 2968 *hevents0 = r1l 982578 1d43fb3a 2969 *hcurves0 = r3l 98257c 1d82e054 2970 *events0 = r2 982580 1d82e058 2971 *curves0 = r2 2972 982584 a00f0018 2973 pcgoto clrcommon 982588 00000000 2974 nop 2975 clear1: 2976 98258c 1c81e056 2977 r1 = *events1 982590 1c83e05a 2978 r3 = *curves1 982594 1d41fb39 2979 *hevents1 = r1l 982598 1d43fb3b 2980 *hcurves1 = r3l 98259c 1d82e056 2981 *events1 = r2 9825a0 1d82e05a 2982 *curves1 = r2 2983 2984 clrcommon: 2985 2986 2987 /* reenable fast channel if its killed */ 9825a4 1c81e070 2988 r1 = *fasthold 9825a8 00000000 2989 nop 9825ac 1ae10000 2990 r1 - 0 9825b0 00af0020 2991 if(eq) pcgoto fastenb 9825b4 14400000 2992 r2 = 0 9825b8 1d42e070 2993 *fasthold = r2l /* clear lower byte */ 9825bc 00000000 2994 nop 9825c0 1c81e070 2995 r1 = *fasthold 9825c4 00000000 2996 nop 9825c8 1ae10000 2997 r1 - 0 9825cc 00af0004 2998 if(eq) pcgoto fastenb 9825d0 c74d0000 2999 r13e = ANARESET 9825d4 1fa901b0 3000 *r13 = r9 3001 fastenb: 9825d8 1d82e070 3002 *fasthold = r2 9825dc 1e81001e 3003 r1 = pcw 9825e0 00000000 3004 nop 9825e4 1b418400 3005 r1 = r1 | 0x8400 /* data + serial interrupt */ 9825e8 00000000 3006 nop 9825ec 1f81001e 3007 pcw = r1 9825f0 00000000 3008 nop 9825f4 bfeff7b8 3009 pcgoto eightsame 9825f8 00000000 3010 nop 3011 3012 3013 3014 /* check to see if fast A/D data is available */ 3015 adcheck: 3016 /* check the status of the A/D converter */ 9825fc 1c81e05e 3017 r1 = *loopcount 982600 00000000 3018 nop 982604 14210001 3019 r1 += 1 982608 00000000 3020 nop 98260c 1d81e05e 3021 *loopcount = r1 3022 3023 3024 xferfast: 982610 00000000 3025 nop 3026 3027 xferstart: 3028 982614 00000000 3029 nop 3030 /* get the address of the next raw pulse */ 982618 1c09e080 3031 r9h = *pulseread 98261c 1c87e080 3032 r7 = *pulseread 982620 1d89e088 3033 *pulseadd = r9 982624 1c88e07e 3034 r8 = *pulsewrite 982628 1c49e081 3035 r9l = *(pulseread + 1) 98262c 18e70100 3036 r7 - r8 982630 00af00cc 3037 if(eq) pcgoto pulsedone 982634 1d89e08a 3038 *(pulseadd+2) = r9 982638 1ccce084 3039 r12e = *pulsebase 98263c 1cc9e088 3040 r9e = *pulseadd 982640 14e70001 3041 r7 += 1 982644 1c88e082 3042 r8 = *pulsemax 982648 980c0120 3043 r12e += r9 /* points to the next read buffer */ 98264c 18e70100 3044 r7 - r8 /* wraparound ?? */ 982650 016f0004 3045 if(lt) pcgoto noreadwrap 982654 1dcce014 3046 *rawpointer = r12e 982658 14e00000 3047 r7 = 0 3048 noreadwrap: 98265c 15000040 3049 r8 = 0x40 /* offset to data */ 982660 1d87e080 3050 *pulseread = r7 982664 980c0100 3051 r12e += r8 982668 00000000 3052 nop 98266c 1dcce010 3053 *rawevent = r12e 3054 /* here is where the analysis routine gets called */ 3055 /* This is Tom's call :) */ 3056 /* timing debug */ 982670 1c82e064 3057 r2 = *softcontrol 982674 c7610000 3058 r1e = CONTROL 982678 1b420008 3059 r2 = r2 | 8 98267c 1fa20030 3060 *r1 = r2 982680 128f1ae8 3061 pccall anal(r18) 982684 00000000 3062 nop 982688 1cd9f060 3063 r21e = *Cstatcollect 98268c 00000000 3064 nop 982690 12990000 3065 call r21(r18) 982694 00000000 3066 nop 3067 /* timing debug */ 982698 1c82e064 3068 r2 = *softcontrol 98269c c7610000 3069 r1e = CONTROL 9826a0 1fa20030 3070 *r1 = r2 3071 /* check to see if a pulse or event */ 9826a4 1c82e05c 3072 r2 = *sendcount 9826a8 1c81e050 3073 r1 = *state 9826ac 1c83e1d6 3074 r3 = *rate_control 9826b0 1ae10002 3075 r1 - 2 /* operational ?? */ 9826b4 00af0008 3076 if(eq) pcgoto rate_oper 9826b8 00000000 3077 nop 9826bc 1c83e1d8 3078 r3 = *(rate_control + 2) /* cal & diag use other half */ 9826c0 00000000 3079 nop 3080 rate_oper: 9826c4 14420001 3081 r2 += 1 9826c8 00000000 3082 nop 9826cc 1d82e05c 3083 *sendcount = r2 9826d0 1be3ff00 3084 r3 & 0xff00 /* check upper bits */ 9826d4 008f0038 3085 if(ne) pcgoto checkcurvelow 9826d8 00000000 3086 nop 9826dc 1bc30007 3087 r3 = r3 & 07 9826e0 00000000 3088 nop 9826e4 18e20060 3089 r2 - r3 9826e8 01af006c 3090 if(le) pcgoto saveshape 9826ec 00000000 3091 nop 3092 saveevent: 9826f0 00000000 3093 nop 9826f4 1cd9f064 3094 r21e = *Ceventroutine 9826f8 00000000 3095 nop 9826fc 12990000 3096 call r21(r18) 982700 00000000 3097 nop 3098 pulsedone: 982704 1cd9f04c 3099 r21e = *Jeventdone 982708 00000000 3100 nop 98270c a0190000 3101 goto r21 982710 00000000 3102 nop 3103 checkcurvelow: 982714 1c43e1d7 3104 r3l = *(rate_control + 1) 982718 1ae10002 3105 r1 - 2 /* operational ?? */ 98271c 00af0008 3106 if(eq) pcgoto rate_oper2 982720 00000000 3107 nop 982724 1c43e1d9 3108 r3l = *(rate_control + 3) /* cal & diag use other half */ 982728 00000000 3109 nop 3110 rate_oper2: 98272c 1ae20001 3111 r2 - 1 /* only check first one */ 982730 018fffb8 3112 if(gt) pcgoto saveevent 982734 00000000 3113 nop 982738 1c82e072 3114 r2 = *partevent 98273c 00000000 3115 nop 982740 14420001 3116 r2 += 1 982744 00000000 3117 nop 982748 1d82e072 3118 *partevent = r2 98274c 18e20060 3119 r2 - r3 /* time to save one */ 982750 016fff98 3120 if(lt) pcgoto saveevent 982754 14400000 3121 r2 = 0 982758 1d82e072 3122 *partevent = r2 3123 3124 /* saveshape */ 3125 3126 3127 3128 saveshape: 3129 /* compress data into buffer */ 98275c 1c81e06e 3130 r1 = *bufferno 982760 00000000 3131 nop 982764 1be1ffff 3132 r1 & 0xffff /* is buffer 1 going out ? */ 982768 00af00d4 3133 if(eq) pcgoto compbuf0 98276c 00000000 3134 nop 982770 1c81e05a 3135 r1 = *curves1 982774 1c82e056 3136 r2 = *events1 982778 14210001 3137 r1 += 1 /* see if there is room for one more curve */ 98277c 18210020 3138 r1 = r1*2 982780 18210020 3139 r1 = r1*2 982784 18210020 3140 r1 = r1*2 982788 18030a01 3141 r3 = r1 98278c 18210020 3142 r1 = r1*2 982790 18030020 3143 r3 += r1 /* r3 = 24x # of potential curves */ 982794 00000000 3144 nop 982798 14200094 3145 r1 = MAXBUFFER 98279c 18810060 3146 r1 -= r3 9827a0 18810040 3147 r1 -= r2 9827a4 01afff44 3148 if(le) pcgoto saveevent 9827a8 00000000 3149 nop 9827ac 1c81e05a 3150 r1 = *curves1 3151 /* location of next event info */ 9827b0 18230040 3152 r3 = r2*2 9827b4 18230060 3153 r3 = r3*2 9827b8 180202e0 3154 r2 = r2 + 1 9827bc 1ccce014 3155 r12e = *rawpointer /* data record for this event */ 3156 9827c0 1d82e056 3157 *events1 = r2 9827c4 1ccbe004 3158 r11e = *eventbuffer1 9827c8 958c0038 3159 r12e += 0x38 /* point to id */ 9827cc 980b0060 3160 r11e += r3 3161 3162 /* get ident , ttp from shape record */ 9827d0 1ea80197 3163 r8 = *r12++ 9827d4 1ea40197 3164 r4 = *r12++ 9827d8 14400000 3165 r2 = 0 9827dc 1ea90197 3166 r9 = *r12++ 3167 9827e0 1fa80177 3168 *r11++ = r8 9827e4 1fa20170 3169 *r11 = r2 /* events set */ 3170 sizeld3: 9827e8 946f0658 3171 r3e = pc + (sizetable - sizeld3 - 8) 9827ec 98030020 3172 r3e += r1 9827f0 98030020 3173 r3e += r1 9827f4 00000000 3174 nop 9827f8 14210001 3175 r1 += 1 9827fc 1ea40070 3176 r4 = *r3 /* position of next shape */ 982800 1d81e05a 3177 *curves1 = r1 982804 18240080 3178 r4=r4*2 982808 1cc2e00c 3179 r2e = *curvebuffer1 98280c 00000000 3180 nop 982810 98020080 3181 r2e += r4 982814 00000000 3182 nop 982818 c0040000 3183 r4e = 0 98281c 98010a0c 3184 r1e = r12 3185 982820 1fa80057 3186 *r2++ = r8 982824 1fa40057 3187 *r2++ = r4 982828 1fa90057 3188 *r2++ = r9 3189 /* change next instruction to have energy 1st entry in shape */ 3190 /* r1e += 2 */ 98282c 1cd9f068 3191 r21e = *Ccompress 982830 00000000 3192 nop 982834 12990000 3193 call r21(r18) 982838 00000000 3194 nop 98283c a00f00cc 3195 pcgoto compdone 982840 00000000 3196 nop 3197 compbuf0: 982844 1c81e058 3198 r1 = *curves0 982848 1c82e054 3199 r2 = *events0 98284c 14210001 3200 r1 += 1 /* see if there is room for one more curve */ 982850 18210020 3201 r1 = r1*2 982854 18210020 3202 r1 = r1*2 982858 18210020 3203 r1 = r1*2 98285c 18030a01 3204 r3 = r1 982860 18210020 3205 r1 = r1*2 982864 18030020 3206 r3 += r1 /* r3 = 24x # of potential curves */ 982868 00000000 3207 nop 98286c 14200094 3208 r1 = MAXBUFFER 982870 18810060 3209 r1 -= r3 982874 18810040 3210 r1 -= r2 982878 01affe70 3211 if(le) pcgoto saveevent 98287c 00000000 3212 nop 982880 1c81e058 3213 r1 = *curves0 3214 /* location of next event info */ 982884 18230040 3215 r3 = r2*2 982888 18230060 3216 r3 = r3*2 98288c 180202e0 3217 r2 = r2 + 1 982890 1ccce014 3218 r12e = *rawpointer /* data record for this event */ 3219 982894 1d82e054 3220 *events0 = r2 982898 1ccbe000 3221 r11e = *eventbuffer0 98289c 958c0038 3222 r12e += 0x38 /* point to id */ 9828a0 980b0060 3223 r11e += r3 3224 /* get ident , ttp from shape record */ 9828a4 1ea80197 3225 r8 = *r12++ 9828a8 1ea40197 3226 r4 = *r12++ 9828ac 14400000 3227 r2 = 0 9828b0 1ea90197 3228 r9 = *r12++ 3229 9828b4 1fa80177 3230 *r11++ = r8 9828b8 1fa20170 3231 *r11 = r2 /* events set */ 3232 sizeld4: 9828bc 946f0584 3233 r3e = pc + (sizetable - sizeld4 - 8) 9828c0 98030020 3234 r3e += r1 9828c4 98030020 3235 r3e += r1 9828c8 00000000 3236 nop 9828cc 14210001 3237 r1 += 1 9828d0 1ea40070 3238 r4 = *r3 /* position of next shape */ 9828d4 1d81e058 3239 *curves0 = r1 9828d8 18240080 3240 r4 = r4*2 9828dc 1cc2e008 3241 r2e = *curvebuffer0 9828e0 00000000 3242 nop 9828e4 98020080 3243 r2e += r4 9828e8 00000000 3244 nop 9828ec c0040000 3245 r4e = 0 9828f0 98010a0c 3246 r1e = r12 3247 9828f4 1fa80057 3248 *r2++ = r8 9828f8 1fa40057 3249 *r2++ = r4 9828fc 1fa90057 3250 *r2++ = r9 3251 /* change next instruction to have energy 1st entry in shape */ 3252 /* r1e += 2 */ 982900 1cd9f068 3253 r21e = *Ccompress 982904 00000000 3254 nop 982908 12990000 3255 call r21(r18) 98290c 00000000 3256 nop 3257 compdone: 3265 #endif 982910 1cd9f04c 3266 r21e = *Jeventdone 982914 00000000 3267 nop 982918 a0190000 3268 goto r21 98291c 00000000 3269 nop 3270 eventdone: 982920 1cd9f008 3271 r21e = *Jmain 982924 00000000 3272 nop 982928 a0190000 3273 goto r21 98292c 00000000 3274 nop 3275 3276 3277 /* callable routine to collect selection statistics */ 3278 statcollect: 982930 1ccce014 3279 r12e = *rawpointer 982934 dfe7e284 3280 r7e = rawstats 982938 958c0038 3281 r12e += 0x38 /* point to id */ 98293c 00000000 3282 nop 982940 1ea60190 3283 r6 = *r12 982944 958c0004 3284 r12e += 4 /* point to ttp */ 982948 1bc6001f 3285 r6 &= 0x1f /* detector number */ 98294c 182600c0 3286 r6 = r6 * 2 982950 182600c0 3287 r6 = r6 * 2 982954 1ea80190 3288 r8 = *r12 982958 980700c0 3289 r7e += r6 98295c 1be88000 3290 r8 & 0x8000 982960 00af0004 3291 if(eq) pcgoto stathigh 982964 00000000 3292 nop 982968 94e70002 3293 r7e += 2 3294 stathigh: 98296c 00000000 3295 nop 982970 1ea600f0 3296 r6 = *r7 982974 00000000 3297 nop 982978 14c60001 3298 r6 += 1 98297c 00af0004 3299 if(eq) pcgoto statsatt 982980 00000000 3300 nop 982984 1fa600f0 3301 *r7 = r6 3302 statsatt: 982988 00340000 3303 return(r18) 98298c 00000000 3304 nop 3305 3306 /* callable routine to save an event */ 3307 eventroutine: 982990 1c81e050 3308 r1 = *state 982994 00000000 3309 nop 982998 1ae10004 3310 r1 - 4 /* calibration ?? -- a treat for Pascal */ 3311 /* if(eq) pcgoto eventexit -- removed at request of la belle France flight2 */ 98299c 00000000 3312 nop 9829a0 00000000 3313 nop 9829a4 1c81e06e 3314 r1 = *bufferno 9829a8 00000000 3315 nop 9829ac 1be1ffff 3316 r1 & 0xffff /* is buffer 1 going out ? */ 9829b0 00af0058 3317 if(eq) pcgoto eventbuf0 9829b4 00000000 3318 nop 9829b8 1c81e05a 3319 r1 = *curves1 9829bc 1c82e056 3320 r2 = *events1 3321 /* need to control total buffer size if there are too many curves */ 3322 /* each curve is equal to 24 events */ 9829c0 18210020 3323 r1 = r1*2 9829c4 18210020 3324 r1 = r1*2 9829c8 18210020 3325 r1 = r1*2 9829cc 18030a01 3326 r3 = r1 9829d0 18210020 3327 r1 = r1*2 9829d4 18030020 3328 r3 += r1 9829d8 00000000 3329 nop 9829dc 14200094 3330 r1 = MAXBUFFER 9829e0 18810060 3331 r1 -= r3 9829e4 18810040 3332 r1 -= r2 9829e8 01af0098 3333 if(le) pcgoto eventexit /* max number */ 9829ec 00000000 3334 nop 9829f0 18240040 3335 r4 = r2*2 9829f4 18240080 3336 r4 = r4*2 9829f8 180202e0 3337 r2 = r2 + 1 9829fc 1ccce014 3338 r12e = *rawpointer /* data record for this event */ 982a00 1d82e056 3339 *events1 = r2 982a04 1ccbe004 3340 r11e = *eventbuffer1 982a08 a00f0054 3341 pcgoto geventadd 982a0c 958c0038 3342 r12e += 0x38 /* point to id */ 3343 eventbuf0: 982a10 1c81e058 3344 r1 = *curves0 982a14 1c82e054 3345 r2 = *events0 3346 /* need to control total buffer size if there are too many curves */ 3347 /* each curve is equal to 24 events */ 982a18 18210020 3348 r1 = r1*2 982a1c 18210020 3349 r1 = r1*2 982a20 18210020 3350 r1 = r1*2 982a24 18030a01 3351 r3 = r1 982a28 18210020 3352 r1 = r1*2 982a2c 18030020 3353 r3 += r1 982a30 00000000 3354 nop 982a34 14200094 3355 r1 = MAXBUFFER 982a38 18810060 3356 r1 -= r3 982a3c 18810040 3357 r1 -= r2 982a40 01af0040 3358 if(le) pcgoto eventexit /* max number */ 982a44 00000000 3359 nop 3360 982a48 18240040 3361 r4 = r2*2 982a4c 18240080 3362 r4 = r4*2 982a50 180202e0 3363 r2 = r2 + 1 982a54 1ccce014 3364 r12e = *rawpointer /* data record for this event */ 982a58 1d82e054 3365 *events0 = r2 982a5c 1ccbe000 3366 r11e = *eventbuffer0 982a60 958c0038 3367 r12e += 0x38 /* point to id */ 3368 geventadd: 982a64 00000000 3369 nop 982a68 1ea80197 3370 r8 = *r12++ 982a6c 1ea20197 3371 r2 = *r12++ 3372 982a70 980b0080 3373 r11e += r4 3374 982a74 1ea20190 3375 r2 = *r12 982a78 00000000 3376 nop 982a7c 1fa80177 3377 *r11++ = r8 982a80 00000000 3378 nop 982a84 1fa20170 3379 *r11 = r2 /* events set */ 3380 eventexit: 982a88 00340000 3381 return(r18) 982a8c 00000000 3382 nop 3383 3384 3385 /* the interrupt routine for getting pulses */ 3386 pulsebade: 982a90 1cc8e0a4 3387 r8e = *r8savep 3388 3389 3390 pulsebuffull: 982a94 1c49e06c 3391 r9l = *lastid 982a98 dfe3e25e 3392 r3e = rawrates 982a9c 18290120 3393 r9 = r9 * 2 982aa0 98030120 3394 r3e += r9 982aa4 1ea10070 3395 r1 = *r3 /* get present value */ 982aa8 00000000 3396 nop 982aac 14210001 3397 r1 += 1 /* increment it */ 982ab0 00af0004 3398 if(eq) pcgoto rateoverflownoe 982ab4 00000000 3399 nop 982ab8 1fa10070 3400 *r3 = r1 /* save rate */ 3401 rateoverflownoe: 3402 #ifdef BADID 3403 /* send id to dfe */ 982abc 1d03e06c 3404 *lastid = r3h /* detector no */ 982ac0 1c49e06c 3405 r9l = *lastid 982ac4 1c81e078 3406 r1 = *id 982ac8 c7230000 3407 r3e = DFELOAD 982acc 19490020 3408 r9 = r9 | r1 982ad0 14210020 3409 r1 = r1 + 0x20 982ad4 1bc17fe0 3410 r1 = r1 & 0x7fe0 3411 /* send id */ 982ad8 1fa90070 3412 *r3 = r9 982adc 1d89e06c 3413 *lastid = r9 /* flight2 */ 982ae0 1d81e078 3414 *id = r1 3415 /* routine to get the data from the fast A/D converter and wait for the ID to finish flight2 */ 982ae4 c6430000 3416 r3e = FASTAD 982ae8 1520000f 3417 r9 = 15 /* emperically determined to last until after id is finished */ 3418 xferloop2: 982aec 1ea10070 3419 r1 = *r3 982af0 00000000 3420 nop 982af4 1ea10070 3421 r1 = *r3 982af8 0d2fffec 3422 if (r9-- >= 0) pcgoto xferloop2 982afc 00000000 3423 nop 3424 /* above instructions flight2 */ 3425 #endif 982b00 1cc7e0a0 3426 r7e = *r7savep 982b04 1cc9e0a8 3427 r9e = *r9savep 3428 3429 notag: 982b08 1c41e070 3430 r1l = *fasthold 982b0c 00000000 3431 nop 982b10 1ae10000 3432 r1 - 0 982b14 008f0018 3433 if(ne) pcgoto xferkillt 982b18 c7430000 3434 r3e = ANARESET 982b1c 1cc1e094 3435 r1e = *r1savep 982b20 1cc2e098 3436 r2e = *r2savep 982b24 1fa30070 3437 *r3 = r3 982b28 1cc3e09c 3438 r3e = *r3savep 982b2c 003e0000 3439 ireturn 982b30 00000000 3440 nop 3441 /* mutex to turn off data collection */ 3442 xferkillt: 982b34 1d41e071 3443 *(fasthold+1) = r1l 982b38 1e82001e 3444 r2 = pcw 982b3c 00000000 3445 nop 982b40 1bc207ff 3446 r2 = r2 & 0x7ff /* serial interrupt */ 982b44 00000000 3447 nop 982b48 1f82001e 3448 pcw = r2 982b4c 1cc1e094 3449 r1e = *r1savep 982b50 1cc2e098 3450 r2e = *r2savep 982b54 1cc3e09c 3451 r3e = *r3savep 982b58 003e0000 3452 ireturn 982b5c 00000000 3453 nop 3454 3455 getpulse: 3456 /* save registers */ 982b60 1dc2e098 3457 *r2savep = r2e 3458 /* check here to see if a tag was given */ 982b64 c7620000 3459 r2e = STATUS 982b68 1dc3e09c 3460 *r3savep = r3e 982b6c 1ea30050 3461 r3 = *r2 /* get status */ 982b70 1dc1e094 3462 *r1savep = r1e 982b74 1be30002 3463 r3 & 0x2 /* check veto */ 982b78 00afff88 3464 if(eq) pcgoto notag 982b7c 1a830100 3465 r3 -= 0x100 /* Adjust for H3ry's Actel reporting scheme */ 982b80 1bc31f00 3466 r3 = r3 & 0x1f00 /* mask off detector bits */ 982b84 c6820000 3467 r2e = FASTENERGY 982b88 1d03e06c 3468 *lastid = r3h /* detector no */ /* flight2 */ 982b8c 1ea20050 3469 r2 = *r2 /* get energy */ 982b90 1dc9e0a8 3470 *r9savep = r9e 982b94 1dc7e0a0 3471 *r7savep = r7e 982b98 1c87e07e 3472 r7 = *pulsewrite 982b9c 1c89e080 3473 r9 = *pulseread 982ba0 14e70001 3474 r7 += 1 982ba4 1c81e082 3475 r1 = *pulsemax 982ba8 1ae90000 3476 r9 - 0 982bac 18095420 3477 if(eq) r9 += r1 /* rollover boundary */ 3478 /* r7 has incremented write pointer */ 982bb0 184900e0 3479 r9 = r7 - r9 982bb4 00affed8 3480 if(eq) pcgoto pulsebuffull 982bb8 14201200 3481 r1 = 0x1200 /* last detector value */ 982bbc 18e30020 3482 r3 - r1 982bc0 018ffecc 3483 if(gt) pcgoto pulsebuffull 982bc4 dfe1e0dc 3484 r1e = energythresh 982bc8 1c49e06c 3485 r9l = *lastid 982bcc 1dc8e0a4 3486 *r8savep = r8e 982bd0 18080a09 3487 r8 = r9 3488 /* r8,r9 has detector number */ 982bd4 18290120 3489 r9 = r9 * 2 982bd8 18290120 3490 r9 = r9 * 2 /* det id x 4 */ 982bdc 98010120 3491 r1e += r9 982be0 1ea30037 3492 r3 = *r1++ /* lower limit */ 982be4 1ea10030 3493 r1 = *r1 /* upper limit */ 3494 /* check energy here */ 982be8 18e20060 3495 r2 - r3 982bec 016ffe9c 3496 if(lt) pcgoto pulsebade 982bf0 18e20020 3497 r2 - r1 982bf4 018ffe94 3498 if(gt) pcgoto pulsebade 982bf8 00000000 3499 nop 3500 982bfc 1dcae0ac 3501 *r10savep = r10e 982c00 1dcbe0b0 3502 *r11savep = r11e 982c04 1dcce0b4 3503 *r12savep = r12e 982c08 19a90120 3504 r9 = r9/2 3505 3506 3507 /* send id to dfe */ 982c0c 1c81e078 3508 r1 = *id 982c10 c7230000 3509 r3e = DFELOAD 982c14 19480020 3510 r8 = r8 | r1 982c18 1b488000 3511 r8 = r8 | 0x8000 /* valid event */ 3512 /* for eng model, put id here */ 3513 #ifndef LABTEST 982c1c 1fa80070 3514 *r3 = r8 /* send it out */ 982c20 1d88e06c 3515 *lastid = r8 /* flight2 */ 3516 #endif 982c24 14210020 3517 r1 = r1 + 0x20 /* advance id value */ 982c28 1bc17fe0 3518 r1 = r1 & 0x7fe0 982c2c dfe3e25e 3519 r3e = rawrates 982c30 1d81e078 3520 *id = r1 3521 3522 982c34 98030120 3523 r3e += r9 982c38 1ea10070 3524 r1 = *r3 /* get present value */ 982c3c 1c09e07e 3525 r9h = *pulsewrite 982c40 14210001 3526 r1 += 1 /* increment it */ 982c44 00af0004 3527 if(eq) pcgoto rateoverflow 982c48 00000000 3528 nop 982c4c 1fa10070 3529 *r3 = r1 /* save rate */ 3530 rateoverflow: 3531 982c50 1d89e08c 3532 *pulseaddi = r9 3535 #endif 982c54 1c49e07f 3536 r9l = *(pulsewrite + 1) 982c58 1c8be082 3537 r11 = *pulsemax 982c5c 1d89e08e 3538 *(pulseaddi + 2) = r9 982c60 1cc9e08c 3539 r9e = *pulseaddi 982c64 1ccce084 3540 r12e = *pulsebase 982c68 1d87e07e 3541 *pulsewrite = r7 982c6c 188a0967 3542 r10 = r7 - r11 982c70 016f0004 3543 if(lt) pcgoto nowrtroll 982c74 15600016 3544 r11 = 22 982c78 1d8ae07e 3545 *pulsewrite = r10 3546 nowrtroll: 982c7c 1c8ae07a 3547 r10 = *eightcount 982c80 980c0120 3548 r12e += r9 982c84 14e00000 3549 r7 = 0 982c88 1faa0190 3550 *r12 = r10 /* put 8 Hz # at front */ 982c8c 958c0038 3551 r12e += 0x38 982c90 1fa80197 3552 *r12++ = r8 /* id */ 982c94 1fa70197 3553 *r12++ = r7 982c98 1fa20197 3554 *r12++ = r2 982c9c 1fa20197 3555 *r12++ = r2 /* energy */ 982ca0 1dcde0b8 3556 *r13savep = r13e 3557 3558 /* routine to get the data from the fast A/D converter */ 982ca4 c64d0000 3559 r13e = FASTAD 3560 3561 /* throw away the the first 20 samples left in the A/D que from before */ 982ca8 1ea701b0 3562 r7 = *r13 982cac 1ea801b0 3563 r8 = *r13 982cb0 1ea901b0 3564 r9 = *r13 982cb4 1eaa01b0 3565 r10 = *r13 982cb8 1ea701b0 3566 r7 = *r13 982cbc 1ea801b0 3567 r8 = *r13 982cc0 1ea901b0 3568 r9 = *r13 982cc4 1eaa01b0 3569 r10 = *r13 982cc8 1ea701b0 3570 r7 = *r13 982ccc 1ea801b0 3571 r8 = *r13 982cd0 1ea901b0 3572 r9 = *r13 982cd4 1eaa01b0 3573 r10 = *r13 982cd8 1ea701b0 3574 r7 = *r13 982cdc 1ea801b0 3575 r8 = *r13 982ce0 1ea901b0 3576 r9 = *r13 982ce4 1eaa01b0 3577 r10 = *r13 982ce8 1ea701b0 3578 r7 = *r13 982cec 1ea801b0 3579 r8 = *r13 982cf0 1ea901b0 3580 r9 = *r13 982cf4 1eaa01b0 3581 r10 = *r13 3582 3583 xferloop1: 982cf8 1ea701b0 3584 r7 = *r13 982cfc 1ea801b0 3585 r8 = *r13 982d00 1ea901b0 3586 r9 = *r13 982d04 1eaa01b0 3587 r10 = *r13 982d08 1fa70197 3588 *r12++ = r7 982d0c 1fa80197 3589 *r12++ = r8 982d10 1fa90197 3590 *r12++ = r9 982d14 1faa0197 3591 *r12++ = r10 982d18 0d6fffd8 3592 if (r11-- >= 0) pcgoto xferloop1 982d1c 00000000 3593 nop 3599 #endif 3600 xferexit: 982d20 1c4ce070 3601 r12l = *fasthold 982d24 00000000 3602 nop 982d28 1aec0000 3603 r12 - 0 982d2c 008f0034 3604 if(ne) pcgoto xferkill 982d30 c74d0000 3605 r13e = ANARESET 982d34 1cc1e094 3606 r1e = *r1savep 982d38 1cc2e098 3607 r2e = *r2savep 982d3c 1cc3e09c 3608 r3e = *r3savep 982d40 1cc7e0a0 3609 r7e = *r7savep 982d44 1cc8e0a4 3610 r8e = *r8savep 982d48 1cc9e0a8 3611 r9e = *r9savep 982d4c 1ccae0ac 3612 r10e = *r10savep 982d50 1ccbe0b0 3613 r11e = *r11savep 982d54 1fa901b0 3614 *r13 = r9 982d58 1ccce0b4 3615 r12e = *r12savep 982d5c 1ccde0b8 3616 r13e = *r13savep 3617 982d60 003e0000 3618 ireturn 982d64 00000000 3619 nop 3620 /* mutex to turn off data collection */ 3621 xferkill: 982d68 1d4ce071 3622 *(fasthold+1) = r12l 982d6c 1e81001e 3623 r1 = pcw 982d70 00000000 3624 nop 982d74 1bc107ff 3625 r1 = r1 & 0x7ff /* serial interrupt */ 982d78 00000000 3626 nop 982d7c 1f81001e 3627 pcw = r1 982d80 00000000 3628 nop 982d84 c74d0000 3629 r13e = ANARESET 982d88 1cc1e094 3630 r1e = *r1savep 982d8c 1cc2e098 3631 r2e = *r2savep 982d90 1cc3e09c 3632 r3e = *r3savep 982d94 1cc7e0a0 3633 r7e = *r7savep 982d98 1cc8e0a4 3634 r8e = *r8savep 982d9c 1cc9e0a8 3635 r9e = *r9savep 982da0 1ccae0ac 3636 r10e = *r10savep 982da4 1ccbe0b0 3637 r11e = *r11savep 982da8 1ccce0b4 3638 r12e = *r12savep 982dac 1ccde0b8 3639 r13e = *r13savep 3640 982db0 003e0000 3641 ireturn 982db4 00000000 3642 nop 3643 3644 3645 3646 3647 /* r1 points to event buffer */ 3648 /* r2 points to data */ 3649 /* does 9 bit packing of shape data */ 3650 /* r4 is bit position for next word */ 3651 /* r5 is scratch */ 3652 /* r6 is the working register */ 3653 /* r7 is scratch */ 3654 /* r8 is a count of words to convert */ 3655 3656 3657 compress: 982db8 14800000 3658 r4 = 0 982dbc 14c00000 3659 r6 = 0 982dc0 1500004f 3660 r8 = 79 /* 80 words */ 982dc4 00000000 3661 nop 3662 comploop: 982dc8 1ae40008 3663 r4 - 8 982dcc 016f0030 3664 if(lt) pcgoto compnext 982dd0 00000000 3665 nop 982dd4 1f660057 3666 *r2++ = r6l 982dd8 198600c0 3667 r6 = r6>>1 982ddc 198600c0 3668 r6 = r6>>1 982de0 198600c0 3669 r6 = r6>>1 982de4 198600c0 3670 r6 = r6>>1 982de8 198600c0 3671 r6 = r6>>1 982dec 198600c0 3672 r6 = r6>>1 982df0 198600c0 3673 r6 = r6>>1 982df4 198600c0 3674 r6 = r6>>1 982df8 1a840008 3675 r4 = r4 -8 982dfc bfefffc4 3676 pcgoto comploop 982e00 00000000 3677 nop 3678 compnext: 982e04 1ea50037 3679 r5 = *r1++ 982e08 00000000 3680 nop 982e0c 1bc501ff 3681 r5 = r5 & 0x1ff 982e10 18070ac4 3682 r7 = r4 -1 982e14 00000000 3683 nop 982e18 016f000c 3684 if(lt) pcgoto nocompshift 982e1c 188702e0 3685 r7 = r7 - 1 982e20 00000000 3686 nop 3687 compleft: 982e24 0ceffff8 3688 if(r7-- >= 0) pcgoto compleft 982e28 182500a0 3689 r5 = r5 * 2 3690 nocompshift: 982e2c 194600a0 3691 r6 = r6 | r5 982e30 14840009 3692 r4 = r4 + 9 982e34 0d0fff8c 3693 if(r8-- >=0 ) pcgoto comploop 982e38 00000000 3694 nop 982e3c 00340000 3695 return(r18) 982e40 00000000 3696 nop 982e44 00000000 3697 nop 3698 /* table of sizes needed for compressed shapes */ 3699 sizetable: 982e48 0000 3700 int 0,48,96,144,192,240,288,336,384,432,480,528,576 982e4a 0030 3700 982e4c 0060 3700 982e4e 0090 3700 982e50 00c0 3700 982e52 00f0 3700 982e54 0120 3700 982e56 0150 3700 982e58 0180 3700 982e5a 01b0 3700 982e5c 01e0 3700 982e5e 0210 3700 982e60 0240 3700 982e62 00 3701 .align 4 982e63 00 3701 3702 testdata1: 982e64 0000 3703 int 0,10,20,30,40,50,60,70,80,90 982e66 000a 3703 982e68 0014 3703 982e6a 001e 3703 982e6c 0028 3703 982e6e 0032 3703 982e70 003c 3703 982e72 0046 3703 982e74 0050 3703 982e76 005a 3703 982e78 0064 3704 int 100,110,120,130,140,150,160,170,180,190 982e7a 006e 3704 982e7c 0078 3704 982e7e 0082 3704 982e80 008c 3704 982e82 0096 3704 982e84 00a0 3704 982e86 00aa 3704 982e88 00b4 3704 982e8a 00be 3704 982e8c 00c8 3705 int 200,210,220,230,240,250,260,260,280,290 982e8e 00d2 3705 982e90 00dc 3705 982e92 00e6 3705 982e94 00f0 3705 982e96 00fa 3705 982e98 0104 3705 982e9a 0104 3705 982e9c 0118 3705 982e9e 0122 3705 982ea0 012c 3706 int 300,310,320,330,340,350,360,370,380,390 982ea2 0136 3706 982ea4 0140 3706 982ea6 014a 3706 982ea8 0154 3706 982eaa 015e 3706 982eac 0168 3706 982eae 0172 3706 982eb0 017c 3706 982eb2 0186 3706 982eb4 0186 3707 int 390,380,370,360,350,340,330,320,310,300 982eb6 017c 3707 982eb8 0172 3707 982eba 0168 3707 982ebc 015e 3707 982ebe 0154 3707 982ec0 014a 3707 982ec2 0140 3707 982ec4 0136 3707 982ec6 012c 3707 982ec8 0122 3708 int 290,280,270,260,250,240,230,220,210,200 982eca 0118 3708 982ecc 010e 3708 982ece 0104 3708 982ed0 00fa 3708 982ed2 00f0 3708 982ed4 00e6 3708 982ed6 00dc 3708 982ed8 00d2 3708 982eda 00c8 3708 982edc 00be 3709 int 190,180,170,160,150,140,130,120,110,100 982ede 00b4 3709 982ee0 00aa 3709 982ee2 00a0 3709 982ee4 0096 3709 982ee6 008c 3709 982ee8 0082 3709 982eea 0078 3709 982eec 006e 3709 982eee 0064 3709 982ef0 005a 3710 int 90,80,70,60,50,40,30,20,10,0 982ef2 0050 3710 982ef4 0046 3710 982ef6 003c 3710 982ef8 0032 3710 982efa 0028 3710 982efc 001e 3710 982efe 0014 3710 982f00 000a 3710 982f02 0000 3710 982f04 0000 3711 int 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 982f06 0000 3711 982f08 0000 3711 982f0a 0000 3711 982f0c 0000 3711 982f0e 0000 3711 982f10 0000 3711 982f12 0000 3711 982f14 0000 3711 982f16 0000 3711 982f18 0000 3711 982f1a 0000 3711 982f1c 0000 3711 982f1e 0000 3711 982f20 0000 3711 982f22 0000 3711 3712 testdata2: 982f24 0000 3713 int 0,1,2,3,4,5,6,7,8,9 982f26 0001 3713 982f28 0002 3713 982f2a 0003 3713 982f2c 0004 3713 982f2e 0005 3713 982f30 0006 3713 982f32 0007 3713 982f34 0008 3713 982f36 0009 3713 982f38 000a 3714 int 10,11,12,13,14,15,16,17,18,19 982f3a 000b 3714 982f3c 000c 3714 982f3e 000d 3714 982f40 000e 3714 982f42 000f 3714 982f44 0010 3714 982f46 0011 3714 982f48 0012 3714 982f4a 0013 3714 982f4c 0014 3715 int 20,21,22,23,24,25,26,26,28,29 982f4e 0015 3715 982f50 0016 3715 982f52 0017 3715 982f54 0018 3715 982f56 0019 3715 982f58 001a 3715 982f5a 001a 3715 982f5c 001c 3715 982f5e 001d 3715 982f60 001e 3716 int 30,31,32,33,34,35,36,37,38,39 982f62 001f 3716 982f64 0020 3716 982f66 0021 3716 982f68 0022 3716 982f6a 0023 3716 982f6c 0024 3716 982f6e 0025 3716 982f70 0026 3716 982f72 0027 3716 982f74 0027 3717 int 39,38,37,36,35,34,33,32,31,30 982f76 0026 3717 982f78 0025 3717 982f7a 0024 3717 982f7c 0023 3717 982f7e 0022 3717 982f80 0021 3717 982f82 0020 3717 982f84 001f 3717 982f86 001e 3717 982f88 001d 3718 int 29,28,27,26,25,24,23,22,21,20 982f8a 001c 3718 982f8c 001b 3718 982f8e 001a 3718 982f90 0019 3718 982f92 0018 3718 982f94 0017 3718 982f96 0016 3718 982f98 0015 3718 982f9a 0014 3718 982f9c 0013 3719 int 19,18,17,16,15,14,13,12,11,10 982f9e 0012 3719 982fa0 0011 3719 982fa2 0010 3719 982fa4 000f 3719 982fa6 000e 3719 982fa8 000d 3719 982faa 000c 3719 982fac 000b 3719 982fae 000a 3719 982fb0 0009 3720 int 9,8,7,6,5,4,3,2,1,0 982fb2 0008 3720 982fb4 0007 3720 982fb6 0006 3720 982fb8 0005 3720 982fba 0004 3720 982fbc 0003 3720 982fbe 0002 3720 982fc0 0001 3720 982fc2 0000 3720 982fc4 0000 3721 int 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 982fc6 0000 3721 982fc8 0000 3721 982fca 0000 3721 982fcc 0000 3721 982fce 0000 3721 982fd0 0000 3721 982fd2 0000 3721 982fd4 0000 3721 982fd6 0000 3721 982fd8 0000 3721 982fda 0000 3721 982fdc 0000 3721 982fde 0000 3721 982fe0 0000 3721 982fe2 0000 3721 3722 testdata3: 982fe4 0001 3723 int 1,1,1,1,1,1,1,1,1,1 982fe6 0001 3723 982fe8 0001 3723 982fea 0001 3723 982fec 0001 3723 982fee 0001 3723 982ff0 0001 3723 982ff2 0001 3723 982ff4 0001 3723 982ff6 0001 3723 982ff8 0001 3724 int 1,1,1,1,1,1,1,1,1,1 982ffa 0001 3724 982ffc 0001 3724 982ffe 0001 3724 983000 0001 3724 983002 0001 3724 983004 0001 3724 983006 0001 3724 983008 0001 3724 98300a 0001 3724 98300c 0001 3725 int 1,1,1,1,1,1,1,1,1,1 98300e 0001 3725 983010 0001 3725 983012 0001 3725 983014 0001 3725 983016 0001 3725 983018 0001 3725 98301a 0001 3725 98301c 0001 3725 98301e 0001 3725 983020 0001 3726 int 1,1,1,1,1,1,1,1,1,1 983022 0001 3726 983024 0001 3726 983026 0001 3726 983028 0001 3726 98302a 0001 3726 98302c 0001 3726 98302e 0001 3726 983030 0001 3726 983032 0001 3726 983034 0001 3727 int 1,1,1,1,1,1,1,1,1,1 983036 0001 3727 983038 0001 3727 98303a 0001 3727 98303c 0001 3727 98303e 0001 3727 983040 0001 3727 983042 0001 3727 983044 0001 3727 983046 0001 3727 983048 0001 3728 int 1,1,1,1,1,1,1,1,1,1 98304a 0001 3728 98304c 0001 3728 98304e 0001 3728 983050 0001 3728 983052 0001 3728 983054 0001 3728 983056 0001 3728 983058 0001 3728 98305a 0001 3728 98305c 0001 3729 int 1,1,1,1,1,1,1,1,1,1 98305e 0001 3729 983060 0001 3729 983062 0001 3729 983064 0001 3729 983066 0001 3729 983068 0001 3729 98306a 0001 3729 98306c 0001 3729 98306e 0001 3729 983070 0001 3730 int 1,1,1,1,1,1,1,1,1,1 983072 0001 3730 983074 0001 3730 983076 0001 3730 983078 0001 3730 98307a 0001 3730 98307c 0001 3730 98307e 0001 3730 983080 0001 3730 983082 0001 3730 983084 0000 3731 int 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 983086 0000 3731 983088 0000 3731 98308a 0000 3731 98308c 0000 3731 98308e 0000 3731 983090 0000 3731 983092 0000 3731 983094 0000 3731 983096 0000 3731 983098 0000 3731 98309a 0000 3731 98309c 0000 3731 98309e 0000 3731 9830a0 0000 3731 9830a2 0000 3731 3732 testdata4: 9830a4 0010 3733 int 16,512,16,512,16,512,16,512,16,512 9830a6 0200 3733 9830a8 0010 3733 9830aa 0200 3733 9830ac 0010 3733 9830ae 0200 3733 9830b0 0010 3733 9830b2 0200 3733 9830b4 0010 3733 9830b6 0200 3733 9830b8 0008 3734 int 8,256,8,256,8,256,8,256,8,256 9830ba 0100 3734 9830bc 0008 3734 9830be 0100 3734 9830c0 0008 3734 9830c2 0100 3734 9830c4 0008 3734 9830c6 0100 3734 9830c8 0008 3734 9830ca 0100 3734 9830cc 0004 3735 int 4,128,4,128,4,128,4,128,4,128 9830ce 0080 3735 9830d0 0004 3735 9830d2 0080 3735 9830d4 0004 3735 9830d6 0080 3735 9830d8 0004 3735 9830da 0080 3735 9830dc 0004 3735 9830de 0080 3735 9830e0 0002 3736 int 2,64,2,64,2,64,2,64,2,64 9830e2 0040 3736 9830e4 0002 3736 9830e6 0040 3736 9830e8 0002 3736 9830ea 0040 3736 9830ec 0002 3736 9830ee 0040 3736 9830f0 0002 3736 9830f2 0040 3736 9830f4 0001 3737 int 1,32,1,32,1,32,1,32,1,32 9830f6 0020 3737 9830f8 0001 3737 9830fa 0020 3737 9830fc 0001 3737 9830fe 0020 3737 983100 0001 3737 983102 0020 3737 983104 0001 3737 983106 0020 3737 983108 01ff 3738 int 511,0,511,0,511,0,511,0,511,0 98310a 0000 3738 98310c 01ff 3738 98310e 0000 3738 983110 01ff 3738 983112 0000 3738 983114 01ff 3738 983116 0000 3738 983118 01ff 3738 98311a 0000 3738 98311c 6f43 3739 int 0x6f43,0x7970,0x6972,0x6867,0x2074,0x2053,0x634d,0x7242,0x6469,0x2065 98311e 7970 3739 983120 6972 3739 983122 6867 3739 983124 2074 3739 983126 2053 3739 983128 634d 3739 98312a 7242 3739 98312c 6469 3739 98312e 2065 3739 983130 6e55 3740 int 0x6e55,0x7669,0x6f20,0x2066,0x6143,0x696c,0x6f66,0x6e72,0x6169,0x6120 983132 7669 3740 983134 6f20 3740 983136 2066 3740 983138 6143 3740 98313a 696c 3740 98313c 6f66 3740 98313e 6e72 3740 983140 6169 3740 983142 6120 3740 983144 6c6c 3741 int 0x6c6c,0x7220,0x6769,0x7468,0x2073,0x6572,0x6573,0x7672,0x6465,0,0,0,0,0,0,0 983146 7220 3741 983148 6769 3741 98314a 7468 3741 98314c 2073 3741 98314e 6572 3741 983150 6573 3741 983152 7672 3741 983154 6465 3741 983156 0000 3741 983158 0000 3741 98315a 0000 3741 98315c 0000 3741 98315e 0000 3741 983160 0000 3741 983162 0000 3741 3742 /* default library selection and control table */ 3743 def_lib_control: 983164 4000 3744 def_lib0: int 0x4000, 0x001a 983166 001a 3744 983168 4000 3745 def_lib1: int 0x4000, 0x001a 98316a 001a 3745 98316c 4000 3746 def_lib2: int 0x4000, 0x001a 98316e 001a 3746 983170 4000 3747 def_lib3: int 0x4000, 0x001a 983172 001a 3747 983174 4000 3748 def_lib4: int 0x4000, 0x001a 983176 001a 3748 983178 4000 3749 def_lib5: int 0x4000, 0x001a 98317a 001a 3749 98317c 4000 3750 def_lib6: int 0x4000, 0x001a 98317e 001a 3750 983180 4000 3751 def_lib7: int 0x4000, 0x001a 983182 001a 3751 983184 4000 3752 def_lib8: int 0x4000, 0x001a 983186 001a 3752 983188 4000 3753 def_lib9: int 0x4000, 0x001a 98318a 001a 3753 98318c 4000 3754 def_lib10: int 0x4000, 0x001a 98318e 001a 3754 983190 4000 3755 def_lib11: int 0x4000, 0x001a 983192 001a 3755 983194 4000 3756 def_lib12: int 0x4000, 0x001a 983196 001a 3756 983198 4000 3757 def_lib13: int 0x4000, 0x001a 98319a 001a 3757 98319c 4000 3758 def_lib14: int 0x4000, 0x001a 98319e 001a 3758 9831a0 4000 3759 def_lib15: int 0x4000, 0x001a 9831a2 001a 3759 9831a4 4000 3760 def_lib16: int 0x4000, 0x001a 9831a6 001a 3760 9831a8 4000 3761 def_lib17: int 0x4000, 0x001a 9831aa 001a 3761 9831ac 4000 3762 def_lib18: int 0x4000, 0x001a 9831ae 001a 3762 9831b0 00 3763 def_libglob: byte 0,0 9831b1 00 3763 3764 /* default library selection and control table */ 9831b2 00 3765 def_ad_offsets: byte 0 9831b3 00 3766 byte 0 9831b4 00 3767 byte 0 9831b5 00 3768 byte 0 9831b6 00 3769 byte 0 9831b7 00 3770 byte 0 9831b8 00 3771 byte 0 9831b9 00 3772 byte 0 3773 3774 _testend: 3775 1 /******************************************************************************/ 2 /* PSD - FM - Scientific Software */ 3 /* -------------------------------------------------------------------------- */ 4 /* Version: 1.08 */ 5 /* Date : 26-May-2000 */ 6 /* Author : Jurgen Knodlseder, CESR (C) 1999-2000 */ 7 /* -------------------------------------------------------------------------- */ 8 /* History: 1.02 29-Aug-1999 JK First version */ 9 /* 1.03 21-Sep-1999 JK adapt to Steve's interface, clean-up code */ 10 /* introduce algorithm parameters, apply */ 11 /* gain corrections. */ 12 /* 1.04 24-Sep-1999 JK First Berkeley version */ 13 /* 1.05 10-Oct-1999 JK Improved/debugged Berkeley version, new */ 14 /* library handling, inluded call tables */ 15 /* 1.06 26-Oct-1999 JK Verified first FM version */ 16 /* 1.07 15-Nov-1999 JK Implemented lower and upper limit */ 17 /* discrimination on pulse area; implemented */ 18 /* new Annex 21 definitions */ 19 /* 1.08 26-May-2000 JK Replaced do instruction in EEPROM code by */ 20 /* conventional loop */ 21 /* Initialise running average outlier counter */ 22 /* properly */ 23 /* -------------------------------------------------------------------------- */ 24 /* */ 25 /* Description: */ 26 /* ============ */ 27 /* This code fragment contains the scientific analysis routine of the PSD */ 28 /* on-board software. It interfaces with the functional on-board software */ 29 /* via the following subroutines: */ 30 /* */ 31 /* analinit(r18) : Initialise the analysis software */ 32 /* correlate(r18) : prepare libraries for fitting */ 33 /* - called at system startup with default parameters */ 34 /* - called after a complete set of library controls has */ 35 /* been received */ 36 /* anal(r18) : scientific analysis routine */ 37 /* addlibrary(r18) : add library */ 38 /* */ 39 /* The only constraint imposed on the register usage is that r18 should be */ 40 /* conserved for subroutine return and r14 should be conserved as stack */ 41 /* pointer. All other registers can be freely used in the subroutines. */ 42 /* Additional to these global subroutines there are the following internal */ 43 /* subroutines: */ 44 /* */ 45 /* inverse(r20) : invert accumulator a0 */ 46 /* calcoffset(r20) : calculate offset lookup tables */ 47 /* eewrite(r18) : write to EEPROM */ 48 /* posterror(r20) : post an error message */ 49 /* */ 50 /* General philosophy: */ 51 /* =================== */ 52 /* A pulse shape is stored in 96 16 Bit words which has been built from 4 */ 53 /* ADCs. The gain and offset of each ADC can be software adjusted using */ 54 /* the "ad_offsets" field from the ENG code. */ 55 /* The code is designed for a maximum of 64 bins per template and 50 */ 56 /* templates per library set. The actual memory allocation can be changed by */ 57 /* modifying the following definitions and recompilation of the code: */ 58 /* M_TPLS : Maximum number of templates bins */ 59 /* M_SHAPE_BINS : Maximum number of shape bins */ 60 /* M_TEMP_BINS : Maximum number of bins in template */ 61 /* Note that the available RAM only allows the storage of the information for */ 62 /* 38 templates of 64 Bins. Hence M_TPLS has been fixed to 38. */ 63 /* */ 64 /* Library management and control: */ 65 /* =============================== */ 66 /* The library templates are stored in a static sized array in EEPROM. For */ 67 /* detector a maximum of M_SETS library sets is available. However, due to */ 68 /* memory limits, the actual available number of library sets may be smaller */ 69 /* than M_SETS and is calculated at runtime in "analinit". In addition to */ 70 /* real library templates an additional "parameter" template is provided for */ 71 /* each library set and detector. This parameter block is loaded by */ 72 /* specifying 0xff (255 dec) as curve number during library upload. */ 73 /* The library is controlled by telemetry. 32 Bits are available for */ 74 /* controlling each detector + 16 Bits for global library control. This */ 75 /* information is accessed via the "library_control" array from ENG. This */ 76 /* array is organised as follows: */ 77 /* library_control[ 0] low = Set for detector 0 (0-7) */ 78 /* library_control[ 0] high = Number of bins in template to be used (0-64) */ 79 /* library_control[ 1] low = Number of templates to be used (0-38) */ 80 /* library_control[ 1] high = free */ 81 /* If either the number of bins in a template or the number of templates is */ 82 /* set to zero, no PSD analysis is performed for the corresponding detectors. */ 83 /* */ 84 /* Internal memory organisation: */ 85 /* ============================= */ 86 /* For the pulse shape analysis, "correlate" prepares a couple of arrays for */ 87 /* fast computation. The logic dimension of these arrays is static. In the */ 88 /* following, these arrays are described in some detail: */ 89 /* lib : library templates */ 90 /* 3d array (i,j,k): i: template bin (0:M_TEMP_BINS-1) */ 91 /* j: template # (0:M_TPLS-1) */ 92 /* k: detector # (0:M_DETS-1) */ 93 /* Axis-2 offsets: off_lib_2 (j*M_TEMP_BINS) */ 94 /* Axis-3 offsets: off_lib_3 (k*M_DETS) */ 95 /* */ 96 /* lib_x_lib : inner products of all templates with themselves */ 97 /* 2d array (i,j): i: template # (0:M_TPLS-1) */ 98 /* j: detector # (0:M_DETS-1) */ 99 /* Axis-2 offsets: off_lxl_2 (j*M_TPLS) */ 100 /* */ 101 /* lib1_x_lib2 : inner products among the templates */ 102 /* 3d array (i,j,k): i: template # 1 (0:M_TPLS-1) */ 103 /* j: template # 2 (0:M_TPLS-1) */ 104 /* k: detector # (0:M_DETS-1) */ 105 /* Axis-2 offsets: off_lxx_2 (j*M_TPLS) */ 106 /* Axis-3 offsets: off_lxx_3 (k*M_TPLS*M_TPLS) */ 107 /* */ 108 /* denominator : denominator for ALPHA calculation */ 109 /* 3d array (i,j,k): i: template # 1 (0:M_TPLS-1) */ 110 /* j: template # 2 (0:M_TPLS-1) */ 111 /* k: detector # (0:M_DETS-1) */ 112 /* Axis-2 offsets: off_lxx_2 (j*M_TPLS) */ 113 /* Axis-3 offsets: off_lxx_3 (k*M_TPLS*M_TPLS) */ 114 /* wgt-alpha : 15 Bit conversion factor (for ALPHA transmission) */ 115 /* 1d array (i): i: detector # (0:M_DETS-1) */ 116 /* */ 117 /* Debugging definitions (invoqued by assembler): */ 118 /* ============================================== */ 119 /* DEBUG : debugging code */ 120 /* ENGSTUB : use stub to emulate Steve's code */ 121 /* TESTDATA : use testdata */ 122 /* TESTLIB : use test parameters */ 123 /* EESTUB : use EEPROM stub */ 124 /* SETDETECTOR : test; fake detector number SETDETECTOR */ 125 /* LIBFM : use FM test library */ 126 /* LIBSAID : use Said test library */ 127 /* LIBBERKELEY : use Berkeley test library */ 128 /* */ 129 /* Analysis software timing: */ 130 /* ========================= */ 131 /* Date: 5-10-99 */ 132 /* Version: 1.05 */ 133 /* Configuration: 1 WS for external RAM */ 134 /* code and large arrays in "extA" RAM, local variables in */ 135 /* "ram0"-"ram2" (optimised array distribution for conflict */ 136 /* wait state minimisation) */ 137 /* +--------+-------+-------+-------+--------+--------+ */ 138 /* | | ics | ws | us | ns/ics | ws/ics | */ 139 /* +--------+-------+-------+-------+--------+--------+ */ 140 /* | step 0 | 242 | 280 | 31.2 | 129 | 1.16 | */ 141 /* | step 1 | 1076 | 1272 | 139.4 | 130 | 1.18 | */ 142 /* | step 2 | 228 | 228 | 28.5 | 125 | 1.00 | */ 143 /* | step 3 | 2547 | 5864 | 401.3 | 158 | 2.30 | */ 144 /* | step 4 | 2386 | 3006 | 313.7 | 131 | 1.26 | */ 145 /* | step 5 | 92 | 96 | 11.6 | 126 | 1.04 | */ 146 /* +--------+-------+-------+-------+--------+--------+ */ 147 /* | total | 6598 | 10738 | 902.2 | 141 | 1.63 | */ 148 /* +--------+-------+-------+-------+--------+--------+ */ 149 /* */ 150 /* Notes: */ 151 /* 28-08-99 : reduce # of memory conflict wait states by putting variables */ 152 /* that are successively accessed in different physical memories */ 153 /* (see 2.6.2, p 2-16) and by re-aranging memory access. */ 154 /* 21-09-99 : Note in chapter 4.4.3, p 4-15: Direct addressing is LIMITED TO */ 155 /* 16 BIT IMMEDIATE. 16 Bit addresses are Bit-15 extended to 24 */ 156 /* Bits, i.e. Bit-15 is copied into Bits 16-23 before being used. */ 157 /* This means that RAM0 through RAM2 can be accessed by 16 Bits */ 158 /* addresses since 0xEzzz and 0xFzzz will be extended to 0xFFEzzz */ 159 /* and 0xFFFzzz. However, EPROMA data (address 0x080000) and */ 160 /* ANALRAM data (address 0x989000) have Bit-15 set to 0, hence the */ 161 /* addresses would translate to 0x000000 and 0x009000, res- */ 162 /* pectively. These addresses are occupied by ROM, hence a */ 163 /* conflict would occur ... */ 164 /******************************************************************************/ 165 166 /******************************************************************************/ 167 /* Include ENG information */ 168 /* -------------------------------------------------------------------------- */ 169 /******************************************************************************/ 172 #endif 173 #ifndef ENGSTUB 174 #include "engmem.h" 1 #include 29 # endif 30 31 #define sp r14 2 3 /* Copyright 1998 Regents University of California All Rights Reserved 4 This software is for use in the Engineering Model and Flight Model of the PSD subassembly 5 of the Integral Spacecraft. Any other use without prior authorization is forbidden */ 6 7 8 /* next definition puts low speed serial records in memory for the SEM */ 9 #define SEMLSDIAG 10 /* next definition allows configuration loading while running */ 11 /* #define LABLOAD */ 12 13 /* this starts things up in calibration mode for testing */ 14 /*#define LABMODEL */ 15 16 /* slow io definitions for memory map */ 17 #define SWROM 0x0000a0 18 #define EPROMA 0x080000 19 #define EPROMB 0x100000 20 #define RAM 0x180000 21 #define RAMINIT 0x98004c 22 #define FASTRAM 0x980020 23 #define EPROMC 0x200000 24 #define EPROMD 0x280000 25 #define FIFO 0x300000 26 /* FASTENERGY no longer b20000 because of timing problems */ 27 #define FASTAD 0x320000 28 #define FASTENERGY 0x340000 29 #define HKAD 0x380000 30 #define DFELOAD 0x390000 31 #define ANARESET 0x3a0000 32 #define CONTROL 0x3b0000 33 #define STATUS 0x3b0000 34 #define DATA151 0x3f0000 35 #define CTRL151 0x3f0004 36 37 38 /* sync word keeps changing 39 #define SYNC1 0x5a 40 #define SYNC2 0xae 41 */ 42 #define SYNC1 0xa 43 #define SYNC2 0x5 44 /* use RAM2 for program storage */ 45 #define INTRAM 0xffe000 46 /* this will sign extend into INTRAM */ 47 #define STORAGE 0xe000 48 /* this is defined with .rsect ".ram2" and the location set with a linker directive */ 49 /* use this on chip ram for the serial interrupts */ 50 #define SERIALRAML 0xfff800 51 #define SERIALRAM 0xf800 52 #define SERIALINTOP 768 53 #define SERIALOUTOFF 768 54 #define SERIALOUTBUF SERIALRAM + SERIALOUTOFF 55 #define SERIALOUTBUFL SERIALRAML + SERIALOUTOFF 56 #define SERIALINPT SERIALRAM + 0x7f0 57 #define SERIALINCNT SERIALRAM + 0x7f4 58 #define SERIALINEXP SERIALRAM + 0x7f8 59 #define SERIALINCHK SERIALRAM + 0x7fc 60 #define SERIALINCMD SERIALRAM + 0x7fe 61 #define SERIALOUTPT SERIALRAM + 0x7e0 62 #define SERIALOUTCNT SERIALRAM + 0x7e4 63 #define SERIALOUTEXP SERIALRAM + 0x7e8 64 #define SERIALOUTCHK SERIALRAM + 0x7ec 65 #define SERIALGETPT SERIALRAM + 0x7d0 66 #define SERIALGETCNT SERIALRAM + 0x7d4 67 #define SERIALOUTFIRST SERIALRAM + 0x7dc 68 #define SERIALOUTDATA SERIALRAM + 0x7d8 69 #define DUMPCHAR SERIALRAM + 0x7c3 70 #define DUMPCHARL SERIALRAML + 0x7c3 71 #define ADDTEMPL SERIALRAML + 0x7c4 72 #define SERIALDEBUG SERIALRAM + 0x7cc 73 74 /* next parameters are for communicating with semgse */ 75 #ifdef SEMLSDIAG 76 #define SERIALFLAG SERIALRAM + 0x7b0 77 #define SERIALIND SERIALRAM + 0x750 78 #define SERIALINDL SERIALRAML + 0x750 79 #define SERIALOUTD SERIALRAM + 0x780 80 #define SERIALOUTDL SERIALRAML + 0x780 81 82 83 #endif 84 #define MAXOUTCNT 36 85 86 /* constants for program */ 87 #define SOP 0x2 88 #define EOP 0x00 89 #define EOT 0x00 90 #define DPESIZE 308 91 /* pick next value to divide 8 Hz int 8 parts */ 92 #define LOOP 0x500 93 #define LOOP1 4000 94 #define LOOP2 8000 95 #define COUNTFREQ 8 96 /* ram buffer locations */ 97 #define EVENTSIZE 300 98 #define MAXEVENTS 100 99 #define MAXBUFFER 148 100 #define MAXCURVES 5 101 #define CURVESIZE 300 102 #define EVENT0 0x988000 103 #define EVENT1 EVENT0+(EVENTSIZE*2) 104 #define CURVE0 EVENT1+(EVENTSIZE*2) 105 #define CURVE1 CURVE0+(CURVESIZE*2) 106 #define LAST CURVE1+(CURVESIZE*2) 107 108 /* Error definitions */ 109 #define LOSTEVENTS 0x80 110 #define NO8HZCLK 1 111 #define BAD8HZCLK 2 112 #define NOHSL 3 113 #define BADLIBCRC 4 114 #define BADCOMMAND 5 115 #define BADSERIAL 6 116 117 /* start of circular buffer for pulses */ 118 #define PBUFFERBASE 0x9f0000 119 /* number of 256 byte buffers available */ 120 #define PBUFFERSIZE 160 121 /* number of events willing to process after 8Hz clock goes high */ 122 #define QUEROLL 10 123 124 #define STACKTOP PBUFFERBASE 125 #define STACKSIZE 512 126 #define STACKSTART (STACKTOP - STACKSIZE) 127 128 /* This line must be at the _end_ of file "engmem.h" */ 129 175 .global anal, correlate, addlibrary, analinit 176 #endif 177 178 179 /******************************************************************************/ 180 /* Maximum array dimensions */ 181 /* -------------------------------------------------------------------------- */ 182 /* Arbitrary modification of these values may cause serious misfunctions. */ 183 /******************************************************************************/ 184 #define M_SETS 8 /* Maximum number of sets per detector */ 185 #define M_DETS 19 /* Maximum number of detectors */ 186 #define M_TPLS 38 /* Maximum number of templates (RAM limited) */ 187 #define M_SHAPE_BINS 96 /* Maximum number of shape bins */ 188 #define M_TEMP_BINS 64 /* Maximum number of bins in template */ 189 190 191 /******************************************************************************/ 192 /* Error code definitions */ 193 /* -------------------------------------------------------------------------- */ 194 /******************************************************************************/ 195 #define ALERR1 0x30 /* addlibrary : Curve number too small (<0) */ 196 #define ALERR2 0x31 /* addlibrary : Curve number too large (>max-1) */ 197 #define ALERR3 0x32 /* addlibrary : Set number too small (<0) */ 198 #define ALERR4 0x33 /* addlibrary : Set number too large (>max-1) */ 199 #define ALERR5 0x34 /* addlibrary : Detector number too small (<0) */ 200 #define ALERR6 0x35 /* addlibrary : Detector number too large (>18) */ 201 #define ALERR7 0x36 /* addlibrary : Curve length too small (<=0) */ 202 #define ALERR8 0x37 /* addlibrary : Curve length too large (>64) */ 203 #define ALERR9 0x38 /* addlibrary : Number of templates too small (<0) */ 204 #define ALERR10 0x39 /* addlibrary : Number of templates too large (>max) */ 205 #define ALERR11 0x3a /* addlibrary : Startbins too small (<1) */ 206 #define ALERR12 0x3b /* addlibrary : Startbins too large (>=bins) */ 207 #define ALERR13 0x3c /* addlibrary : Endbins too small (<1) */ 208 #define ALERR14 0x3d /* addlibrary : Endbins too large (>bins-startbins) */ 209 #define ALERR15 0x3e /* addlibrary : Mean bin too small (<0) */ 210 #define ALERR16 0x3f /* addlibrary : Mean bin too large (>bins-1) */ 211 #define EEERR1 0x40 /* eewrite : Failed to write */ 212 #define COERR1 0x41 /* correlate : Set number too small. */ 213 #define COERR2 0x42 /* correlate : Set number too large. */ 214 #define COERR3 0x43 /* correlate : Too few bins used for template. */ 215 #define COERR4 0x44 /* correlate : Too many bins used for template. */ 216 #define COERR5 0x45 /* correlate : Too few templates used. */ 217 #define COERR6 0x46 /* correlate : Too many templates used. */ 218 #define COERR7 0x47 /* correlate : No valid library template available. */ 219 #define COERR8 0x48 /* correlate : Too many library templates available. */ 220 #define COERR9 0x49 /* correlate : Number of bins in shape not equal 96. */ 221 #define COERR10 0x4a /* correlate : Number of bins in start block too small. */ 222 #define COERR11 0x4b /* correlate : Number of bins in start block too large. */ 223 #define COERR12 0x4c /* correlate : Number of bins in end block too small. */ 224 #define COERR13 0x4d /* correlate : Number of bins in end block too large. */ 225 #define COERR14 0x4e /* correlate : Mid bin index too small. */ 226 #define COERR15 0x4f /* correlate : Mid bin index too large. */ 227 228 229 /******************************************************************************/ 230 /* PSD library control block */ 231 /* -------------------------------------------------------------------------- */ 232 /******************************************************************************/ 233 #define libctrlSet 0 /* 1: Selected library set */ 234 #define libctrlBins (libctrlSet+1) /* 1: Number of bins in template */ 235 #define libctrlTpls (libctrlBins+1) /* 1: Number of templates */ 236 #define libctrlVoid (libctrlTpls+1) /* 1: Void */ 237 238 239 /******************************************************************************/ 240 /* PSD algorithm parameter block */ 241 /* -------------------------------------------------------------------------- */ 242 /* Make sure that the integers and floats are properly aligned! */ 243 /******************************************************************************/ 244 #define libparNum 0 /* 0 : 1: Number of templates in library */ 245 #define libparBins (libparNum+1) /* 1 : 1: Number of bins in template */ 246 #define libparStart (libparBins+1) /* 2 : 1: Number of bins in start block */ 247 #define libparEnd (libparStart+1) /* 3 : 1: Number of bins in end block */ 248 #define libparMid (libparEnd+1) /* 4 : 1: Time for early/late separation */ 249 #define libparMin (libparMid+1) /* 5 : 1: Minimum pulse duration */ 250 #define libparMax (libparMin+1) /* 6 : 1: Maximum pulse duration */ 251 #define libparBaseAvg (libparMax+1) /* 7 : 1: Baseline averaging weight */ 252 #define libparBaseOut (libparBaseAvg+1) /* 8 : 1: Baseline outlier value */ 253 #define libparBaseMaxOut (libparBaseOut+1) /* 9 : 1: Baseline maximum outliers */ 254 #define libparMinBase (libparBaseMaxOut+3) /* 12 : 2: Minimum baseline */ 255 #define libparMaxBase (libparMinBase+2) /* 14 : 2: Maximum baseline */ 256 #define libparMinPulse (libparMaxBase+2) /* 16 : 2: Minimum pulse area */ 257 #define libparMaxPulse (libparMinPulse+2) /* 18 : 2: Maximum pulse area */ 258 #define libparSaturate (libparMaxPulse+2) /* 20 : 2: Pulse saturation value */ 259 #define libparEnergy (libparSaturate+2) /* 22 : 2: 10 Energy values */ 260 #define libparDTTPmin (libparEnergy+2*10) /* 42 : 2: 10 Delta TTP min values */ 261 #define libparDTTPmax (libparDTTPmin+2*10) /* 62 : 2: 10 Delta TTP max values */ 262 #define libparFltBins (libparDTTPmax+2*11) /* 84 : 4: Floated number of bins */ 263 #define libparInvStart (libparFltBins+4) /* 88 : 4: Inverse bins in start block */ 264 #define libparInvEnd (libparInvStart+4) /* 92 : 4: Inverse bins in end block */ 265 #define libparThFract (libparInvEnd+4) /* 96 : 4: Threshold fraction */ 266 #define libparBaseThisF (libparThFract+4) /* 100 : 4: Weighting factor for actual baseline */ 267 #define libparBaseAvgF (libparBaseThisF+4) /* 104 : 4: Weighting factor for avg. baseline */ 268 #define libparFltMinBase (libparBaseAvgF+4) /* 108 : 4: Floated minimum baseline */ 269 #define libparFltMaxBase (libparFltMinBase+4) /* 112 : 4: Floated maximum baseline */ 270 #define libparFltMinPulse (libparFltMaxBase+4) /* 116 : 4: Floated minimum pulse area */ 271 #define libparFltMaxPulse (libparFltMinPulse+4) /* 120 : 4: Floated maximum pulse area */ 272 #define libparTRSneg (libparFltMaxPulse+4) /* 124 : 4: 10 TRS (negative DTTP) */ 273 #define libparTRSpos (libparTRSneg+4*10) /* 164 : 4: 10 TRS (positive DTTP) */ 274 #define LIBPARSIZE (libparTRSpos+4*10) /* Size of parameter block (204 Bytes) */ 275 276 277 /******************************************************************************/ 278 /* 15 Bit management */ 279 /* -------------------------------------------------------------------------- */ 280 /* The 15 Bit information value is calculated following the formula: */ 281 /* */ 282 /* INFO = (alpha * wgt_alpha) * N_t * N_t + TTP2 * N_t + TTP1 + INFO_MINVAL */ 283 /* */ 284 /* where */ 285 /* wgt_alpha = (INFO_MAXVAL - INFO_MINVAL - N_t*N_t + 1) / (N_t*N_t * 0.5) */ 286 /* alpha = [0.0, 0.5] is the mixing parameter */ 287 /* N_t is the number of templates */ 288 /* TTP1 is the template index of the larger pulse */ 289 /* TTP2 is the template index of the smaller pulse */ 290 /* Error messages have values between 0x0000 and INFO_MINVAL-1 and */ 291 /* additionally may have Bit 15 set or not set (depending on desired */ 292 /* functionality). Therefore mask Bit 15 for error code analysis. */ 293 /* */ 294 /* Example: N_t = 30 => wgt_alpha = 70.782222 */ 295 /* */ 296 /******************************************************************************/ 297 #define INFO_ERR0 0x8000 /* No library (multiple) */ 298 #define INFO_ERR1 0x8001 /* Saturated pulse (multiple) */ 299 #define INFO_ERR2 0x8002 /* Pulse area too small */ 300 #define INFO_ERR3 0x0003 /* ATTP = 0 */ 301 #define INFO_ERR4 0x0004 /* ATTP too large */ 302 #define INFO_ERR5 0x0005 /* Baseline too small */ 303 #define INFO_ERR6 0x0006 /* Pulse start in baseline */ 304 #define INFO_ERR7 0x0007 /* Early pulse ends in baseline */ 305 #define INFO_ERR8 0x0008 /* Pulse ends too late */ 306 #define INFO_ERR9 0x0009 /* Pulse too short */ 307 #define INFO_ERR10 0x000a /* Pulse too long */ 308 #define INFO_ERR11 0x000b /* Invalid detector */ 309 #define INFO_ERR12 0x000c /* Pulse area less or equal 0.0 */ 310 #define INFO_ERR13 0x000d /* Baseline too high */ 311 #define INFO_ERR14 0x000e /* Baseline outlier */ 312 #define INFO_ERR15 0x800f /* Pulse area too large */ 313 #define INFO_MINVAL 0x0010 /* Minimum information value */ 314 #define INFO_MAXVAL 0x7fff /* Maximum information value */ 315 316 317 /******************************************************************************/ 318 /* RAM Memory management */ 319 /* -------------------------------------------------------------------------- */ 320 /* For 19 detectors, 38 templates, and 64 bins per template the following */ 321 /* memory allocation occurs: */ 322 /* */ 323 /* array size Bytes address */ 324 /* ------------------------------------------------------------ */ 325 /* lib 4*M_DETS*M_TPLS*M_TEMP_BINS 184832 0x989000 */ 326 /* lib_x_lib 4*M_DETS*M_TPLS 2808 0x9b6200 */ 327 /* lib1_x_lib2 4*M_DETS*M_TPLS*M_TPLS 109744 0x9b6d48 */ 328 /* innerproducts 4*M_TPLS 152 0x9b6de0 */ 329 /* denominator 4*M_DETS*M_TPLS*M_TPLS 109744 0x9d1a90 */ 330 /* wgt_alpha 4*M_DETS 76 0x9ec740 */ 331 /* lib_params LIBPARSIZE*M_DETS 3876 0x9ec78c */ 332 /* ---------------------------------------------------------------------- */ 333 /* ANALRAMEND 0x9ed6b0 */ 334 /******************************************************************************/ 335 #define ANALRAM 0x989000 336 #define lib ANALRAM 337 #define lib_x_lib ( lib+(4*M_DETS*M_TPLS*M_TEMP_BINS)) 338 #define lib1_x_lib2 ( lib_x_lib+(4*M_DETS*M_TPLS)) 339 #define innerproducts ( lib1_x_lib2+(4*M_DETS*M_TPLS*M_TPLS)) 340 #define denominator (innerproducts+(4*M_TPLS)) 341 #define wgt_alpha ( denominator+(4*M_DETS*M_TPLS*M_TPLS)) 342 #define lib_params ( wgt_alpha+(4*M_DETS)) 343 #define ANALRAMEND ( lib_params+(LIBPARSIZE*M_DETS)) 344 345 346 /******************************************************************************/ 347 /* EEPROM memory management */ 348 /* -------------------------------------------------------------------------- */ 349 /******************************************************************************/ 357 #endif 358 #ifndef EESTUB 359 #define LIBMEM EPROMA 360 #endif 361 #define libEE LIBMEM /* Start of library manager */ 362 #define SIZEOFLIB ((M_TPLS+1)*M_TEMP_BINS*4) /* Number of Bytes in a library set */ 363 #define SIZEOFSET (M_DETS*SIZEOFLIB) /* Size of library set */ 364 #define SIZEOFLIBMEM (0x080000) /* Size of library storage */ 365 #define NUMOFLIBS (M_DETS*M_SETS) /* Number of libraries */ 366 #define PSDPARABLOCK 0xff /* PSD parameter set */ 367 #define LOWPADD 0x15554 /* 0x5555 shifted twice to the left */ 368 #define HIPADD 0x0aaa8 /* 0x2aaa shifted twice to the left */ 369 #define EEPROMMASK 0x0010 /* This will have one bit in the next */ 370 /* to low order nibble for each EEPROM. */ 371 /* Only EEPROMA is installed at this time. */ 372 373 374 /******************************************************************************/ 375 /* PSD fixed algorithm parameters */ 376 /* -------------------------------------------------------------------------- */ 377 /* Arbitrary changement of these parameters may lead to serious misfunction. */ 378 /******************************************************************************/ 379 #define N_MIN_BINS 6 /* Minimum number of template bins (6) */ 380 #define N_MAX_BINS 64 /* Maximum number of template bins (64) */ 381 #define GAIN_STEP 0.0005 /* Resolution for gain parameter [0.936,1.0635] */ 382 #define OFFSET_STEP 0.05 /* Resolution for offset parameter [-6.4,6.35]*/ 385 #endif 386 #ifndef ENGSTUB 389 #endif 390 #ifndef EESTUB 391 #define N_DETS 19 /* Number of detectors for FM model */ 392 #endif 393 #endif 396 #endif 397 #ifndef TESTDATA 398 #define N_SHAPE_BINS 96 /* Number of bins in pulse for FM model */ 399 #endif 400 401 402 /******************************************************************************/ 403 /* Set test library parameters */ 404 /* -------------------------------------------------------------------------- */ 405 /******************************************************************************/ 408 #endif 411 #endif 414 #endif 417 #endif 418 419 420 /******************************************************************************/ 421 /* Debugging option */ 422 /* -------------------------------------------------------------------------- */ 423 /******************************************************************************/ 431 #endif 432 433 434 /******************************************************************************/ 435 /* DUMMY */ 436 /* -------------------------------------------------------------------------- */ 437 /* Version: 1.02 */ 438 /* Date : 29-Aug-1999 */ 439 /* Author : Jurgen Knodlseder, CESR (C) 1999 */ 440 /* -------------------------------------------------------------------------- */ 441 /* History: 1.02 29-Aug-1999 JK First version */ 442 /* -------------------------------------------------------------------------- */ 443 /* Task: */ 444 /* ===== */ 445 /* Algorithm dummy that drives the scientific analysis package for the */ 446 /* simulator mode. */ 447 /******************************************************************************/ 448 .align 4 481 #endif 482 483 484 /******************************************************************************/ 485 /* LOADLIBRARIES */ 486 /* -------------------------------------------------------------------------- */ 487 /* Version: 1.00 */ 488 /* Date : 10-Oct-1999 */ 489 /* Author : Jurgen Knodlseder, CESR (C) 1999 */ 490 /* -------------------------------------------------------------------------- */ 491 /* History: 1.00 10-Oct-1999 JK First version */ 492 /* -------------------------------------------------------------------------- */ 493 /* Task: */ 494 /* ===== */ 495 /* Load libraries in EEPROM. Only used for testing or initial library loading */ 496 /******************************************************************************/ 497 loadlibraries: 576 #endif 577 578 579 /******************************************************************************/ 580 /* ANALINIT */ 581 /* -------------------------------------------------------------------------- */ 582 /* Version: 1.07 */ 583 /* Date : 18-Oct-1999 */ 584 /* Author : Jurgen Knodlseder, CESR (C) 1999 */ 585 /* -------------------------------------------------------------------------- */ 586 /* History: 1.02 29-Aug-1999 JK First version */ 587 /* 1.03 21-Sep-1999 JK Conform to Tom's library management scheme */ 588 /* 1.04 23-Sep-1999 JK Add library management check */ 589 /* 1.05 4-Oct-1999 JK Remove library management table; move */ 590 /* constants floating to "addlibrary". */ 591 /* 1.06 10-Oct-1999 JK Add jump and call tables */ 592 /* 1.07 18-Oct-1999 JK Reset baseline averages */ 593 /* -------------------------------------------------------------------------- */ 594 /* Task: */ 595 /* ===== */ 596 /* Initialise scientific software package. */ 597 /* -------------------------------------------------------------------------- */ 598 /* */ 599 /* Usage: */ 600 /* ====== */ 601 /* pccall analinit(r18) */ 602 /* nop */ 603 /* */ 604 /* Parameters: */ 605 /* =========== */ 606 /* 1) Input: */ 607 /* 2) Output: Jaddlibrary l : "addlibrary" routine entry address */ 608 /* Jcorrelatey l : "correlate" routine entry address */ 609 /* Jposterror l : "posterror" entry address */ 610 /* Canal_step0 l : Analysis step 0 entry address */ 611 /* Canal_step1 l : Analysis step 1 entry address */ 612 /* Canal_step2 l : Analysis step 2 entry address */ 613 /* Canal_step3 l : Analysis step 3 entry address */ 614 /* Canal_step4 l : Analysis step 4 entry address */ 615 /* Canal_step5 l : Analysis step 5 entry address */ 616 /* Ccalcoffset l : "calcoffset" entry address */ 617 /* Ceewrite l : "eewrite" entry address */ 618 /* n_temp_sets i : Maximum number of template sets */ 619 /* 3) Internal: temp l : temporary memory location */ 620 /* */ 621 /* Register usage: */ 622 /* =============== */ 623 /* r1e : Multiple usage */ 624 /* r2e : Multiple usage */ 625 /* r3e : Temporary memory address */ 626 /* r18e : PC for subroutine return */ 627 /* r20e : calcoffset return address */ 628 /* a0 : Multiple usage accumulator */ 629 /* a1 : Multiple usage accumulator */ 630 /* */ 631 /* Subroutines: */ 632 /* ============ */ 633 /* pccall calcoffset(r20) : calculate lookup tables */ 634 /* pccall loadlibraries(r20) : optional loading of libraries */ 635 /* */ 636 /* -------------------------------------------------------------------------- */ 637 /* */ 638 /* Description: */ 639 /* ============ */ 640 /* This routine initialises some algorithm parameters and calculates the */ 641 /* memory look-up tables. It also initialises the jump and call table vectors */ 642 /* that allow for an easy replacement of some code fragments. */ 643 /* The maximum number of library sets is determined by */ 644 /* trunc( SIZEOFLIBMEM / SIZEOFSET ) */ 645 /* */ 646 /* Notes: */ 647 /* ====== */ 648 /******************************************************************************/ 649 analinit: 650 651 /* Initialise */ 9831bc 1dcee62c 652 *stackcopy = r14e /* Save stack pointer */ 9831c0 17400000 653 dauc = 0x00 /* Enable floating point round */ 654 655 /* Initialise jump table */ 9831c4 944f0668 656 r2e = pc + (myaddlibrary - . - 8) /* Get addlibrary entry */ 9831c8 1dc2f300 657 *Jaddlibrary = r2e /* Store it in jump vector */ 9831cc 944f00ec 658 r2e = pc + (mycorrelate - . - 8) /* Get correlate entry */ 9831d0 1dc2f304 659 *Jcorrelate = r2e /* Store it in jump vector */ 9831d4 944f0f64 660 r2e = pc + (myposterror - . - 8) /* Get posterror entry */ 9831d8 1dc2f308 661 *Jposterror = r2e /* Store it in jump vector */ 662 663 /* Initialise call table */ 9831dc 944f10e0 664 r2e = pc + (anal_step0 - . - 8) /* Get analysis step 0 entry */ 9831e0 1dc2f30c 665 *Canal_step0 = r2e /* Store it in call vector */ 9831e4 944f1310 666 r2e = pc + (anal_step1 - . - 8) /* Get analysis step 1 entry */ 9831e8 1dc2f310 667 *Canal_step1 = r2e /* Store it in call vector */ 9831ec 944f1b04 668 r2e = pc + (anal_step2 - . - 8) /* Get analysis step 2 entry */ 9831f0 1dc2f314 669 *Canal_step2 = r2e /* Store it in call vector */ 9831f4 944f1c3c 670 r2e = pc + (anal_step3 - . - 8) /* Get analysis step 3 entry */ 9831f8 1dc2f318 671 *Canal_step3 = r2e /* Store it in call vector */ 9831fc 944f21f0 672 r2e = pc + (anal_step4 - . - 8) /* Get analysis step 4 entry */ 983200 1dc2f31c 673 *Canal_step4 = r2e /* Store it in call vector */ 983204 944f2690 674 r2e = pc + (anal_step5 - . - 8) /* Get analysis step 5 entry */ 983208 1dc2f320 675 *Canal_step5 = r2e /* Store it in call vector */ 98320c 944f0db4 676 r2e = pc + (eewrite - . - 8) /* Get eewrite entry */ 983210 1dc2f324 677 *Ceewrite = r2e /* Store it in call vector */ 983214 944f0cdc 678 r2e = pc + (calcoffset - . - 8) /* Get calcoffset entry */ 983218 1dc2f328 679 *Ccalcoffset = r2e /* Store it in call vector */ 680 681 /* Evaluate maximum number of sets */ 98321c dfe3e604 682 r3e = temp /* Get temporary memory address */ 983220 c041e500 683 r1e = SIZEOFSET /* Get size of library set */ 983224 1fe10070 684 *r3 = r1e /* Store in temporary memory */ 983228 7d000c07 685 a0 = float24(*r3) /* Float result */ 98322c c1010000 686 r1e = SIZEOFLIBMEM /* Get size of memory */ 983230 1fe10070 687 *r3 = r1e /* Store in temporary memory */ 983234 130f0eb0 688 pccall inverse(r20) /* Invert result */ 983238 00000000 689 nop 98323c 7d200c07 690 a1 = float24(*r3) /* Float result */ 983240 00000000 691 nop 983244 00000000 692 nop 983248 70000087 693 a0 = a1 * a0 /* Evaluate maximum number of sets */ 98324c 17400010 694 dauc = 0x10 /* Switch to truncation mode */ 983250 7d800018 695 *r3 = a0 = int24(a0) /* Truncate maximum number of sets */ 983254 17400000 696 dauc = 0x00 /* Switch to rounding mode */ 983258 00000000 697 nop 98325c 00000000 698 nop 983260 1ea10070 699 r1 = *r3 /* Load maximum number of sets */ 983264 00000000 700 nop 983268 1d81e5c8 701 *n_temp_sets = r1 /* ... and store it */ 702 703 /* Calculate offset tables */ 98326c 1cc2f328 704 r2e = *Ccalcoffset /* Load call vector */ 983270 00000000 705 nop /* Wait for register load */ 983274 13020000 706 call r2(r20) /* Calculate offset tables */ 983278 00000000 707 nop 708 /* Reset baseline averages */ 98327c dfe1e498 709 r1e = baseline_avg /* Get pointer to baseline averages */ 983280 dfe4e4e4 710 r4e = baseline_nout /* Get pointer to baseline outliers */ 983284 944f2770 711 r2e = pc + (zero - . - 8) /* Point to 0.0 */ 983288 c0050000 712 r5e = 0 /* Get 0 */ 98328c 14600011 713 r3 = M_DETS - 2 /* Set loop counter over detectors */ 983290 1f650097 714 anloop1: *r4++ = r5l /* Set baseline outliers to 0 */ 983294 3000080f 715 *r1++ = a0 = *r2 /* Set average baseline to 0.0 */ 983298 0c6ffff0 716 if (r3-- >= 0) pcgoto anloop1 /* Next detector */ 98329c 00000000 717 nop 718 719 /* Option: load test library in EEPROM */ 723 #endif 724 /* Return to caller */ 9832a0 1ccee62c 725 r14e = *stackcopy /* Recover stack pointer */ 9832a4 00000000 726 nop 9832a8 00340000 727 return(r18) 9832ac 00000000 728 nop 729 730 731 /******************************************************************************/ 732 /* CORRELATE */ 733 /* -------------------------------------------------------------------------- */ 734 /* Version: 1.08 */ 735 /* Date : 15-Nov-1999 */ 736 /* Author : Jurgen Knodlseder, CESR (C) 1999 */ 737 /* -------------------------------------------------------------------------- */ 738 /* History: 1.02 29-Aug-1999 JK First version */ 739 /* 1.03 18-Sep-1999 JK adapt to Steve's code; add normalisation */ 740 /* array */ 741 /* 1.04 23-Sep-1999 JK copy selected library to RAM; remove */ 742 /* normalisation array; verify library */ 743 /* existence and set lib_valid flags */ 744 /* 1.05 5-Oct-1999 JK remove library management; add some checks */ 745 /* 1.06 10-Oct-1999 JK add jump table warper */ 746 /* 1.07 14-Oct-1999 JK copy library parameter tables to RAM and */ 747 /* check them on consistency */ 748 /* 1.08 15-Nov-1999 JK Use only 3 Bits for library set */ 749 /* -------------------------------------------------------------------------- */ 750 /* Task: */ 751 /* ===== */ 752 /* Prepares library for fast pulse fitting: */ 753 /* - copy and verify library parameter block to RAM */ 754 /* - copy library to RAM */ 755 /* - normalise all library pulses to unit area */ 756 /* - evaluate the correlation coefficients */ 757 /* -------------------------------------------------------------------------- */ 758 /* */ 759 /* Usage: */ 760 /* ====== */ 761 /* pccall correlate(r18) */ 762 /* nop */ 763 /* */ 764 /* Parameters: */ 765 /* =========== */ 766 /* 1) Input: off_lEE_3 l : EEPROM library offset table */ 767 /* off_lEE_4 l : EEPROM library offset table */ 768 /* off_lxl_2 l : lib_x_lib offset table */ 769 /* off_lxx_3 l : lib1_x_lib2 offset table */ 770 /* off_lib_p l : Library parameter block offset table */ 771 /* libEE f : EEPROM pulse template libraries */ 772 /* 2) Output: lib f : normalised library templates */ 773 /* lib_x_lib f : inner product of templates */ 774 /* lib1_x_lib2 f : inner products among templates */ 775 /* lib_params x : RAM library parameter blocks */ 776 /* denominator f : denominator for double pulse fitting */ 777 /* wgt_alpha f : alpha weighting factor for 15 Bits */ 778 /* lib_valid b : Library validity (1=valid, 0=invalid) */ 779 /* 3) Internal: libbase l : lib base address */ 780 /* lxlbase l : lib_x_lib base address */ 781 /* lxxbase l : lib1_x_lib2 base address */ 782 /* zero f : Floating point zero */ 783 /* */ 784 /* Register usage: */ 785 /* =============== */ 786 /* r1e : Pointer to base address of selected library */ 787 /* r2 : Selected number of bins per template */ 788 /* r3 : Selected number of templates */ 789 /* r4 : denominator base address */ 790 /* r5e : Multiple usage */ 791 /* r6e : Multiple usage */ 792 /* r7e : lib_x_lib base address */ 793 /* r8e : lib1_x_lib2 base address */ 794 /* r9e : Multiple usage */ 795 /* r10 : Template 1 counter */ 796 /* r11 : Template 2 counter */ 797 /* r12 : Template bin counter */ 798 /* r13e : Multiple usage */ 799 /* r14e : Multiple usage */ 800 /* r15 : Actual detector index */ 801 /* r16e : pointer to actual library control block */ 802 /* r17e : lib_x_lib base address for actual detector */ 803 /* r18e : PC for subroutine return */ 804 /* r19e : Empty parameter */ 805 /* r20e : Multiple usage */ 806 /* a0 : Multiple usage accumulator */ 807 /* */ 808 /* Subroutines: */ 809 /* ============ */ 810 /* pccall inverse(r20) : invert a0 */ 811 /* */ 812 /* -------------------------------------------------------------------------- */ 813 /* */ 814 /* Description: */ 815 /* ============ */ 816 /* For all detectors, this routine copies the selected library templates to */ 817 /* RAM, normalises the library pulses to unit area and evaluates: */ 818 /* 1) the inner product of all templates with themselves */ 819 /* 2) the inner product among all templates */ 820 /* 3) the denominators for the double pulse fitting */ 821 /* The library control block and the library parameter block is analysed for */ 822 /* each detector and inconsistencies or boundary violations are signalled by */ 823 /* warnings or error messages. For warnings, autocorrections are performed */ 824 /* and stored in the corresponding control block. For errors, the evalutions */ 825 /* are skipped and the corresponding detector is invalidated. */ 826 /* The denominator and the normalisation factor is inverted using the */ 827 /* subroutine 'inverse'. The mixing parameter weighting factor for the 15 Bit */ 828 /* information block is evaluated. */ 829 /* If there is no valid library for a given set and detector then the */ 830 /* correlation evaluation for this selection is skipped and the problem is */ 831 /* signalled by an error code. */ 832 /* */ 833 /* 1) Algorithm: p = sum_i f_i * f_i */ 834 /* Storage : lib_x_lib */ 835 /* */ 836 /* 2) Algorithm: p = sum_i f_i * g_i */ 837 /* Storage : lib1_x_lib2 */ 838 /* */ 839 /* 3) Algorithm: d = 1. / sum_i f_i f_i + g_i g_i - 2 f_i g_i */ 840 /* Exception: sum_i is 0.0. This happens for */ 841 /* a) f_i = g_i : Set d = 0.0. This leads to ALPHA = 0.0, */ 842 /* corresponding to the fit of a single pulse. */ 843 /* b) else : Set d = 0.0. */ 844 /* Storage : denominator */ 845 /* */ 846 /* 15 Bit alpha weighting factor: */ 847 /* Algorithm: wgt_alpha = (INFO_MAXVAL - INFO_MINVAL - N_t*N_t + 1) / */ 848 /* (N_t*N_t * 0.5) */ 849 /* where N_t = n_templates */ 850 /* */ 851 /* Notes: */ 852 /* ====== */ 853 /* * The correlation coefficients are only calculated for the selected number */ 854 /* of templates. However, to minimise bookkeeping, the denominators are */ 855 /* calculated for the entire array. This is not coherent but it should */ 856 /* actually have no impact on the analysis. */ 857 /* * For the moment redundant values are stored in the lib1_x_lib2 array. If */ 858 /* memory allocation will turn out to become problematic, a more efficient */ 859 /* storage can be designed. However, one could only gain by a factor of 2. */ 860 /* * After a call to "correlate" the library control block parameters are */ 861 /* verified for libraries that are flagged as valid. Hence no further check */ 862 /* on the library control block parameters has to be performed. */ 863 /* */ 864 /* Error codes: */ 865 /* ============ */ 866 /* COERR1 : (Error) Set number too small. */ 867 /* COERR2 : (Error) Set number too high. */ 868 /* COERR3 : (Error) Too few bins used for template. */ 869 /* COERR4 : (Error) Too many bins used for template. */ 870 /* COERR5 : (Error) Too few templates used for fitting. */ 871 /* COERR6 : (Error) Too many templates used for fitting. */ 872 /* COERR7 : (Error) No valid library available for this detector. */ 873 /* COERR8 : (Error) Too many library templates available for this detector. */ 874 /* COERR9 : (Error) Number of bins in shape not equal 96. EEPROM error. */ 875 /* COERR10: (Error) Number of bins in start block too small. */ 876 /* COERR11: (Error) Number of bins in start block too large. */ 877 /* COERR12: (Error) Number of bins in end block too small. */ 878 /* COERR13: (Error) Number of bins in end block too large. */ 879 /* COERR14: (Error) Mid bin index too small. */ 880 /* COERR15: (Error) Mid bin index too large. */ 881 /******************************************************************************/ 882 correlate: 883 /* Jump table warper */ 9832b0 1cc2f304 884 r2e = *Jcorrelate /* Load jump vector */ 9832b4 00000000 885 nop /* Wait for register load */ 9832b8 a0020000 886 goto r2 /* Jump into code */ 9832bc 00000000 887 nop 888 /******************************************************************************/ 889 /* Default code (can be replaced by uploaded code) */ 890 /******************************************************************************/ 891 mycorrelate: 892 /* Initialisation */ 9832c0 1dcee62c 893 *stackcopy = r14e /* Save stack pointer */ 9832c4 dfeee4f7 894 r14e = lib_valid /* Get library validity array */ 9832c8 16a00011 895 r19 = M_DETS - 2 /* Set loop counter */ 9832cc 14400000 896 r2 = 0 /* Default: Library is invalid */ 9832d0 1f6201d7 897 coloop1: *r14++ = r2l /* Reset valid flag */ 9832d4 0eaffff4 898 if (r19-- >= 0) pcgoto coloop1 /* Next detector */ 9832d8 00000000 899 nop 900 901 /* Loop over all 19 detectors (r15 = 0 - 18) */ 9832dc 16200000 902 r15 = 0 /* Initialise detector index */ 9832e0 182a0220 903 coloop2: r10 = r15 * 2 /* Get 4-Byte offset for this detector */ 9832e4 182a0140 904 r10 = r10 * 2 9832e8 dff2e188 905 r16e = library_control /* Get address of library control */ 9832ec 98120140 906 r16e = r16 + r10 /* Get actual library control block */ 9832f0 dfeee4f7 907 r14e = lib_valid /* Get library validity array */ 9832f4 980e0220 908 r14e = r14 + r15 /* Add detector offset */ 909 910 /* Extract library set number and verify that */ 911 /* it lies in the valid boundaries. Otherwise */ 912 /* autorestrict the set number and post warning. */ 9832f8 94320000 913 r1e = r16 + libctrlSet /* Pointer on library set */ 9832fc 1e620030 914 r2l = *r1 /* Get library set number */ 983300 1c85e5c8 915 r5 = *n_temp_sets /* Get maximum number of template sets */ 983304 1bc20007 916 r2 = r2 & 7 /* Use only first 3 Bits of set */ 983308 1ae20000 917 r2 - 0 /* Set >= 0 ? */ 98330c 016f044c 918 if (lt) pcgoto coErr1 /* No, then error */ 983310 18e200a0 919 r2 - r5 /* Set < n_temp_sets ? */ 983314 014f0450 920 if (ge) pcgoto coErr2 /* No, then error */ 983318 00000000 921 nop 922 /* Evaluate curve base address in EEPROM */ 98331c c1070000 923 r7e = libEE /* Get EEPROM base address */ 983320 dfe5f460 924 r5e = off_lEE_4 /* Get offset table base address */ 983324 98220040 925 r2e = r2 * 2 /* Get set 4-Byte offset */ 983328 98220040 926 r2e = r2 * 2 98332c 98050040 927 r5e = r5 + r2 /* r5e -> off_lEE_4[set] */ 983330 1ee600b0 928 r6e = *r5 /* r6e = off_lEE_4[set] (offset) */ 983334 00000000 929 nop 983338 980700c0 930 r7e = r7 + r6 /* Add set offset */ 98333c dfe5f414 931 r5e = off_lEE_3 /* Get offset table base address */ 983340 98050140 932 r5e = r5 + r10 /* r5e -> off_lEE_3[detector] */ 983344 1ee600b0 933 r6e = *r5 /* r6e = off_lEE_3[detector] (offset) */ 983348 00000000 934 nop 98334c 980700c0 935 r7e = r7 + r6 /* Add set offset */ 983350 1dc7e618 936 *libbase = r7e /* Store EEPROM base address */ 937 938 /* Extract number of bins per template and */ 939 /* verify that it lies within the boundaries. */ 940 /* Otherwise autorestrict and post warning. */ 983354 98010af2 941 r1e = r16 + libctrlBins /* Pointer on template bins */ 983358 1e620030 942 r2l = *r1 /* Get number of bins per template */ 98335c 00000000 943 nop /* Wait for register load */ 983360 1ae20006 944 r2 - N_MIN_BINS /* Number >= 6 ? */ 983364 016f040c 945 if (lt) pcgoto coErr3 /* No, then error */ 983368 14a00040 946 r5 = N_MAX_BINS /* Maximum: 64 bins */ 98336c 18e200a0 947 r2 - r5 /* Number <= 64 ? */ 983370 018f040c 948 if (gt) pcgoto coErr4 /* No, then error */ 983374 00000000 949 nop 983378 1d82e5c6 950 *n_temp_bins = r2 /* Store parameter */ 951 952 /* Copy library parameter block to RAM */ 98337c 1cc7e618 953 r7e = *libbase /* Get library base address */ 983380 dfe5f32c 954 r5e = off_lib_2 /* Get offset table base address */ 983384 14400026 955 r2 = M_TPLS /* Get parameter block index */ 983388 98220040 956 r2e = r2 * 2 /* Get set 4-Byte offset */ 98338c 98220040 957 r2e = r2 * 2 983390 98050040 958 r5e = r5 + r2 /* r5e -> off_lib_2[M_TPLS] */ 983394 1ee600b0 959 r6e = *r5 /* r6e = off_lib_2[M_TPLS] (offset) */ 983398 00000000 960 nop 98339c 980700c0 961 r7e = r7 + r6 /* Add offset */ 9833a0 d3c1c78c 962 r1e = lib_params /* Get library parameter block base address */ 9833a4 dfe5e50c 963 r5e = off_lib_p /* Get offset table base address */ 9833a8 98050140 964 r5e = r5 + r10 /* r5e -> off_lib_p[detector] */ 9833ac 1ee600b0 965 r6e = *r5 /* r6e = off_lib_p[detector] (offset) */ 9833b0 00000000 966 nop 9833b4 980100c0 967 r1e = r1 + r6 /* Add offset */ 9833b8 98020a01 968 r2e = r1 /* Copy RAM library parameter address */ 9833bc 158000ca 969 r12 = (LIBPARSIZE - 2) /* Initialise Byte loop counter */ 9833c0 1e6500f7 970 coloop3: r5l = *r7++ /* Read one Byte */ 9833c4 00000000 971 nop /* Wait for register load */ 9833c8 1f650057 972 *r2++ = r5l /* Write one Byte */ 9833cc 0d8fffec 973 if (r12-- >= 0) pcgoto coloop3 /* Next Byte */ 9833d0 00000000 974 nop 975 976 /* Verify library parameter block */ 9833d4 94c10000 977 r6e = r1 + libparNum 9833d8 1e6400d0 978 r4l = *r6 /* Get number of templates */ 9833dc 00000000 979 nop 9833e0 1ae40000 980 r4 - 0 /* Number of templates > 0 ? */ 9833e4 01af03bc 981 if (le) pcgoto coErr7 /* No, then error */ 9833e8 1ae40026 982 r4 - M_TPLS /* Number of templates <= M_TPLS ? */ 9833ec 018f03c0 983 if (gt) pcgoto coErr8 /* No, then error */ 9833f0 98060ae1 984 r6e = r1 + libparBins 9833f4 1e6400d0 985 r4l = *r6 /* Get number of bins in shape */ 9833f8 00000000 986 nop 9833fc 1ae40060 987 r4 - N_SHAPE_BINS /* Number = N_SHAPE_BINS ? */ 983400 008f03b8 988 if (ne) pcgoto coErr9 /* No, then error */ 983404 94c10002 989 r6e = r1 + libparStart 983408 1e6400d0 990 r4l = *r6 /* Get number of bins in start block */ 98340c 00000000 991 nop 983410 1ae40000 992 r4 - 0 /* Start bins > 0 ? */ 983414 01af03b0 993 if (le) pcgoto coErr10 /* No, then error */ 983418 1ae40060 994 r4 - N_SHAPE_BINS /* Start bins < N_SHAPE_BINS ? */ 98341c 014f03b4 995 if (ge) pcgoto coErr11 /* No, then error */ 983420 14a00060 996 r5 = N_SHAPE_BINS /* Get number of bins */ 983424 18850080 997 r5 = r5 - r4 /* Get number of remaining bins */ 983428 94c10003 998 r6e = r1 + libparEnd 98342c 1e6400d0 999 r4l = *r6 /* Get number of bins in end block */ 983430 00000000 1000 nop 983434 1ae40000 1001 r4 - 0 /* End bins > 0 ? */ 983438 01af03a4 1002 if (le) pcgoto coErr12 /* No, then error */ 98343c 18e400a0 1003 r4 - r5 /* End bins <= remaining bins ? */ 983440 018f03a8 1004 if (gt) pcgoto coErr13 /* No, then error */ 983444 94c10004 1005 r6e = r1 + libparMid 983448 1e6400d0 1006 r4l = *r6 /* Get mean bin */ 98344c 00000000 1007 nop 983450 1ae40000 1008 r4 - 0 /* Mean bin >= 0 ? */ 983454 016f03a0 1009 if (lt) pcgoto coErr14 /* No, then error */ 983458 1ae40060 1010 r4 - N_SHAPE_BINS /* Mean bins < N_SHAPE_BINS ? */ 98345c 014f03a4 1011 if (ge) pcgoto coErr15 /* No, then error */ 983460 00000000 1012 nop 1013 1014 /* Extract number of templates and verify */ 1015 /* that it lies within the boundaries. */ 983464 94c10000 1016 r6e = r1 + libparNum 983468 1e6400d0 1017 r4l = *r6 /* Get number of templates */ 98346c 94320002 1018 r1e = r16 + libctrlTpls /* Pointer on number of templates */ 983470 1e620030 1019 r2l = *r1 /* Number of templates */ 983474 00000000 1020 nop /* Wait for register load */ 983478 1ae20000 1021 r2 - 0 /* Number > 0 ? */ 98347c 01af030c 1022 if (le) pcgoto coErr5 /* No, then error */ 983480 00000000 1023 nop 983484 18e20080 1024 r2 - r4 /* Number <= maximum ? */ 983488 018f030c 1025 if (gt) pcgoto coErr6 /* No, then error */ 98348c 00000000 1026 nop 983490 1d82e5c4 1027 *n_templates = r2 /* Store in variable */ 1028 1029 /* If surveyved until this point then set */ 1030 /* the library validity flag (r14) */ 983494 14400001 1031 r2 = 1 /* Library is valid */ 983498 1f6201d0 1032 *r14 = r2l /* Set valid flag */ 1033 1034 /* Get lib_x_lib base address for actual */ 1035 /* detector */ 98349c dfe5f480 1036 r5e = off_lxl_2 /* Get offset table base address */ 9834a0 98050140 1037 r5e = r5 + r10 /* r5e -> off_lxl_2[detector] */ 9834a4 1ee600b0 1038 r6e = *r5 /* r6e = off_lxl_2[detector] (offset) */ 9834a8 d3676200 1039 r7e = lib_x_lib /* Pointer on library inner products base address */ 9834ac 980700c0 1040 r7e = r7 + r6 /* Add offset (in Bytes) */ 9834b0 1dc7e610 1041 *lxlbase = r7e /* Store base address */ 1042 1043 /* Get denominator and lib1_x_lib2 base addresses for */ 1044 /* actual detector */ 9834b4 dfe5f564 1045 r5e = off_lxx_3 /* Get offset table base address */ 9834b8 98050140 1046 r5e = r5 + r10 /* r5e -> off_lxx_3[detector] */ 9834bc 1ee600b0 1047 r6e = *r5 /* r6e = off_lxx_3[detector] (offset) */ 9834c0 d3676d48 1048 r7e = lib1_x_lib2 /* Pointer on library inner products base address */ 9834c4 980700c0 1049 r7e = r7 + r6 /* Add offset (in Bytes) */ 9834c8 1dc7e614 1050 *lxxbase = r7e /* Store base address */ 9834cc d3a71a90 1051 r7e = denominator /* Pointer on denominator base address */ 9834d0 980700c0 1052 r7e = r7 + r6 /* Add offset (in Bytes) */ 9834d4 1dc7e61c 1053 *denbase = r7e /* Store base address */ 1054 1055 /* Evaluate alpha weighting factor */ 9834d8 d3c1c740 1056 r1e = wgt_alpha /* Get base address of mixing parameter wgt. factor */ 9834dc 98010140 1057 r1e = r1 + r10 /* Add detector offset */ 9834e0 dfe2e604 1058 r2e = temp /* Get temporary memory */ 9834e4 1c83e5c4 1059 r3 = *n_templates /* Get number of templates to use */ 9834e8 00000000 1060 nop /* Wait for register load */ 9834ec 1fa30050 1061 *r2 = r3 /* Store in temporary memory */ 9834f0 79200807 1062 a1 = float(*r2) /* Float number of templates */ 9834f4 95cf2504 1063 r14e = pc + (half - . - 8) /* Pointer to floating point 0.5 */ 9834f8 30003807 1064 a0 = *r14 /* a0 = 0.5 */ 9834fc 00000000 1065 nop /* Wait 1 ic for a1 */ 983500 70204090 1066 *r2 = a1 = a1 * a1 /* *r2 = a1 = N_t * N_t */ 983504 c0037fff 1067 r3e = INFO_MAXVAL /* Get maximum 15 Bit value */ 983508 c0040010 1068 r4e = INFO_MINVAL /* Get minimum 15 Bit value */ 98350c 98830080 1069 r3e = r3 - r4 /* Build difference */ 983510 70004007 1070 a0 = a0 * a1 /* a0 = 0.5 * N_t * N_t */ 983514 980302e0 1071 r3e = r3 + 1 /* r3e = INFO_MAXVAL - INFO_MINVAL + 1 */ 983518 00000000 1072 nop /* Wait 2 ics for a0 */ 98351c 00000000 1073 nop 983520 02af0030 1074 if (aeq) pcgoto cojmp9 /* If a0 = 0.0 then wgt_alpha = 0.0 */ 983524 00000000 1075 nop 983528 130f0bbc 1076 pccall inverse(r20) /* a0 = 1.0 / (0.5 * N_t * N_t) */ 98352c 00000000 1077 nop 983530 30200807 1078 a1 = *r2 /* a1 = N_t * N_t */ 983534 00000000 1079 nop 983538 1fa30050 1080 *r2 = r3 98353c 79400807 1081 a2 = float(*r2) /* a2 = INFO_MAXVAL - INFO_MINVAL + 1 */ 983540 34c04107 1082 a2 = a2 - a1 /* a2 = INFO_MAXVAL - INFO_MINVAL + 1 - N_t*N_t */ 983544 00000000 1083 nop /* Wait 3 ics for a2 */ 983548 00000000 1084 nop 98354c 00000000 1085 nop 983550 030f0008 1086 if (agt) pcgoto cojmp10 /* If a2 < 0.0 then wgt_alpha = 0.0 */ 983554 00000000 1087 nop 983558 95cf249c 1088 cojmp9: r14e = pc + (zero - . - 8) /* a0 = 0.0 */ 98355c 30003807 1089 a0 = *r14 983560 7000800f 1090 cojmp10: *r1++ = a0 = a0 * a2 /* Save wgt_alpha */ 1091 1092 /* Copy library to RAM and normalise templates */ 1093 /* to unit area */ 983564 1cc8e618 1094 r8e = *libbase /* Get pointer on library set base address in EEPROM */ 983568 dfe5f3c8 1095 r5e = off_lib_3 /* Get offset table base address */ 98356c 98050140 1096 r5e = r5 + r10 /* r5e -> off_lib_3[detector] */ 983570 1ee600b0 1097 r6e = *r5 /* r6e = off_lib_3[detector] (offset) */ 983574 d3079000 1098 r7e = lib /* Pointer on library array in RAM */ 983578 980700c0 1099 r7e = r7 + r6 /* Add RAM offset (in Bytes) */ 98357c 1dc7e618 1100 *libbase = r7e /* Store RAM base address */ 983580 1c83e5c4 1101 r3 = *n_templates /* Get number of templates to use */ 983584 95cf2470 1102 r14e = pc + (zero - . - 8) /* Pointer to floating point zero */ 983588 15400000 1103 r10 = 0 /* Set template loop counter (ttp=0) */ 98358c dfe5f32c 1104 coloop4: r5e = off_lib_2 /* Get offset table base address */ 983590 980b0a0a 1105 r11e = r10 /* Transform template index ... */ 983594 982b0160 1106 r11e = r11 * 2 /* ... into 4-Byte offset */ 983598 982b0160 1107 r11e = r11 * 2 98359c 98050160 1108 r5e = r5 + r11 /* r5e -> off_lib_2[ttp] */ 9835a0 1ee600b0 1109 r6e = *r5 /* r6e = off_lib_2[ttp] */ 9835a4 98050a08 1110 r5e = r8 /* Source base address (EEPROM) */ 9835a8 1cc7e618 1111 r7e = *libbase /* Destination base address (RAM) */ 9835ac 980500c0 1112 r5e = r5 + r6 /* Add source offset */ 9835b0 980700c0 1113 r7e = r7 + r6 /* Add destination offset */ 9835b4 30003807 1114 a0 = *r14 /* Reset accumulator */ 9835b8 1c8ce5c6 1115 r12 = *n_temp_bins /* Get number of bins in template */ 9835bc 98060a05 1116 r6e = r5 /* Copy source base address */ 9835c0 1a8c0002 1117 r12 = r12 - 2 /* Set template bin counter */ 9835c4 340dc007 1118 coloop5: a0 = a0 + *r6++ /* accumulate content */ 9835c8 0d8ffff4 1119 if (r12-- >= 0) pcgoto coloop5 /* Next template bin */ 9835cc 00000000 1120 nop 9835d0 1c8ce5c6 1121 r12 = *n_temp_bins /* Get number of bins in template */ 9835d4 02af0010 1122 if (aeq) pcgoto cojmp4 /* a0 = 0.0? Yes, then a0 = 0.0 and no inversion */ 9835d8 00000000 1123 nop 9835dc 130f0b08 1124 pccall inverse(r20) /* Invert a0 */ 9835e0 00000000 1125 nop 9835e4 a00f0004 1126 pcgoto cojmp5 9835e8 00000000 1127 nop 9835ec 30003807 1128 cojmp4: a0 = *r14 /* a0 = 0.0 */ 9835f0 1a8c0002 1129 cojmp5: r12 = r12 - 2 /* Set template bin counter */ 9835f4 702bc03f 1130 coloop6: *r7++ = a1 = a0 * *r5++ /* Normalise and copy template to RAM */ 9835f8 0d8ffff4 1131 if (r12-- >= 0) pcgoto coloop6 /* Next template bin */ 9835fc 00000000 1132 nop 983600 154a0001 1133 r10 += 1 /* Increment template index */ 983604 18ea0060 1134 r10 - r3 /* All templates ? */ 983608 016fff7c 1135 if (lt) pcgoto coloop4 /* No ... */ 98360c 00000000 1136 nop 1137 1138 /* Evaluate inner products */ 983610 1c83e5c4 1139 r3 = *n_templates /* Get number of templates to use */ 983614 1cc7e610 1140 r7e = *lxlbase /* Point to lib_x_lib base address */ 983618 948f23dc 1141 r4e = pc + (zero - . - 8) /* Pointer to floating point zero */ 98361c 15600000 1142 r11 = 0 /* Set template 2 loop counter */ 1143 /* Loop over template 2 */ 983620 15400000 1144 coloop7: r10 = 0 /* Set template 1 loop counter */ 983624 dfe6f32c 1145 r6e = off_lib_2 /* Get library offset table base address */ 983628 dfe5f4cc 1146 r5e = off_lxx_2 /* Get lib1_x_lib2 offset table base address */ 98362c 980c0a0b 1147 r12e = r11 /* Transform TTP2 template index ... */ 983630 982c0180 1148 r12e = r12 * 2 /* ... in 4-Byte offset index */ 983634 982c0180 1149 r12e = r12 * 2 983638 98060180 1150 r6e = r6 + r12 /* r6e -> off_lib_2[ttp2] */ 98363c 98050180 1151 r5e = r5 + r12 /* r5e -> off_lxx_2[ttp2] */ 983640 1eec00d0 1152 r12e = *r6 /* r12e = off_lib_2[ttp2] */ 983644 1cc9e618 1153 r9e = *libbase /* Get library base address */ 983648 00000000 1154 nop /* Wait for register load */ 98364c 98090180 1155 r9e = r9 + r12 /* Add offset */ 983650 1eec00b0 1156 r12e = *r5 /* r12e = off_lxx_2[ttp2] */ 983654 1cc8e614 1157 r8e = *lxxbase /* Get lib1_x_lib2 base address */ 983658 00000000 1158 nop 98365c 98080180 1159 r8e = r8 + r12 /* Add offset */ 1160 /* Loop over template 1 */ 983660 98050a09 1161 coloop8: r5e = r9 /* Set template 2 start address */ 983664 dfe6f32c 1162 r6e = off_lib_2 /* Get offset table base address */ 983668 980c0a0a 1163 r12e = r10 /* Transform TTP1 template index ... */ 98366c 982c0180 1164 r12e = r12 * 2 /* ... in 4-Byte offset index */ 983670 982c0180 1165 r12e = r12 * 2 983674 98060180 1166 r6e = r6 + r12 /* r6e -> off_lib_2[ttp1] */ 983678 1eec00d0 1167 r12e = *r6 /* r12e = off_lib_2[ttp1] */ 98367c 1cc6e618 1168 r6e = *libbase /* Get library base address */ 983680 00000000 1169 nop /* Wait for register load */ 983684 98060180 1170 r6e = r6 + r12 /* Add offset */ 1171 /* Loop over the bins of one template */ 983688 1c8ce5c6 1172 r12 = *n_temp_bins /* Load number of bins in template */ 98368c 30001007 1173 a0 = *r4 /* Reset accumulator */ 983690 1a8c0002 1174 r12 = r12 - 2 /* Set template bin counter */ 983694 600dd787 1175 coloop9: a0 = a0 + *r5++ * *r6++ /* accumulate content */ 983698 0d8ffff4 1176 if (r12-- >= 0) pcgoto coloop9 /* Next template bin */ 98369c 00000000 1177 nop 9836a0 18ea0160 1178 r10 - r11 /* Template 1 = Template 2 ? */ 9836a4 008f0004 1179 if (ne) pcgoto cojmp6 /* No, then continue ... */ 9836a8 00000000 1180 nop 9836ac 3000003f 1181 *r7++ = a0 = a0 /* Yes, then store in lib_x_lib array */ 9836b0 30000047 1182 cojmp6: *r8++ = a0 = a0 /* Store in lib1_x_lib2 anyways */ 9836b4 154a0001 1183 r10 += 1 /* Increment TTP1 */ 9836b8 18ea0060 1184 r10 - r3 /* All templates 1 ? */ 9836bc 016fff9c 1185 if (lt) pcgoto coloop8 /* No ... */ 9836c0 00000000 1186 nop 9836c4 156b0001 1187 r11 += 1 /* Increment TTP2 */ 9836c8 18eb0060 1188 r11 - r3 /* All templates 2 ? */ 9836cc 016fff4c 1189 if (lt) pcgoto coloop7 /* No ... */ 9836d0 00000000 1190 nop 1191 /* Evaluate inverse of denominators */ 9836d4 95cf2320 1192 r14e = pc + (zero - . - 8) /* Pointer to floating point zero */ 9836d8 1cc4e61c 1193 r4e = *denbase /* Get denominator base address */ 9836dc 1cc8e614 1194 r8e = *lxxbase /* Get lib1_x_lib2 base address */ 9836e0 1cc5e610 1195 r5e = *lxlbase /* gg base address (lib_x_lib) */ 9836e4 15600024 1196 r11 = M_TPLS - 2 /* Set template 2 loop counter */ 9836e8 1cc6e610 1197 coloop10: r6e = *lxlbase /* ff base address (lib_x_lib) */ 9836ec 15400024 1198 r10 = M_TPLS - 2 /* Set template 1 loop counter */ 9836f0 30001b87 1199 coloop11: a0 = *r6++ /* a0 = ff */ 9836f4 340a0007 1200 a0 = a0 + *r5 /* a0 = ff + gg */ 9836f8 34900007 1201 a0 = a0 - *r8 /* a0 = ff + gg - fg */ 9836fc 3491c007 1202 a0 = a0 - *r8++ /* a0 = ff + gg - 2 fg */ 983700 18ea0160 1203 r10 - r11 /* Template 1 = Template 2 ? */ 983704 00af0018 1204 if (eq) pcgoto cojmp7 /* Yes, then a0 = 0.0 and no inversion */ 983708 00000000 1205 nop 98370c 02af0014 1206 if (aeq) pcgoto cojmp8 /* a0 = 0.0? Yes, then a0 = 0.0 and no inversion */ 983710 00000000 1207 nop 983714 130f09d0 1208 pccall inverse(r20) /* Invert a0 */ 983718 00000000 1209 nop 98371c a00f0004 1210 pcgoto cojmp8 983720 00000000 1211 nop 983724 30003807 1212 cojmp7: a0 = *r14 /* a0 = 0.0 */ 983728 30000027 1213 cojmp8: *r4++ = a0 = a0 /* and store result */ 98372c 00000000 1214 nop 983730 0d4fffb8 1215 if (r10-- >= 0) pcgoto coloop11 /* Next template 1 */ 983734 00000000 1216 nop 983738 0d6fffa8 1217 if (r11-- >= 0) pcgoto coloop10 /* Next template 2 */ 98373c 94a50004 1218 r5e = r5 + 4 /* Increment template 2 address (latent) */ 1219 1220 /* Next detector */ 983740 16310001 1221 cojmp11: r15 += 1 /* Increment detector index */ 983744 1af10013 1222 r15 - N_DETS /* All detectors done ? */ 983748 016ffb90 1223 if (lt) pcgoto coloop2 /* No ... */ 98374c 00000000 1224 nop 1225 1226 /* Return to caller */ 983750 1ccee62c 1227 r14e = *stackcopy 983754 00000000 1228 nop 983758 00340000 1229 return(r18) 98375c 00000000 1230 nop 1231 1232 /* Error handling */ 983760 14600041 1233 coErr1: r3 = COERR1 /* Number of set too small */ 983764 a00f00a8 1234 pcgoto coErr 983768 00000000 1235 nop 98376c 14600042 1236 coErr2: r3 = COERR2 /* Number of set too large */ 983770 a00f009c 1237 pcgoto coErr 983774 00000000 1238 nop 983778 14600043 1239 coErr3: r3 = COERR3 /* Number of bins too small */ 98377c a00f0090 1240 pcgoto coErr 983780 00000000 1241 nop 983784 14600044 1242 coErr4: r3 = COERR4 /* Number of bins too large */ 983788 a00f0084 1243 pcgoto coErr 98378c 00000000 1244 nop 983790 14600045 1245 coErr5: r3 = COERR5 /* Number of templates too small */ 983794 a00f0078 1246 pcgoto coErr 983798 00000000 1247 nop 98379c 14600046 1248 coErr6: r3 = COERR6 /* Number of templates too large */ 9837a0 a00f006c 1249 pcgoto coErr 9837a4 00000000 1250 nop 9837a8 14600047 1251 coErr7: r3 = COERR7 /* No template for this library */ 9837ac a00f0060 1252 pcgoto coErr 9837b0 00000000 1253 nop 9837b4 14600048 1254 coErr8: r3 = COERR8 /* Too many templates for this library */ 9837b8 a00f0054 1255 pcgoto coErr 9837bc 00000000 1256 nop 9837c0 14600049 1257 coErr9: r3 = COERR9 /* Number of bins in shape not equal 96 */ 9837c4 a00f0048 1258 pcgoto coErr 9837c8 00000000 1259 nop 9837cc 1460004a 1260 coErr10: r3 = COERR10 /* Number of bins in start block too small */ 9837d0 a00f003c 1261 pcgoto coErr 9837d4 00000000 1262 nop 9837d8 1460004b 1263 coErr11: r3 = COERR11 /* Number of bins in start block too large */ 9837dc a00f0030 1264 pcgoto coErr 9837e0 00000000 1265 nop 9837e4 1460004c 1266 coErr12: r3 = COERR12 /* Number of bins in end block too small */ 9837e8 a00f0024 1267 pcgoto coErr 9837ec 00000000 1268 nop 9837f0 1460004d 1269 coErr13: r3 = COERR13 /* Number of bins in end block too large */ 9837f4 a00f0018 1270 pcgoto coErr 9837f8 00000000 1271 nop 9837fc 1460004e 1272 coErr14: r3 = COERR14 /* Mid bin index too large */ 983800 a00f000c 1273 pcgoto coErr 983804 00000000 1274 nop 983808 1460004f 1275 coErr15: r3 = COERR15 /* Mid bin index too large */ 98380c a00f0000 1276 pcgoto coErr 983810 00000000 1277 nop 1278 /* Do housekeeping error processing here */ 983814 130f0914 1279 coErr: pccall posterror(r20) /* Post error message */ 983818 00000000 1280 nop 1281 98381c bfefff1c 1282 pcgoto cojmp11 /* Continue processing for next detector */ 983820 00000000 1283 nop 1284 1285 1286 /******************************************************************************/ 1287 /* ADDLIBRARY */ 1288 /* -------------------------------------------------------------------------- */ 1289 /* Version: 1.09 */ 1290 /* Date : 15-Nov-1999 */ 1291 /* Author : Jurgen Knodlseder, CESR (C) 1999 */ 1292 /* -------------------------------------------------------------------------- */ 1293 /* History: 1.03 30-Aug-1999 JK First version */ 1294 /* 1.04 24-Sep-1999 JK First Berkeley version */ 1295 /* 1.05 28-Sep-1999 JK Remove library management; include */ 1296 /* parameter block */ 1297 /* 1.06 10-Oct-1999 JK Add jump vector warper; verify parameter */ 1298 /* block */ 1299 /* 1.07 15-Oct-1999 JK Correct libloaddata memory structure */ 1300 /* 1.08 18-Oct-1999 JK Added average baseline weighting factor */ 1301 /* 1.09 15-Nov-1999 JK Modified parameter block structure */ 1302 /* -------------------------------------------------------------------------- */ 1303 /* Task: */ 1304 /* ===== */ 1305 /* Add library vector to EEPROMs. */ 1306 /* -------------------------------------------------------------------------- */ 1307 /* */ 1308 /* Usage: */ 1309 /* ====== */ 1310 /* pccall addlibrary(r18) */ 1311 /* nop */ 1312 /* */ 1313 /* Parameters: */ 1314 /* =========== */ 1315 /* 1) Input: libloaddetector i : Detector number */ 1316 /* libloadset i : Template set number */ 1317 /* libloadcurve i : Curve number */ 1318 /* libloadlength i : Length of curve */ 1319 /* n_temp_sets i : Maximum number of template sets */ 1320 /* 2) Output: */ 1321 /* 3) Internal: pulse f : Template floating point array */ 1322 /* */ 1323 /* Register usage: */ 1324 /* =============== */ 1325 /* r1e : Template data */ 1326 /* r2 : Multiple usage */ 1327 /* r3 : Error code for "posterror" */ 1328 /* r5 : Multiple usage */ 1329 /* r6 : Multiple usage */ 1330 /* r7e : EEPROM destination address */ 1331 /* r8e : EEPROM source address */ 1332 /* r9e : EEPROM size of memory write in Bytes */ 1333 /* r18e : PC for subroutine return */ 1334 /* r19e : copy of r18e */ 1335 /* r20e : posterror return code */ 1336 /* */ 1337 /* Subroutines: */ 1338 /* ============ */ 1339 /* pccall eewrite(r18) : EEPROM write routine */ 1340 /* */ 1341 /* -------------------------------------------------------------------------- */ 1342 /* */ 1343 /* Description: */ 1344 /* ============ */ 1345 /* The information of the shape to be added is stored in a data structure */ 1346 /* starting at "libloaddetector". Note that the structure starting from */ 1347 /* "libloaddata" is separated in 32-bit words where the most significant */ 1348 /* Byte is always set to 0x00. */ 1349 /* */ 1350 /* +--------------+ libloaddetector */ 1351 /* | Detector | */ 1352 /* +--------------+ libloadset */ 1353 /* | Set number | */ 1354 /* +--------------+ libloadcurve */ 1355 /* | Curve number | */ 1356 /* +--------------+ libloadlength */ 1357 /* | Length | */ 1358 /* +--------------+ libloaddata */ 1359 /* | n_templates | Data 0 */ 1360 /* | n_start_bins | */ 1361 /* | n_end_bins | */ 1362 /* | 0x00 | */ 1363 /* +--------------+ */ 1364 /* | time_mid | Data 1 */ 1365 /* |pulse_dur_min | */ 1366 /* |pulse_dur_max | */ 1367 /* | 0x00 | */ 1368 /* +--------------+ */ 1369 /* | baseline_wgt | Data 2 */ 1370 /* | baseline_out | */ 1371 /* |baseline_mout | */ 1372 /* | 0x00 | */ 1373 /* +--------------+ */ 1374 /* | minbase | Data 3 */ 1375 /* | minbase | */ 1376 /* | 0x00 | */ 1377 /* | 0x00 | */ 1378 /* +--------------+ */ 1379 /* | maxbase | Data 4 */ 1380 /* | maxbase | */ 1381 /* | 0x00 | */ 1382 /* | 0x00 | */ 1383 /* +--------------+ */ 1384 /* | minpulse| Data 5 */ 1385 /* | minpulse| */ 1386 /* | 0x00 | */ 1387 /* | 0x00 | */ 1388 /* +--------------+ */ 1389 /* | maxpulse| Data 6 */ 1390 /* | maxpulse| */ 1391 /* | 0x00 | */ 1392 /* | 0x00 | */ 1393 /* +--------------+ */ 1394 /* |pulse_saturate| Data 7 */ 1395 /* |pulse_saturate| */ 1396 /* | 0x00 | */ 1397 /* | 0x00 | */ 1398 /* +--------------+ */ 1399 /* | thres_fract | Data 8 */ 1400 /* | thres_fract | */ 1401 /* | thres_fract | */ 1402 /* | 0x00 | */ 1403 /* +--------------+ */ 1404 /* | energy 0 | Data 9 */ 1405 /* | energy 0 | */ 1406 /* | 0x00 | */ 1407 /* | 0x00 | */ 1408 /* +--------------+ */ 1409 /* : : */ 1410 /* : : */ 1411 /* +--------------+ */ 1412 /* | energy 9 | Data 18 */ 1413 /* | energy 9 | */ 1414 /* | 0x00 | */ 1415 /* | 0x00 | */ 1416 /* +--------------+ */ 1417 /* | DTTPmin 0 | Data 19 */ 1418 /* | DTTPmin 1 | */ 1419 /* | DTTPmin 2 | */ 1420 /* | 0x00 | */ 1421 /* +--------------+ */ 1422 /* | DTTPmin 3 | Data 20 */ 1423 /* | DTTPmin 4 | */ 1424 /* | DTTPmin 5 | */ 1425 /* | 0x00 | */ 1426 /* +--------------+ */ 1427 /* | DTTPmin 6 | Data 21 */ 1428 /* | DTTPmin 7 | */ 1429 /* | DTTPmin 8 | */ 1430 /* | 0x00 | */ 1431 /* +--------------+ */ 1432 /* | DTTPmin 9 | Data 22 */ 1433 /* | DTTPmax 0 | */ 1434 /* | DTTPmax 1 | */ 1435 /* | 0x00 | */ 1436 /* +--------------+ */ 1437 /* | DTTPmax 2 | Data 23 */ 1438 /* | DTTPmax 3 | */ 1439 /* | DTTPmax 4 | */ 1440 /* | 0x00 | */ 1441 /* +--------------+ */ 1442 /* | DTTPmax 5 | Data 24 */ 1443 /* | DTTPmax 6 | */ 1444 /* | DTTPmax 7 | */ 1445 /* | 0x00 | */ 1446 /* +--------------+ */ 1447 /* | DTTPmax 8 | Data 25 */ 1448 /* | DTTPmax 9 | */ 1449 /* | 0x00 | */ 1450 /* | 0x00 | */ 1451 /* +--------------+ */ 1452 /* | TRS neg 0 | Data 26 */ 1453 /* | TRS neg 0 | */ 1454 /* | TRS neg 0 | */ 1455 /* | 0x00 | */ 1456 /* +--------------+ */ 1457 /* : : */ 1458 /* : : */ 1459 /* +--------------+ */ 1460 /* | TRS neg 9 | Data 35 */ 1461 /* | TRS neg 9 | */ 1462 /* | TRS neg 9 | */ 1463 /* | 0x00 | */ 1464 /* +--------------+ */ 1465 /* | TRS pos 0 | Data 36 */ 1466 /* | TRS pos 0 | */ 1467 /* | TRS pos 0 | */ 1468 /* | 0x00 | */ 1469 /* +--------------+ */ 1470 /* : : */ 1471 /* : : */ 1472 /* +--------------+ */ 1473 /* | TRS pos 9 | Data 45 */ 1474 /* | TRS pos 9 | */ 1475 /* | TRS pos 9 | */ 1476 /* | 0x00 | */ 1477 /* +--------------+ */ 1478 /* */ 1479 /* The format of the library templates in memory is as follows: */ 1480 /* */ 1481 /* +----------------+ libEE (usually 0x080000) */ 1482 /* | Lib: 0, Tpl: 0 | 4*M_TEMP_BINS Bytes */ 1483 /* | Lib: 0, Tpl: 1 | 4*M_TEMP_BINS Bytes */ 1484 /* : : : : */ 1485 /* | Lib: 0, Tpl: n | 4*M_TEMP_BINS Bytes */ 1486 /* +----------------+ */ 1487 /* | Lib: 1, Tpl: 0 | 4*M_TEMP_BINS Bytes */ 1488 /* | Lib: 1, Tpl: 1 | 4*M_TEMP_BINS Bytes */ 1489 /* : : : : */ 1490 /* | Lib: 1, Tpl: n | 4*M_TEMP_BINS Bytes */ 1491 /* +----------------+ */ 1492 /* : : : : */ 1493 /* | Lib: m, Tpl: n | 4*M_TEMP_BINS Bytes */ 1494 /* +----------------+ */ 1495 /* */ 1496 /* All templates have a fixed length of M_TEMP_BINS (usually 64 bins) in */ 1497 /* memory. The number of templates in a library is fixed to M_TPLS. The total */ 1498 /* size of a library in bytes is: SIZEOFLIB = (M_TPLS+1)*(M_TEMP_BINS)*4. */ 1499 /* Selection parameters are loaded as a special curve (curve number 0xff). */ 1500 /* */ 1501 /* Notes: */ 1502 /* ====== */ 1503 /* All parameters are boundary checked. Note that each parameter has 2 bounds */ 1504 /* (lower and upper bound; a value of 0xff would mean -1, hence has to be */ 1505 /* checked against 0). */ 1506 /* The threshold fraction and the smaller peak threshold are transferred as */ 1507 /* 24 Bit signed fixed point value with a dynamic step size of 1/8388607. */ 1508 /* This means that i.e. for a threshold fraction of 0.006 transfer */ 1509 /* 0.006*8388607 and for a smaller peak threshold of 0.25 transfer */ 1510 /* 0.25*8388607. */ 1511 /******************************************************************************/ 1512 addlibrary: 1513 /* Jump table warper */ 983824 1cc2f300 1514 r2e = *Jaddlibrary /* Load jump vector */ 983828 00000000 1515 nop /* Wait for register load */ 98382c a0020000 1516 goto r2 /* Jump into code */ 983830 00000000 1517 nop 1518 /******************************************************************************/ 1519 /* Default code (can be replaced by uploaded code) */ 1520 /******************************************************************************/ 1521 myaddlibrary: 1522 /* Initialise */ 983834 1dcee62c 1523 *stackcopy = r14e /* Save stack pointer */ 983838 98150a14 1524 r19e = r18 /* Save return address */ 1525 1526 /* Verify curve number */ 98383c 1c42fc2c 1527 r2l = *libloadcurve /* Get the curve number */ 983840 00000000 1528 nop 983844 1ae200ff 1529 r2 - PSDPARABLOCK /* Curve is parameter curve ? */ 983848 00af0018 1530 if (eq) pcgoto alcont1 /* Yes, then continue */ 98384c 00000000 1531 nop 983850 1ae20000 1532 r2 - 0 /* Curve >= 0 ? */ 983854 016f05c8 1533 if (lt) pcgoto alErr1 /* No, then error */ 983858 00000000 1534 nop 98385c 1ae20026 1535 r2 - M_TPLS /* Curve < M_TPLS ? */ 983860 014f05c8 1536 if (ge) pcgoto alErr2 /* No, then error */ 983864 00000000 1537 nop 1538 1539 /* Verify set number */ 983868 1c42fc2a 1540 alcont1: r2l = *libloadset /* Get set number */ 98386c 1c85e5c8 1541 r5 = *n_temp_sets /* Get maximum number of template sets */ 983870 1ae20000 1542 r2 - 0 /* Set >= 0 ? */ 983874 016f05c0 1543 if (lt) pcgoto alErr3 /* No, then error */ 983878 00000000 1544 nop 98387c 18e200a0 1545 r2 - r5 /* Set < n_temp_sets ? */ 983880 014f05c0 1546 if (ge) pcgoto alErr4 /* No, then error */ 983884 00000000 1547 nop 1548 1549 /* Verify detector number */ 983888 1c42fc28 1550 r2l = *libloaddetector /* Get detector number */ 98388c 00000000 1551 nop 983890 1ae20000 1552 r2 - 0 /* Detector >= 0 ? */ 983894 016f05b8 1553 if (lt) pcgoto alErr5 /* No, then error */ 983898 00000000 1554 nop 98389c 1ae20013 1555 r2 - M_DETS /* Detector < 19 ? */ 9838a0 014f05b8 1556 if (ge) pcgoto alErr6 /* No, then error */ 9838a4 00000000 1557 nop 1558 1559 /* Verify template length */ 9838a8 1c42fc2e 1560 r2l = *libloadlength /* Get template length */ 9838ac 00000000 1561 nop 9838b0 1ae20000 1562 r2 - 0 /* Length > 0 ? */ 9838b4 01af05b0 1563 if (le) pcgoto alErr7 /* No, then error */ 9838b8 00000000 1564 nop 9838bc 1ae20040 1565 r2 - M_TEMP_BINS /* Length <= M_TEMP_BINS ? */ 9838c0 018f05b0 1566 if (gt) pcgoto alErr8 /* No, then error */ 9838c4 00000000 1567 nop 1568 /* Evaluate curve base address in EEPROM */ 9838c8 c1070000 1569 r7e = libEE /* Get EEPROM base address */ 9838cc 1c42fc2a 1570 r2l = *libloadset /* Get set number */ 9838d0 dfe5f460 1571 r5e = off_lEE_4 /* Get offset table base address */ 9838d4 98220040 1572 r2e = r2 * 2 /* Get set 4-Byte offset */ 9838d8 98220040 1573 r2e = r2 * 2 9838dc 98050040 1574 r5e = r5 + r2 /* r5e -> off_lEE_4[set] */ 9838e0 1ee600b0 1575 r6e = *r5 /* r6e = off_lEE_4[set] (offset) */ 9838e4 00000000 1576 nop 9838e8 980700c0 1577 r7e = r7 + r6 /* Add set offset */ 9838ec 1c42fc28 1578 r2l = *libloaddetector /* Get detector number */ 9838f0 dfe5f414 1579 r5e = off_lEE_3 /* Get offset table base address */ 9838f4 98220040 1580 r2e = r2 * 2 /* Get set 4-Byte offset */ 9838f8 98220040 1581 r2e = r2 * 2 9838fc 98050040 1582 r5e = r5 + r2 /* r5e -> off_lEE_3[detector] */ 983900 1ee600b0 1583 r6e = *r5 /* r6e = off_lEE_3[detector] (offset) */ 983904 00000000 1584 nop 983908 980700c0 1585 r7e = r7 + r6 /* Add set offset */ 98390c 1c42fc2c 1586 r2l = *libloadcurve /* Get curve number */ 983910 dfe5f32c 1587 r5e = off_lib_2 /* Get offset table base address */ 983914 1ae200ff 1588 r2 - PSDPARABLOCK /* Curve = parameter block ? */ 983918 008f0004 1589 if (ne) pcgoto alcont2 /* No, then continue */ 98391c 00000000 1590 nop 983920 14400026 1591 r2 = M_TPLS /* Yes, then store in last template */ 983924 98220040 1592 alcont2: r2e = r2 * 2 /* Get set 4-Byte offset */ 983928 98220040 1593 r2e = r2 * 2 98392c 98050040 1594 r5e = r5 + r2 /* r5e -> off_lib_2[curve] */ 983930 1ee600b0 1595 r6e = *r5 /* r6e = off_lib_2[curve] (offset) */ 983934 00000000 1596 nop 983938 980700c0 1597 r7e = r7 + r6 /* Add curve offset */ 1598 1599 /* Decide on template type */ 98393c 1c42fc2c 1600 r2l = *libloadcurve /* Get the curve number */ 983940 00000000 1601 nop 983944 1ae200ff 1602 r2 - PSDPARABLOCK /* Parameter block ? */ 983948 00af0034 1603 if (eq) pcgoto parCurve /* Yes ... */ 98394c 00000000 1604 nop 1605 /* Standard template: Float template */ 983950 1c42fc2e 1606 r2l = *libloadlength /* Get number of elements to move */ 983954 dfe1fc30 1607 r1e = libloaddata /* Get library data block address */ 983958 1a820002 1608 r2 = r2 - 2 /* Set loop counter */ 98395c dfe5f5b0 1609 r5e = pulse /* Get base address of float array */ 983960 7d2007af 1610 alloop1: *r5++ = a1 = float24(*r1++) /* Float template value */ 983964 0c4ffff4 1611 if (r2-- >= 0) pcgoto alloop1 /* Next ... */ 983968 00000000 1612 nop 98396c 1c49fc2e 1613 r9l = *libloadlength /* Get number of elements to write */ 983970 00000000 1614 nop 983974 98290120 1615 r9e = r9 * 2 /* ... in Bytes */ 983978 98290120 1616 r9e = r9 * 2 98397c a00f0484 1617 pcgoto writeROM /* Write data to EEPROM */ 983980 00000000 1618 nop 1619 /* Parameter template: Extract parameters */ 983984 dfe1fc30 1620 parCurve: r1e = libloaddata /* Get library data block address */ 983988 dfe3e604 1621 r3e = temp /* Get temporary memory address */ 98398c dfe5f5b0 1622 r5e = pulse /* Use pulse as buffer */ 983990 1e620037 1623 r2l = *r1++ /* Extract number of templates (8 bit) */ 983994 00000000 1624 nop 983998 1ae20000 1625 r2 - 0 /* Number of templates >= 0 */ 98399c 016f04e0 1626 if (lt) pcgoto alErr9 /* No, then error */ 9839a0 1ae20026 1627 r2 - M_TPLS /* Number of templates <= M_TPLS */ 9839a4 018f04e4 1628 if (gt) pcgoto alErr10 /* No, then error */ 9839a8 94c50000 1629 r6e = r5 + libparNum 9839ac 1f6200d0 1630 *r6 = r2l /* Store value */ 9839b0 14400060 1631 r2 = N_SHAPE_BINS /* Get (constant) number of bins */ 9839b4 98060ae5 1632 r6e = r5 + libparBins 9839b8 1f6200d0 1633 *r6 = r2l /* Store value */ 9839bc 1fe20070 1634 *r3 = r2e /* Store also in temporary memory */ 9839c0 94c50054 1635 r6e = r5 + libparFltBins 9839c4 79000c30 1636 *r6 = a0 = float(*r3) /* Float and store value */ 9839c8 1e620037 1637 r2l = *r1++ /* Extract number of start bins (8 bit) */ 9839cc 00000000 1638 nop 9839d0 1ae20000 1639 r2 - 0 /* Start bins > 0 */ 9839d4 01af04c0 1640 if (le) pcgoto alErr11 /* No, then error */ 9839d8 1ae20060 1641 r2 - N_SHAPE_BINS /* Start bins < N_SHAPE_BINS */ 9839dc 014f04c4 1642 if (ge) pcgoto alErr12 /* No, then error */ 9839e0 94c50002 1643 r6e = r5 + libparStart 9839e4 1f6200d0 1644 *r6 = r2l /* Store value */ 9839e8 1fe20070 1645 *r3 = r2e /* Store also in temporary memory */ 9839ec 94c50058 1646 r6e = r5 + libparInvStart 9839f0 79000c07 1647 a0 = float(*r3) /* Float value */ 9839f4 00000000 1648 nop 9839f8 00000000 1649 nop 9839fc 00000000 1650 nop 983a00 02af0008 1651 if (aeq) pcgoto alcont3 /* Do not invert 0.0 */ 983a04 00000000 1652 nop 983a08 130f06dc 1653 pccall inverse(r20) /* Invert result */ 983a0c 00000000 1654 nop 983a10 30000030 1655 alcont3: *r6 = a0 = a0 /* Float and store value */ 983a14 1e620037 1656 r2l = *r1++ /* Extract number of end bins (8 bit) */ 983a18 00000000 1657 nop 983a1c 1ae20000 1658 r2 - 0 /* End bins > 0 */ 983a20 01af048c 1659 if (le) pcgoto alErr13 /* No, then error */ 983a24 94c50002 1660 r6e = r5 + libparStart /* Point to start bins */ 983a28 1e6600d0 1661 r6l = *r6 /* Get number of start bins */ 983a2c 15200060 1662 r9 = N_SHAPE_BINS /* Get number of bins */ 983a30 188900c0 1663 r9 = r9 - r6 /* Get number of remaining bins */ 983a34 18e20120 1664 r2 - r9 /* End bins <= remaining bins */ 983a38 018f0480 1665 if (gt) pcgoto alErr14 /* No, then error */ 983a3c 94c50003 1666 r6e = r5 + libparEnd 983a40 1f6200d0 1667 *r6 = r2l /* Store value */ 983a44 1fe20070 1668 *r3 = r2e /* Store also in temporary memory */ 983a48 94c5005c 1669 r6e = r5 + libparInvEnd 983a4c 79000c07 1670 a0 = float(*r3) /* Float value */ 983a50 00000000 1671 nop 983a54 00000000 1672 nop 983a58 00000000 1673 nop 983a5c 02af0008 1674 if (aeq) pcgoto alcont4 /* Do not invert 0.0 */ 983a60 00000000 1675 nop 983a64 130f0680 1676 pccall inverse(r20) /* Invert result */ 983a68 00000000 1677 nop 983a6c 30000030 1678 alcont4: *r6 = a0 = a0 /* Float and store value */ 983a70 1e620037 1679 r2l = *r1++ /* Skip empty Byte */ 983a74 00000000 1680 nop 983a78 1e620037 1681 r2l = *r1++ /* Extract mean bin (8 bit) */ 983a7c 00000000 1682 nop 983a80 1ae20000 1683 r2 - 0 /* Mean bin >= 0 */ 983a84 016f0440 1684 if (lt) pcgoto alErr15 /* No, then error */ 983a88 1ae20060 1685 r2 - N_SHAPE_BINS /* Mean bin < N_SHAPE_BINS */ 983a8c 014f0444 1686 if (ge) pcgoto alErr16 /* No, then error */ 983a90 94c50004 1687 r6e = r5 + libparMid 983a94 1f6200d0 1688 *r6 = r2l /* Store value */ 983a98 1e620037 1689 r2l = *r1++ /* Extract minimum duration (8 bit) */ 983a9c 94c50005 1690 r6e = r5 + libparMin 983aa0 1f6200d0 1691 *r6 = r2l /* Store value */ 983aa4 00000000 1692 nop 983aa8 1e620037 1693 r2l = *r1++ /* Extract maximum duration (8 bit) */ 983aac 94c50006 1694 r6e = r5 + libparMax 983ab0 1f6200d0 1695 *r6 = r2l /* Store value */ 983ab4 00000000 1696 nop 983ab8 1e620037 1697 r2l = *r1++ /* Skip empty Byte */ 983abc 00000000 1698 nop 983ac0 1e620037 1699 r2l = *r1++ /* Extract baseline averaging weight (8 bit) */ 983ac4 94c50007 1700 r6e = r5 + libparBaseAvg 983ac8 1f6200d0 1701 *r6 = r2l /* Store value */ 983acc 1fe20070 1702 *r3 = r2e /* Store also in temporary memory */ 983ad0 944f1f3c 1703 r2e = pc + (byteTfloat - . - 8) /* Point to 1/255 */ 983ad4 7d000c07 1704 a0 = float24(*r3) /* Float value */ 983ad8 30200807 1705 a1 = *r2 /* Get conversion value */ 983adc 00000000 1706 nop 983ae0 00000000 1707 nop 983ae4 00000000 1708 nop 983ae8 70004007 1709 a0 = a0 * a1 /* Devide integer by 255 */ 983aec 00000000 1710 nop 983af0 94c50068 1711 r6e = r5 + libparBaseAvgF 983af4 944f1f00 1712 r2e = pc + (zero - . - 8) /* Point to 0.0 */ 983af8 34a40007 1713 a1 = a0 - *r2 /* a0 less than 0.0 ? */ 983afc 7a800807 1714 a0 = ifalt(*r2) /* Yes, then a0 = 0.0 */ 983b00 944f1efc 1715 r2e = pc + (one - . - 8) /* Point to 1.0 */ 983b04 35240007 1716 a1 = -a0 + *r2 /* a0 greater than 1.0 ? */ 983b08 7a800807 1717 a0 = ifalt(*r2) /* Yes, then a0 = 1.0 */ 983b0c 30000030 1718 *r6 = a0 = a0 /* Store baseline fraction */ 983b10 94c50064 1719 r6e = r5 + libparBaseThisF 983b14 34800830 1720 *r6 = a0 = *r2 - a0 /* Compute complement (1-a0) */ 983b18 1e620037 1721 r2l = *r1++ /* Extract baseline outlier value (8 bit) */ 983b1c 94c50008 1722 r6e = r5 + libparBaseOut 983b20 1f6200d0 1723 *r6 = r2l /* Store value */ 983b24 1e620037 1724 r2l = *r1++ /* Extract maximum baseline outliers (8 bit) */ 983b28 94c50009 1725 r6e = r5 + libparBaseMaxOut 983b2c 1f6200d0 1726 *r6 = r2l /* Store value */ 983b30 1e620037 1727 r2l = *r1++ /* Skip empty Byte */ 983b34 00000000 1728 nop 983b38 1ea20037 1729 r2 = *r1++ /* Extract minimum baseline (16 bit) */ 983b3c 94c5000c 1730 r6e = r5 + libparMinBase 983b40 1fa200d0 1731 *r6 = r2 /* Store value */ 983b44 1fe20070 1732 *r3 = r2e /* Store also in temporary memory */ 983b48 94c5006c 1733 r6e = r5 + libparFltMinBase 983b4c 79000c30 1734 *r6 = a0 = float(*r3) /* Float and store value */ 983b50 1ea20037 1735 r2 = *r1++ /* Skip empty word */ 983b54 00000000 1736 nop 983b58 1ea20037 1737 r2 = *r1++ /* Extract maximum baseline (16 bit) */ 983b5c 94c5000e 1738 r6e = r5 + libparMaxBase 983b60 1fa200d0 1739 *r6 = r2 /* Store value */ 983b64 1fe20070 1740 *r3 = r2e /* Store also in temporary memory */ 983b68 94c50070 1741 r6e = r5 + libparFltMaxBase 983b6c 79000c30 1742 *r6 = a0 = float(*r3) /* Float and store value */ 983b70 1ea20037 1743 r2 = *r1++ /* Skip empty word */ 983b74 00000000 1744 nop 983b78 1ee20037 1745 r2e = *r1++ /* Extract minimum pulse area (32 bit) */ 983b7c 94c50010 1746 r6e = r5 + libparMinPulse 983b80 9bc2ffff 1747 r2e = r2 & 0xffff /* Use only lowest 16 Bits */ 983b84 1fa200d0 1748 *r6 = r2 /* Store value */ 983b88 1fe20070 1749 *r3 = r2e /* Store also in temporary memory */ 983b8c 94c50074 1750 r6e = r5 + libparFltMinPulse 983b90 7d000c30 1751 *r6 = a0 = float24(*r3) /* Float and store value */ 983b94 1ee20037 1752 r2e = *r1++ /* Extract maximum pulse area (32 bit) */ 983b98 94c50012 1753 r6e = r5 + libparMaxPulse 983b9c 9bc2ffff 1754 r2e = r2 & 0xffff /* Use only lowest 16 Bits */ 983ba0 1fa200d0 1755 *r6 = r2 /* Store value */ 983ba4 1fe20070 1756 *r3 = r2e /* Store also in temporary memory */ 983ba8 94c50078 1757 r6e = r5 + libparFltMaxPulse 983bac 7d000c30 1758 *r6 = a0 = float24(*r3) /* Float and store value */ 983bb0 1ee20037 1759 r2e = *r1++ /* Extract saturation value (32 bit) */ 983bb4 94c50014 1760 r6e = r5 + libparSaturate 983bb8 9bc201ff 1761 r2e = r2 & 0x01ff /* Keep only 9 least significant bits */ 983bbc 1fa200d0 1762 *r6 = r2 /* Store value */ 983bc0 1ee20037 1763 r2e = *r1++ /* Extract threshold fraction (32 bit) */ 983bc4 94c50060 1764 r6e = r5 + libparThFract 983bc8 1fe20070 1765 *r3 = r2e /* Store in temporary memory */ 983bcc 944f1e48 1766 r2e = pc + (longTfloat - . - 8) /* Point to 1/8388607 */ 983bd0 7d000c07 1767 a0 = float24(*r3) /* Float value */ 983bd4 30200807 1768 a1 = *r2 /* Get conversion value */ 983bd8 00000000 1769 nop 983bdc 00000000 1770 nop 983be0 00000000 1771 nop 983be4 70004007 1772 a0 = a0 * a1 /* Devide integer by 8388607 */ 983be8 00000000 1773 nop 983bec 00000000 1774 nop 983bf0 944f1e04 1775 r2e = pc + (zero - . - 8) /* Point to 0.0 */ 983bf4 34a40007 1776 a1 = a0 - *r2 /* a0 less than 0.0 ? */ 983bf8 7a800807 1777 a0 = ifalt(*r2) /* Yes, then a0 = 0.0 */ 983bfc 944f1e00 1778 r2e = pc + (one - . - 8) /* Point to 1.0 */ 983c00 35240007 1779 a1 = -a0 + *r2 /* a0 greater than 1.0 ? */ 983c04 7a800807 1780 a0 = ifalt(*r2) /* Yes, then a0 = 1.0 */ 983c08 30000030 1781 *r6 = a0 = a0 /* Store threshold fraction */ 1782 1783 /* Get 10 energy values */ 983c0c 15200008 1784 r9 = 8 /* Set loop counter */ 983c10 94c50016 1785 r6e = r5 + libparEnergy 983c14 1ee20037 1786 alloop2: r2e = *r1++ /* Extract energy value (32 bits) */ 983c18 00000000 1787 nop 983c1c 9bc2ffff 1788 r2e = r2 & 0xffff /* Keep only 16 least significant bits */ 983c20 1fa200d7 1789 *r6++ = r2 /* Store value */ 983c24 0d2fffe8 1790 if (r9-- >= 0) pcgoto alloop2 /* Next ... */ 983c28 00000000 1791 nop 1792 /* Get 10 Delta TTP min values */ 983c2c 94c5002a 1793 r6e = r5 + libparDTTPmin 983c30 1e620037 1794 r2l = *r1++ /* Extract Delta TTP min 0 value (8 bits) */ 983c34 00000000 1795 nop 983c38 1fa200d7 1796 *r6++ = r2 /* Store value */ 983c3c 1e620037 1797 r2l = *r1++ /* Extract Delta TTP min 1 value (8 bits) */ 983c40 00000000 1798 nop 983c44 1fa200d7 1799 *r6++ = r2 /* Store value */ 983c48 1e620037 1800 r2l = *r1++ /* Extract Delta TTP min 2 value (8 bits) */ 983c4c 00000000 1801 nop 983c50 1fa200d7 1802 *r6++ = r2 /* Store value */ 983c54 1e620037 1803 r2l = *r1++ /* Skip empty Byte */ 983c58 00000000 1804 nop 983c5c 1e620037 1805 r2l = *r1++ /* Extract Delta TTP min 3 value (8 bits) */ 983c60 00000000 1806 nop 983c64 1fa200d7 1807 *r6++ = r2 /* Store value */ 983c68 1e620037 1808 r2l = *r1++ /* Extract Delta TTP min 4 value (8 bits) */ 983c6c 00000000 1809 nop 983c70 1fa200d7 1810 *r6++ = r2 /* Store value */ 983c74 1e620037 1811 r2l = *r1++ /* Extract Delta TTP min 5 value (8 bits) */ 983c78 00000000 1812 nop 983c7c 1fa200d7 1813 *r6++ = r2 /* Store value */ 983c80 1e620037 1814 r2l = *r1++ /* Skip empty Byte */ 983c84 00000000 1815 nop 983c88 1e620037 1816 r2l = *r1++ /* Extract Delta TTP min 6 value (8 bits) */ 983c8c 00000000 1817 nop 983c90 1fa200d7 1818 *r6++ = r2 /* Store value */ 983c94 1e620037 1819 r2l = *r1++ /* Extract Delta TTP min 7 value (8 bits) */ 983c98 00000000 1820 nop 983c9c 1fa200d7 1821 *r6++ = r2 /* Store value */ 983ca0 1e620037 1822 r2l = *r1++ /* Extract Delta TTP min 8 value (8 bits) */ 983ca4 00000000 1823 nop 983ca8 1fa200d7 1824 *r6++ = r2 /* Store value */ 983cac 1e620037 1825 r2l = *r1++ /* Skip empty Byte */ 983cb0 00000000 1826 nop 983cb4 1e620037 1827 r2l = *r1++ /* Extract Delta TTP min 9 value (8 bits) */ 983cb8 00000000 1828 nop 983cbc 1fa200d7 1829 *r6++ = r2 /* Store value */ 1830 1831 /* Get 10 Delta TTP max values */ 983cc0 1e620037 1832 r2l = *r1++ /* Extract Delta TTP max 0 value (8 bits) */ 983cc4 00000000 1833 nop 983cc8 1fa200d7 1834 *r6++ = r2 /* Store value */ 983ccc 1e620037 1835 r2l = *r1++ /* Extract Delta TTP max 1 value (8 bits) */ 983cd0 00000000 1836 nop 983cd4 1fa200d7 1837 *r6++ = r2 /* Store value */ 983cd8 1e620037 1838 r2l = *r1++ /* Skip empty Byte */ 983cdc 00000000 1839 nop 983ce0 1e620037 1840 r2l = *r1++ /* Extract Delta TTP max 2 value (8 bits) */ 983ce4 00000000 1841 nop 983ce8 1fa200d7 1842 *r6++ = r2 /* Store value */ 983cec 1e620037 1843 r2l = *r1++ /* Extract Delta TTP max 3 value (8 bits) */ 983cf0 00000000 1844 nop 983cf4 1fa200d7 1845 *r6++ = r2 /* Store value */ 983cf8 1e620037 1846 r2l = *r1++ /* Extract Delta TTP max 4 value (8 bits) */ 983cfc 00000000 1847 nop 983d00 1fa200d7 1848 *r6++ = r2 /* Store value */ 983d04 1e620037 1849 r2l = *r1++ /* Skip empty Byte */ 983d08 00000000 1850 nop 983d0c 1e620037 1851 r2l = *r1++ /* Extract Delta TTP max 5 value (8 bits) */ 983d10 00000000 1852 nop 983d14 1fa200d7 1853 *r6++ = r2 /* Store value */ 983d18 1e620037 1854 r2l = *r1++ /* Extract Delta TTP max 6 value (8 bits) */ 983d1c 00000000 1855 nop 983d20 1fa200d7 1856 *r6++ = r2 /* Store value */ 983d24 1e620037 1857 r2l = *r1++ /* Extract Delta TTP max 7 value (8 bits) */ 983d28 00000000 1858 nop 983d2c 1fa200d7 1859 *r6++ = r2 /* Store value */ 983d30 1e620037 1860 r2l = *r1++ /* Skip empty Byte */ 983d34 00000000 1861 nop 983d38 1e620037 1862 r2l = *r1++ /* Extract Delta TTP max 8 value (8 bits) */ 983d3c 00000000 1863 nop 983d40 1fa200d7 1864 *r6++ = r2 /* Store value */ 983d44 1e620037 1865 r2l = *r1++ /* Extract Delta TTP max 9 value (8 bits) */ 983d48 00000000 1866 nop 983d4c 1fa200d7 1867 *r6++ = r2 /* Store value */ 983d50 1ea20037 1868 r2 = *r1++ /* Skip empty word */ 983d54 00000000 1869 nop 1870 /* Get 10 TRS neg. values */ 983d58 15200008 1871 r9 = 8 /* Set loop counter */ 983d5c 94c5007c 1872 r6e = r5 + libparTRSneg 983d60 944f1cb4 1873 r2e = pc + (longTfloat - . - 8) /* Pointer to 1/8388607 */ 983d64 30400807 1874 a2 = *r2 /* a2 = 1/8388607 */ 983d68 7d000787 1875 alloop5: a0 = float24(*r1++) /* Float TRS neg. value (32 bit) */ 983d6c 00000000 1876 nop 983d70 00000000 1877 nop 983d74 00000000 1878 nop 983d78 70008007 1879 a0 = a0 * a2 /* Devide integer by 8388607 */ 983d7c 00000000 1880 nop 983d80 00000000 1881 nop 983d84 944f1c70 1882 r2e = pc + (zero - . - 8) /* Point to 0.0 */ 983d88 34a40007 1883 a1 = a0 - *r2 /* a0 less than 0.0 ? */ 983d8c 7a800807 1884 a0 = ifalt(*r2) /* Yes, then a0 = 0.0 */ 983d90 944f1c6c 1885 r2e = pc + (one - . - 8) /* Point to 1.0 */ 983d94 35240007 1886 a1 = -a0 + *r2 /* a0 greater than 1.0 ? */ 983d98 7a800807 1887 a0 = ifalt(*r2) /* Yes, then a0 = 1.0 */ 983d9c 30000037 1888 *r6++ = a0 = a0 /* Store TRS neg. values fraction */ 983da0 0d2fffc0 1889 if (r9-- >= 0) pcgoto alloop5 /* Next ... */ 983da4 00000000 1890 nop 1891 1892 /* Get 10 TRS pos. values */ 983da8 15200008 1893 r9 = 8 /* Set loop counter */ 983dac 94c500a4 1894 r6e = r5 + libparTRSpos 983db0 944f1c64 1895 r2e = pc + (longTfloat - . - 8) /* Pointer to 1/8388607 */ 983db4 30400807 1896 a2 = *r2 /* a2 = 1/8388607 */ 983db8 7d000787 1897 alloop6: a0 = float24(*r1++) /* Float TRS pos. value (32 bit) */ 983dbc 00000000 1898 nop 983dc0 00000000 1899 nop 983dc4 00000000 1900 nop 983dc8 70008007 1901 a0 = a0 * a2 /* Devide integer by 8388607 */ 983dcc 00000000 1902 nop 983dd0 00000000 1903 nop 983dd4 944f1c20 1904 r2e = pc + (zero - . - 8) /* Point to 0.0 */ 983dd8 34a40007 1905 a1 = a0 - *r2 /* a0 less than 0.0 ? */ 983ddc 7a800807 1906 a0 = ifalt(*r2) /* Yes, then a0 = 0.0 */ 983de0 944f1c1c 1907 r2e = pc + (one - . - 8) /* Point to 1.0 */ 983de4 35240007 1908 a1 = -a0 + *r2 /* a0 greater than 1.0 ? */ 983de8 7a800807 1909 a0 = ifalt(*r2) /* Yes, then a0 = 1.0 */ 983dec 30000037 1910 *r6++ = a0 = a0 /* Store TRS pos. values fraction */ 983df0 0d2fffc0 1911 if (r9-- >= 0) pcgoto alloop6 /* Next ... */ 983df4 00000000 1912 nop 1913 1914 /* Prepare EEPROM writing */ 983df8 1c49fc2e 1915 r9l = *libloadlength /* Get number of elements to write */ 983dfc 00000000 1916 nop 983e00 98290120 1917 r9e = r9 * 2 /* ... in Bytes */ 983e04 98290120 1918 r9e = r9 * 2 1919 1920 /* Write to EEPROM */ 983e08 dfe8f5b0 1921 writeROM: r8e = pulse /* Get base address of float array */ 983e0c 1cc2f324 1922 r2e = *Ceewrite /* Load call vector */ 983e10 00000000 1923 nop /* Wait for register load */ 983e14 12820000 1924 call r2(r18) /* Write EEPROM */ 983e18 00000000 1925 nop 983e1c a00f00c8 1926 pcgoto aldone /* Goto end */ 983e20 00000000 1927 nop 1928 /* Error handling */ 983e24 14600030 1929 alErr1: r3 = ALERR1 /* Curve number too small */ 983e28 a00f00b4 1930 pcgoto alErr 983e2c 00000000 1931 nop 983e30 14600031 1932 alErr2: r3 = ALERR2 /* Curve number too large */ 983e34 a00f00a8 1933 pcgoto alErr 983e38 00000000 1934 nop 983e3c 14600032 1935 alErr3: r3 = ALERR3 /* Set number too small */ 983e40 a00f009c 1936 pcgoto alErr 983e44 00000000 1937 nop 983e48 14600033 1938 alErr4: r3 = ALERR4 /* Set number too large */ 983e4c a00f0090 1939 pcgoto alErr 983e50 00000000 1940 nop 983e54 14600034 1941 alErr5: r3 = ALERR5 /* Detector number too small */ 983e58 a00f0084 1942 pcgoto alErr 983e5c 00000000 1943 nop 983e60 14600035 1944 alErr6: r3 = ALERR6 /* Detector number too large */ 983e64 a00f0078 1945 pcgoto alErr 983e68 00000000 1946 nop 983e6c 14600036 1947 alErr7: r3 = ALERR7 /* Template length too small */ 983e70 a00f006c 1948 pcgoto alErr 983e74 00000000 1949 nop 983e78 14600037 1950 alErr8: r3 = ALERR8 /* Template length too large */ 983e7c a00f0060 1951 pcgoto alErr 983e80 00000000 1952 nop 983e84 14600038 1953 alErr9: r3 = ALERR9 /* Number of templates too small */ 983e88 a00f0054 1954 pcgoto alErr 983e8c 00000000 1955 nop 983e90 14600039 1956 alErr10: r3 = ALERR10 /* Number of templates too large */ 983e94 a00f0048 1957 pcgoto alErr 983e98 00000000 1958 nop 983e9c 1460003a 1959 alErr11: r3 = ALERR11 /* Startbins too small */ 983ea0 a00f003c 1960 pcgoto alErr 983ea4 00000000 1961 nop 983ea8 1460003b 1962 alErr12: r3 = ALERR12 /* Startbins too large */ 983eac a00f0030 1963 pcgoto alErr 983eb0 00000000 1964 nop 983eb4 1460003c 1965 alErr13: r3 = ALERR13 /* Endbins too small */ 983eb8 a00f0024 1966 pcgoto alErr 983ebc 00000000 1967 nop 983ec0 1460003d 1968 alErr14: r3 = ALERR14 /* Endbins too large */ 983ec4 a00f0018 1969 pcgoto alErr 983ec8 00000000 1970 nop 983ecc 1460003e 1971 alErr15: r3 = ALERR15 /* Mean bin too small */ 983ed0 a00f000c 1972 pcgoto alErr 983ed4 00000000 1973 nop 983ed8 1460003f 1974 alErr16: r3 = ALERR16 /* Mean bin too large */ 983edc a00f0000 1975 pcgoto alErr 983ee0 00000000 1976 nop 1977 /* Do housekeeping error processing here */ 983ee4 130f0244 1978 alErr: pccall posterror(r20) /* Post error message */ 983ee8 00000000 1979 nop 1980 1981 /* Return to caller */ 983eec 1ccee62c 1982 aldone: r14e = *stackcopy /* Recover stack pointer */ 983ef0 00350000 1983 return(r19) 983ef4 00000000 1984 nop 1985 1986 1987 /******************************************************************************/ 1988 /* CALCOFFSET */ 1989 /* -------------------------------------------------------------------------- */ 1990 /* Version: 1.05 */ 1991 /* Date : 14-Oct-1999 */ 1992 /* Author : Jurgen Knodlseder, CESR (C) 1999 */ 1993 /* -------------------------------------------------------------------------- */ 1994 /* History: 1.02 29-Aug-1999 JK First version */ 1995 /* 1.03 22-Sep-1999 JK Adapted to PSD library management */ 1996 /* 1.04 28-Sep-1999 JK Added detector set offset; simplify code */ 1997 /* 1.05 14-Oct-1999 JK Add library parameter block offsets */ 1998 /* -------------------------------------------------------------------------- */ 1999 /* Task: */ 2000 /* ===== */ 2001 /* Calculate lookup tables for fast memory access. */ 2002 /* -------------------------------------------------------------------------- */ 2003 /* */ 2004 /* Usage: */ 2005 /* ====== */ 2006 /* pccall calcoffset(r20) */ 2007 /* nop */ 2008 /* */ 2009 /* Parameters: */ 2010 /* =========== */ 2011 /* 1) Input: */ 2012 /* 2) Output: off_lxl_2[M_DETS] l : lib_x_lib offset table */ 2013 /* off_lxx_2[M_TPLS] l : lib1_x_lib2 offset table - tpl. axis (2)*/ 2014 /* off_lxx_3[M_DETS] l : lib1_x_lib2 offset table - det. axis (3)*/ 2015 /* off_lib_2[M_TPLS] l : library offset table - tpl. axis (2) */ 2016 /* off_lib_3[M_DETS] l : library offset table - det. axis (3) */ 2017 /* off_lEE_3[M_DETS] l : EEPROM library offset table - axis (3) */ 2018 /* off_lEE_4[M_SETS] l : EEPROM library offset table - axis (4) */ 2019 /* off_lib_p[M_DETS] l : Library parameter block offset table */ 2020 /* 3) Internal: temp l : Temporary memory location */ 2021 /* */ 2022 /* Register usage: */ 2023 /* =============== */ 2024 /* r1e : Offset */ 2025 /* r2e : Offset table address */ 2026 /* r20e : PC for subroutine return */ 2027 /* */ 2028 /* Subroutines: */ 2029 /* ============ */ 2030 /* */ 2031 /* -------------------------------------------------------------------------- */ 2032 /* */ 2033 /* Description: */ 2034 /* ============ */ 2035 /* Calculates several lookup tables for fast memory access. 2d arrays have */ 2036 /* only one lookup table (e.g. off_lxl_2) for the second axis, 3d arrays have */ 2037 /* two lookup tables (e.g. off_lxx_2 and off_lxx_3) for the second and the */ 2038 /* third axis. */ 2039 /* Example: Suppose the array lib_x_lib, that contains floating point values, */ 2040 /* has 5 columns (axis 1) and 3 rows (axis 2): */ 2041 /* +--+--+--+--+--+ */ 2042 /* |00|10|20|30|40| */ 2043 /* +--+--+--+--+--+ */ 2044 /* |01|11|21|31|41| */ 2045 /* +--+--+--+--+--+ */ 2046 /* |02|12|22|32|42| */ 2047 /* +--+--+--+--+--+ */ 2048 /* In memory, this array will be stored as a linear chain of 5*3=15 */ 2049 /* Bytes: */ 2050 /* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ */ 2051 /* |00|10|20|30|40|01|11|21|31|41|02|12|22|32|42| */ 2052 /* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ */ 2053 /* To access the cell in column 3 and row 2 (i.e. cell 32; note that */ 2054 /* indices start with 0) one needs to add (2*5+3)*4 = 13*4 = 52 Bytes*/ 2055 /* to the base address of the table (note that a floating point */ 2056 /* number occupies 4 Bytes). Since the DSP32C has no integer */ 2057 /* multiplication instruction, one would need to transform the */ 2058 /* parameters to floats, make the calcuations, and re-transform to */ 2059 /* integer to extract the offset. This can be avoided by pre- */ 2060 /* calculating the offsets (in Bytes) of all table rows from the */ 2061 /* table base address. For the above example, the offset table */ 2062 /* (also lookup table) would have 3 elements of the following */ 2063 /* content: */ 2064 /* +----+----+----+ */ 2065 /* | 0 | 20 | 40 | */ 2066 /* +----+----+----+ */ 2067 /* To get the total offset of the element in column 3 and row 2 one */ 2068 /* adds now the offset of row 2 (=40) to the column offset (3*4=12) */ 2069 /* to obtain a total offset of 52 Bytes. */ 2070 /* Coding: Here comes a code fragment of the above example. The table base */ 2071 /* address can be found in "table", the lookup table is given in */ 2072 /* "lookup", the column index is in register r1 and the row index is */ 2073 /* in register r2: */ 2074 /* r4e = lookup * Get lookup table base * */ 2075 /* r2 = r2 * 2 * Row index in Bytes * */ 2076 /* r2 = r2 * 2 */ 2077 /* r4e = r4 + r2 * Add to lookup table base * */ 2078 /* r3e = *r4 * Get offset from table * */ 2079 /* r1 = r1 * 2 * Column index in Bytes * */ 2080 /* r1 = r1 * 2 */ 2081 /* r3e = r3 + r1 * Add to row offset * */ 2082 /* r4e = table * Get table base * */ 2083 /* r4e = r4 + r3 * Add offset * */ 2084 /* Now the content can be accessed by reading *r4. */ 2085 /* */ 2086 /* Notes: */ 2087 /* ====== */ 2088 /* */ 2089 /******************************************************************************/ 2090 calcoffset: 2091 /* Calculate offset tables for library templates */ 2092 /* Axis-2 offsets: off_lib_2 */ 983ef8 c0010000 2093 r1e = 0 /* First offset is 0 */ 983efc dfe2f32c 2094 r2e = off_lib_2 /* Get base address of offset table */ 983f00 16a00025 2095 r19 = M_TPLS - 1 /* Entries: Maximum number of templates + 1 */ 983f04 1fe10057 2096 caloop1: *r2++ = r1e /* Store offset in lookup table */ 983f08 0eaffff4 2097 if (r19-- >= 0) pcgoto caloop1 /* Next library */ 983f0c 94210100 2098 r1e = r1 + (4*M_TEMP_BINS) /* Add offset (latent) */ 2099 /* Axis-3 offsets: off_lib_3 */ 983f10 c0010000 2100 r1e = 0 /* First offset is 0 */ 983f14 dfe2f3c8 2101 r2e = off_lib_3 /* Get base address of offset table */ 983f18 16a00011 2102 r19 = M_DETS - 2 /* Entries: Number of detectors */ 983f1c 1fe10057 2103 caloop2: *r2++ = r1e /* Store offset in lookup table */ 983f20 0eaffff4 2104 if (r19-- >= 0) pcgoto caloop2 /* Next detector */ 983f24 94212600 2105 r1e = r1 + (4*M_TPLS*M_TEMP_BINS) 2106 /* Add offset (latent) */ 2107 /* EEPROM Axis-3 offsets: off_lEE_3 */ 983f28 c0010000 2108 r1e = 0 /* First offset is 0 */ 983f2c dfe2f414 2109 r2e = off_lEE_3 /* Get base address of offset table */ 983f30 c0032700 2110 r3e = SIZEOFLIB /* Get offset */ 983f34 16a00011 2111 r19 = M_DETS - 2 /* Entries: Number of detectors */ 983f38 1fe10057 2112 caloop3: *r2++ = r1e /* Store offset in lookup table */ 983f3c 0eaffff4 2113 if (r19-- >= 0) pcgoto caloop3 /* Next set */ 983f40 98010060 2114 r1e = r1 + r3 /* Add offset (latent) */ 2115 /* EEPROM Axis-4 offsets: off_lEE_4 */ 983f44 c0010000 2116 r1e = 0 /* First offset is 0 */ 983f48 dfe2f460 2117 r2e = off_lEE_4 /* Get base address of offset table */ 983f4c c043e500 2118 r3e = SIZEOFSET /* Get offset */ 983f50 16a00006 2119 r19 = M_SETS - 2 /* Entries: Number of sets */ 983f54 1fe10057 2120 caloop4: *r2++ = r1e /* Store offset in lookup table */ 983f58 0eaffff4 2121 if (r19-- >= 0) pcgoto caloop4 /* Next set */ 983f5c 98010060 2122 r1e = r1 + r3 /* Add offset (latent) */ 2123 2124 /* Calculate offset tables for inner products */ 2125 /* Axis-2 offsets: off_lxl_2 */ 983f60 c0010000 2126 r1e = 0 /* First offset is 0 */ 983f64 dfe2f480 2127 r2e = off_lxl_2 /* Get base address of offset table */ 983f68 16a00011 2128 r19 = M_DETS - 2 /* Entries: Number of detectors */ 983f6c 1fe10057 2129 caloop5: *r2++ = r1e /* Store offset in lookup table */ 983f70 0eaffff4 2130 if (r19-- >= 0) pcgoto caloop5 /* Next library */ 983f74 94210098 2131 r1e = r1 + (4*M_TPLS) /* Add offset (latent) */ 2132 2133 /* Calculate offset tables for inner products */ 2134 /* Axis-2 offsets: off_lxl_2 */ 983f78 c0010000 2135 r1e = 0 /* First offset is 0 */ 983f7c dfe2f4cc 2136 r2e = off_lxx_2 /* Get base address of offset table */ 983f80 16a00024 2137 r19 = M_TPLS - 2 /* Entries: Number of templates */ 983f84 1fe10057 2138 caloop6: *r2++ = r1e /* Store offset in lookup table */ 983f88 0eaffff4 2139 if (r19-- >= 0) pcgoto caloop6 /* Next library */ 983f8c 94210098 2140 r1e = r1 + (4*M_TPLS) /* Add offset (latent) */ 2141 /* Axis-3 offsets: off_lxl_3 */ 983f90 c0010000 2142 r1e = 0 /* First offset is 0 */ 983f94 dfe2f564 2143 r2e = off_lxx_3 /* Get base address of offset table */ 983f98 16a00011 2144 r19 = M_DETS - 2 /* Entries: Number of detectors */ 983f9c 1fe10057 2145 caloop7: *r2++ = r1e /* Store offset in lookup table */ 983fa0 0eaffff4 2146 if (r19-- >= 0) pcgoto caloop7 /* Next library */ 983fa4 94211690 2147 r1e = r1 + (4*M_TPLS*M_TPLS) /* Add offset (latent) */ 2148 2149 /* Calculate offset tables for library parameter block */ 983fa8 c0010000 2150 r1e = 0 /* First offset is 0 */ 983fac dfe2e50c 2151 r2e = off_lib_p /* Get base address of offset table */ 983fb0 16a00011 2152 r19 = M_DETS - 2 /* Entries: Number of detectors */ 983fb4 1fe10057 2153 caloop8: *r2++ = r1e /* Store offset in lookup table */ 983fb8 0eaffff4 2154 if (r19-- >= 0) pcgoto caloop8 /* Next library */ 983fbc 942100cc 2155 r1e = r1 + (LIBPARSIZE) /* Add offset (latent) */ 2156 2157 /* Return to caller */ 983fc0 00380000 2158 return(r20) 983fc4 00000000 2159 nop 2160 2161 2162 /******************************************************************************/ 2163 /* EEWRITE */ 2164 /* -------------------------------------------------------------------------- */ 2165 /* Version: 1.05 */ 2166 /* Date : 26-May-2000 */ 2167 /* Author : Jurgen Knodlseder, CESR (C) 1999-2000 */ 2168 /* -------------------------------------------------------------------------- */ 2169 /* History: 1.03 30-Aug-1999 JK First version */ 2170 /* 1.04 10-Oct-1999 JK Add memory-write verification */ 2171 /* 1.05 26-May-2000 JK Replace do loop by convention loop */ 2172 /* -------------------------------------------------------------------------- */ 2173 /* Task: */ 2174 /* ===== */ 2175 /* Write to EEPROMs. */ 2176 /* -------------------------------------------------------------------------- */ 2177 /* */ 2178 /* Usage: */ 2179 /* ====== */ 2180 /* pccall eewrite(r18) */ 2181 /* nop */ 2182 /* */ 2183 /* Parameters: */ 2184 /* =========== */ 2185 /* 1) Input: */ 2186 /* 2) Output: */ 2187 /* 3) Internal: */ 2188 /* */ 2189 /* Register usage: */ 2190 /* =============== */ 2191 /* r1e : Number of Bytes to write on actual page */ 2192 /* r2e : Multiple usage */ 2193 /* r3e : Multiple usage */ 2194 /* r4e : Multiple usage */ 2195 /* r7e : Destination address */ 2196 /* r8e : Source address */ 2197 /* r9e : Number of bytes to program */ 2198 /* r18e : PC for subroutine return */ 2199 /* r20e : posterror return code */ 2200 /* */ 2201 /* Subroutines: */ 2202 /* ============ */ 2203 /* */ 2204 /* -------------------------------------------------------------------------- */ 2205 /* */ 2206 /* Description: */ 2207 /* ============ */ 2208 /* This subroutine performs the general write to EEPROMs. Instead of a */ 2209 /* general timing cycle this routine attempts to do DATA polling as descibed */ 2210 /* in the ATMEL AT28C010 documentation. After writing of an idividual page */ 2211 /* the memory-write is verified and an error message is emitted in the case */ 2212 /* of an error. */ 2213 /* */ 2214 /* Notes: */ 2215 /* ===== */ 2216 /* * On entry, r7 has the EEPROM address to program. The high address will be */ 2217 /* masked-off to get the right EEPROM page. */ 2218 /* * The use of the DO-statement for EEPROM prevents any interrupt to occur */ 2219 /* during EEPROM write. To avoid interrupt problems during EEPROM writing */ 2220 /* the DO-statement was replaced by a conventional loop. */ 2221 /******************************************************************************/ 2233 #endif 2234 #ifndef EESTUB 2235 eewrite: 2236 /* Loop through the Bytes */ 983fc8 1ae90000 2237 eloop1: r9 - 0 /* Any more bytes to write? */ 983fcc 01af0110 2238 if (le) pcgoto ejmp2 /* No, then stop now ... */ 983fd0 00000000 2239 nop 2240 /* Write some data */ 983fd4 df040000 2241 r4e = 0xf80000 /* Mask off the low bits to get the correct */ 983fd8 99c400e0 2242 r4e &= r7 /* set of EEPROMs to enable for writing */ 983fdc c0215554 2243 r1e = LOWPADD /* EEPROM set A,B */ 983fe0 c002aaa8 2244 r2e = HIPADD /* EEPROM set C,D */ 983fe4 98010080 2245 r1e += r4 /* Select address 0x5555 of all EEPROM chips */ 983fe8 98020080 2246 r2e += r4 /* Select address 0x2aaa of all EEPROM chips */ 983fec 1460aaaa 2247 r3 = 0xaaaa 983ff0 14805555 2248 r4 = 0x5555 983ff4 1fa30037 2249 *r1++ = r3 /* A,B: send 0xaa to address 0x5555 */ 983ff8 00000000 2250 nop 983ffc 1fa30036 2251 *r1-- = r3 /* C,D: send 0xaa to address 0x5555 */ 984000 00000000 2252 nop 984004 1fa40057 2253 *r2++ = r4 /* A,B: send 0x55 to address 0x2aaa */ 984008 1460a0a0 2254 r3 = 0xa0a0 /* Get ready for next write */ 98400c 1fa40056 2255 *r2-- = r4 /* C,D: send 0x55 to address 0x2aaa */ 984010 00000000 2256 nop 984014 1fa30037 2257 *r1++ = r3 /* A,B: send 0xa0 to address 0x5555 */ 984018 00000000 2258 nop 98401c 1fa30036 2259 *r1-- = r3 /* C,D: send 0xa0 to address 0x5555 */ 984020 00000000 2260 nop 2261 /* Determine number of Bytes to write on actual page */ 984024 dfe1fe00 2262 r1e = 0xfffe00 /* Set page boundary mask */ 984028 99c100e0 2263 r1e = r1 & r7 /* Find precedent page boundary */ 98402c 94210200 2264 r1e = r1 + 0x200 /* Get next page boundary */ 984030 988100e0 2265 r1e = r1 - r7 /* Number of Bytes to the next page boundary */ 984034 98e10120 2266 r1e - r9 /* Larger then number of remaining Bytes ? */ 984038 9801ae09 2267 if (ge) r1e = r9 /* Yes, write only the remaining Bytes */ 98403c 00000000 2268 nop 984040 1dc8e57c 2269 *eesrc = r8e /* Save source address */ 984044 1dc7e580 2270 *eedst = r7e /* Save destination address */ 984048 1dc1e578 2271 *eenum = r1e /* Save number of Bytes to write */ 2272 2273 /* Write r1 Bytes to EEPROM */ 98404c 9a810002 2274 r1e = r1 - 2 /* Set loop counter */ 984050 1e620117 2275 eloop1a: r2l = *r8++ /* Get the data */ 984054 00000000 2276 nop /* Wait for register load */ 984058 1f6200f7 2277 *r7++ = r2l /* Write the data */ 98405c 0c2fffec 2278 if (r1-- >= 0) pcgoto eloop1a /* All Bytes written ? */ 984060 00000000 2279 nop /* Latency */ 2280 /* Verify memory-writing */ 984064 c0047fff 2281 r4e = 0x7fff /* Repeat verification many times ... */ 984068 1cc8e57c 2282 eloop2: r8e = *eesrc /* Recover source address */ 98406c 1cc7e580 2283 r7e = *eedst /* Recover destination address */ 984070 1cc1e578 2284 r1e = *eenum /* Recover number of Bytes written */ 984074 1e6200f7 2285 eloop3: r2l = *r7++ /* Read EEPROM */ 984078 1e630117 2286 r3l = *r8++ /* Read RAM */ 98407c 00000000 2287 nop 984080 18e20060 2288 r2 - r3 /* EEPROM = RAM ? */ 984084 00af0020 2289 if (eq) pcgoto ejmp1 /* Yes, then test next Byte */ 984088 00000000 2290 nop 98408c 988402e0 2291 r4e = r4 - 1 /* No, then try again */ 984090 018fffd0 2292 if (gt) pcgoto eloop2 /* No time-out: continue */ 984094 00000000 2293 nop 984098 14600040 2294 r3 = EEERR1 /* Time-out: send error */ 98409c 130f008c 2295 pccall posterror(r20) /* Post error message */ 9840a0 00000000 2296 nop 9840a4 a00f0038 2297 pcgoto ejmp2 /* Exit subroutine */ 9840a8 00000000 2298 nop 9840ac 988102e0 2299 ejmp1: r1e = r1 - 1 /* Reduce Byte counter */ 9840b0 018fffbc 2300 if (gt) pcgoto eloop3 /* Continue if there are more Bytes to test */ 9840b4 00000000 2301 nop 2302 /* Write successful, continue writing */ 9840b8 1cc1e578 2303 r1e = *eenum /* Recover number of Bytes written */ 9840bc 1cc8e57c 2304 r8e = *eesrc /* Recover source address */ 9840c0 1cc7e580 2305 r7e = *eedst /* Recover destination address */ 9840c4 98890020 2306 r9e = r9 - r1 /* Reduce Byte counter */ 9840c8 98070020 2307 r7e = r7 + r1 /* Increase destination address */ 9840cc 98080020 2308 r8e = r8 + r1 /* Increase source address */ 9840d0 14201770 2309 r1 = 6000 /* Wait before trying to write more */ 9840d4 0c2ffff8 2310 eloop4: if (r1-- >= 0) pcgoto eloop4 /* wait and wait and ... */ 9840d8 00000000 2311 nop 9840dc bfeffee4 2312 pcgoto eloop1 /* Write next page */ 9840e0 00000000 2313 nop 2314 /* Return to caller */ 9840e4 00340000 2315 ejmp2: return(r18) 9840e8 00000000 2316 nop 2317 #endif 2318 2319 2320 /******************************************************************************/ 2321 /* INVERSE */ 2322 /* -------------------------------------------------------------------------- */ 2323 /* Version: 1.02 */ 2324 /* Date : 29-Aug-1999 */ 2325 /* Author : Jurgen Knodlseder, CESR (C) 1999 */ 2326 /* -------------------------------------------------------------------------- */ 2327 /* History: 1.02 29-Aug-1999 JK First version */ 2328 /* -------------------------------------------------------------------------- */ 2329 /* Task: */ 2330 /* ===== */ 2331 /* Calculate the inverse of DAU register a0. */ 2332 /* -------------------------------------------------------------------------- */ 2333 /* */ 2334 /* Usage: */ 2335 /* ====== */ 2336 /* pccall inverse(r20) */ 2337 /* nop */ 2338 /* */ 2339 /* Parameters: */ 2340 /* =========== */ 2341 /* 1) Input: a0 f : Floating point number to invert */ 2342 /* 2) Output: a0 f : Inverted floating point number */ 2343 /* 3) Internal: invConsts f : Array of correction coefficients */ 2344 /* */ 2345 /* Register usage: */ 2346 /* =============== */ 2347 /* r9e : Pointer to correction coefficients */ 2348 /* r20e : PC for subroutine return */ 2349 /* a0 : I/O accumulator */ 2350 /* a1 : Multiple usage accumulator */ 2351 /* a2 : Multiple usage accumulator */ 2352 /* a3 : Multiple usage accumulator */ 2353 /* */ 2354 /* Subroutines: */ 2355 /* ============ */ 2356 /* */ 2357 /* -------------------------------------------------------------------------- */ 2358 /* */ 2359 /* Description: */ 2360 /* ============ */ 2361 /* Inversion algorithm inspired by section 4.5.1 (page 4-17) of the DSP32C */ 2362 /* Digital Signal Processor Information Manual (January 1990). */ 2363 /* */ 2364 /* Notes: */ 2365 /* ====== */ 2366 /* */ 2367 /******************************************************************************/ 2368 inverse: 9840ec 7f600007 2369 a3 = seed(a0) /* Get seed for number to be inverted */ 9840f0 952f1930 2370 r9e = pc + (invConsts - . - 8) 9840f4 00000000 2371 nop 9840f8 2c402787 2372 a2 = *r9++ + a3 * a0 9840fc 7033c187 2373 a1 = a3 * *r9++ 984100 00000000 2374 nop 984104 2840a787 2375 a2 = *r9++ + a2 * a2 984108 70000087 2376 a0 = a1 * a0 98410c 00000000 2377 nop 984110 70404107 2378 a2 = a2 * a1 984114 28202407 2379 a1 = *r9 + a2 * a0 984118 00000000 2380 nop 98411c 00000000 2381 nop 984120 68808087 2382 a0 = a2 - a1 * a2 984124 00000000 2383 nop 2384 /* Return to caller */ 984128 00380000 2385 return(r20) 98412c 00000000 2386 nop 2387 2388 2389 /******************************************************************************/ 2390 /* POSTERROR */ 2391 /* -------------------------------------------------------------------------- */ 2392 /* Version: 1.05 */ 2393 /* Date : 10-Oct-1999 */ 2394 /* Author : Jurgen Knodlseder, CESR (C) 1999 */ 2395 /* -------------------------------------------------------------------------- */ 2396 /* History: 1.04 23-Sep-1999 JK First version */ 2397 /* 1.05 10-Oct-1999 JK Add jump table warper */ 2398 /* -------------------------------------------------------------------------- */ 2399 /* Task: */ 2400 /* ===== */ 2401 /* Post an error message. */ 2402 /* -------------------------------------------------------------------------- */ 2403 /* */ 2404 /* Usage: */ 2405 /* ====== */ 2406 /* pccall posterror(r20) */ 2407 /* nop */ 2408 /* */ 2409 /* Parameters: */ 2410 /* =========== */ 2411 /* 1) Input: r3 b : Error code */ 2412 /* 2) Output: herrortype b : Error type */ 2413 /* herrorcnt b : Error counter */ 2414 /* status+1 b : Status word */ 2415 /* 3) Internal: */ 2416 /* */ 2417 /* Register usage: */ 2418 /* =============== */ 2419 /* r20e : PC for subroutine return */ 2420 /* */ 2421 /* -------------------------------------------------------------------------- */ 2422 /* */ 2423 /* Description: */ 2424 /* ============ */ 2425 /* Post an error message on the system. */ 2426 /******************************************************************************/ 2427 posterror: 2428 /* Jump table warper */ 984130 1cc2f308 2429 r2e = *Jposterror /* Load jump vector */ 984134 00000000 2430 nop /* Wait for register load */ 984138 a0020000 2431 goto r2 /* Jump into code */ 98413c 00000000 2432 nop 2433 /******************************************************************************/ 2434 /* Default code (can be replaced by uploaded code) */ 2435 /******************************************************************************/ 2436 myposterror: 2437 /* Post error message */ 984140 1d43fb3d 2438 *herrortype = r3l /* Store error code */ 984144 1c43fb3c 2439 r3l = *herrorcnt /* Load error counter */ 984148 00000000 2440 nop 98414c 14630001 2441 r3 += 1 /* ... increment it ... */ 984150 1d43fb3c 2442 *herrorcnt = r3l /* ... and store it back */ 984154 1c43e04d 2443 r3l = *(status + 1) /* Load status Byte */ 984158 00000000 2444 nop 98415c 1b430080 2445 r3 |= 0x80 /* Set error indicator */ 984160 00000000 2446 nop 984164 1d43e04d 2447 *(status + 1) = r3l /* Save status Byte */ 2448 984168 00380000 2449 return(r20) 98416c 00000000 2450 nop 2451 2452 2453 /******************************************************************************/ 2454 /* ANAL */ 2455 /* -------------------------------------------------------------------------- */ 2456 /* Scientific analysis routine. Execute step by step (this design allows for */ 2457 /* an easy replacement of scientific analysis modules) */ 2458 /******************************************************************************/ 2459 anal: 2460 /* Save stack pointer */ 984170 1dcee62c 2461 *stackcopy = r14e 2462 /* 6 step scientific analysis */ 984174 1cc2f30c 2463 __step0: r2e = *Canal_step0 /* Load call vector */ 984178 00000000 2464 nop /* Wait for register load */ 98417c 11420000 2465 call r2(r10) /* Make analysis step 0 */ 984180 00000000 2466 nop 984184 1cc2f310 2467 __step1: r2e = *Canal_step1 /* Load call vector */ 984188 00000000 2468 nop /* Wait for register load */ 98418c 11420000 2469 call r2(r10) /* Make analysis step 1 */ 984190 00000000 2470 nop 984194 1cc2f314 2471 __step2: r2e = *Canal_step2 /* Load call vector */ 984198 00000000 2472 nop /* Wait for register load */ 98419c 11420000 2473 call r2(r10) /* Make analysis step 2 */ 9841a0 00000000 2474 nop 9841a4 1cc2f318 2475 __step3: r2e = *Canal_step3 /* Load call vector */ 9841a8 00000000 2476 nop /* Wait for register load */ 9841ac 11420000 2477 call r2(r10) /* Make analysis step 3 */ 9841b0 00000000 2478 nop 9841b4 1cc2f31c 2479 __step4: r2e = *Canal_step4 /* Load call vector */ 9841b8 00000000 2480 nop /* Wait for register load */ 9841bc 11420000 2481 call r2(r10) /* Make analysis step 4 */ 9841c0 00000000 2482 nop 9841c4 1cc2f320 2483 __step5: r2e = *Canal_step5 /* Load call vector */ 9841c8 00000000 2484 nop /* Wait for register load */ 9841cc 11420000 2485 call r2(r10) /* Make analysis step 5 */ 9841d0 00000000 2486 nop 2487 2488 /* Return to caller */ 9841d4 1ccee62c 2489 r14e = *stackcopy /* Recover stack pointer */ 9841d8 00000000 2490 nop 9841dc 00340000 2491 return(r18) 9841e0 00000000 2492 nop 2493 2494 2495 /******************************************************************************/ 2496 /* END */ 2497 /* -------------------------------------------------------------------------- */ 2498 /* Version: 1.05 */ 2499 /* Date : 15-Nov-1999 */ 2500 /* Author : Jurgen Knodlseder, CESR (C) 1999 */ 2501 /* -------------------------------------------------------------------------- */ 2502 /* History: 1.02 30-Aug-1999 JK First version */ 2503 /* 1.03 20-Sep-1999 JK Add error codes */ 2504 /* 1.04 9-Oct-1999 JK Recover stack pointer on exit */ 2505 /* 1.05 15-Nov-1999 JK Add error code for too large pulse area */ 2506 /* -------------------------------------------------------------------------- */ 2507 /* Task: */ 2508 /* ===== */ 2509 /* End-point for non-treated pulses. */ 2510 /* -------------------------------------------------------------------------- */ 2511 /* */ 2512 /* Usage: */ 2513 /* ====== */ 2514 /* */ 2515 /* Parameters: */ 2516 /* =========== */ 2517 /* 1) Input: rawevent l : Pointer to curve data (preceeded by curve */ 2518 /* information. */ 2519 /* 2) Output: */ 2520 /* 3) Internal: */ 2521 /* */ 2522 /* Register usage: */ 2523 /* =============== */ 2524 /* r1e : Pointer to rawevent */ 2525 /* r3e : Pointer to 16 Bit word */ 2526 /* r4 : 16 Bit error code */ 2527 /* r18e : PC for subroutine return */ 2528 /* */ 2529 /* Subroutines: */ 2530 /* ============ */ 2531 /* */ 2532 /* -------------------------------------------------------------------------- */ 2533 /* */ 2534 /* Description: */ 2535 /* ============ */ 2536 /* Set the PSD information block in case of an uncomplete pulse analysis. */ 2537 /* */ 2538 /* Notes: */ 2539 /* ====== */ 2540 /* */ 2541 /******************************************************************************/ 2542 /* Various entry points */ 9841e4 14808000 2543 endErr0: r4 = INFO_ERR0 /* No library */ 9841e8 a00f00b4 2544 pcgoto endErr 9841ec 00000000 2545 nop 9841f0 14808001 2546 endErr1: r4 = INFO_ERR1 /* Saturated pulse */ 9841f4 a00f00a8 2547 pcgoto endErr 9841f8 00000000 2548 nop 9841fc 14808002 2549 endErr2: r4 = INFO_ERR2 /* Pulse area too small */ 984200 a00f009c 2550 pcgoto endErr 984204 00000000 2551 nop 984208 14800003 2552 endErr3: r4 = INFO_ERR3 /* ATTP = 0 */ 98420c a00f0090 2553 pcgoto endErr 984210 00000000 2554 nop 984214 14800004 2555 endErr4: r4 = INFO_ERR4 /* ATTP too large */ 984218 a00f0084 2556 pcgoto endErr 98421c 00000000 2557 nop 984220 14800005 2558 endErr5: r4 = INFO_ERR5 /* Baseline too small */ 984224 a00f0078 2559 pcgoto endErr 984228 00000000 2560 nop 98422c 14800006 2561 endErr6: r4 = INFO_ERR6 /* Pulse start in baseline */ 984230 a00f006c 2562 pcgoto endErr 984234 00000000 2563 nop 984238 14800007 2564 endErr7: r4 = INFO_ERR7 /* Early pulse ends in baseline */ 98423c a00f0060 2565 pcgoto endErr 984240 00000000 2566 nop 984244 14800008 2567 endErr8: r4 = INFO_ERR8 /* Pulse ends too late */ 984248 a00f0054 2568 pcgoto endErr 98424c 00000000 2569 nop 984250 14800009 2570 endErr9: r4 = INFO_ERR9 /* Pulse too short */ 984254 a00f0048 2571 pcgoto endErr 984258 00000000 2572 nop 98425c 1480000a 2573 endErr10: r4 = INFO_ERR10 /* Pulse too long */ 984260 a00f003c 2574 pcgoto endErr 984264 00000000 2575 nop 984268 1480000b 2576 endErr11: r4 = INFO_ERR11 /* Invalid detector number */ 98426c a00f0030 2577 pcgoto endErr 984270 00000000 2578 nop 984274 1480000c 2579 endErr12: r4 = INFO_ERR12 /* Pulse area less or equal 0 */ 984278 a00f0024 2580 pcgoto endErr 98427c 00000000 2581 nop 984280 1480000d 2582 endErr13: r4 = INFO_ERR13 /* Baseline too large */ 984284 a00f0018 2583 pcgoto endErr 984288 00000000 2584 nop 98428c 1480000e 2585 endErr14: r4 = INFO_ERR14 /* Baseline outliers */ 984290 a00f000c 2586 pcgoto endErr 984294 00000000 2587 nop 984298 1480800f 2588 endErr15: r4 = INFO_ERR15 /* Pulse area too large */ 98429c a00f0000 2589 pcgoto endErr 9842a0 00000000 2590 nop 2591 /* Extract information from event data */ 9842a4 1cc1e010 2592 endErr: r1e = *rawevent /* Point to raw event buffer */ 9842a8 00000000 2593 nop /* latency for memory access */ 9842ac 9461fffc 2594 r3e = r1 - 4 /* Point to 16-Bit word */ 9842b0 1fa40070 2595 *r3 = r4 /* Store in 16-Bit word */ 2596 2597 /* Return to caller */ 9842b4 1ccee62c 2598 r14e = *stackcopy /* Recover stack pointer */ 9842b8 00000000 2599 nop 9842bc 00340000 2600 return(r18) 9842c0 00000000 2601 nop 2602 2603 2604 /******************************************************************************/ 2605 /* STEP 0 */ 2606 /* -------------------------------------------------------------------------- */ 2607 /* Version: 1.07 */ 2608 /* Date : 26-May-2000 */ 2609 /* Author : Jurgen Knodlseder, CESR (C) 1999-2000 */ 2610 /* -------------------------------------------------------------------------- */ 2611 /* History: 1.02 30-Aug-1999 JK First version */ 2612 /* 1.03 21-Sep-1999 JK Add information extraction */ 2613 /* 1.04 23-Sep-1999 JK Handle no library case */ 2614 /* 1.05 4-Oct-1999 JK Remove library manager; add parameter block*/ 2615 /* 1.06 15-Nov-1999 JK Implement new parameter block structure; */ 2616 /* add HK baseline/noise address calculation; */ 2617 /* remove energy dependent selection (now in */ 2618 /* step1 since energy is derived from pulse */ 2619 /* area) */ 2620 /* 1.07 26-May-2000 JK Calculate address of baseline_nout for a */ 2621 /* 1 Byte array */ 2622 /* -------------------------------------------------------------------------- */ 2623 /* Task: */ 2624 /* ===== */ 2625 /* Initialise pulse shape treatment. */ 2626 /* -------------------------------------------------------------------------- */ 2627 /* */ 2628 /* Usage: */ 2629 /* ====== */ 2630 /* pccall anal_step0(r10) */ 2631 /* nop */ 2632 /* */ 2633 /* Parameters: */ 2634 /* =========== */ 2635 /* 1) Input: rawevent l : Pointer to curve data (preceeded by curve */ 2636 /* information. */ 2637 /* 2) Output: libbase l : Library base address */ 2638 /* lxlbase l : lib_x_lib base address */ 2639 /* lxxbase l : lib1_x_lib2 base address */ 2640 /* psd_energy l : PSD event energy */ 2641 /* detector l : Detector number */ 2642 /* walpha f : 15 Bit ALPHA weighting factor */ 2643 /* avgbaseadd l : Address of baseline averages */ 2644 /* noutbaseadd l : Address of baseline outliers */ 2645 /* hkavgbaseadd l : Address of HK baseline averages */ 2646 /* hkavgnoiseadd l : Address of HK noise averages */ 2647 /* n_temp_bins i : Number of bins in template */ 2648 /* n_templates i : Number of templates used */ 2649 /* n_start_bins i : Number of bins in start block */ 2650 /* n_end_bins i : Number of bins in end block */ 2651 /* time_mid i : Mean time bin for late/early separation */ 2652 /* pulse_dur_min i : Minimum pulse duration */ 2653 /* pulse_dur_max i : Maximum pulse duration */ 2654 /* pulse_saturate i : Pulse saturation value */ 2655 /* inv_start_bins f : Inverse number of start bins */ 2656 /* inv_end_bins f : Inverse number of end bins */ 2657 /* thres_frac f : Threshold fraction */ 2658 /* minbase f : Minimum baseline */ 2659 /* maxbase f : Maximum baseline */ 2660 /* minpulse f : Minimum pulse area */ 2661 /* maxpulse f : Maximum pulse area */ 2662 /* dttpmin i : Minimum Delta TTP */ 2663 /* dttpmax i : Maximum Delta TTP */ 2664 /* maxthresneg f : Maximum negative peak threshold */ 2665 /* maxthrespos f : Maximum positive peak threshold */ 2666 /* 3) Internal: */ 2667 /* */ 2668 /* Register usage: */ 2669 /* =============== */ 2670 /* r1e : Multiple usage */ 2671 /* r2e : Multiple usage */ 2672 /* r3e : Multiple usage */ 2673 /* r4e : 4 Byte detector offset */ 2674 /* r5e : Multiple usage */ 2675 /* r6e : Multiple usage */ 2676 /* r7e : Multiple usage */ 2677 /* r8e : Multiple usage */ 2678 /* r10e : PC for subroutine return */ 2679 /* */ 2680 /* Subroutines: */ 2681 /* ============ */ 2682 /* */ 2683 /* -------------------------------------------------------------------------- */ 2684 /* */ 2685 /* Description: */ 2686 /* ============ */ 2687 /* Extracts the relevant information (detector number, energy) from the curve */ 2688 /* data. The information is accessed via the "rawevent" variable. "rawevent" */ 2689 /* points to the actual curve data, preceeded by an information block. The */ 2690 /* definition of this information block is as follows (each row is a 16 Bit */ 2691 /* word): */ 2692 /* */ 2693 /* +--------+ */ 2694 /* | ID | -8 : Event identifier (contains detector ID) */ 2695 /* +--------+ */ 2696 /* | 0x0000 | -6 : Always 0x0000 */ 2697 /* +--------+ */ 2698 /* | PSD | -4 : PSD 16 Bit word (contains energy on input) */ 2699 /* +--------+ */ 2700 /* | Energy | -2 : Energy */ 2701 /* +--------+ */ 2702 /* *rawevent -> | Bin 0 | 0 : Pulse shape bin 0 */ 2703 /* +--------+ */ 2704 /* | Bin 1 | 2 : Pulse shape bin 1 */ 2705 /* +--------+ */ 2706 /* : : */ 2707 /* +--------+ */ 2708 /* | Bin 95 | 190 : Pulse shape bin 95 */ 2709 /* +--------+ */ 2710 /* Verifies that the detector number if comprised in 0-18. Extracts the */ 2711 /* selection parameters from the library parameter block. */ 2712 /* */ 2713 /* Notes: */ 2714 /* ====== */ 2715 /* */ 2716 /* Requirements: */ 2717 /* ============= */ 2718 /* */ 2719 /* 16-Bit error codes: */ 2720 /* =================== */ 2721 /* 11 : Invalid detector number (outside 0-18) */ 2722 /******************************************************************************/ 2723 anal_step0: 2724 2725 /* Extract information from event data */ 9842c4 1cc1e010 2726 r1e = *rawevent /* Point to raw event buffer */ 9842c8 00000000 2727 nop /* latency for memory access */ 9842cc 9441fff8 2728 r2e = r1 - 8 /* Point to identifier */ 9842d0 9461fffe 2729 r3e = r1 - 2 /* Point to energy */ 9842d4 1ea40070 2730 r4 = *r3 /* Get energy */ 9842d8 00000000 2731 nop 9842dc 1bc401ff 2732 r4 &= 0x01ff /* Use only 9 lowest Bits */ 9842e0 1d84e642 2733 *psd_energy = r4 /* Store energy */ 9842e4 1ea40050 2734 r4 = *r2 /* Get detector number (0-18) */ 9842e8 00000000 2735 nop 2738 #endif 9842ec 1bc4001f 2739 r4 &= 0x001f /* Use only 5 lowest Bits */ 9842f0 1d84e63e 2740 *detector = r4 /* Store detector number */ 9842f4 1ae40000 2741 r4 - 0 /* Detector number < 0 ? */ 9842f8 016fff68 2742 if (lt) pcgoto endErr11 /* Yes, then break */ 9842fc 00000000 2743 nop 984300 1ae40012 2744 r4 - 18 /* Detector number > 18 ? */ 984304 018fff5c 2745 if (gt) pcgoto endErr11 /* Yes, then break */ 984308 00000000 2746 nop 98430c 18240080 2747 r4 = r4 * 2 /* Get 4-Byte offset for this detector (r4) */ 984310 18240080 2748 r4 = r4 * 2 2749 2750 /* Verify if there is a valid library for this */ 2751 /* detector */ 984314 1c82e63e 2752 r2 = *detector /* Get detector number */ 984318 dfe3e4f7 2753 r3e = lib_valid /* Get library validity array */ 98431c 98030040 2754 r3e = r3 + r2 /* Add 1-Byte detector offset */ 984320 1e630070 2755 r3l = *r3 /* Load validity flag */ 984324 00000000 2756 nop 984328 1ae30000 2757 r3 - 0 /* Detector valid ? */ 98432c 00affeb0 2758 if (eq) pcgoto endErr0 /* No, then break now */ 984330 00000000 2759 nop 2760 /* Get number of baseline outliers addresse */ 984334 dfe1e4e4 2761 r1e = baseline_nout /* Get base address of baseline outliers array */ 984338 98010040 2762 r1e = r1 + r2 /* Add 1-Byte detector offset */ 98433c 1dc1e5b8 2763 *noutbaseadd = r1e /* Store address */ 2764 2765 /* Get HK baseline and noise addresses */ 984340 18220040 2766 r2 = r2 * 2 /* Two Bytes per detector */ 984344 dfe1fbf8 2767 r1e = lib_status /* Get base address of HK status */ 984348 98010040 2768 r1e = r1 + r2 /* Add 2-Byte detector offset */ 98434c 1dc1e5bc 2769 *hkavgbaseadd = r1e /* Store address */ 984350 980102e0 2770 r1e = r1 + 1 /* Point to next Byte */ 984354 1dc1e5c0 2771 *hkavgnoiseadd = r1e /* Store address */ 2772 2773 /* Get library base address */ 984358 dfe2f3c8 2774 r2e = off_lib_3 /* Get offset table base address */ 98435c 98020080 2775 r2e = r2 + r4 /* r2e -> off_lib_3[detector] */ 984360 1ee30050 2776 r3e = *r2 /* r3e = off_lib_3[detector] (offset) */ 984364 d3019000 2777 r1e = lib /* Pointer on library array in RAM */ 984368 98010060 2778 r1e = r1 + r3 /* Add offset (in Bytes) */ 98436c 1dc1e618 2779 *libbase = r1e /* Store RAM base address */ 2780 2781 /* Get 15 Bit weighting factor */ 984370 d3c1c740 2782 r1e = wgt_alpha /* Get base address of weighting array */ 984374 98010080 2783 r1e = r1 + r4 /* Add 4-Byte detector offset */ 984378 dfe2e60c 2784 r2e = walpha /* Get actual ALPHA weighting factor address */ 98437c 30000410 2785 *r2 = a0 = *r1 /* Copy ALPHA weighting factor */ 2786 2787 /* Get average baseline addresse */ 984380 dfe1e498 2788 r1e = baseline_avg /* Get base address of average baseline array */ 984384 98010080 2789 r1e = r1 + r4 /* Add 4-Byte detector offset */ 984388 1dc1e5b4 2790 *avgbaseadd = r1e /* Store address */ 2791 2792 /* Extract information from library control block */ 98438c dfe1e188 2793 r1e = library_control /* Get base address of library control block */ 984390 98010080 2794 r1e = r1 + r4 /* Add detector offset */ 984394 1e620037 2795 r2l = *r1++ /* Extract library set (not used) */ 984398 00000000 2796 nop 98439c 1e620037 2797 r2l = *r1++ /* Number of bins per template ... */ 9843a0 00000000 2798 nop /* Wait for register load */ 9843a4 1d82e5c6 2799 *n_temp_bins = r2 /* Store in variable */ 9843a8 1e620037 2800 r2l = *r1++ /* Number of templates ... */ 9843ac 00000000 2801 nop /* Wait for register load */ 9843b0 1d82e5c4 2802 *n_templates = r2 /* Store in variable */ 9843b4 1e620037 2803 r2l = *r1++ /* Empty ... */ 9843b8 00000000 2804 nop 2805 2806 /* Get lib_x_lib base address for actual detector */ 9843bc dfe1f480 2807 r1e = off_lxl_2 /* Get offset table base address */ 9843c0 98010080 2808 r1e = r1 + r4 /* r1e -> off_lxl_2[detector] */ 9843c4 1ee20030 2809 r2e = *r1 /* r2e = off_lxl_2[detector] (offset) */ 9843c8 d3636200 2810 r3e = lib_x_lib /* Pointer on library inner products base address */ 9843cc 98030040 2811 r3e = r3 + r2 /* Add offset (in Bytes) */ 9843d0 1dc3e610 2812 *lxlbase = r3e /* store offset for later use */ 2813 2814 /* Get lib1_x_lib2 and denominator base addresses */ 2815 /* for actual detector */ 9843d4 dfe1f564 2816 r1e = off_lxx_3 /* Get offset table base address */ 9843d8 98010080 2817 r1e = r1 + r4 /* r1e -> off_lxx_3[detector] */ 9843dc 1ee20030 2818 r2e = *r1 /* r2e = off_lxx_3[detector] (offset) */ 9843e0 d3636d48 2819 r3e = lib1_x_lib2 /* Pointer on library inner products base address */ 9843e4 98030040 2820 r3e = r3 + r2 /* Add offset (in Bytes) */ 9843e8 1dc3e614 2821 *lxxbase = r3e /* store offset for later use */ 9843ec d3a31a90 2822 r3e = denominator /* Pointer on denominator base address */ 9843f0 98030040 2823 r3e = r3 + r2 /* Add offset (in Bytes) */ 9843f4 1dc3e61c 2824 *denbase = r3e /* Store base address */ 2825 2826 /* Extract info from library parameter block (EEPROM) */ 9843f8 d3c1c78c 2827 r1e = lib_params /* Get library parameter block base address */ 9843fc dfe5e50c 2828 r5e = off_lib_p /* Get offset table base address */ 984400 98050080 2829 r5e = r5 + r4 /* r5e -> off_lib_p[detector] */ 984404 1ee600b0 2830 r6e = *r5 /* r6e = off_lib_p[detector] (offset) */ 984408 00000000 2831 nop 98440c 980100c0 2832 r1e = r1 + r6 /* Add offset */ 984410 1dc1e620 2833 *parbase = r1e /* Store base address */ 984414 94410002 2834 r2e = r1 + libparStart 984418 1e630050 2835 r3l = *r2 /* Number of bins in start block */ 98441c 94410003 2836 r2e = r1 + libparEnd 984420 1d83e5cc 2837 *n_start_bins = r3 /* Store in variable */ 984424 1e630050 2838 r3l = *r2 /* Number of bins in end block */ 984428 94410004 2839 r2e = r1 + libparMid 98442c 1d83e5ce 2840 *n_end_bins = r3 /* Store in variable */ 984430 1e630050 2841 r3l = *r2 /* Time for early/late separation */ 984434 94410005 2842 r2e = r1 + libparMin 984438 1d83e5ca 2843 *time_mid = r3 /* Store in variable */ 98443c 1e630050 2844 r3l = *r2 /* Minimum pulse duration */ 984440 94410006 2845 r2e = r1 + libparMax 984444 1d83e5d0 2846 *pulse_dur_min = r3 /* Store in variable */ 984448 1e630050 2847 r3l = *r2 /* Maximum pulse duration */ 98444c 94410014 2848 r2e = r1 + libparSaturate 984450 1d83e5d2 2849 *pulse_dur_max = r3 /* Store in variable */ 984454 1ea30050 2850 r3 = *r2 /* Pulse saturation value */ 984458 94410054 2851 r2e = r1 + libparFltBins /* Floated number of bins */ 98445c 1d83e5d4 2852 *pulse_saturate = r3 /* Store in variable */ 984460 dfe3e5a0 2853 r3e = shapebins 984464 30000818 2854 *r3 = a0 = *r2 /* Store in variable */ 984468 94410058 2855 r2e = r1 + libparInvStart /* Inverse bins in start block */ 98446c dfe3e598 2856 r3e = inv_start_bins 984470 30000818 2857 *r3 = a0 = *r2 /* Store in variable */ 984474 9441005c 2858 r2e = r1 + libparInvEnd /* Inverse bins in end block */ 984478 dfe3e59c 2859 r3e = inv_end_bins 98447c 30000818 2860 *r3 = a0 = *r2 /* Store in variable */ 984480 94410060 2861 r2e = r1 + libparThFract /* Threshold fraction */ 984484 dfe3e584 2862 r3e = thresh_frac 984488 30000818 2863 *r3 = a0 = *r2 /* Store in variable */ 98448c 9441006c 2864 r2e = r1 + libparFltMinBase /* Floated minimum baseline */ 984490 dfe3e588 2865 r3e = minbase 984494 30000818 2866 *r3 = a0 = *r2 /* Store in variable */ 984498 94410070 2867 r2e = r1 + libparFltMaxBase /* Floated maximum baseline */ 98449c dfe3e58c 2868 r3e = maxbase 9844a0 30000818 2869 *r3 = a0 = *r2 /* Store in variable */ 9844a4 94410074 2870 r2e = r1 + libparFltMinPulse /* Floated minimum pulse area */ 9844a8 dfe3e590 2871 r3e = minpulse 9844ac 30000818 2872 *r3 = a0 = *r2 /* Store in variable */ 9844b0 94410078 2873 r2e = r1 + libparFltMaxPulse /* Floated maximum pulse area */ 9844b4 dfe3e594 2874 r3e = maxpulse 9844b8 30000818 2875 *r3 = a0 = *r2 /* Store in variable */ 9844bc 94410064 2876 r2e = r1 + libparBaseThisF /* Weighting factor for actual baseline */ 9844c0 dfe3e5ac 2877 r3e = base_this_fract 9844c4 30000818 2878 *r3 = a0 = *r2 /* Store in variable */ 9844c8 94410068 2879 r2e = r1 + libparBaseAvgF /* Weighting factor for avg. baseline */ 9844cc dfe3e5b0 2880 r3e = base_avg_fract 9844d0 30000818 2881 *r3 = a0 = *r2 /* Store in variable */ 9844d4 94410008 2882 r2e = r1 + libparBaseOut /* Baseline outlier value */ 9844d8 1e630050 2883 r3l = *r2 /* Get value (8 bits) */ 9844dc 00000000 2884 nop 9844e0 1d83e5da 2885 *base_outlier = r3 /* Store in variable */ 9844e4 94410009 2886 r2e = r1 + libparBaseMaxOut /* Baseline maximum subsequent outliers */ 9844e8 1e630050 2887 r3l = *r2 /* Get value (8 bits) */ 9844ec 00000000 2888 nop 9844f0 1d83e5dc 2889 *base_max_outlier = r3 /* Store in variable */ 2890 2891 /* Return to caller */ 9844f4 002a0000 2892 return(r10) 9844f8 00000000 2893 nop 2894 2895 2896 /******************************************************************************/ 2897 /* STEP 1 */ 2898 /* -------------------------------------------------------------------------- */ 2899 /* Version: 1.07 */ 2900 /* Date : 26-May-2000 */ 2901 /* Author : Jurgen Knodlseder, CESR (C) 1999-2000 */ 2902 /* -------------------------------------------------------------------------- */ 2903 /* History: 1.02 30-Aug-1999 JK First version */ 2904 /* 1.03 20-Sep-1999 JK Add error codes */ 2905 /* 1.04 10-Oct-1999 JK Verify baseline (lower and upper limit); */ 2906 /* Discard empty pulses */ 2907 /* 1.05 19-Oct-1999 JK Introduced running average baseline */ 2908 /* 1.06 15-Nov-1999 JK Add pulse area limits, delete pulse */ 2909 /* threshold; save average baseline in HK */ 2910 /* 1.07 26-May-2000 JK Change maximum baseline outlier counter */ 2911 /* logic to handle 1 Byte variables */ 2912 /* -------------------------------------------------------------------------- */ 2913 /* Task: */ 2914 /* ===== */ 2915 /* Pulse preparation. */ 2916 /* -------------------------------------------------------------------------- */ 2917 /* */ 2918 /* Usage: */ 2919 /* ====== */ 2920 /* pccall anal_step1(r10) */ 2921 /* nop */ 2922 /* */ 2923 /* Parameters: */ 2924 /* =========== */ 2925 /* 1) Input: rawevent l : Pointer to curve data (preceeded by curve */ 2926 /* information) */ 2927 /* n_start_bins l : Number of bins in start block */ 2928 /* n_end_bins l : Number of bins in end block */ 2929 /* minpulse f : Minimum pulse area */ 2930 /* maxpulse f : Maximum pulse area */ 2931 /* time_mid l : Late/early separation time */ 2932 /* thresh_frac f : Threshold fraction */ 2933 /* maxbase f : Maximum baseline amplitude */ 2934 /* ad_offsets b : ADC gains and offsets */ 2935 /* base_outlier i : Baseline average outlier value */ 2936 /* base_max_outlier i : Maximum number of subsequent outliers */ 2937 /* 2) Output: integral l : Uncorrected pulse integral */ 2938 /* integral_start l : Uncorrected pulse integral in start block */ 2939 /* integral_mid l : Uncorrected pulse integral in mid block */ 2940 /* integral_end l : Uncorrected pulse integral in end block */ 2941 /* attp i : Absolute TTP */ 2942 /* pulse f : Floating point pulse shape */ 2943 /* baseline f : Baseline */ 2944 /* threshold f : Pulse threshold (float) */ 2945 /* net_integral f : Net pulse integral (float) */ 2946 /* gain0 f : ADC 0-3 gains */ 2947 /* offset0 f : ADC 0-3 offsets */ 2948 /* 3) Internal: */ 2949 /* */ 2950 /* Register usage: */ 2951 /* =============== */ 2952 /* r1e : Raw event pulse shape address */ 2953 /* r2e : Floated shape address */ 2954 /* r3 : Multiple usage */ 2955 /* r4e : Start block integral address */ 2956 /* r5e : Mid block integral address */ 2957 /* r6e : End block integral address */ 2958 /* r7e : Total integral address */ 2959 /* r8 : Multiple usage */ 2960 /* r9 : Multiple usage */ 2961 /* r10e : PC for subroutine return */ 2962 /* r14e : Pointer to floating point 1.0 */ 2963 /* r15 : Gain correction offsets */ 2964 /* a0 : Multiple usage accumulator (maximum pulse) */ 2965 /* a1 : Multiple usage accumulator */ 2966 /* a2 : Multiple usage accumulator */ 2967 /* a3 : Multiple usage accumulator */ 2968 /* */ 2969 /* Subroutines: */ 2970 /* ============ */ 2971 /* */ 2972 /* -------------------------------------------------------------------------- */ 2973 /* */ 2974 /* Description: */ 2975 /* ============ */ 2976 /* The measured pulse is prepared for the analysis. The following steps are */ 2977 /* performed in the given order: */ 2978 /* 1) Float the pulse */ 2979 /* 2) Apply ADC gain corrections */ 2980 /* 3) Calculate brute integral */ 2981 /* 4) Determine absolute TTP */ 2982 /* 5) Reject: saturated pulses */ 2983 /* empty pulses */ 2984 /* badly truncated pulses */ 2985 /* 6) Determine baseline */ 2986 /* 7) Determine pulse threshold */ 2987 /* */ 2988 /* Notes: */ 2989 /* ====== */ 2990 /* */ 2991 /* Requirements: */ 2992 /* ============= */ 2993 /* 1 <= n_start_bins < N_SHAPE_BINS (checked in "addlibrary") */ 2994 /* 1 <= n_end_bins <= N_SHAPE_BINS-n_start_bins (checked in "addlibrary") */ 2995 /* */ 2996 /* 16-Bit error codes: */ 2997 /* =================== */ 2998 /* 1 : Pulse saturated */ 2999 /* 2 : Pulse empty */ 3000 /* 3 : ATTP = 0 */ 3001 /* 4 : ATTP too large */ 3002 /* 5 : Baseline too small */ 3003 /* 13 : Baseline too large */ 3004 /* 12 : Integral smaller or equal 0.0 */ 3005 /******************************************************************************/ 3006 anal_step1: 3007 /* Float the pulse */ 9844fc 1cc1e010 3008 r1e = *rawevent /* Get 9-Bit shape address */ 984500 dfe2f5b0 3009 r2e = pulse /* Get floating point shape address */ 984504 79000797 3010 *r2++ = a0 = float(*r1++) /* 1 */ 984508 79000797 3011 *r2++ = a0 = float(*r1++) /* 2 */ 98450c 79000797 3012 *r2++ = a0 =