1 radix dec 2 0020 global__variables__bank0 equ 32 3 00a0 global__variables__bank1 equ 160 4 0120 global__variables__bank2 equ 288 5 01f0 global__variables__bank3 equ 496 6 004c global__bit__variables__bank0 equ 76 7 00a0 global__bit__variables__bank1 equ 160 8 0120 global__bit__variables__bank2 equ 288 9 01f0 global__bit__variables__bank3 equ 496 10 0000 indf___register equ 0 11 0002 pcl___register equ 2 12 0003 c___byte equ 3 13 0000 c___bit equ 0 14 0003 z___byte equ 3 15 0002 z___bit equ 2 16 0003 rp0___byte equ 3 17 0005 rp0___bit equ 5 18 0003 rp1___byte equ 3 19 0006 rp1___bit equ 6 20 0003 irp___byte equ 3 21 0007 irp___bit equ 7 22 0085 trisa___register equ 0x85 23 0086 trisb___register equ 0x86 24 0004 fsr___register equ 4 25 000a pclath___register equ 10 26 org 0 27 start: 28 000 0000 nop 29 001 0000 nop 30 002 0000 nop 31 003 2805 goto skip___interrupt 32 interrupt___vector: 33 004 0009 retfie 34 skip___interrupt: 35 ; Initialize A/D system to allow digital I/O 36 005 3007 movlw 7 37 006 009f movwf 31 38 ; Switch from register bank 0 to register bank 1 (which contains 159) 39 007 1683 bsf rp0___byte,rp0___bit 40 ; Register bank is now 1 41 008 019f clrf 159 42 ; Initialize TRIS registers 43 009 30da movlw 218 44 00a 0086 movwf trisb___register 45 00b 018a clrf pclath___register 46 ; Switch from register bank 1 to register bank 0 47 00c 1283 bcf rp0___byte,rp0___bit 48 ; Register bank is now 0 49 00d 2a00 goto main 50 ; comment ############################################################################# 51 ; comment {} 52 ; comment {Copyright < c > 1999 - 2001 by Wayne C . Gramlich .} 53 ; comment {All rights reserved .} 54 ; comment {} 55 ; comment {Permission to use , copy , modify , distribute , and sell this software} 56 ; comment {for any purpose is hereby granted without fee provided that the above} 57 ; comment {copyright notice and this permission are retained . The author makes} 58 ; comment {no representations about the suitability of this software for any purpose .} 59 ; comment {It is provided { as is } without express or implied warranty .} 60 ; comment {} 61 ; comment {This is software needed to run Laser1 RoboBrick . All communication} 62 ; comment {occurs at 2400 baud . See :} 63 ; comment {} 64 ; comment {http : / / web . gramlich . net / projects / robobricks / laser1 / index . html} 65 ; comment {} 66 ; comment {for more details .} 67 ; comment {} 68 ; comment ############################################################################# 69 ; processor pic16f628 cp = off cpd = off lvp = off bowden = off mclre = on pwrte = off wdte = off fosc = xt 70 ; 16169=0x3f29 8199=0x2007 71 __config 16169 72 2007 configuration___address equ 8199 73 ; comment {processor pic16f84 cp = off dp = off pwrte = disabled wdte = disabled fosc = xt} 74 ; comment {Some timing constants :} 75 ; constant clock_rate 10000000 76 989680 clock_rate equ 10000000 77 ; constant clock_ticks_per_instruction 4 78 0004 clock_ticks_per_instruction equ 4 79 ; constant instructions_per_second clock_rate / clock_ticks_per_instruction 80 2625a0 instructions_per_second equ 2500000 81 ; constant baud_rate 2400 82 0960 baud_rate equ 2400 83 ; constant instructions_per_bit clock_rate / {{ clock_ticks_per_instruction * baud_rate }} 84 0411 instructions_per_bit equ 1041 85 ; constant delays_per_bit 3 86 0003 delays_per_bit equ 3 87 ; constant instructions_per_delay instructions_per_bit / delays_per_bit 88 015b instructions_per_delay equ 347 89 ; comment {Some bit definitions < see schematic > :} 90 ; constant laser_enable_bit 0 91 0000 laser_enable_bit equ 0 92 ; constant serial_in_bit 1 93 0001 serial_in_bit equ 1 94 ; constant serial_out_bit 2 95 0002 serial_out_bit equ 2 96 ; constant laser_in_bit 3 97 0003 laser_in_bit equ 3 98 ; constant servo_out_bit 5 99 0005 servo_out_bit equ 5 100 ; constant low_in_bit 6 101 0006 low_in_bit equ 6 102 ; constant high_in_bit 7 103 0007 high_in_bit equ 7 104 ; comment {Some port and pin definitions :} 105 0005 porta equ 5 106 0006 portb equ 6 107 0006 laser_enable_pin__byte equ 6 108 0000 laser_enable_pin__bit equ 0 109 0006 serial_out_pin__byte equ 6 110 0002 serial_out_pin__bit equ 2 111 0006 serial_in_pin__byte equ 6 112 0001 serial_in_pin__bit equ 1 113 0006 laser_in_pin__byte equ 6 114 0003 laser_in_pin__bit equ 3 115 0006 servo_out_pin__byte equ 6 116 0005 servo_out_pin__bit equ 5 117 0006 low_in_pin__byte equ 6 118 0006 low_in_pin__bit equ 6 119 0006 high_in_pin__byte equ 6 120 0007 high_in_pin__bit equ 7 121 ; comment {Some register and bit declarations :} 122 ; comment {Status register :} 123 0003 status equ 3 124 ; bind c status @ 0 125 0003 c equ status+0 126 0003 c__byte equ status+0 127 0000 c__bit equ 0 128 ; bind z status @ 2 129 0003 z equ status+0 130 0003 z__byte equ status+0 131 0002 z__bit equ 2 132 ; comment {INTCON : Interrupt Control} 133 000b intcon equ 11 134 ; bind gie intcon @ 7 135 000b gie equ intcon+0 136 000b gie__byte equ intcon+0 137 0007 gie__bit equ 7 138 ; bind peie intcon @ 6 139 000b peie equ intcon+0 140 000b peie__byte equ intcon+0 141 0006 peie__bit equ 6 142 ; comment {PIR1 :} 143 000c pir1 equ 12 144 ; bind eeif pir1 @ 7 145 000c eeif equ pir1+0 146 000c eeif__byte equ pir1+0 147 0007 eeif__bit equ 7 148 ; bind cmif pir1 @ 6 149 000c cmif equ pir1+0 150 000c cmif__byte equ pir1+0 151 0006 cmif__bit equ 6 152 ; bind rcif pir1 @ 5 153 000c rcif equ pir1+0 154 000c rcif__byte equ pir1+0 155 0005 rcif__bit equ 5 156 ; bind txif pir1 @ 4 157 000c txif equ pir1+0 158 000c txif__byte equ pir1+0 159 0004 txif__bit equ 4 160 ; bind ccp1if pir1 @ 2 161 000c ccp1if equ pir1+0 162 000c ccp1if__byte equ pir1+0 163 0002 ccp1if__bit equ 2 164 ; bind tmr2if pir1 @ 1 165 000c tmr2if equ pir1+0 166 000c tmr2if__byte equ pir1+0 167 0001 tmr2if__bit equ 1 168 ; bind tmr1if pir1 @ 0 169 000c tmr1if equ pir1+0 170 000c tmr1if__byte equ pir1+0 171 0000 tmr1if__bit equ 0 172 ; comment {TMR1L : Timer 1 Low :} 173 000e tmr1l equ 14 174 ; comment {TMR1H : Timer1 High :} 175 000f tmr1h equ 15 176 ; comment {T1CON : Timer 1 Contro :} 177 0010 t1con equ 16 178 ; bind t1ckps1 t1con @ 5 179 0010 t1ckps1 equ t1con+0 180 0010 t1ckps1__byte equ t1con+0 181 0005 t1ckps1__bit equ 5 182 ; bind t1ckps0 t1con @ 4 183 0010 t1ckps0 equ t1con+0 184 0010 t1ckps0__byte equ t1con+0 185 0004 t1ckps0__bit equ 4 186 ; bind t1oscen t1con @ 3 187 0010 t1oscen equ t1con+0 188 0010 t1oscen__byte equ t1con+0 189 0003 t1oscen__bit equ 3 190 ; bind t1sync t1con @ 2 191 0010 t1sync equ t1con+0 192 0010 t1sync__byte equ t1con+0 193 0002 t1sync__bit equ 2 194 ; bind tmr1cs t1con @ 1 195 0010 tmr1cs equ t1con+0 196 0010 tmr1cs__byte equ t1con+0 197 0001 tmr1cs__bit equ 1 198 ; bind tmr1on t1con @ 0 199 0010 tmr1on equ t1con+0 200 0010 tmr1on__byte equ t1con+0 201 0000 tmr1on__bit equ 0 202 ; comment {CCPR1L : Capture / Compare / PWM Low :} 203 0015 ccpr1l equ 21 204 ; comment {CCPR1H : Capture / Compare / PWM High :} 205 0016 ccpr1h equ 22 206 ; comment {CCP1CON : Capture / Compare / PWM Control :} 207 0017 ccp1con equ 23 208 ; bind ccp1x ccp1con @ 5 209 0017 ccp1x equ ccp1con+0 210 0017 ccp1x__byte equ ccp1con+0 211 0005 ccp1x__bit equ 5 212 ; bind ccp1y ccp1con @ 4 213 0017 ccp1y equ ccp1con+0 214 0017 ccp1y__byte equ ccp1con+0 215 0004 ccp1y__bit equ 4 216 ; bind ccp1m3 ccp1con @ 3 217 0017 ccp1m3 equ ccp1con+0 218 0017 ccp1m3__byte equ ccp1con+0 219 0003 ccp1m3__bit equ 3 220 ; bind ccp1m2 ccp1con @ 2 221 0017 ccp1m2 equ ccp1con+0 222 0017 ccp1m2__byte equ ccp1con+0 223 0002 ccp1m2__bit equ 2 224 ; bind ccp1m1 ccp1con @ 1 225 0017 ccp1m1 equ ccp1con+0 226 0017 ccp1m1__byte equ ccp1con+0 227 0001 ccp1m1__bit equ 1 228 ; bind ccp1m0 ccp1con @ 0 229 0017 ccp1m0 equ ccp1con+0 230 0017 ccp1m0__byte equ ccp1con+0 231 0000 ccp1m0__bit equ 0 232 ; comment {PIR2 :} 233 008c pie1 equ 140 234 ; bind eeie pie1 @ 7 235 008c eeie equ pie1+0 236 008c eeie__byte equ pie1+0 237 0007 eeie__bit equ 7 238 ; bind cmie pie1 @ 6 239 008c cmie equ pie1+0 240 008c cmie__byte equ pie1+0 241 0006 cmie__bit equ 6 242 ; bind rcie pie1 @ 5 243 008c rcie equ pie1+0 244 008c rcie__byte equ pie1+0 245 0005 rcie__bit equ 5 246 ; bind txie pie1 @ 4 247 008c txie equ pie1+0 248 008c txie__byte equ pie1+0 249 0004 txie__bit equ 4 250 ; bind ccp1ie pie1 @ 2 251 008c ccp1ie equ pie1+0 252 008c ccp1ie__byte equ pie1+0 253 0002 ccp1ie__bit equ 2 254 ; bind tmr2ie pie1 @ 1 255 008c tmr2ie equ pie1+0 256 008c tmr2ie__byte equ pie1+0 257 0001 tmr2ie__bit equ 1 258 ; bind tmr1ie pie1 @ 0 259 008c tmr1ie equ pie1+0 260 008c tmr1ie__byte equ pie1+0 261 0000 tmr1ie__bit equ 0 262 ; comment {Some globals :} 263 ; constant maximum_captures 7 264 0007 maximum_captures equ 7 265 004c interrupt_enable equ global__bit__variables__bank0+0 266 004c interrupt_enable__byte equ global__bit__variables__bank0+0 267 0000 interrupt_enable__bit equ 0 268 004c interrupt_pending equ global__bit__variables__bank0+0 269 004c interrupt_pending__byte equ global__bit__variables__bank0+0 270 0001 interrupt_pending__bit equ 1 271 004c servo_enable equ global__bit__variables__bank0+0 272 004c servo_enable__byte equ global__bit__variables__bank0+0 273 0002 servo_enable__bit equ 2 274 004c sweeping equ global__bit__variables__bank0+0 275 004c sweeping__byte equ global__bit__variables__bank0+0 276 0003 sweeping__bit equ 3 277 0020 servo equ global__variables__bank0+0 278 0021 servo_low equ global__variables__bank0+1 279 0022 servo_high equ global__variables__bank0+2 280 0023 state equ global__variables__bank0+3 281 0024 middle equ global__variables__bank0+4 282 0025 high equ global__variables__bank0+5 283 0026 capture_index equ global__variables__bank0+6 284 0027 capture_count equ global__variables__bank0+7 285 0028 capture_low equ global__variables__bank0+8 286 002f capture_middle equ global__variables__bank0+15 287 0036 capture_high equ global__variables__bank0+22 288 ; comment {The state variable states :} 289 ; constant state_idle 0 290 0000 state_idle equ 0 291 ; constant state_forward_up1 1 292 0001 state_forward_up1 equ 1 293 ; constant state_forward_down1 2 294 0002 state_forward_down1 equ 2 295 ; constant state_forward_up2 3 296 0003 state_forward_up2 equ 3 297 ; constant state_forward_down2 4 298 0004 state_forward_down2 equ 4 299 ; constant state_backward_up1 5 300 0005 state_backward_up1 equ 5 301 ; constant state_backward_down1 6 302 0006 state_backward_down1 equ 6 303 ; constant state_backward_up2 7 304 0007 state_backward_up2 equ 7 305 ; constant state_backward_down2 8 306 0008 state_backward_down2 equ 8 307 ; string_constants Start 308 string___fetch: 309 00e 0082 movwf pcl___register 310 ; id = 1 , 0 , 24 , 0 , 0 , 0 , 0 , 0 , 0r'16' , 7 , 0s'Laser1A' , 15 , 0s'Gramlich&Benson' 311 0000 id___string equ 0 312 id: 313 00f 0782 addwf pcl___register,f 314 ; Length = 48 315 010 3430 retlw 48 316 ; 1 317 011 3401 retlw 1 318 ; 0 319 012 3400 retlw 0 320 ; 24 321 013 3418 retlw 24 322 ; 0 323 014 3400 retlw 0 324 ; 0 325 015 3400 retlw 0 326 ; 0 327 016 3400 retlw 0 328 ; 0 329 017 3400 retlw 0 330 ; 0 331 018 3400 retlw 0 332 ; 0r'16' 333 019 349b retlw 155 ; random number 334 01a 34f6 retlw 246 ; random number 335 01b 3493 retlw 147 ; random number 336 01c 3441 retlw 65 ; random number 337 01d 345d retlw 93 ; random number 338 01e 3467 retlw 103 ; random number 339 01f 3407 retlw 7 ; random number 340 020 34e2 retlw 226 ; random number 341 021 3403 retlw 3 ; random number 342 022 343d retlw 61 ; random number 343 023 344d retlw 77 ; random number 344 024 34b9 retlw 185 ; random number 345 025 34ca retlw 202 ; random number 346 026 3410 retlw 16 ; random number 347 027 3491 retlw 145 ; random number 348 028 3459 retlw 89 ; random number 349 ; 7 350 029 3407 retlw 7 351 ; `Laser1A' 352 02a 344c retlw 76 353 02b 3461 retlw 97 354 02c 3473 retlw 115 355 02d 3465 retlw 101 356 02e 3472 retlw 114 357 02f 3431 retlw 49 358 030 3441 retlw 65 359 ; 15 360 031 340f retlw 15 361 ; `Gramlich&Benson' 362 032 3447 retlw 71 363 033 3472 retlw 114 364 034 3461 retlw 97 365 035 346d retlw 109 366 036 346c retlw 108 367 037 3469 retlw 105 368 038 3463 retlw 99 369 039 3468 retlw 104 370 03a 3426 retlw 38 371 03b 3442 retlw 66 372 03c 3465 retlw 101 373 03d 346e retlw 110 374 03e 3473 retlw 115 375 03f 346f retlw 111 376 040 346e retlw 110 377 ; string__constants End 378 379 ; procedure delay start 380 ; optimize 0 381 delay: 382 ; Procedure must be called with PCLATH set to code bank 0 383 003d delay__variables__base equ global__variables__bank0+29 384 003d delay__bytes__base equ delay__variables__base+0 385 0040 delay__bits__base equ delay__variables__base+3 386 0004 delay__total__bytes equ 4 387 003f delay__224byte0 equ delay__bytes__base+2 388 003f delay__260byte1 equ delay__bytes__base+2 389 003f delay__242byte1 equ delay__bytes__base+2 390 003f delay__254byte1 equ delay__bytes__base+2 391 003f delay__163byte2 equ delay__bytes__base+2 392 003f delay__248byte1 equ delay__bytes__base+2 393 003f delay__223byte0 equ delay__bytes__base+2 394 003f delay__195byte1 equ delay__bytes__base+2 395 003f delay__225byte0 equ delay__bytes__base+2 396 003f delay__235byte1 equ delay__bytes__base+2 397 003f delay__182byte0 equ delay__bytes__base+2 398 003f delay__190byte1 equ delay__bytes__base+2 399 003f delay__172byte2 equ delay__bytes__base+2 400 003f delay__174byte0 equ delay__bytes__base+2 401 003f delay__202byte1 equ delay__bytes__base+2 402 003f delay__210byte2 equ delay__bytes__base+2 403 003f delay__148byte1 equ delay__bytes__base+2 404 003f delay__176byte0 equ delay__bytes__base+2 405 ; arguments_none 406 ; uniform_delay instructions_per_delay 407 ; Uniform delay remaining = 343 Accumulated Delay = 0 408 ; Uniform delay remaining = 343 Accumulated Delay = 0 409 ; Delay 1 third of a bit : 410 ; Uniform delay remaining = 343 Accumulated Delay = 0 411 ; Uniform delay remaining = 343 Accumulated Delay = 0 412 003d delay__counter equ delay__bytes__base+0 413 ; Uniform delay remaining = 343 Accumulated Delay = 0 414 003e delay__middle equ delay__bytes__base+1 415 ; Uniform delay remaining = 343 Accumulated Delay = 0 416 ; Uniform delay remaining = 343 Accumulated Delay = 0 417 ; Deal with servo pulse : 418 ; Uniform delay remaining = 343 Accumulated Delay = 0 419 ; counter := counter + 1 420 041 0abd incf delay__counter,f 421 ; Uniform delay remaining = 342 Accumulated Delay = 1 422 ; if { counter = 144 } start 423 042 3090 movlw 144 424 043 023d subwf delay__counter,w 425 ; expression=`{ counter = 144 }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 426 044 1903 btfsc z___byte,z___bit 427 ; if { counter = 144 } body start 428 ; Uniform delay remaining = 342 Accumulated Delay = 0 429 ; counter := 0 430 045 01bd clrf delay__counter 431 ; Uniform delay remaining = 341 Accumulated Delay = 1 432 ; Uniform delay remaining = 341 Accumulated Delay = 1 433 ; if { counter = 144 } body end 434 ; if exp=` counter = 144 ' false skip delay=4 435 ; Other expression=`{ counter = 144 }' delay=4 436 ; if { counter = 144 } end 437 ; Uniform delay remaining = 338 Accumulated Delay = 5 438 ; if { servo_enable } start 439 ; expression=`{ servo_enable }' exp_delay=0 true_delay=8 false_delay=0 true_size=11 false_size=0 440 046 194c btfsc servo_enable__byte,servo_enable__bit 441 047 284d goto label163__0true 442 label163__0false: 443 ; Delay 7 cycles 444 048 3002 movlw 2 445 049 00bf movwf delay__163byte2 446 delay__163delay1: 447 04a 0bbf decfsz delay__163byte2,f 448 04b 284a goto delay__163delay1 449 04c 2858 goto label163__0end 450 label163__0true: 451 ; if { servo_enable } body start 452 ; Uniform delay remaining = 338 Accumulated Delay = 0 453 ; if { counter = 0 } start 454 04d 083d movf delay__counter,w 455 ; expression=`{ counter = 0 }' exp_delay=1 true_delay=1 false_delay=4 true_size=1 false_size=4 456 04e 1d03 btfss z___byte,z___bit 457 04f 2854 goto label164__0false 458 label164__0true: 459 ; if { counter = 0 } body start 460 ; Uniform delay remaining = 338 Accumulated Delay = 0 461 ; servo_out_pin := 1 462 050 1686 bsf servo_out_pin__byte,servo_out_pin__bit 463 ; Uniform delay remaining = 337 Accumulated Delay = 1 464 ; Uniform delay remaining = 337 Accumulated Delay = 1 465 ; if { counter = 0 } body end 466 ; Delay 2 cycles 467 051 0000 nop 468 052 0000 nop 469 053 2858 goto label164__0end 470 label164__0false: 471 054 083d movf delay__counter,w 472 055 0220 subwf servo,w 473 ; expression=`{ counter = servo }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 474 056 1903 btfsc z___byte,z___bit 475 ; else_if { counter = servo } body start 476 ; Uniform delay remaining = 338 Accumulated Delay = 0 477 ; servo_out_pin := 0 478 057 1286 bcf servo_out_pin__byte,servo_out_pin__bit 479 ; Uniform delay remaining = 337 Accumulated Delay = 1 480 ; Uniform delay remaining = 337 Accumulated Delay = 1 481 ; else_if { counter = servo } body end 482 ; if exp=` counter = servo ' false skip delay=4 483 ; Other expression=`{ counter = servo }' delay=4 484 ; if exp=` counter = 0 ' total delay=8 485 ; if exp=` counter = 0 ' generic 486 label164__0end: 487 ; Other expression=`{ counter = 0 }' delay=8 488 ; if { counter = 0 } end 489 ; Uniform delay remaining = 330 Accumulated Delay = 8 490 ; Uniform delay remaining = 330 Accumulated Delay = 8 491 ; if { servo_enable } body end 492 ; if exp=`servo_enable' total delay=11 493 ; if exp=`servo_enable' generic 494 label163__0end: 495 ; Other expression=`{ servo_enable }' delay=11 496 ; if { servo_enable } end 497 ; Uniform delay remaining = 327 Accumulated Delay = 16 498 ; Uniform delay remaining = 327 Accumulated Delay = 16 499 ; Process any capture event : 500 ; Uniform delay remaining = 327 Accumulated Delay = 16 501 ; if { ccp1if } start 502 ; expression=`{ ccp1if }' exp_delay=0 true_delay=39 false_delay=0 true_size=44 false_size=0 503 058 190c btfsc ccp1if__byte,ccp1if__bit 504 059 2860 goto label172__0true 505 label172__0false: 506 ; Delay 38 cycles 507 05a 300c movlw 12 508 05b 00bf movwf delay__172byte2 509 delay__172delay1: 510 05c 0bbf decfsz delay__172byte2,f 511 05d 285c goto delay__172delay1 512 05e 0000 nop 513 05f 288c goto label172__0end 514 label172__0true: 515 ; if { ccp1if } body start 516 ; Uniform delay remaining = 327 Accumulated Delay = 0 517 ; ccp1if := 0 518 060 110c bcf ccp1if__byte,ccp1if__bit 519 ; Uniform delay remaining = 326 Accumulated Delay = 1 520 ; capture_low ~~ {{ capture_index }} := ccpr1l 521 061 0815 movf ccpr1l,w 522 062 00bf movwf delay__174byte0 523 063 3028 movlw LOW capture_low 524 064 0726 addwf capture_index,w 525 065 0084 movwf fsr___register 526 066 083f movf delay__174byte0,w 527 067 1383 bcf irp___register,irp___bit 528 068 0080 movwf indf___register 529 ; Uniform delay remaining = 318 Accumulated Delay = 9 530 ; middle := ccpr1h 531 069 0816 movf ccpr1h,w 532 06a 00be movwf delay__middle 533 ; Uniform delay remaining = 316 Accumulated Delay = 11 534 ; capture_middle ~~ {{ capture_index }} := middle 535 06b 083e movf delay__middle,w 536 06c 00bf movwf delay__176byte0 537 06d 302f movlw LOW capture_middle 538 06e 0726 addwf capture_index,w 539 06f 0084 movwf fsr___register 540 070 083f movf delay__176byte0,w 541 071 1383 bcf irp___register,irp___bit 542 072 0080 movwf indf___register 543 ; Uniform delay remaining = 308 Accumulated Delay = 19 544 ; if { tmr1if && ! {{ middle @ 7 }} } start 545 ; expression=`tmr1if' exp_delay=0 true_delay=5 false_delay=2 true_size=6 false_size=1 546 073 180c btfsc tmr1if__byte,tmr1if__bit 547 074 287a goto label177__3true 548 label177__3false: 549 ; Delay 4 cycles 550 075 0000 nop 551 076 0000 nop 552 077 0000 nop 553 078 0000 nop 554 079 2880 goto and177__0false 555 label177__3true: 556 ; Alias variable for select middle @ 7 557 003e delay__middle__177select1 equ delay__middle+0 558 003e delay__middle__177select1__byte equ delay__middle+0 559 0007 delay__middle__177select1__bit equ 7 560 ; expression=`{{ middle @ 7 }}' exp_delay=0 true_delay=0 false_delay=2 true_size=0 false_size=2 561 07a 1fbe btfss delay__middle__177select1__byte,delay__middle__177select1__bit 562 07b 287e goto label177__2false 563 label177__2true: 564 ; Delay 1 cycles 565 07c 0000 nop 566 07d 2880 goto label177__2end 567 label177__2false: 568 and177__0true: 569 ; if { tmr1if && ! {{ middle @ 7 }} } body start 570 ; Uniform delay remaining = 308 Accumulated Delay = 0 571 ; Capture occured after counter overflowed : 572 ; Uniform delay remaining = 308 Accumulated Delay = 0 573 ; tmr1if := 0 574 07e 100c bcf tmr1if__byte,tmr1if__bit 575 ; Uniform delay remaining = 307 Accumulated Delay = 1 576 ; high := high + 1 577 07f 0aa5 incf high,f 578 ; Uniform delay remaining = 306 Accumulated Delay = 2 579 ; Uniform delay remaining = 306 Accumulated Delay = 2 580 ; if { tmr1if && ! {{ middle @ 7 }} } body end 581 ; if exp=` middle @ 7 ' total delay=5 582 ; if exp=` middle @ 7 ' generic 583 label177__2end: 584 ; Other expression=`{{ middle @ 7 }}' delay=5 585 ; if exp=`tmr1if' total delay=8 586 ; if exp=`tmr1if' generic 587 label177__3end: 588 ; Other expression=`tmr1if' delay=8 589 and177__0false: 590 and177__0end: 591 ; if { tmr1if && ! {{ middle @ 7 }} } end 592 ; Uniform delay remaining = 300 Accumulated Delay = 27 593 ; capture_high ~~ {{ capture_index }} := high 594 080 0825 movf high,w 595 081 00bf movwf delay__182byte0 596 082 3036 movlw LOW capture_high 597 083 0726 addwf capture_index,w 598 084 0084 movwf fsr___register 599 085 083f movf delay__182byte0,w 600 086 1383 bcf irp___register,irp___bit 601 087 0080 movwf indf___register 602 ; Uniform delay remaining = 292 Accumulated Delay = 35 603 ; if { capture_index != maximum_captures } start 604 088 3007 movlw 7 605 089 0226 subwf capture_index,w 606 ; expression=`{ capture_index != maximum_captures }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 607 08a 1d03 btfss z___byte,z___bit 608 ; if { capture_index != maximum_captures } body start 609 ; Uniform delay remaining = 292 Accumulated Delay = 0 610 ; capture_index := capture_index + 1 611 08b 0aa6 incf capture_index,f 612 ; Uniform delay remaining = 291 Accumulated Delay = 1 613 ; Uniform delay remaining = 291 Accumulated Delay = 1 614 ; if { capture_index != maximum_captures } body end 615 ; if exp=` capture_index != maximum_captures ' false skip delay=4 616 ; Other expression=`{ capture_index != maximum_captures }' delay=4 617 ; if { capture_index != maximum_captures } end 618 ; Uniform delay remaining = 288 Accumulated Delay = 39 619 ; Uniform delay remaining = 288 Accumulated Delay = 39 620 ; if { ccp1if } body end 621 ; if exp=`ccp1if' total delay=42 622 ; if exp=`ccp1if' generic 623 label172__0end: 624 ; Other expression=`{ ccp1if }' delay=42 625 ; if { ccp1if } end 626 ; Uniform delay remaining = 285 Accumulated Delay = 58 627 ; Uniform delay remaining = 285 Accumulated Delay = 58 628 ; Process state variable : 629 ; Uniform delay remaining = 285 Accumulated Delay = 58 630 ; switch state 631 08c 3000 movlw HIGH switch__189block_start 632 08d 008a movwf pclath___register 633 08e 0823 movf state,w 634 ; case state_idle 635 ; case state_forward_up1 636 ; case state_forward_down1 637 ; case state_forward_up2 638 ; case state_forward_down2 639 ; case state_backward_up1 640 ; case state_backward_down1 641 ; case state_backward_up2 642 ; case state_backward_down2 643 switch__189block_start: 644 08f 0782 addwf pcl___register,f 645 090 2899 goto switch__189block190 646 091 28a2 goto switch__189block195 647 092 28b1 goto switch__189block202 648 093 28be goto switch__189block208 649 094 28f0 goto switch__189block235 650 095 28ff goto switch__189block242 651 096 290c goto switch__189block248 652 097 2919 goto switch__189block254 653 098 2926 goto switch__189block260 654 switch__189block_end: 655 ; switch_check 189 switch__189block_start switch__189block_end 656 switch__189block190: 657 ; Uniform delay remaining = 285 Accumulated Delay = 0 658 ; Do nothing : 659 ; Uniform delay remaining = 285 Accumulated Delay = 0 660 ; servo_enable := 0 661 099 114c bcf servo_enable__byte,servo_enable__bit 662 ; Uniform delay remaining = 284 Accumulated Delay = 1 663 ; sweeping := 0 664 09a 11cc bcf sweeping__byte,sweeping__bit 665 ; Uniform delay remaining = 283 Accumulated Delay = 2 666 ; Uniform delay remaining = 283 Accumulated Delay = 2 667 ; Delay 42 cycles 668 09b 300d movlw 13 669 09c 00bf movwf delay__190byte1 670 delay__190delay0: 671 09d 0bbf decfsz delay__190byte1,f 672 09e 289d goto delay__190delay0 673 09f 0000 nop 674 0a0 0000 nop 675 0a1 292f goto switch__189end 676 switch__189block195: 677 ; Uniform delay remaining = 285 Accumulated Delay = 0 678 ; if { low_in_pin } start 679 ; expression=`{ low_in_pin }' exp_delay=0 true_delay=4 false_delay=0 true_size=4 false_size=0 680 0a2 1b06 btfsc low_in_pin__byte,low_in_pin__bit 681 0a3 28a8 goto label196__0true 682 label196__0false: 683 ; Delay 3 cycles 684 0a4 0000 nop 685 0a5 0000 nop 686 0a6 0000 nop 687 0a7 28ac goto label196__0end 688 label196__0true: 689 ; if { low_in_pin } body start 690 ; Uniform delay remaining = 285 Accumulated Delay = 0 691 ; state := state_forward_down1 692 0a8 3002 movlw 2 693 0a9 00a3 movwf state 694 ; Uniform delay remaining = 283 Accumulated Delay = 2 695 ; laser_enable_pin := 1 696 0aa 1406 bsf laser_enable_pin__byte,laser_enable_pin__bit 697 ; Uniform delay remaining = 282 Accumulated Delay = 3 698 ; tmr1on := 1 699 0ab 1410 bsf tmr1on__byte,tmr1on__bit 700 ; Uniform delay remaining = 281 Accumulated Delay = 4 701 ; Uniform delay remaining = 281 Accumulated Delay = 4 702 ; if { low_in_pin } body end 703 ; if exp=`low_in_pin' total delay=7 704 ; if exp=`low_in_pin' generic 705 label196__0end: 706 ; Other expression=`{ low_in_pin }' delay=7 707 ; if { low_in_pin } end 708 ; Uniform delay remaining = 278 Accumulated Delay = 7 709 ; Uniform delay remaining = 278 Accumulated Delay = 7 710 ; Delay 37 cycles 711 0ac 300c movlw 12 712 0ad 00bf movwf delay__195byte1 713 delay__195delay0: 714 0ae 0bbf decfsz delay__195byte1,f 715 0af 28ae goto delay__195delay0 716 0b0 292f goto switch__189end 717 switch__189block202: 718 ; Uniform delay remaining = 285 Accumulated Delay = 0 719 ; Force the servo to the high location : 720 ; Uniform delay remaining = 285 Accumulated Delay = 0 721 ; if { ! low_in_pin } start 722 ; expression=`low_in_pin' exp_delay=0 true_delay=0 false_delay=2 true_size=0 false_size=2 723 0b1 1f06 btfss low_in_pin__byte,low_in_pin__bit 724 0b2 28b5 goto label204__0false 725 label204__0true: 726 ; Delay 1 cycles 727 0b3 0000 nop 728 0b4 28b7 goto label204__0end 729 label204__0false: 730 ; if { ! low_in_pin } body start 731 ; Uniform delay remaining = 285 Accumulated Delay = 0 732 ; state := state_forward_up2 733 0b5 3003 movlw 3 734 0b6 00a3 movwf state 735 ; Uniform delay remaining = 283 Accumulated Delay = 2 736 ; Uniform delay remaining = 283 Accumulated Delay = 2 737 ; if { ! low_in_pin } body end 738 ; if exp=`low_in_pin' total delay=5 739 ; if exp=`low_in_pin' generic 740 label204__0end: 741 ; Other expression=`low_in_pin' delay=5 742 ; if { ! low_in_pin } end 743 ; Uniform delay remaining = 280 Accumulated Delay = 5 744 ; Uniform delay remaining = 280 Accumulated Delay = 5 745 ; Delay 39 cycles 746 0b7 300c movlw 12 747 0b8 00bf movwf delay__202byte1 748 delay__202delay0: 749 0b9 0bbf decfsz delay__202byte1,f 750 0ba 28b9 goto delay__202delay0 751 0bb 0000 nop 752 0bc 0000 nop 753 0bd 292f goto switch__189end 754 switch__189block208: 755 ; Uniform delay remaining = 285 Accumulated Delay = 0 756 ; Force servo to low location : 757 ; Uniform delay remaining = 285 Accumulated Delay = 0 758 ; if { low_in_pin } start 759 ; expression=`{ low_in_pin }' exp_delay=0 true_delay=41 false_delay=0 true_size=42 false_size=0 760 0be 1b06 btfsc low_in_pin__byte,low_in_pin__bit 761 0bf 28c5 goto label210__0true 762 label210__0false: 763 ; Delay 40 cycles 764 0c0 300d movlw 13 765 0c1 00bf movwf delay__210byte2 766 delay__210delay1: 767 0c2 0bbf decfsz delay__210byte2,f 768 0c3 28c2 goto delay__210delay1 769 0c4 28ef goto label210__0end 770 label210__0true: 771 ; if { low_in_pin } body start 772 ; Uniform delay remaining = 285 Accumulated Delay = 0 773 ; Turn off the timer and laser : 774 ; Uniform delay remaining = 285 Accumulated Delay = 0 775 ; tmr1on := 0 776 0c5 1010 bcf tmr1on__byte,tmr1on__bit 777 ; Uniform delay remaining = 284 Accumulated Delay = 1 778 ; laser_enable_pin := 0 779 0c6 1006 bcf laser_enable_pin__byte,laser_enable_pin__bit 780 ; Uniform delay remaining = 283 Accumulated Delay = 2 781 ; state := state_forward_down2 782 0c7 3004 movlw 4 783 0c8 00a3 movwf state 784 ; Uniform delay remaining = 281 Accumulated Delay = 4 785 ; Uniform delay remaining = 281 Accumulated Delay = 4 786 ; Deal with any counter overflow : 787 ; Uniform delay remaining = 281 Accumulated Delay = 4 788 ; if { tmr1if } start 789 ; expression=`{ tmr1if }' exp_delay=0 true_delay=2 false_delay=0 true_size=2 false_size=0 790 0c9 180c btfsc tmr1if__byte,tmr1if__bit 791 0ca 28cd goto label217__0true 792 label217__0false: 793 ; Delay 1 cycles 794 0cb 0000 nop 795 0cc 28cf goto label217__0end 796 label217__0true: 797 ; if { tmr1if } body start 798 ; Uniform delay remaining = 281 Accumulated Delay = 0 799 ; tmr1if := 0 800 0cd 100c bcf tmr1if__byte,tmr1if__bit 801 ; Uniform delay remaining = 280 Accumulated Delay = 1 802 ; high := high + 1 803 0ce 0aa5 incf high,f 804 ; Uniform delay remaining = 279 Accumulated Delay = 2 805 ; Uniform delay remaining = 279 Accumulated Delay = 2 806 ; if { tmr1if } body end 807 ; if exp=`tmr1if' total delay=5 808 ; if exp=`tmr1if' generic 809 label217__0end: 810 ; Other expression=`{ tmr1if }' delay=5 811 ; if { tmr1if } end 812 ; Uniform delay remaining = 276 Accumulated Delay = 9 813 ; Uniform delay remaining = 276 Accumulated Delay = 9 814 ; Record the 24 - bit timer : 815 ; Uniform delay remaining = 276 Accumulated Delay = 9 816 ; capture_low ~~ {{ capture_index }} := ccpr1l 817 0cf 0815 movf ccpr1l,w 818 0d0 00bf movwf delay__223byte0 819 0d1 3028 movlw LOW capture_low 820 0d2 0726 addwf capture_index,w 821 0d3 0084 movwf fsr___register 822 0d4 083f movf delay__223byte0,w 823 0d5 1383 bcf irp___register,irp___bit 824 0d6 0080 movwf indf___register 825 ; Uniform delay remaining = 268 Accumulated Delay = 17 826 ; capture_middle ~~ {{ capture_index }} := ccpr1h 827 0d7 0816 movf ccpr1h,w 828 0d8 00bf movwf delay__224byte0 829 0d9 302f movlw LOW capture_middle 830 0da 0726 addwf capture_index,w 831 0db 0084 movwf fsr___register 832 0dc 083f movf delay__224byte0,w 833 0dd 1383 bcf irp___register,irp___bit 834 0de 0080 movwf indf___register 835 ; Uniform delay remaining = 260 Accumulated Delay = 25 836 ; capture_high ~~ {{ capture_index }} := high 837 0df 0825 movf high,w 838 0e0 00bf movwf delay__225byte0 839 0e1 3036 movlw LOW capture_high 840 0e2 0726 addwf capture_index,w 841 0e3 0084 movwf fsr___register 842 0e4 083f movf delay__225byte0,w 843 0e5 1383 bcf irp___register,irp___bit 844 0e6 0080 movwf indf___register 845 ; Uniform delay remaining = 252 Accumulated Delay = 33 846 ; if { capture_index = maximum_captures } start 847 0e7 3007 movlw 7 848 0e8 0226 subwf capture_index,w 849 ; expression=`{ capture_index = maximum_captures }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 850 0e9 1903 btfsc z___byte,z___bit 851 ; if { capture_index = maximum_captures } body start 852 ; Uniform delay remaining = 252 Accumulated Delay = 0 853 ; We have an error : 854 ; Uniform delay remaining = 252 Accumulated Delay = 0 855 ; capture_count := 0xff 856 0ea 30ff movlw 255 857 ; 1 instructions found for sharing 858 ; Uniform delay remaining = 250 Accumulated Delay = 2 859 ; if { capture_index = maximum_captures } body end 860 0eb 1d03 btfss z___byte,z___bit 861 ; else body start 862 ; Uniform delay remaining = 252 Accumulated Delay = 0 863 ; capture_count := capture_index + 1 864 0ec 0a26 incf capture_index,w 865 ; 1 instructions found for sharing 866 ; Uniform delay remaining = 250 Accumulated Delay = 2 867 ; else body end 868 ; if exp=` capture_index = maximum_captures ' single true and false skip delay=6 869 ; Other expression=`{ capture_index = maximum_captures }' delay=6 870 ; 1 shared instructions follow 871 0ed 00a7 movwf capture_count 872 ; if { capture_index = maximum_captures } end 873 ; Uniform delay remaining = 245 Accumulated Delay = 40 874 ; capture_index := 0 875 0ee 01a6 clrf capture_index 876 ; Uniform delay remaining = 244 Accumulated Delay = 41 877 ; Uniform delay remaining = 244 Accumulated Delay = 41 878 ; if { low_in_pin } body end 879 ; if exp=`low_in_pin' total delay=44 880 ; if exp=`low_in_pin' generic 881 label210__0end: 882 ; Other expression=`{ low_in_pin }' delay=44 883 ; if { low_in_pin } end 884 ; Uniform delay remaining = 241 Accumulated Delay = 44 885 ; Uniform delay remaining = 241 Accumulated Delay = 44 886 0ef 292f goto switch__189end 887 switch__189block235: 888 ; Uniform delay remaining = 285 Accumulated Delay = 0 889 ; Force the servo to the high location : 890 ; Uniform delay remaining = 285 Accumulated Delay = 0 891 ; if { ! low_in_pin } start 892 ; expression=`low_in_pin' exp_delay=0 true_delay=0 false_delay=4 true_size=0 false_size=4 893 0f0 1f06 btfss low_in_pin__byte,low_in_pin__bit 894 0f1 28f6 goto label237__0false 895 label237__0true: 896 ; Delay 3 cycles 897 0f2 0000 nop 898 0f3 0000 nop 899 0f4 0000 nop 900 0f5 28fa goto label237__0end 901 label237__0false: 902 ; if { ! low_in_pin } body start 903 ; Uniform delay remaining = 285 Accumulated Delay = 0 904 ; state := state_backward_up1 905 0f6 3005 movlw 5 906 0f7 00a3 movwf state 907 ; Uniform delay remaining = 283 Accumulated Delay = 2 908 ; servo := servo_high 909 0f8 0822 movf servo_high,w 910 0f9 00a0 movwf servo 911 ; Uniform delay remaining = 281 Accumulated Delay = 4 912 ; Uniform delay remaining = 281 Accumulated Delay = 4 913 ; if { ! low_in_pin } body end 914 ; if exp=`low_in_pin' total delay=7 915 ; if exp=`low_in_pin' generic 916 label237__0end: 917 ; Other expression=`low_in_pin' delay=7 918 ; if { ! low_in_pin } end 919 ; Uniform delay remaining = 278 Accumulated Delay = 7 920 ; Uniform delay remaining = 278 Accumulated Delay = 7 921 ; Delay 37 cycles 922 0fa 300c movlw 12 923 0fb 00bf movwf delay__235byte1 924 delay__235delay0: 925 0fc 0bbf decfsz delay__235byte1,f 926 0fd 28fc goto delay__235delay0 927 0fe 292f goto switch__189end 928 switch__189block242: 929 ; Uniform delay remaining = 285 Accumulated Delay = 0 930 ; Force the servo to the high location : 931 ; Uniform delay remaining = 285 Accumulated Delay = 0 932 ; if { low_in_pin } start 933 ; expression=`{ low_in_pin }' exp_delay=0 true_delay=2 false_delay=0 true_size=2 false_size=0 934 0ff 1b06 btfsc low_in_pin__byte,low_in_pin__bit 935 100 2903 goto label244__0true 936 label244__0false: 937 ; Delay 1 cycles 938 101 0000 nop 939 102 2905 goto label244__0end 940 label244__0true: 941 ; if { low_in_pin } body start 942 ; Uniform delay remaining = 285 Accumulated Delay = 0 943 ; state := state_backward_down1 944 103 3006 movlw 6 945 104 00a3 movwf state 946 ; Uniform delay remaining = 283 Accumulated Delay = 2 947 ; Uniform delay remaining = 283 Accumulated Delay = 2 948 ; if { low_in_pin } body end 949 ; if exp=`low_in_pin' total delay=5 950 ; if exp=`low_in_pin' generic 951 label244__0end: 952 ; Other expression=`{ low_in_pin }' delay=5 953 ; if { low_in_pin } end 954 ; Uniform delay remaining = 280 Accumulated Delay = 5 955 ; Uniform delay remaining = 280 Accumulated Delay = 5 956 ; Delay 39 cycles 957 105 300c movlw 12 958 106 00bf movwf delay__242byte1 959 delay__242delay0: 960 107 0bbf decfsz delay__242byte1,f 961 108 2907 goto delay__242delay0 962 109 0000 nop 963 10a 0000 nop 964 10b 292f goto switch__189end 965 switch__189block248: 966 ; Uniform delay remaining = 285 Accumulated Delay = 0 967 ; Force the servo to the high location : 968 ; Uniform delay remaining = 285 Accumulated Delay = 0 969 ; if { ! low_in_pin } start 970 ; expression=`low_in_pin' exp_delay=0 true_delay=0 false_delay=2 true_size=0 false_size=2 971 10c 1f06 btfss low_in_pin__byte,low_in_pin__bit 972 10d 2910 goto label250__0false 973 label250__0true: 974 ; Delay 1 cycles 975 10e 0000 nop 976 10f 2912 goto label250__0end 977 label250__0false: 978 ; if { ! low_in_pin } body start 979 ; Uniform delay remaining = 285 Accumulated Delay = 0 980 ; state := state_backward_up2 981 110 3007 movlw 7 982 111 00a3 movwf state 983 ; Uniform delay remaining = 283 Accumulated Delay = 2 984 ; Uniform delay remaining = 283 Accumulated Delay = 2 985 ; if { ! low_in_pin } body end 986 ; if exp=`low_in_pin' total delay=5 987 ; if exp=`low_in_pin' generic 988 label250__0end: 989 ; Other expression=`low_in_pin' delay=5 990 ; if { ! low_in_pin } end 991 ; Uniform delay remaining = 280 Accumulated Delay = 5 992 ; Uniform delay remaining = 280 Accumulated Delay = 5 993 ; Delay 39 cycles 994 112 300c movlw 12 995 113 00bf movwf delay__248byte1 996 delay__248delay0: 997 114 0bbf decfsz delay__248byte1,f 998 115 2914 goto delay__248delay0 999 116 0000 nop 1000 117 0000 nop 1001 118 292f goto switch__189end 1002 switch__189block254: 1003 ; Uniform delay remaining = 285 Accumulated Delay = 0 1004 ; Force the servo to the high location : 1005 ; Uniform delay remaining = 285 Accumulated Delay = 0 1006 ; if { low_in_pin } start 1007 ; expression=`{ low_in_pin }' exp_delay=0 true_delay=2 false_delay=0 true_size=2 false_size=0 1008 119 1b06 btfsc low_in_pin__byte,low_in_pin__bit 1009 11a 291d goto label256__0true 1010 label256__0false: 1011 ; Delay 1 cycles 1012 11b 0000 nop 1013 11c 291f goto label256__0end 1014 label256__0true: 1015 ; if { low_in_pin } body start 1016 ; Uniform delay remaining = 285 Accumulated Delay = 0 1017 ; state := state_backward_down2 1018 11d 3008 movlw 8 1019 11e 00a3 movwf state 1020 ; Uniform delay remaining = 283 Accumulated Delay = 2 1021 ; Uniform delay remaining = 283 Accumulated Delay = 2 1022 ; if { low_in_pin } body end 1023 ; if exp=`low_in_pin' total delay=5 1024 ; if exp=`low_in_pin' generic 1025 label256__0end: 1026 ; Other expression=`{ low_in_pin }' delay=5 1027 ; if { low_in_pin } end 1028 ; Uniform delay remaining = 280 Accumulated Delay = 5 1029 ; Uniform delay remaining = 280 Accumulated Delay = 5 1030 ; Delay 39 cycles 1031 11f 300c movlw 12 1032 120 00bf movwf delay__254byte1 1033 delay__254delay0: 1034 121 0bbf decfsz delay__254byte1,f 1035 122 2921 goto delay__254delay0 1036 123 0000 nop 1037 124 0000 nop 1038 125 292f goto switch__189end 1039 switch__189block260: 1040 ; Uniform delay remaining = 285 Accumulated Delay = 0 1041 ; Force the servo to the high location : 1042 ; Uniform delay remaining = 285 Accumulated Delay = 0 1043 ; if { ! low_in_pin } start 1044 ; expression=`low_in_pin' exp_delay=0 true_delay=0 false_delay=1 true_size=0 false_size=1 1045 126 1f06 btfss low_in_pin__byte,low_in_pin__bit 1046 ; if { ! low_in_pin } body start 1047 ; Uniform delay remaining = 285 Accumulated Delay = 0 1048 ; state := state_idle 1049 127 01a3 clrf state 1050 ; Uniform delay remaining = 284 Accumulated Delay = 1 1051 ; Uniform delay remaining = 284 Accumulated Delay = 1 1052 ; if { ! low_in_pin } body end 1053 ; if exp=`low_in_pin' true skip delay=2 1054 ; Other expression=`low_in_pin' delay=2 1055 ; if { ! low_in_pin } end 1056 ; Uniform delay remaining = 283 Accumulated Delay = 2 1057 ; Uniform delay remaining = 283 Accumulated Delay = 2 1058 ; Delay 42 cycles 1059 128 300d movlw 13 1060 129 00bf movwf delay__260byte1 1061 delay__260delay0: 1062 12a 0bbf decfsz delay__260byte1,f 1063 12b 292a goto delay__260delay0 1064 12c 0000 nop 1065 12d 0000 nop 1066 12e 292f goto switch__189end 1067 switch__189end: 1068 ; Total switch delay = 52 exp_delay=3 case_delay=46 1069 ; Uniform delay remaining = 233 Accumulated Delay = 110 1070 ; Uniform delay remaining = 233 Accumulated Delay = 110 1071 ; Process any counter overflow : 1072 ; Uniform delay remaining = 233 Accumulated Delay = 110 1073 ; if { tmr1if } start 1074 ; expression=`{ tmr1if }' exp_delay=0 true_delay=2 false_delay=0 true_size=2 false_size=0 1075 12f 180c btfsc tmr1if__byte,tmr1if__bit 1076 130 2933 goto label269__0true 1077 label269__0false: 1078 ; Delay 1 cycles 1079 131 0000 nop 1080 132 2935 goto label269__0end 1081 label269__0true: 1082 ; if { tmr1if } body start 1083 ; Uniform delay remaining = 233 Accumulated Delay = 0 1084 ; tmr1if := 0 1085 133 100c bcf tmr1if__byte,tmr1if__bit 1086 ; Uniform delay remaining = 232 Accumulated Delay = 1 1087 ; high := high + 1 1088 134 0aa5 incf high,f 1089 ; Uniform delay remaining = 231 Accumulated Delay = 2 1090 ; Uniform delay remaining = 231 Accumulated Delay = 2 1091 ; if { tmr1if } body end 1092 ; if exp=`tmr1if' total delay=5 1093 ; if exp=`tmr1if' generic 1094 label269__0end: 1095 ; Other expression=`{ tmr1if }' delay=5 1096 ; if { tmr1if } end 1097 ; Uniform delay remaining = 228 Accumulated Delay = 115 1098 ; Uniform delay remaining = 228 Accumulated Delay = 115 1099 ; Uniform delay remaining = 228 Accumulated Delay = 115 1100 ; Soak up remaining 228 cycles 1101 ; Delay 228 cycles 1102 135 304b movlw 75 1103 136 00bf movwf delay__148byte1 1104 delay__148delay0: 1105 137 0bbf decfsz delay__148byte1,f 1106 138 2937 goto delay__148delay0 1107 139 0000 nop 1108 13a 0000 nop 1109 ; procedure delay end 1110 13b 3400 retlw 0 1111 ; optimize 1 1112 1113 ; procedure get_byte start 1114 get_byte: 1115 ; Procedure must be called with PCLATH set to code bank 0 1116 0041 get_byte__variables__base equ global__variables__bank0+33 1117 0041 get_byte__bytes__base equ get_byte__variables__base+0 1118 0044 get_byte__bits__base equ get_byte__variables__base+3 1119 0003 get_byte__total__bytes equ 3 1120 ; arguments_none 1121 0041 get_byte__0return__byte equ get_byte__bytes__base+0 1122 ; Wait for an 8 - bit byte from < serial_in_pin > , read it , and return it . 1123 0042 get_byte__result equ get_byte__bytes__base+1 1124 0043 get_byte__count equ get_byte__bytes__base+2 1125 ; Wait until a start bit arrives : 1126 ; `while serial_in_pin ...' start 1127 get_byte__286while__continue: 1128 ; expression=`serial_in_pin' exp_delay=0 true_delay=348 false_delay=2 true_size=2 false_size=1 1129 13c 1c86 btfss serial_in_pin__byte,serial_in_pin__bit 1130 13d 2940 goto get_byte__286while__break 1131 ; call delay {{ }} 1132 13e 2041 call delay 1133 13f 293c goto get_byte__286while__continue 1134 ; if exp=`serial_in_pin' false goto 1135 ; Other expression=`serial_in_pin' delay=-1 1136 get_byte__286while__break: 1137 ; `while serial_in_pin ...' end 1138 ; interrupt_enable := 0 1139 140 104c bcf interrupt_enable__byte,interrupt_enable__bit 1140 ; Skip over the start bit : 1141 ; call delay {{ }} 1142 141 2041 call delay 1143 ; call delay {{ }} 1144 142 2041 call delay 1145 ; call delay {{ }} 1146 143 2041 call delay 1147 ; Sample in the middle third of each data bit : 1148 ; result := 0 1149 144 01c2 clrf get_byte__result 1150 ; `count_down count 8 ...' start 1151 145 3008 movlw 8 1152 146 00c3 movwf get_byte__count 1153 get_byte__298_loop: 1154 ; call delay {{ }} 1155 147 2041 call delay 1156 ; result := result >> 1 1157 148 1003 bcf c___byte,c___bit 1158 149 0cc2 rrf get_byte__result,f 1159 ; if { serial_in_pin } start 1160 ; expression=`{ serial_in_pin }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 1161 14a 1886 btfsc serial_in_pin__byte,serial_in_pin__bit 1162 ; if { serial_in_pin } body start 1163 ; result @ 7 := 1 1164 ; Select result @ 7 1165 0042 get_byte__result__302select0 equ get_byte__result+0 1166 0042 get_byte__result__302select0__byte equ get_byte__result+0 1167 0007 get_byte__result__302select0__bit equ 7 1168 14b 17c2 bsf get_byte__result__302select0__byte,get_byte__result__302select0__bit 1169 ; if { serial_in_pin } body end 1170 ; if exp=`serial_in_pin' false skip delay=2 1171 ; Other expression=`{ serial_in_pin }' delay=2 1172 ; if { serial_in_pin } end 1173 ; call delay {{ }} 1174 14c 2041 call delay 1175 ; call delay {{ }} 1176 14d 2041 call delay 1177 14e 0bc3 decfsz get_byte__count,f 1178 14f 2947 goto get_byte__298_loop 1179 get_byte__298_done: 1180 ; `count_down count 8 ...' end 1181 ; Skip over 1 / 3 of the stop bit : 1182 ; call delay {{ }} 1183 150 2041 call delay 1184 ; return result 1185 151 0842 movf get_byte__result,w 1186 152 00c1 movwf get_byte__0return__byte 1187 153 3400 retlw 0 1188 ; procedure get_byte end 1189 1190 ; procedure send_byte start 1191 send_byte: 1192 ; Procedure must be called with PCLATH set to code bank 0 1193 0044 send_byte__variables__base equ global__variables__bank0+36 1194 0044 send_byte__bytes__base equ send_byte__variables__base+0 1195 0046 send_byte__bits__base equ send_byte__variables__base+2 1196 0002 send_byte__total__bytes equ 2 1197 0044 send_byte__data equ send_byte__bytes__base+0 1198 ; Send < data > to < serial_out_pin > . 1199 0045 send_byte__count equ send_byte__bytes__base+1 1200 ; Send the start bit : 1201 ; serial_out_pin := 0 1202 154 1106 bcf serial_out_pin__byte,serial_out_pin__bit 1203 ; call delay {{ }} 1204 155 2041 call delay 1205 ; call delay {{ }} 1206 156 2041 call delay 1207 ; call delay {{ }} 1208 157 2041 call delay 1209 ; Send the data : 1210 ; `count_down count 8 ...' start 1211 158 3008 movlw 8 1212 159 00c5 movwf send_byte__count 1213 send_byte__329_loop: 1214 ; serial_out_pin := data @ 0 1215 ; Alias variable for select data @ 0 1216 0044 send_byte__data__330select0 equ send_byte__data+0 1217 0044 send_byte__data__330select0__byte equ send_byte__data+0 1218 0000 send_byte__data__330select0__bit equ 0 1219 15a 1c44 btfss send_byte__data__330select0__byte,send_byte__data__330select0__bit 1220 15b 1106 bcf serial_out_pin__byte,serial_out_pin__bit 1221 15c 1844 btfsc send_byte__data__330select0__byte,send_byte__data__330select0__bit 1222 15d 1506 bsf serial_out_pin__byte,serial_out_pin__bit 1223 ; data := data >> 1 1224 15e 1003 bcf c___byte,c___bit 1225 15f 0cc4 rrf send_byte__data,f 1226 ; call delay {{ }} 1227 160 2041 call delay 1228 ; call delay {{ }} 1229 161 2041 call delay 1230 ; call delay {{ }} 1231 162 2041 call delay 1232 163 0bc5 decfsz send_byte__count,f 1233 164 295a goto send_byte__329_loop 1234 send_byte__329_done: 1235 ; `count_down count 8 ...' end 1236 ; Send the stop bit : 1237 ; serial_out_pin := 1 1238 165 1506 bsf serial_out_pin__byte,serial_out_pin__bit 1239 ; call delay {{ }} 1240 166 2041 call delay 1241 ; call delay {{ }} 1242 167 2041 call delay 1243 ; call delay {{ }} 1244 168 2041 call delay 1245 ; procedure send_byte end 1246 169 3400 retlw 0 1247 1248 ; procedure reset start 1249 reset: 1250 ; Procedure must be called with PCLATH set to code bank 0 1251 0046 reset__variables__base equ global__variables__bank0+38 1252 0046 reset__bytes__base equ reset__variables__base+0 1253 0047 reset__bits__base equ reset__variables__base+1 1254 0001 reset__total__bytes equ 1 1255 0046 reset__353byte0 equ reset__bytes__base+0 1256 0046 reset__354byte0 equ reset__bytes__base+0 1257 0046 reset__355byte0 equ reset__bytes__base+0 1258 ; arguments_none 1259 ; Reset everything : 1260 ; capture_index := 0 1261 16a 01a6 clrf capture_index 1262 ; `while capture_index < maximum_captures ...' start 1263 reset__352while__continue: 1264 16b 3007 movlw 7 1265 16c 0226 subwf capture_index,w 1266 ; expression=` capture_index < maximum_captures ' exp_delay=2 true_delay=24 false_delay=2 true_size=23 false_size=1 1267 16d 1803 btfsc c___byte,c___bit 1268 16e 2986 goto reset__352while__break 1269 ; capture_high ~~ {{ capture_index }} := 0 1270 16f 01c6 clrf reset__353byte0 1271 170 3036 movlw LOW capture_high 1272 171 0726 addwf capture_index,w 1273 172 0084 movwf fsr___register 1274 173 0846 movf reset__353byte0,w 1275 174 1383 bcf irp___register,irp___bit 1276 175 0080 movwf indf___register 1277 ; capture_middle ~~ {{ capture_index }} := 0 1278 176 01c6 clrf reset__354byte0 1279 177 302f movlw LOW capture_middle 1280 178 0726 addwf capture_index,w 1281 179 0084 movwf fsr___register 1282 17a 0846 movf reset__354byte0,w 1283 17b 1383 bcf irp___register,irp___bit 1284 17c 0080 movwf indf___register 1285 ; capture_low ~~ {{ capture_index }} := 0 1286 17d 01c6 clrf reset__355byte0 1287 17e 3028 movlw LOW capture_low 1288 17f 0726 addwf capture_index,w 1289 180 0084 movwf fsr___register 1290 181 0846 movf reset__355byte0,w 1291 182 1383 bcf irp___register,irp___bit 1292 183 0080 movwf indf___register 1293 ; capture_index := capture_index + 1 1294 184 0aa6 incf capture_index,f 1295 185 296b goto reset__352while__continue 1296 ; if exp=` capture_index < maximum_captures ' false goto 1297 ; Other expression=` capture_index < maximum_captures ' delay=-1 1298 reset__352while__break: 1299 ; `while capture_index < maximum_captures ...' end 1300 ; capture_index := 0 1301 186 01a6 clrf capture_index 1302 ; procedure reset end 1303 187 3400 retlw 0 1304 ; comment {This is used to get the switch statements to work out :} 1305 ; origin 0x200 1306 org 512 1307 1308 ; procedure main start 1309 main: 1310 ; Procedure must be called with PCLATH set to code bank 0 1311 0047 main__variables__base equ global__variables__bank0+39 1312 0047 main__bytes__base equ main__variables__base+0 1313 004c main__bits__base equ main__variables__base+5 1314 0005 main__total__bytes equ 5 1315 004b main__410byte0 equ main__bytes__base+4 1316 004b main__509byte0 equ main__bytes__base+4 1317 004b main__407byte0 equ main__bytes__base+4 1318 004b main__512byte0 equ main__bytes__base+4 1319 ; arguments_none 1320 ; Main program . 1321 0047 main__command equ main__bytes__base+0 1322 0048 main__glitch equ main__bytes__base+1 1323 0049 main__id_index equ main__bytes__base+2 1324 004a main__temporary equ main__bytes__base+3 1325 ; glitch := 0 1326 200 01c8 clrf main__glitch 1327 ; id_index := 0 1328 201 01c9 clrf main__id_index 1329 ; serial_out_pin := 1 1330 202 1506 bsf serial_out_pin__byte,serial_out_pin__bit 1331 ; servo := 14 1332 203 300e movlw 14 1333 204 00a0 movwf servo 1334 ; servo_low := 5 1335 205 3005 movlw 5 1336 206 00a1 movwf servo_low 1337 ; servo_high := 17 1338 207 3011 movlw 17 1339 208 00a2 movwf servo_high 1340 ; servo_enable := 0 1341 209 114c bcf servo_enable__byte,servo_enable__bit 1342 ; sweeping := 0 1343 20a 11cc bcf sweeping__byte,sweeping__bit 1344 ; laser_enable_pin := 0 1345 20b 1006 bcf laser_enable_pin__byte,laser_enable_pin__bit 1346 ; state := state_idle 1347 20c 01a3 clrf state 1348 ; high := 0 1349 20d 01a5 clrf high 1350 ; call reset {{ }} 1351 20e 216a call reset 1352 ; Initialize timer : 1353 ; t1ckps0 := 0 1354 20f 1210 bcf t1ckps0__byte,t1ckps0__bit 1355 ; t1ckps1 := 0 1356 210 1290 bcf t1ckps1__byte,t1ckps1__bit 1357 ; t1oscen := 0 1358 211 1190 bcf t1oscen__byte,t1oscen__bit 1359 ; t1sync := 1 1360 ; tmr1cs := 0 1361 212 1090 bcf tmr1cs__byte,tmr1cs__bit 1362 ; tmr1on := 0 1363 213 1010 bcf tmr1on__byte,tmr1on__bit 1364 ; Make sure all interrupts are off : 1365 ; intcon := 0 1366 214 018b clrf intcon 1367 ; Turn off CCP : 1368 ; ccp1con := 0 1369 215 0197 clrf ccp1con 1370 ; loop_forever ... start 1371 main__402loop__forever: 1372 ; Wait for command : 1373 ; command := get_byte {{ }} 1374 216 213c call get_byte 1375 217 0841 movf get_byte__0return__byte,w 1376 218 00c7 movwf main__command 1377 ; Dispatch on command : 1378 ; switch { command >> 6 } 1379 219 3002 movlw HIGH switch__407block_start 1380 21a 008a movwf pclath___register 1381 21b 0e47 swapf main__command,w 1382 21c 00cb movwf main__407byte0 1383 21d 0ccb rrf main__407byte0,f 1384 21e 0c4b rrf main__407byte0,w 1385 21f 3903 andlw 3 1386 ; case 0 1387 ; case 1 2 1388 ; case 3 1389 switch__407block_start: 1390 220 0782 addwf pcl___register,f 1391 221 2a25 goto switch__407block408 1392 222 2aa4 goto switch__407block504 1393 223 2aa4 goto switch__407block504 1394 224 2aa5 goto switch__407block507 1395 switch__407block_end: 1396 ; switch_check 407 switch__407block_start switch__407block_end 1397 switch__407block408: 1398 ; Command = 00 xx xxxx : 1399 ; switch { command >> 3 } 1400 225 3002 movlw HIGH switch__410block_start 1401 226 008a movwf pclath___register 1402 227 0c47 rrf main__command,w 1403 228 00cb movwf main__410byte0 1404 229 0ccb rrf main__410byte0,f 1405 22a 0c4b rrf main__410byte0,w 1406 22b 391f andlw 31 1407 ; case 0 1408 ; case 1 1409 switch__410block_start: 1410 22c 0782 addwf pcl___register,f 1411 22d 2a35 goto switch__410block411 1412 22e 2a85 goto switch__410block475 1413 22f 2aa3 goto switch__410default499 1414 230 2aa3 goto switch__410default499 1415 231 2aa3 goto switch__410default499 1416 232 2aa3 goto switch__410default499 1417 233 2aa3 goto switch__410default499 1418 234 2aa3 goto switch__410default499 1419 switch__410block_end: 1420 ; switch_check 410 switch__410block_start switch__410block_end 1421 switch__410block411: 1422 ; Command = 0000 0 xxx : 1423 ; switch { command & 7 } 1424 235 3002 movlw HIGH switch__413block_start 1425 236 008a movwf pclath___register 1426 237 3007 movlw 7 1427 238 0547 andwf main__command,w 1428 ; case 0 1 1429 ; case 2 1430 ; case 3 1431 ; case 4 1432 ; case 5 1433 ; case 6 1434 ; case 7 1435 switch__413block_start: 1436 239 0782 addwf pcl___register,f 1437 23a 2a42 goto switch__413block414 1438 23b 2a42 goto switch__413block414 1439 23c 2a47 goto switch__413block418 1440 23d 2a56 goto switch__413block435 1441 23e 2a6d goto switch__413block442 1442 23f 2a6f goto switch__413block446 1443 240 2a73 goto switch__413block451 1444 241 2a77 goto switch__413block456 1445 switch__413block_end: 1446 ; switch_check 413 switch__413block_start switch__413block_end 1447 switch__413block414: 1448 ; Set Laser Enable < Command = 0000 000 z > : 1449 ; laser_enable_pin := command @ 0 1450 ; Alias variable for select command @ 0 1451 0047 main__command__416select0 equ main__command+0 1452 0047 main__command__416select0__byte equ main__command+0 1453 0000 main__command__416select0__bit equ 0 1454 242 1c47 btfss main__command__416select0__byte,main__command__416select0__bit 1455 243 1006 bcf laser_enable_pin__byte,laser_enable_pin__bit 1456 244 1847 btfsc main__command__416select0__byte,main__command__416select0__bit 1457 245 1406 bsf laser_enable_pin__byte,laser_enable_pin__bit 1458 246 2a84 goto switch__413end 1459 switch__413block418: 1460 ; Read Laser < Command = 0000 0010 > : 1461 ; temporary := capture_count & 0xf 1462 247 300f movlw 15 1463 248 0527 andwf capture_count,w 1464 249 00ca movwf main__temporary 1465 ; if { ! laser_in_pin } start 1466 ; expression=`laser_in_pin' exp_delay=0 true_delay=0 false_delay=1 true_size=0 false_size=1 1467 24a 1d86 btfss laser_in_pin__byte,laser_in_pin__bit 1468 ; if { ! laser_in_pin } body start 1469 ; temporary @ 4 := 1 1470 ; Select temporary @ 4 1471 004a main__temporary__422select0 equ main__temporary+0 1472 004a main__temporary__422select0__byte equ main__temporary+0 1473 0004 main__temporary__422select0__bit equ 4 1474 24b 164a bsf main__temporary__422select0__byte,main__temporary__422select0__bit 1475 ; if { ! laser_in_pin } body end 1476 ; if exp=`laser_in_pin' true skip delay=2 1477 ; Other expression=`laser_in_pin' delay=2 1478 ; if { ! laser_in_pin } end 1479 ; if { low_in_pin } start 1480 ; expression=`{ low_in_pin }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 1481 24c 1b06 btfsc low_in_pin__byte,low_in_pin__bit 1482 ; if { low_in_pin } body start 1483 ; temporary @ 5 := 1 1484 ; Select temporary @ 5 1485 004a main__temporary__425select0 equ main__temporary+0 1486 004a main__temporary__425select0__byte equ main__temporary+0 1487 0005 main__temporary__425select0__bit equ 5 1488 24d 16ca bsf main__temporary__425select0__byte,main__temporary__425select0__bit 1489 ; if { low_in_pin } body end 1490 ; if exp=`low_in_pin' false skip delay=2 1491 ; Other expression=`{ low_in_pin }' delay=2 1492 ; if { low_in_pin } end 1493 ; if { high_in_pin } start 1494 ; expression=`{ high_in_pin }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 1495 24e 1b86 btfsc high_in_pin__byte,high_in_pin__bit 1496 ; if { high_in_pin } body start 1497 ; temporary @ 6 := 1 1498 ; Select temporary @ 6 1499 004a main__temporary__428select0 equ main__temporary+0 1500 004a main__temporary__428select0__byte equ main__temporary+0 1501 0006 main__temporary__428select0__bit equ 6 1502 24f 174a bsf main__temporary__428select0__byte,main__temporary__428select0__bit 1503 ; if { high_in_pin } body end 1504 ; if exp=`high_in_pin' false skip delay=2 1505 ; Other expression=`{ high_in_pin }' delay=2 1506 ; if { high_in_pin } end 1507 ; if { sweeping } start 1508 ; expression=`{ sweeping }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 1509 250 19cc btfsc sweeping__byte,sweeping__bit 1510 ; if { sweeping } body start 1511 ; temporary @ 7 := 1 1512 ; Select temporary @ 7 1513 004a main__temporary__431select0 equ main__temporary+0 1514 004a main__temporary__431select0__byte equ main__temporary+0 1515 0007 main__temporary__431select0__bit equ 7 1516 251 17ca bsf main__temporary__431select0__byte,main__temporary__431select0__bit 1517 ; if { sweeping } body end 1518 ; if exp=`sweeping' false skip delay=2 1519 ; Other expression=`{ sweeping }' delay=2 1520 ; if { sweeping } end 1521 ; call send_byte {{ temporary }} 1522 252 084a movf main__temporary,w 1523 253 00c4 movwf send_byte__data 1524 254 2154 call send_byte 1525 255 2a84 goto switch__413end 1526 switch__413block435: 1527 ; Read last caputure < Command = 0000 0011 > : 1528 ; call send_byte {{ capture_high ~~ {{ capture_index }} }} 1529 256 3036 movlw LOW capture_high 1530 257 0726 addwf capture_index,w 1531 258 0084 movwf fsr___register 1532 259 1383 bcf irp___register,irp___bit 1533 25a 0800 movf indf___register,w 1534 25b 00c4 movwf send_byte__data 1535 25c 2154 call send_byte 1536 ; call send_byte {{ capture_middle ~~ {{ capture_index }} }} 1537 25d 302f movlw LOW capture_middle 1538 25e 0726 addwf capture_index,w 1539 25f 0084 movwf fsr___register 1540 260 1383 bcf irp___register,irp___bit 1541 261 0800 movf indf___register,w 1542 262 00c4 movwf send_byte__data 1543 263 2154 call send_byte 1544 ; call send_byte {{ capture_low ~~ {{ capture_index }} }} 1545 264 3028 movlw LOW capture_low 1546 265 0726 addwf capture_index,w 1547 266 0084 movwf fsr___register 1548 267 1383 bcf irp___register,irp___bit 1549 268 0800 movf indf___register,w 1550 269 00c4 movwf send_byte__data 1551 26a 2154 call send_byte 1552 ; capture_index := capture_index + 1 1553 26b 0aa6 incf capture_index,f 1554 26c 2a84 goto switch__413end 1555 switch__413block442: 1556 ; Disable Servo < Command = 0000 0100 > : 1557 ; servo_enable := 0 1558 26d 114c bcf servo_enable__byte,servo_enable__bit 1559 26e 2a84 goto switch__413end 1560 switch__413block446: 1561 ; Enable Servo Low < Command = 0000 0101 > : 1562 ; servo_enable := 1 1563 26f 154c bsf servo_enable__byte,servo_enable__bit 1564 ; servo := servo_low 1565 270 0821 movf servo_low,w 1566 271 00a0 movwf servo 1567 272 2a84 goto switch__413end 1568 switch__413block451: 1569 ; Enable Servo High < Command = 0000 0101 > : 1570 ; servo_enable := 1 1571 273 154c bsf servo_enable__byte,servo_enable__bit 1572 ; servo := servo_high 1573 274 0822 movf servo_high,w 1574 275 00a0 movwf servo 1575 276 2a84 goto switch__413end 1576 switch__413block456: 1577 ; Sweep < Command = 0000 0111 > : 1578 ; call reset {{ }} 1579 277 216a call reset 1580 ; sweeping := 1 1581 278 15cc bsf sweeping__byte,sweeping__bit 1582 ; servo_enable := 1 1583 279 154c bsf servo_enable__byte,servo_enable__bit 1584 ; servo := servo_low 1585 27a 0821 movf servo_low,w 1586 27b 00a0 movwf servo 1587 ; state := state_forward_up1 1588 27c 3001 movlw 1 1589 27d 00a3 movwf state 1590 ; Turn on CCP : 1591 ; ccp1con := 4 1592 27e 3004 movlw 4 1593 27f 0097 movwf ccp1con 1594 ; ccp1if := 0 1595 280 110c bcf ccp1if__byte,ccp1if__bit 1596 ; Clear timer 1 : 1597 ; tmr1l := 0 1598 281 018e clrf tmr1l 1599 ; tmr1h := 0 1600 282 018f clrf tmr1h 1601 ; high := 0 1602 283 01a5 clrf high 1603 switch__413end: 1604 284 2aa3 goto switch__410end 1605 switch__410block475: 1606 ; Undefinded command ; do nothing : 1607 ; switch { command & 7 } 1608 285 3002 movlw HIGH switch__477block_start 1609 286 008a movwf pclath___register 1610 287 3007 movlw 7 1611 288 0547 andwf main__command,w 1612 ; case 0 1613 ; case 1 1614 ; case 2 1615 ; case 3 1616 switch__477block_start: 1617 289 0782 addwf pcl___register,f 1618 28a 2a92 goto switch__477block478 1619 28b 2a96 goto switch__477block482 1620 28c 2a9a goto switch__477block486 1621 28d 2a9e goto switch__477block490 1622 28e 2aa2 goto switch__477default494 1623 28f 2aa2 goto switch__477default494 1624 290 2aa2 goto switch__477default494 1625 291 2aa2 goto switch__477default494 1626 switch__477block_end: 1627 ; switch_check 477 switch__477block_start switch__477block_end 1628 switch__477block478: 1629 ; Set Servo Low < Command = 0000 1000 > 1630 ; servo_low := get_byte {{ }} 1631 292 213c call get_byte 1632 293 0841 movf get_byte__0return__byte,w 1633 294 00a1 movwf servo_low 1634 295 2aa2 goto switch__477end 1635 switch__477block482: 1636 ; Set Servo High < Command = 0000 1001 > 1637 ; servo_high := get_byte {{ }} 1638 296 213c call get_byte 1639 297 0841 movf get_byte__0return__byte,w 1640 298 00a2 movwf servo_high 1641 299 2aa2 goto switch__477end 1642 switch__477block486: 1643 ; Read Servo Low < Command = 0000 1010 > 1644 ; call send_byte {{ servo_low }} 1645 29a 0821 movf servo_low,w 1646 29b 00c4 movwf send_byte__data 1647 29c 2154 call send_byte 1648 29d 2aa2 goto switch__477end 1649 switch__477block490: 1650 ; Read Servo Low < Command = 0000 1011 > 1651 ; call send_byte {{ servo_high }} 1652 29e 0822 movf servo_high,w 1653 29f 00c4 movwf send_byte__data 1654 2a0 2154 call send_byte 1655 2a1 2aa2 goto switch__477end 1656 switch__477default494: 1657 ; < Command = 0000 11 xx > 1658 switch__477end: 1659 2a2 2aa3 goto switch__410end 1660 switch__410default499: 1661 ; Do Nothing : 1662 switch__410end: 1663 2a3 2b0f goto switch__407end 1664 switch__407block504: 1665 ; Do nothing < Command = 01 xx xxxx or 10 xx xxxx > : 1666 2a4 2b0f goto switch__407end 1667 switch__407block507: 1668 ; Command = 11 xx xxxx : 1669 ; switch { {{ command >> 3 }} & 7 } 1670 2a5 3002 movlw HIGH switch__509block_start 1671 2a6 008a movwf pclath___register 1672 2a7 0c47 rrf main__command,w 1673 2a8 00cb movwf main__509byte0 1674 2a9 0ccb rrf main__509byte0,f 1675 2aa 0c4b rrf main__509byte0,w 1676 2ab 3907 andlw 7 1677 ; case 5 1678 ; case 6 1679 ; case 7 1680 switch__509block_start: 1681 2ac 0782 addwf pcl___register,f 1682 2ad 2b0f goto switch__509end 1683 2ae 2b0f goto switch__509end 1684 2af 2b0f goto switch__509end 1685 2b0 2b0f goto switch__509end 1686 2b1 2b0f goto switch__509end 1687 2b2 2ab5 goto switch__509block510 1688 2b3 2ac5 goto switch__509block524 1689 2b4 2ae1 goto switch__509block542 1690 switch__509block_end: 1691 ; switch_check 509 switch__509block_start switch__509block_end 1692 switch__509block510: 1693 ; Command = 1110 1 xxx : 1694 ; if { {{ command & 7 }} = 7 } start 1695 2b5 3007 movlw 7 1696 2b6 0547 andwf main__command,w 1697 2b7 00cb movwf main__512byte0 1698 2b8 3007 movlw 7 1699 2b9 024b subwf main__512byte0,w 1700 ; expression=`{ {{ command & 7 }} = 7 }' exp_delay=5 true_delay=6 false_delay=0 true_size=8 false_size=0 1701 2ba 1d03 btfss z___byte,z___bit 1702 2bb 2ac4 goto label512__1end 1703 ; if { {{ command & 7 }} = 7 } body start 1704 ; Return Interrupt Bits < Command = 1110 1111 > : 1705 ; temporary := 0 1706 2bc 01ca clrf main__temporary 1707 ; if { interrupt_enable } start 1708 ; expression=`{ interrupt_enable }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 1709 2bd 184c btfsc interrupt_enable__byte,interrupt_enable__bit 1710 ; if { interrupt_enable } body start 1711 ; temporary @ 1 := 1 1712 ; Select temporary @ 1 1713 004a main__temporary__516select0 equ main__temporary+0 1714 004a main__temporary__516select0__byte equ main__temporary+0 1715 0001 main__temporary__516select0__bit equ 1 1716 2be 14ca bsf main__temporary__516select0__byte,main__temporary__516select0__bit 1717 ; if { interrupt_enable } body end 1718 ; if exp=`interrupt_enable' false skip delay=2 1719 ; Other expression=`{ interrupt_enable }' delay=2 1720 ; if { interrupt_enable } end 1721 ; if { interrupt_pending } start 1722 ; expression=`{ interrupt_pending }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 1723 2bf 18cc btfsc interrupt_pending__byte,interrupt_pending__bit 1724 ; if { interrupt_pending } body start 1725 ; temporary @ 0 := 1 1726 ; Select temporary @ 0 1727 004a main__temporary__519select0 equ main__temporary+0 1728 004a main__temporary__519select0__byte equ main__temporary+0 1729 0000 main__temporary__519select0__bit equ 0 1730 2c0 144a bsf main__temporary__519select0__byte,main__temporary__519select0__bit 1731 ; if { interrupt_pending } body end 1732 ; if exp=`interrupt_pending' false skip delay=2 1733 ; Other expression=`{ interrupt_pending }' delay=2 1734 ; if { interrupt_pending } end 1735 ; call send_byte {{ temporary }} 1736 2c1 084a movf main__temporary,w 1737 2c2 00c4 movwf send_byte__data 1738 2c3 2154 call send_byte 1739 ; if { {{ command & 7 }} = 7 } body end 1740 label512__1end: 1741 ; if exp=` {{ command & 7 }} = 7 ' empty false 1742 ; Other expression=`{ {{ command & 7 }} = 7 }' delay=-1 1743 ; if { {{ command & 7 }} = 7 } end 1744 2c4 2b0f goto switch__509end 1745 switch__509block524: 1746 ; Shared Interrupt commands < Command = 1111 0 xxx > : 1747 ; switch { command & 7 } 1748 2c5 3002 movlw HIGH switch__526block_start 1749 2c6 008a movwf pclath___register 1750 2c7 3007 movlw 7 1751 2c8 0547 andwf main__command,w 1752 ; case 0 1 2 3 1753 ; case 4 5 1754 ; case 6 7 1755 switch__526block_start: 1756 2c9 0782 addwf pcl___register,f 1757 2ca 2ad2 goto switch__526block527 1758 2cb 2ad2 goto switch__526block527 1759 2cc 2ad2 goto switch__526block527 1760 2cd 2ad2 goto switch__526block527 1761 2ce 2ad9 goto switch__526block532 1762 2cf 2ad9 goto switch__526block532 1763 2d0 2add goto switch__526block536 1764 2d1 2add goto switch__526block536 1765 switch__526block_end: 1766 ; switch_check 526 switch__526block_start switch__526block_end 1767 switch__526block527: 1768 ; Set interrupt enable and pending < Command = 1111 00 ep > : 1769 ; interrupt_enable := command @ 1 1770 ; Alias variable for select command @ 1 1771 0047 main__command__529select0 equ main__command+0 1772 0047 main__command__529select0__byte equ main__command+0 1773 0001 main__command__529select0__bit equ 1 1774 2d2 104c bcf interrupt_enable__byte,interrupt_enable__bit 1775 2d3 18c7 btfsc main__command__529select0__byte,main__command__529select0__bit 1776 2d4 144c bsf interrupt_enable__byte,interrupt_enable__bit 1777 ; interrupt_pending := command @ 0 1778 ; Alias variable for select command @ 0 1779 0047 main__command__530select0 equ main__command+0 1780 0047 main__command__530select0__byte equ main__command+0 1781 0000 main__command__530select0__bit equ 0 1782 2d5 10cc bcf interrupt_pending__byte,interrupt_pending__bit 1783 2d6 1847 btfsc main__command__530select0__byte,main__command__530select0__bit 1784 2d7 14cc bsf interrupt_pending__byte,interrupt_pending__bit 1785 2d8 2ae0 goto switch__526end 1786 switch__526block532: 1787 ; Set Interrupt pending bit only < Command = 1111 010 p > : 1788 ; interrupt_pending := command @ 0 1789 ; Alias variable for select command @ 0 1790 0047 main__command__534select0 equ main__command+0 1791 0047 main__command__534select0__byte equ main__command+0 1792 0000 main__command__534select0__bit equ 0 1793 2d9 10cc bcf interrupt_pending__byte,interrupt_pending__bit 1794 2da 1847 btfsc main__command__534select0__byte,main__command__534select0__bit 1795 2db 14cc bsf interrupt_pending__byte,interrupt_pending__bit 1796 2dc 2ae0 goto switch__526end 1797 switch__526block536: 1798 ; Set Interrupt pending bit only < Command = 1111 011 e > : 1799 ; interrupt_enable := command @ 0 1800 ; Alias variable for select command @ 0 1801 0047 main__command__538select0 equ main__command+0 1802 0047 main__command__538select0__byte equ main__command+0 1803 0000 main__command__538select0__bit equ 0 1804 2dd 104c bcf interrupt_enable__byte,interrupt_enable__bit 1805 2de 1847 btfsc main__command__538select0__byte,main__command__538select0__bit 1806 2df 144c bsf interrupt_enable__byte,interrupt_enable__bit 1807 switch__526end: 1808 2e0 2b0f goto switch__509end 1809 switch__509block542: 1810 ; Shared commands . 1811 ; switch { command & 7 } 1812 2e1 3002 movlw HIGH switch__544block_start 1813 2e2 008a movwf pclath___register 1814 2e3 3007 movlw 7 1815 2e4 0547 andwf main__command,w 1816 ; case 0 1817 ; case 1 1818 ; case 2 1819 ; case 3 1820 ; case 4 1821 ; case 5 1822 ; case 6 1823 ; case 7 1824 switch__544block_start: 1825 2e5 0782 addwf pcl___register,f 1826 2e6 2aee goto switch__544block545 1827 2e7 2aef goto switch__544block549 1828 2e8 2af0 goto switch__544block553 1829 2e9 2af3 goto switch__544block557 1830 2ea 2af6 goto switch__544block561 1831 2eb 2b05 goto switch__544block572 1832 2ec 2b07 goto switch__544block576 1833 2ed 2b0c goto switch__544block581 1834 switch__544block_end: 1835 ; switch_check 544 switch__544block_start switch__544block_end 1836 switch__544block545: 1837 ; Clock Decrement < Command = 1111 1000 > : 1838 ; Do nothing : 1839 2ee 2b0f goto switch__544end 1840 switch__544block549: 1841 ; Clock Increment < Command = 1111 1001 > : 1842 ; Do nothing : 1843 2ef 2b0f goto switch__544end 1844 switch__544block553: 1845 ; Clock Read < Command = 1111 1010 > : 1846 ; call send_byte {{ 0 }} 1847 2f0 01c4 clrf send_byte__data 1848 2f1 2154 call send_byte 1849 2f2 2b0f goto switch__544end 1850 switch__544block557: 1851 ; Clock Pulse < Command = 1111 1011 > : 1852 ; call send_byte {{ 0 }} 1853 2f3 01c4 clrf send_byte__data 1854 2f4 2154 call send_byte 1855 2f5 2b0f goto switch__544end 1856 switch__544block561: 1857 ; ID Next < Command = 1111 1100 > : 1858 ; if { id_index >= id . size } start 1859 2f6 3030 movlw 48 1860 2f7 0249 subwf main__id_index,w 1861 ; expression=`{ id_index >= id . size }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 1862 2f8 1803 btfsc c___byte,c___bit 1863 ; if { id_index >= id . size } body start 1864 ; id_index := 0 1865 2f9 01c9 clrf main__id_index 1866 ; if { id_index >= id . size } body end 1867 ; if exp=` id_index >= id . size ' false skip delay=4 1868 ; Other expression=`{ id_index >= id . size }' delay=4 1869 ; if { id_index >= id . size } end 1870 ; call send_byte {{ id ~~ {{ id_index }} }} 1871 2fa 0a49 incf main__id_index,w 1872 2fb 018a clrf pclath___register 1873 2fc 200f call id 1874 2fd 00c4 movwf send_byte__data 1875 2fe 2154 call send_byte 1876 ; id_index := id_index + 1 1877 2ff 0ac9 incf main__id_index,f 1878 ; if { id_index >= id . size } start 1879 300 3030 movlw 48 1880 301 0249 subwf main__id_index,w 1881 ; expression=`{ id_index >= id . size }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 1882 302 1803 btfsc c___byte,c___bit 1883 ; if { id_index >= id . size } body start 1884 ; id_index := 0 1885 303 01c9 clrf main__id_index 1886 ; if { id_index >= id . size } body end 1887 ; if exp=` id_index >= id . size ' false skip delay=4 1888 ; Other expression=`{ id_index >= id . size }' delay=4 1889 ; if { id_index >= id . size } end 1890 304 2b0f goto switch__544end 1891 switch__544block572: 1892 ; ID Reset < Command = 1111 1101 > : 1893 ; id_index := 0 1894 305 01c9 clrf main__id_index 1895 306 2b0f goto switch__544end 1896 switch__544block576: 1897 ; Glitch Read < Command = 1111 1110 > : 1898 ; call send_byte {{ glitch }} 1899 307 0848 movf main__glitch,w 1900 308 00c4 movwf send_byte__data 1901 309 2154 call send_byte 1902 ; glitch := 0 1903 30a 01c8 clrf main__glitch 1904 30b 2b0f goto switch__544end 1905 switch__544block581: 1906 ; Glitch < Command = 1111 1111 > : 1907 ; if { glitch != 0xff } start 1908 30c 0a48 incf main__glitch,w 1909 ; expression=`{ glitch != 0xff }' exp_delay=1 true_delay=1 false_delay=0 true_size=1 false_size=0 1910 30d 1d03 btfss z___byte,z___bit 1911 ; if { glitch != 0xff } body start 1912 ; glitch := glitch + 1 1913 30e 0ac8 incf main__glitch,f 1914 ; if { glitch != 0xff } body end 1915 ; if exp=` glitch != 0xff ' false skip delay=3 1916 ; Other expression=`{ glitch != 0xff }' delay=3 1917 ; if { glitch != 0xff } end 1918 switch__544end: 1919 switch__509end: 1920 switch__407end: 1921 30f 2a16 goto main__402loop__forever 1922 ; loop_forever ... end 1923 ; procedure main end 1924 1925 ; Register bank 0 used 44 bytes of 96 available bytes 1926 ; Register bank 1 used 0 bytes of 80 available bytes 1927 ; Register bank 2 used 0 bytes of 48 available bytes 1928 ; Register bank 3 used 0 bytes of 0 available bytes 1929 1930 end