radix dec global__variables__bank0 equ 32 global__variables__bank1 equ 160 global__variables__bank2 equ 288 global__variables__bank3 equ 496 global__bit__variables__bank0 equ 76 global__bit__variables__bank1 equ 160 global__bit__variables__bank2 equ 288 global__bit__variables__bank3 equ 496 indf___register equ 0 pcl___register equ 2 c___byte equ 3 c___bit equ 0 z___byte equ 3 z___bit equ 2 rp0___byte equ 3 rp0___bit equ 5 rp1___byte equ 3 rp1___bit equ 6 irp___byte equ 3 irp___bit equ 7 trisa___register equ 0x85 trisb___register equ 0x86 fsr___register equ 4 pclath___register equ 10 org 0 start: nop nop nop goto skip___interrupt interrupt___vector: retfie skip___interrupt: ; Initialize A/D system to allow digital I/O movlw 7 movwf 31 ; Switch from register bank 0 to register bank 1 (which contains 159) bsf rp0___byte,rp0___bit ; Register bank is now 1 clrf 159 ; Initialize TRIS registers movlw 218 movwf trisb___register clrf pclath___register ; Switch from register bank 1 to register bank 0 bcf rp0___byte,rp0___bit ; Register bank is now 0 goto main ; comment ############################################################################# ; comment {} ; comment {Copyright < c > 1999 - 2001 by Wayne C . Gramlich .} ; comment {All rights reserved .} ; comment {} ; comment {Permission to use , copy , modify , distribute , and sell this software} ; comment {for any purpose is hereby granted without fee provided that the above} ; comment {copyright notice and this permission are retained . The author makes} ; comment {no representations about the suitability of this software for any purpose .} ; comment {It is provided { as is } without express or implied warranty .} ; comment {} ; comment {This is software needed to run Laser1 RoboBrick . All communication} ; comment {occurs at 2400 baud . See :} ; comment {} ; comment {http : / / web . gramlich . net / projects / robobricks / laser1 / index . html} ; comment {} ; comment {for more details .} ; comment {} ; comment ############################################################################# ; processor pic16f628 cp = off cpd = off lvp = off bowden = off mclre = on pwrte = off wdte = off fosc = xt ; 16169=0x3f29 8199=0x2007 __config 16169 configuration___address equ 8199 ; comment {processor pic16f84 cp = off dp = off pwrte = disabled wdte = disabled fosc = xt} ; comment {Some timing constants :} ; constant clock_rate 10000000 clock_rate equ 10000000 ; constant clock_ticks_per_instruction 4 clock_ticks_per_instruction equ 4 ; constant instructions_per_second clock_rate / clock_ticks_per_instruction instructions_per_second equ 2500000 ; constant baud_rate 2400 baud_rate equ 2400 ; constant instructions_per_bit clock_rate / {{ clock_ticks_per_instruction * baud_rate }} instructions_per_bit equ 1041 ; constant delays_per_bit 3 delays_per_bit equ 3 ; constant instructions_per_delay instructions_per_bit / delays_per_bit instructions_per_delay equ 347 ; comment {Some bit definitions < see schematic > :} ; constant laser_enable_bit 0 laser_enable_bit equ 0 ; constant serial_in_bit 1 serial_in_bit equ 1 ; constant serial_out_bit 2 serial_out_bit equ 2 ; constant laser_in_bit 3 laser_in_bit equ 3 ; constant servo_out_bit 5 servo_out_bit equ 5 ; constant low_in_bit 6 low_in_bit equ 6 ; constant high_in_bit 7 high_in_bit equ 7 ; comment {Some port and pin definitions :} porta equ 5 portb equ 6 laser_enable_pin__byte equ 6 laser_enable_pin__bit equ 0 serial_out_pin__byte equ 6 serial_out_pin__bit equ 2 serial_in_pin__byte equ 6 serial_in_pin__bit equ 1 laser_in_pin__byte equ 6 laser_in_pin__bit equ 3 servo_out_pin__byte equ 6 servo_out_pin__bit equ 5 low_in_pin__byte equ 6 low_in_pin__bit equ 6 high_in_pin__byte equ 6 high_in_pin__bit equ 7 ; comment {Some register and bit declarations :} ; comment {Status register :} status equ 3 ; bind c status @ 0 c equ status+0 c__byte equ status+0 c__bit equ 0 ; bind z status @ 2 z equ status+0 z__byte equ status+0 z__bit equ 2 ; comment {INTCON : Interrupt Control} intcon equ 11 ; bind gie intcon @ 7 gie equ intcon+0 gie__byte equ intcon+0 gie__bit equ 7 ; bind peie intcon @ 6 peie equ intcon+0 peie__byte equ intcon+0 peie__bit equ 6 ; comment {PIR1 :} pir1 equ 12 ; bind eeif pir1 @ 7 eeif equ pir1+0 eeif__byte equ pir1+0 eeif__bit equ 7 ; bind cmif pir1 @ 6 cmif equ pir1+0 cmif__byte equ pir1+0 cmif__bit equ 6 ; bind rcif pir1 @ 5 rcif equ pir1+0 rcif__byte equ pir1+0 rcif__bit equ 5 ; bind txif pir1 @ 4 txif equ pir1+0 txif__byte equ pir1+0 txif__bit equ 4 ; bind ccp1if pir1 @ 2 ccp1if equ pir1+0 ccp1if__byte equ pir1+0 ccp1if__bit equ 2 ; bind tmr2if pir1 @ 1 tmr2if equ pir1+0 tmr2if__byte equ pir1+0 tmr2if__bit equ 1 ; bind tmr1if pir1 @ 0 tmr1if equ pir1+0 tmr1if__byte equ pir1+0 tmr1if__bit equ 0 ; comment {TMR1L : Timer 1 Low :} tmr1l equ 14 ; comment {TMR1H : Timer1 High :} tmr1h equ 15 ; comment {T1CON : Timer 1 Contro :} t1con equ 16 ; bind t1ckps1 t1con @ 5 t1ckps1 equ t1con+0 t1ckps1__byte equ t1con+0 t1ckps1__bit equ 5 ; bind t1ckps0 t1con @ 4 t1ckps0 equ t1con+0 t1ckps0__byte equ t1con+0 t1ckps0__bit equ 4 ; bind t1oscen t1con @ 3 t1oscen equ t1con+0 t1oscen__byte equ t1con+0 t1oscen__bit equ 3 ; bind t1sync t1con @ 2 t1sync equ t1con+0 t1sync__byte equ t1con+0 t1sync__bit equ 2 ; bind tmr1cs t1con @ 1 tmr1cs equ t1con+0 tmr1cs__byte equ t1con+0 tmr1cs__bit equ 1 ; bind tmr1on t1con @ 0 tmr1on equ t1con+0 tmr1on__byte equ t1con+0 tmr1on__bit equ 0 ; comment {CCPR1L : Capture / Compare / PWM Low :} ccpr1l equ 21 ; comment {CCPR1H : Capture / Compare / PWM High :} ccpr1h equ 22 ; comment {CCP1CON : Capture / Compare / PWM Control :} ccp1con equ 23 ; bind ccp1x ccp1con @ 5 ccp1x equ ccp1con+0 ccp1x__byte equ ccp1con+0 ccp1x__bit equ 5 ; bind ccp1y ccp1con @ 4 ccp1y equ ccp1con+0 ccp1y__byte equ ccp1con+0 ccp1y__bit equ 4 ; bind ccp1m3 ccp1con @ 3 ccp1m3 equ ccp1con+0 ccp1m3__byte equ ccp1con+0 ccp1m3__bit equ 3 ; bind ccp1m2 ccp1con @ 2 ccp1m2 equ ccp1con+0 ccp1m2__byte equ ccp1con+0 ccp1m2__bit equ 2 ; bind ccp1m1 ccp1con @ 1 ccp1m1 equ ccp1con+0 ccp1m1__byte equ ccp1con+0 ccp1m1__bit equ 1 ; bind ccp1m0 ccp1con @ 0 ccp1m0 equ ccp1con+0 ccp1m0__byte equ ccp1con+0 ccp1m0__bit equ 0 ; comment {PIR2 :} pie1 equ 140 ; bind eeie pie1 @ 7 eeie equ pie1+0 eeie__byte equ pie1+0 eeie__bit equ 7 ; bind cmie pie1 @ 6 cmie equ pie1+0 cmie__byte equ pie1+0 cmie__bit equ 6 ; bind rcie pie1 @ 5 rcie equ pie1+0 rcie__byte equ pie1+0 rcie__bit equ 5 ; bind txie pie1 @ 4 txie equ pie1+0 txie__byte equ pie1+0 txie__bit equ 4 ; bind ccp1ie pie1 @ 2 ccp1ie equ pie1+0 ccp1ie__byte equ pie1+0 ccp1ie__bit equ 2 ; bind tmr2ie pie1 @ 1 tmr2ie equ pie1+0 tmr2ie__byte equ pie1+0 tmr2ie__bit equ 1 ; bind tmr1ie pie1 @ 0 tmr1ie equ pie1+0 tmr1ie__byte equ pie1+0 tmr1ie__bit equ 0 ; comment {Some globals :} ; constant maximum_captures 7 maximum_captures equ 7 interrupt_enable equ global__bit__variables__bank0+0 interrupt_enable__byte equ global__bit__variables__bank0+0 interrupt_enable__bit equ 0 interrupt_pending equ global__bit__variables__bank0+0 interrupt_pending__byte equ global__bit__variables__bank0+0 interrupt_pending__bit equ 1 servo_enable equ global__bit__variables__bank0+0 servo_enable__byte equ global__bit__variables__bank0+0 servo_enable__bit equ 2 sweeping equ global__bit__variables__bank0+0 sweeping__byte equ global__bit__variables__bank0+0 sweeping__bit equ 3 servo equ global__variables__bank0+0 servo_low equ global__variables__bank0+1 servo_high equ global__variables__bank0+2 state equ global__variables__bank0+3 middle equ global__variables__bank0+4 high equ global__variables__bank0+5 capture_index equ global__variables__bank0+6 capture_count equ global__variables__bank0+7 capture_low equ global__variables__bank0+8 capture_middle equ global__variables__bank0+15 capture_high equ global__variables__bank0+22 ; comment {The state variable states :} ; constant state_idle 0 state_idle equ 0 ; constant state_forward_up1 1 state_forward_up1 equ 1 ; constant state_forward_down1 2 state_forward_down1 equ 2 ; constant state_forward_up2 3 state_forward_up2 equ 3 ; constant state_forward_down2 4 state_forward_down2 equ 4 ; constant state_backward_up1 5 state_backward_up1 equ 5 ; constant state_backward_down1 6 state_backward_down1 equ 6 ; constant state_backward_up2 7 state_backward_up2 equ 7 ; constant state_backward_down2 8 state_backward_down2 equ 8 ; string_constants Start string___fetch: movwf pcl___register ; id = 1 , 0 , 24 , 0 , 0 , 0 , 0 , 0 , 0r'16' , 7 , 0s'Laser1A' , 15 , 0s'Gramlich&Benson' id___string equ 0 id: addwf pcl___register,f ; Length = 48 retlw 48 ; 1 retlw 1 ; 0 retlw 0 ; 24 retlw 24 ; 0 retlw 0 ; 0 retlw 0 ; 0 retlw 0 ; 0 retlw 0 ; 0 retlw 0 ; 0r'16' retlw 155 ; random number retlw 246 ; random number retlw 147 ; random number retlw 65 ; random number retlw 93 ; random number retlw 103 ; random number retlw 7 ; random number retlw 226 ; random number retlw 3 ; random number retlw 61 ; random number retlw 77 ; random number retlw 185 ; random number retlw 202 ; random number retlw 16 ; random number retlw 145 ; random number retlw 89 ; random number ; 7 retlw 7 ; `Laser1A' retlw 76 retlw 97 retlw 115 retlw 101 retlw 114 retlw 49 retlw 65 ; 15 retlw 15 ; `Gramlich&Benson' retlw 71 retlw 114 retlw 97 retlw 109 retlw 108 retlw 105 retlw 99 retlw 104 retlw 38 retlw 66 retlw 101 retlw 110 retlw 115 retlw 111 retlw 110 ; string__constants End ; procedure delay start ; optimize 0 delay: ; Procedure must be called with PCLATH set to code bank 0 delay__variables__base equ global__variables__bank0+29 delay__bytes__base equ delay__variables__base+0 delay__bits__base equ delay__variables__base+3 delay__total__bytes equ 4 delay__224byte0 equ delay__bytes__base+2 delay__260byte1 equ delay__bytes__base+2 delay__242byte1 equ delay__bytes__base+2 delay__254byte1 equ delay__bytes__base+2 delay__163byte2 equ delay__bytes__base+2 delay__248byte1 equ delay__bytes__base+2 delay__223byte0 equ delay__bytes__base+2 delay__195byte1 equ delay__bytes__base+2 delay__225byte0 equ delay__bytes__base+2 delay__235byte1 equ delay__bytes__base+2 delay__182byte0 equ delay__bytes__base+2 delay__190byte1 equ delay__bytes__base+2 delay__172byte2 equ delay__bytes__base+2 delay__174byte0 equ delay__bytes__base+2 delay__202byte1 equ delay__bytes__base+2 delay__210byte2 equ delay__bytes__base+2 delay__148byte1 equ delay__bytes__base+2 delay__176byte0 equ delay__bytes__base+2 ; arguments_none ; uniform_delay instructions_per_delay ; Uniform delay remaining = 343 Accumulated Delay = 0 ; Uniform delay remaining = 343 Accumulated Delay = 0 ; Delay 1 third of a bit : ; Uniform delay remaining = 343 Accumulated Delay = 0 ; Uniform delay remaining = 343 Accumulated Delay = 0 delay__counter equ delay__bytes__base+0 ; Uniform delay remaining = 343 Accumulated Delay = 0 delay__middle equ delay__bytes__base+1 ; Uniform delay remaining = 343 Accumulated Delay = 0 ; Uniform delay remaining = 343 Accumulated Delay = 0 ; Deal with servo pulse : ; Uniform delay remaining = 343 Accumulated Delay = 0 ; counter := counter + 1 incf delay__counter,f ; Uniform delay remaining = 342 Accumulated Delay = 1 ; if { counter = 144 } start movlw 144 subwf delay__counter,w ; expression=`{ counter = 144 }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 btfsc z___byte,z___bit ; if { counter = 144 } body start ; Uniform delay remaining = 342 Accumulated Delay = 0 ; counter := 0 clrf delay__counter ; Uniform delay remaining = 341 Accumulated Delay = 1 ; Uniform delay remaining = 341 Accumulated Delay = 1 ; if { counter = 144 } body end ; if exp=` counter = 144 ' false skip delay=4 ; Other expression=`{ counter = 144 }' delay=4 ; if { counter = 144 } end ; Uniform delay remaining = 338 Accumulated Delay = 5 ; if { servo_enable } start ; expression=`{ servo_enable }' exp_delay=0 true_delay=8 false_delay=0 true_size=11 false_size=0 btfsc servo_enable__byte,servo_enable__bit goto label163__0true label163__0false: ; Delay 7 cycles movlw 2 movwf delay__163byte2 delay__163delay1: decfsz delay__163byte2,f goto delay__163delay1 goto label163__0end label163__0true: ; if { servo_enable } body start ; Uniform delay remaining = 338 Accumulated Delay = 0 ; if { counter = 0 } start movf delay__counter,w ; expression=`{ counter = 0 }' exp_delay=1 true_delay=1 false_delay=4 true_size=1 false_size=4 btfss z___byte,z___bit goto label164__0false label164__0true: ; if { counter = 0 } body start ; Uniform delay remaining = 338 Accumulated Delay = 0 ; servo_out_pin := 1 bsf servo_out_pin__byte,servo_out_pin__bit ; Uniform delay remaining = 337 Accumulated Delay = 1 ; Uniform delay remaining = 337 Accumulated Delay = 1 ; if { counter = 0 } body end ; Delay 2 cycles nop nop goto label164__0end label164__0false: movf delay__counter,w subwf servo,w ; expression=`{ counter = servo }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 btfsc z___byte,z___bit ; else_if { counter = servo } body start ; Uniform delay remaining = 338 Accumulated Delay = 0 ; servo_out_pin := 0 bcf servo_out_pin__byte,servo_out_pin__bit ; Uniform delay remaining = 337 Accumulated Delay = 1 ; Uniform delay remaining = 337 Accumulated Delay = 1 ; else_if { counter = servo } body end ; if exp=` counter = servo ' false skip delay=4 ; Other expression=`{ counter = servo }' delay=4 ; if exp=` counter = 0 ' total delay=8 ; if exp=` counter = 0 ' generic label164__0end: ; Other expression=`{ counter = 0 }' delay=8 ; if { counter = 0 } end ; Uniform delay remaining = 330 Accumulated Delay = 8 ; Uniform delay remaining = 330 Accumulated Delay = 8 ; if { servo_enable } body end ; if exp=`servo_enable' total delay=11 ; if exp=`servo_enable' generic label163__0end: ; Other expression=`{ servo_enable }' delay=11 ; if { servo_enable } end ; Uniform delay remaining = 327 Accumulated Delay = 16 ; Uniform delay remaining = 327 Accumulated Delay = 16 ; Process any capture event : ; Uniform delay remaining = 327 Accumulated Delay = 16 ; if { ccp1if } start ; expression=`{ ccp1if }' exp_delay=0 true_delay=39 false_delay=0 true_size=44 false_size=0 btfsc ccp1if__byte,ccp1if__bit goto label172__0true label172__0false: ; Delay 38 cycles movlw 12 movwf delay__172byte2 delay__172delay1: decfsz delay__172byte2,f goto delay__172delay1 nop goto label172__0end label172__0true: ; if { ccp1if } body start ; Uniform delay remaining = 327 Accumulated Delay = 0 ; ccp1if := 0 bcf ccp1if__byte,ccp1if__bit ; Uniform delay remaining = 326 Accumulated Delay = 1 ; capture_low ~~ {{ capture_index }} := ccpr1l movf ccpr1l,w movwf delay__174byte0 movlw LOW capture_low addwf capture_index,w movwf fsr___register movf delay__174byte0,w bcf irp___register,irp___bit movwf indf___register ; Uniform delay remaining = 318 Accumulated Delay = 9 ; middle := ccpr1h movf ccpr1h,w movwf delay__middle ; Uniform delay remaining = 316 Accumulated Delay = 11 ; capture_middle ~~ {{ capture_index }} := middle movf delay__middle,w movwf delay__176byte0 movlw LOW capture_middle addwf capture_index,w movwf fsr___register movf delay__176byte0,w bcf irp___register,irp___bit movwf indf___register ; Uniform delay remaining = 308 Accumulated Delay = 19 ; if { tmr1if && ! {{ middle @ 7 }} } start ; expression=`tmr1if' exp_delay=0 true_delay=5 false_delay=2 true_size=6 false_size=1 btfsc tmr1if__byte,tmr1if__bit goto label177__3true label177__3false: ; Delay 4 cycles nop nop nop nop goto and177__0false label177__3true: ; Alias variable for select middle @ 7 delay__middle__177select1 equ delay__middle+0 delay__middle__177select1__byte equ delay__middle+0 delay__middle__177select1__bit equ 7 ; expression=`{{ middle @ 7 }}' exp_delay=0 true_delay=0 false_delay=2 true_size=0 false_size=2 btfss delay__middle__177select1__byte,delay__middle__177select1__bit goto label177__2false label177__2true: ; Delay 1 cycles nop goto label177__2end label177__2false: and177__0true: ; if { tmr1if && ! {{ middle @ 7 }} } body start ; Uniform delay remaining = 308 Accumulated Delay = 0 ; Capture occured after counter overflowed : ; Uniform delay remaining = 308 Accumulated Delay = 0 ; tmr1if := 0 bcf tmr1if__byte,tmr1if__bit ; Uniform delay remaining = 307 Accumulated Delay = 1 ; high := high + 1 incf high,f ; Uniform delay remaining = 306 Accumulated Delay = 2 ; Uniform delay remaining = 306 Accumulated Delay = 2 ; if { tmr1if && ! {{ middle @ 7 }} } body end ; if exp=` middle @ 7 ' total delay=5 ; if exp=` middle @ 7 ' generic label177__2end: ; Other expression=`{{ middle @ 7 }}' delay=5 ; if exp=`tmr1if' total delay=8 ; if exp=`tmr1if' generic label177__3end: ; Other expression=`tmr1if' delay=8 and177__0false: and177__0end: ; if { tmr1if && ! {{ middle @ 7 }} } end ; Uniform delay remaining = 300 Accumulated Delay = 27 ; capture_high ~~ {{ capture_index }} := high movf high,w movwf delay__182byte0 movlw LOW capture_high addwf capture_index,w movwf fsr___register movf delay__182byte0,w bcf irp___register,irp___bit movwf indf___register ; Uniform delay remaining = 292 Accumulated Delay = 35 ; if { capture_index != maximum_captures } start movlw 7 subwf capture_index,w ; expression=`{ capture_index != maximum_captures }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 btfss z___byte,z___bit ; if { capture_index != maximum_captures } body start ; Uniform delay remaining = 292 Accumulated Delay = 0 ; capture_index := capture_index + 1 incf capture_index,f ; Uniform delay remaining = 291 Accumulated Delay = 1 ; Uniform delay remaining = 291 Accumulated Delay = 1 ; if { capture_index != maximum_captures } body end ; if exp=` capture_index != maximum_captures ' false skip delay=4 ; Other expression=`{ capture_index != maximum_captures }' delay=4 ; if { capture_index != maximum_captures } end ; Uniform delay remaining = 288 Accumulated Delay = 39 ; Uniform delay remaining = 288 Accumulated Delay = 39 ; if { ccp1if } body end ; if exp=`ccp1if' total delay=42 ; if exp=`ccp1if' generic label172__0end: ; Other expression=`{ ccp1if }' delay=42 ; if { ccp1if } end ; Uniform delay remaining = 285 Accumulated Delay = 58 ; Uniform delay remaining = 285 Accumulated Delay = 58 ; Process state variable : ; Uniform delay remaining = 285 Accumulated Delay = 58 ; switch state movlw HIGH switch__189block_start movwf pclath___register movf state,w ; case state_idle ; case state_forward_up1 ; case state_forward_down1 ; case state_forward_up2 ; case state_forward_down2 ; case state_backward_up1 ; case state_backward_down1 ; case state_backward_up2 ; case state_backward_down2 switch__189block_start: addwf pcl___register,f goto switch__189block190 goto switch__189block195 goto switch__189block202 goto switch__189block208 goto switch__189block235 goto switch__189block242 goto switch__189block248 goto switch__189block254 goto switch__189block260 switch__189block_end: ; switch_check 189 switch__189block_start switch__189block_end switch__189block190: ; Uniform delay remaining = 285 Accumulated Delay = 0 ; Do nothing : ; Uniform delay remaining = 285 Accumulated Delay = 0 ; servo_enable := 0 bcf servo_enable__byte,servo_enable__bit ; Uniform delay remaining = 284 Accumulated Delay = 1 ; sweeping := 0 bcf sweeping__byte,sweeping__bit ; Uniform delay remaining = 283 Accumulated Delay = 2 ; Uniform delay remaining = 283 Accumulated Delay = 2 ; Delay 42 cycles movlw 13 movwf delay__190byte1 delay__190delay0: decfsz delay__190byte1,f goto delay__190delay0 nop nop goto switch__189end switch__189block195: ; Uniform delay remaining = 285 Accumulated Delay = 0 ; if { low_in_pin } start ; expression=`{ low_in_pin }' exp_delay=0 true_delay=4 false_delay=0 true_size=4 false_size=0 btfsc low_in_pin__byte,low_in_pin__bit goto label196__0true label196__0false: ; Delay 3 cycles nop nop nop goto label196__0end label196__0true: ; if { low_in_pin } body start ; Uniform delay remaining = 285 Accumulated Delay = 0 ; state := state_forward_down1 movlw 2 movwf state ; Uniform delay remaining = 283 Accumulated Delay = 2 ; laser_enable_pin := 1 bsf laser_enable_pin__byte,laser_enable_pin__bit ; Uniform delay remaining = 282 Accumulated Delay = 3 ; tmr1on := 1 bsf tmr1on__byte,tmr1on__bit ; Uniform delay remaining = 281 Accumulated Delay = 4 ; Uniform delay remaining = 281 Accumulated Delay = 4 ; if { low_in_pin } body end ; if exp=`low_in_pin' total delay=7 ; if exp=`low_in_pin' generic label196__0end: ; Other expression=`{ low_in_pin }' delay=7 ; if { low_in_pin } end ; Uniform delay remaining = 278 Accumulated Delay = 7 ; Uniform delay remaining = 278 Accumulated Delay = 7 ; Delay 37 cycles movlw 12 movwf delay__195byte1 delay__195delay0: decfsz delay__195byte1,f goto delay__195delay0 goto switch__189end switch__189block202: ; Uniform delay remaining = 285 Accumulated Delay = 0 ; Force the servo to the high location : ; Uniform delay remaining = 285 Accumulated Delay = 0 ; if { ! low_in_pin } start ; expression=`low_in_pin' exp_delay=0 true_delay=0 false_delay=2 true_size=0 false_size=2 btfss low_in_pin__byte,low_in_pin__bit goto label204__0false label204__0true: ; Delay 1 cycles nop goto label204__0end label204__0false: ; if { ! low_in_pin } body start ; Uniform delay remaining = 285 Accumulated Delay = 0 ; state := state_forward_up2 movlw 3 movwf state ; Uniform delay remaining = 283 Accumulated Delay = 2 ; Uniform delay remaining = 283 Accumulated Delay = 2 ; if { ! low_in_pin } body end ; if exp=`low_in_pin' total delay=5 ; if exp=`low_in_pin' generic label204__0end: ; Other expression=`low_in_pin' delay=5 ; if { ! low_in_pin } end ; Uniform delay remaining = 280 Accumulated Delay = 5 ; Uniform delay remaining = 280 Accumulated Delay = 5 ; Delay 39 cycles movlw 12 movwf delay__202byte1 delay__202delay0: decfsz delay__202byte1,f goto delay__202delay0 nop nop goto switch__189end switch__189block208: ; Uniform delay remaining = 285 Accumulated Delay = 0 ; Force servo to low location : ; Uniform delay remaining = 285 Accumulated Delay = 0 ; if { low_in_pin } start ; expression=`{ low_in_pin }' exp_delay=0 true_delay=41 false_delay=0 true_size=42 false_size=0 btfsc low_in_pin__byte,low_in_pin__bit goto label210__0true label210__0false: ; Delay 40 cycles movlw 13 movwf delay__210byte2 delay__210delay1: decfsz delay__210byte2,f goto delay__210delay1 goto label210__0end label210__0true: ; if { low_in_pin } body start ; Uniform delay remaining = 285 Accumulated Delay = 0 ; Turn off the timer and laser : ; Uniform delay remaining = 285 Accumulated Delay = 0 ; tmr1on := 0 bcf tmr1on__byte,tmr1on__bit ; Uniform delay remaining = 284 Accumulated Delay = 1 ; laser_enable_pin := 0 bcf laser_enable_pin__byte,laser_enable_pin__bit ; Uniform delay remaining = 283 Accumulated Delay = 2 ; state := state_forward_down2 movlw 4 movwf state ; Uniform delay remaining = 281 Accumulated Delay = 4 ; Uniform delay remaining = 281 Accumulated Delay = 4 ; Deal with any counter overflow : ; Uniform delay remaining = 281 Accumulated Delay = 4 ; if { tmr1if } start ; expression=`{ tmr1if }' exp_delay=0 true_delay=2 false_delay=0 true_size=2 false_size=0 btfsc tmr1if__byte,tmr1if__bit goto label217__0true label217__0false: ; Delay 1 cycles nop goto label217__0end label217__0true: ; if { tmr1if } body start ; Uniform delay remaining = 281 Accumulated Delay = 0 ; tmr1if := 0 bcf tmr1if__byte,tmr1if__bit ; Uniform delay remaining = 280 Accumulated Delay = 1 ; high := high + 1 incf high,f ; Uniform delay remaining = 279 Accumulated Delay = 2 ; Uniform delay remaining = 279 Accumulated Delay = 2 ; if { tmr1if } body end ; if exp=`tmr1if' total delay=5 ; if exp=`tmr1if' generic label217__0end: ; Other expression=`{ tmr1if }' delay=5 ; if { tmr1if } end ; Uniform delay remaining = 276 Accumulated Delay = 9 ; Uniform delay remaining = 276 Accumulated Delay = 9 ; Record the 24 - bit timer : ; Uniform delay remaining = 276 Accumulated Delay = 9 ; capture_low ~~ {{ capture_index }} := ccpr1l movf ccpr1l,w movwf delay__223byte0 movlw LOW capture_low addwf capture_index,w movwf fsr___register movf delay__223byte0,w bcf irp___register,irp___bit movwf indf___register ; Uniform delay remaining = 268 Accumulated Delay = 17 ; capture_middle ~~ {{ capture_index }} := ccpr1h movf ccpr1h,w movwf delay__224byte0 movlw LOW capture_middle addwf capture_index,w movwf fsr___register movf delay__224byte0,w bcf irp___register,irp___bit movwf indf___register ; Uniform delay remaining = 260 Accumulated Delay = 25 ; capture_high ~~ {{ capture_index }} := high movf high,w movwf delay__225byte0 movlw LOW capture_high addwf capture_index,w movwf fsr___register movf delay__225byte0,w bcf irp___register,irp___bit movwf indf___register ; Uniform delay remaining = 252 Accumulated Delay = 33 ; if { capture_index = maximum_captures } start movlw 7 subwf capture_index,w ; expression=`{ capture_index = maximum_captures }' exp_delay=2 true_delay=1 false_delay=1 true_size=1 false_size=1 btfsc z___byte,z___bit ; if { capture_index = maximum_captures } body start ; Uniform delay remaining = 252 Accumulated Delay = 0 ; We have an error : ; Uniform delay remaining = 252 Accumulated Delay = 0 ; capture_count := 0xff movlw 255 ; 1 instructions found for sharing ; Uniform delay remaining = 250 Accumulated Delay = 2 ; if { capture_index = maximum_captures } body end btfss z___byte,z___bit ; else body start ; Uniform delay remaining = 252 Accumulated Delay = 0 ; capture_count := capture_index + 1 incf capture_index,w ; 1 instructions found for sharing ; Uniform delay remaining = 250 Accumulated Delay = 2 ; else body end ; if exp=` capture_index = maximum_captures ' single true and false skip delay=6 ; Other expression=`{ capture_index = maximum_captures }' delay=6 ; 1 shared instructions follow movwf capture_count ; if { capture_index = maximum_captures } end ; Uniform delay remaining = 245 Accumulated Delay = 40 ; capture_index := 0 clrf capture_index ; Uniform delay remaining = 244 Accumulated Delay = 41 ; Uniform delay remaining = 244 Accumulated Delay = 41 ; if { low_in_pin } body end ; if exp=`low_in_pin' total delay=44 ; if exp=`low_in_pin' generic label210__0end: ; Other expression=`{ low_in_pin }' delay=44 ; if { low_in_pin } end ; Uniform delay remaining = 241 Accumulated Delay = 44 ; Uniform delay remaining = 241 Accumulated Delay = 44 goto switch__189end switch__189block235: ; Uniform delay remaining = 285 Accumulated Delay = 0 ; Force the servo to the high location : ; Uniform delay remaining = 285 Accumulated Delay = 0 ; if { ! low_in_pin } start ; expression=`low_in_pin' exp_delay=0 true_delay=0 false_delay=4 true_size=0 false_size=4 btfss low_in_pin__byte,low_in_pin__bit goto label237__0false label237__0true: ; Delay 3 cycles nop nop nop goto label237__0end label237__0false: ; if { ! low_in_pin } body start ; Uniform delay remaining = 285 Accumulated Delay = 0 ; state := state_backward_up1 movlw 5 movwf state ; Uniform delay remaining = 283 Accumulated Delay = 2 ; servo := servo_high movf servo_high,w movwf servo ; Uniform delay remaining = 281 Accumulated Delay = 4 ; Uniform delay remaining = 281 Accumulated Delay = 4 ; if { ! low_in_pin } body end ; if exp=`low_in_pin' total delay=7 ; if exp=`low_in_pin' generic label237__0end: ; Other expression=`low_in_pin' delay=7 ; if { ! low_in_pin } end ; Uniform delay remaining = 278 Accumulated Delay = 7 ; Uniform delay remaining = 278 Accumulated Delay = 7 ; Delay 37 cycles movlw 12 movwf delay__235byte1 delay__235delay0: decfsz delay__235byte1,f goto delay__235delay0 goto switch__189end switch__189block242: ; Uniform delay remaining = 285 Accumulated Delay = 0 ; Force the servo to the high location : ; Uniform delay remaining = 285 Accumulated Delay = 0 ; if { low_in_pin } start ; expression=`{ low_in_pin }' exp_delay=0 true_delay=2 false_delay=0 true_size=2 false_size=0 btfsc low_in_pin__byte,low_in_pin__bit goto label244__0true label244__0false: ; Delay 1 cycles nop goto label244__0end label244__0true: ; if { low_in_pin } body start ; Uniform delay remaining = 285 Accumulated Delay = 0 ; state := state_backward_down1 movlw 6 movwf state ; Uniform delay remaining = 283 Accumulated Delay = 2 ; Uniform delay remaining = 283 Accumulated Delay = 2 ; if { low_in_pin } body end ; if exp=`low_in_pin' total delay=5 ; if exp=`low_in_pin' generic label244__0end: ; Other expression=`{ low_in_pin }' delay=5 ; if { low_in_pin } end ; Uniform delay remaining = 280 Accumulated Delay = 5 ; Uniform delay remaining = 280 Accumulated Delay = 5 ; Delay 39 cycles movlw 12 movwf delay__242byte1 delay__242delay0: decfsz delay__242byte1,f goto delay__242delay0 nop nop goto switch__189end switch__189block248: ; Uniform delay remaining = 285 Accumulated Delay = 0 ; Force the servo to the high location : ; Uniform delay remaining = 285 Accumulated Delay = 0 ; if { ! low_in_pin } start ; expression=`low_in_pin' exp_delay=0 true_delay=0 false_delay=2 true_size=0 false_size=2 btfss low_in_pin__byte,low_in_pin__bit goto label250__0false label250__0true: ; Delay 1 cycles nop goto label250__0end label250__0false: ; if { ! low_in_pin } body start ; Uniform delay remaining = 285 Accumulated Delay = 0 ; state := state_backward_up2 movlw 7 movwf state ; Uniform delay remaining = 283 Accumulated Delay = 2 ; Uniform delay remaining = 283 Accumulated Delay = 2 ; if { ! low_in_pin } body end ; if exp=`low_in_pin' total delay=5 ; if exp=`low_in_pin' generic label250__0end: ; Other expression=`low_in_pin' delay=5 ; if { ! low_in_pin } end ; Uniform delay remaining = 280 Accumulated Delay = 5 ; Uniform delay remaining = 280 Accumulated Delay = 5 ; Delay 39 cycles movlw 12 movwf delay__248byte1 delay__248delay0: decfsz delay__248byte1,f goto delay__248delay0 nop nop goto switch__189end switch__189block254: ; Uniform delay remaining = 285 Accumulated Delay = 0 ; Force the servo to the high location : ; Uniform delay remaining = 285 Accumulated Delay = 0 ; if { low_in_pin } start ; expression=`{ low_in_pin }' exp_delay=0 true_delay=2 false_delay=0 true_size=2 false_size=0 btfsc low_in_pin__byte,low_in_pin__bit goto label256__0true label256__0false: ; Delay 1 cycles nop goto label256__0end label256__0true: ; if { low_in_pin } body start ; Uniform delay remaining = 285 Accumulated Delay = 0 ; state := state_backward_down2 movlw 8 movwf state ; Uniform delay remaining = 283 Accumulated Delay = 2 ; Uniform delay remaining = 283 Accumulated Delay = 2 ; if { low_in_pin } body end ; if exp=`low_in_pin' total delay=5 ; if exp=`low_in_pin' generic label256__0end: ; Other expression=`{ low_in_pin }' delay=5 ; if { low_in_pin } end ; Uniform delay remaining = 280 Accumulated Delay = 5 ; Uniform delay remaining = 280 Accumulated Delay = 5 ; Delay 39 cycles movlw 12 movwf delay__254byte1 delay__254delay0: decfsz delay__254byte1,f goto delay__254delay0 nop nop goto switch__189end switch__189block260: ; Uniform delay remaining = 285 Accumulated Delay = 0 ; Force the servo to the high location : ; Uniform delay remaining = 285 Accumulated Delay = 0 ; if { ! low_in_pin } start ; expression=`low_in_pin' exp_delay=0 true_delay=0 false_delay=1 true_size=0 false_size=1 btfss low_in_pin__byte,low_in_pin__bit ; if { ! low_in_pin } body start ; Uniform delay remaining = 285 Accumulated Delay = 0 ; state := state_idle clrf state ; Uniform delay remaining = 284 Accumulated Delay = 1 ; Uniform delay remaining = 284 Accumulated Delay = 1 ; if { ! low_in_pin } body end ; if exp=`low_in_pin' true skip delay=2 ; Other expression=`low_in_pin' delay=2 ; if { ! low_in_pin } end ; Uniform delay remaining = 283 Accumulated Delay = 2 ; Uniform delay remaining = 283 Accumulated Delay = 2 ; Delay 42 cycles movlw 13 movwf delay__260byte1 delay__260delay0: decfsz delay__260byte1,f goto delay__260delay0 nop nop goto switch__189end switch__189end: ; Total switch delay = 52 exp_delay=3 case_delay=46 ; Uniform delay remaining = 233 Accumulated Delay = 110 ; Uniform delay remaining = 233 Accumulated Delay = 110 ; Process any counter overflow : ; Uniform delay remaining = 233 Accumulated Delay = 110 ; if { tmr1if } start ; expression=`{ tmr1if }' exp_delay=0 true_delay=2 false_delay=0 true_size=2 false_size=0 btfsc tmr1if__byte,tmr1if__bit goto label269__0true label269__0false: ; Delay 1 cycles nop goto label269__0end label269__0true: ; if { tmr1if } body start ; Uniform delay remaining = 233 Accumulated Delay = 0 ; tmr1if := 0 bcf tmr1if__byte,tmr1if__bit ; Uniform delay remaining = 232 Accumulated Delay = 1 ; high := high + 1 incf high,f ; Uniform delay remaining = 231 Accumulated Delay = 2 ; Uniform delay remaining = 231 Accumulated Delay = 2 ; if { tmr1if } body end ; if exp=`tmr1if' total delay=5 ; if exp=`tmr1if' generic label269__0end: ; Other expression=`{ tmr1if }' delay=5 ; if { tmr1if } end ; Uniform delay remaining = 228 Accumulated Delay = 115 ; Uniform delay remaining = 228 Accumulated Delay = 115 ; Uniform delay remaining = 228 Accumulated Delay = 115 ; Soak up remaining 228 cycles ; Delay 228 cycles movlw 75 movwf delay__148byte1 delay__148delay0: decfsz delay__148byte1,f goto delay__148delay0 nop nop ; procedure delay end retlw 0 ; optimize 1 ; procedure get_byte start get_byte: ; Procedure must be called with PCLATH set to code bank 0 get_byte__variables__base equ global__variables__bank0+33 get_byte__bytes__base equ get_byte__variables__base+0 get_byte__bits__base equ get_byte__variables__base+3 get_byte__total__bytes equ 3 ; arguments_none get_byte__0return__byte equ get_byte__bytes__base+0 ; Wait for an 8 - bit byte from < serial_in_pin > , read it , and return it . get_byte__result equ get_byte__bytes__base+1 get_byte__count equ get_byte__bytes__base+2 ; Wait until a start bit arrives : ; `while serial_in_pin ...' start get_byte__286while__continue: ; expression=`serial_in_pin' exp_delay=0 true_delay=348 false_delay=2 true_size=2 false_size=1 btfss serial_in_pin__byte,serial_in_pin__bit goto get_byte__286while__break ; call delay {{ }} call delay goto get_byte__286while__continue ; if exp=`serial_in_pin' false goto ; Other expression=`serial_in_pin' delay=-1 get_byte__286while__break: ; `while serial_in_pin ...' end ; interrupt_enable := 0 bcf interrupt_enable__byte,interrupt_enable__bit ; Skip over the start bit : ; call delay {{ }} call delay ; call delay {{ }} call delay ; call delay {{ }} call delay ; Sample in the middle third of each data bit : ; result := 0 clrf get_byte__result ; `count_down count 8 ...' start movlw 8 movwf get_byte__count get_byte__298_loop: ; call delay {{ }} call delay ; result := result >> 1 bcf c___byte,c___bit rrf get_byte__result,f ; if { serial_in_pin } start ; expression=`{ serial_in_pin }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 btfsc serial_in_pin__byte,serial_in_pin__bit ; if { serial_in_pin } body start ; result @ 7 := 1 ; Select result @ 7 get_byte__result__302select0 equ get_byte__result+0 get_byte__result__302select0__byte equ get_byte__result+0 get_byte__result__302select0__bit equ 7 bsf get_byte__result__302select0__byte,get_byte__result__302select0__bit ; if { serial_in_pin } body end ; if exp=`serial_in_pin' false skip delay=2 ; Other expression=`{ serial_in_pin }' delay=2 ; if { serial_in_pin } end ; call delay {{ }} call delay ; call delay {{ }} call delay decfsz get_byte__count,f goto get_byte__298_loop get_byte__298_done: ; `count_down count 8 ...' end ; Skip over 1 / 3 of the stop bit : ; call delay {{ }} call delay ; return result movf get_byte__result,w movwf get_byte__0return__byte retlw 0 ; procedure get_byte end ; procedure send_byte start send_byte: ; Procedure must be called with PCLATH set to code bank 0 send_byte__variables__base equ global__variables__bank0+36 send_byte__bytes__base equ send_byte__variables__base+0 send_byte__bits__base equ send_byte__variables__base+2 send_byte__total__bytes equ 2 send_byte__data equ send_byte__bytes__base+0 ; Send < data > to < serial_out_pin > . send_byte__count equ send_byte__bytes__base+1 ; Send the start bit : ; serial_out_pin := 0 bcf serial_out_pin__byte,serial_out_pin__bit ; call delay {{ }} call delay ; call delay {{ }} call delay ; call delay {{ }} call delay ; Send the data : ; `count_down count 8 ...' start movlw 8 movwf send_byte__count send_byte__329_loop: ; serial_out_pin := data @ 0 ; Alias variable for select data @ 0 send_byte__data__330select0 equ send_byte__data+0 send_byte__data__330select0__byte equ send_byte__data+0 send_byte__data__330select0__bit equ 0 btfss send_byte__data__330select0__byte,send_byte__data__330select0__bit bcf serial_out_pin__byte,serial_out_pin__bit btfsc send_byte__data__330select0__byte,send_byte__data__330select0__bit bsf serial_out_pin__byte,serial_out_pin__bit ; data := data >> 1 bcf c___byte,c___bit rrf send_byte__data,f ; call delay {{ }} call delay ; call delay {{ }} call delay ; call delay {{ }} call delay decfsz send_byte__count,f goto send_byte__329_loop send_byte__329_done: ; `count_down count 8 ...' end ; Send the stop bit : ; serial_out_pin := 1 bsf serial_out_pin__byte,serial_out_pin__bit ; call delay {{ }} call delay ; call delay {{ }} call delay ; call delay {{ }} call delay ; procedure send_byte end retlw 0 ; procedure reset start reset: ; Procedure must be called with PCLATH set to code bank 0 reset__variables__base equ global__variables__bank0+38 reset__bytes__base equ reset__variables__base+0 reset__bits__base equ reset__variables__base+1 reset__total__bytes equ 1 reset__353byte0 equ reset__bytes__base+0 reset__354byte0 equ reset__bytes__base+0 reset__355byte0 equ reset__bytes__base+0 ; arguments_none ; Reset everything : ; capture_index := 0 clrf capture_index ; `while capture_index < maximum_captures ...' start reset__352while__continue: movlw 7 subwf capture_index,w ; expression=` capture_index < maximum_captures ' exp_delay=2 true_delay=24 false_delay=2 true_size=23 false_size=1 btfsc c___byte,c___bit goto reset__352while__break ; capture_high ~~ {{ capture_index }} := 0 clrf reset__353byte0 movlw LOW capture_high addwf capture_index,w movwf fsr___register movf reset__353byte0,w bcf irp___register,irp___bit movwf indf___register ; capture_middle ~~ {{ capture_index }} := 0 clrf reset__354byte0 movlw LOW capture_middle addwf capture_index,w movwf fsr___register movf reset__354byte0,w bcf irp___register,irp___bit movwf indf___register ; capture_low ~~ {{ capture_index }} := 0 clrf reset__355byte0 movlw LOW capture_low addwf capture_index,w movwf fsr___register movf reset__355byte0,w bcf irp___register,irp___bit movwf indf___register ; capture_index := capture_index + 1 incf capture_index,f goto reset__352while__continue ; if exp=` capture_index < maximum_captures ' false goto ; Other expression=` capture_index < maximum_captures ' delay=-1 reset__352while__break: ; `while capture_index < maximum_captures ...' end ; capture_index := 0 clrf capture_index ; procedure reset end retlw 0 ; comment {This is used to get the switch statements to work out :} ; origin 0x200 org 512 ; procedure main start main: ; Procedure must be called with PCLATH set to code bank 0 main__variables__base equ global__variables__bank0+39 main__bytes__base equ main__variables__base+0 main__bits__base equ main__variables__base+5 main__total__bytes equ 5 main__410byte0 equ main__bytes__base+4 main__509byte0 equ main__bytes__base+4 main__407byte0 equ main__bytes__base+4 main__512byte0 equ main__bytes__base+4 ; arguments_none ; Main program . main__command equ main__bytes__base+0 main__glitch equ main__bytes__base+1 main__id_index equ main__bytes__base+2 main__temporary equ main__bytes__base+3 ; glitch := 0 clrf main__glitch ; id_index := 0 clrf main__id_index ; serial_out_pin := 1 bsf serial_out_pin__byte,serial_out_pin__bit ; servo := 14 movlw 14 movwf servo ; servo_low := 5 movlw 5 movwf servo_low ; servo_high := 17 movlw 17 movwf servo_high ; servo_enable := 0 bcf servo_enable__byte,servo_enable__bit ; sweeping := 0 bcf sweeping__byte,sweeping__bit ; laser_enable_pin := 0 bcf laser_enable_pin__byte,laser_enable_pin__bit ; state := state_idle clrf state ; high := 0 clrf high ; call reset {{ }} call reset ; Initialize timer : ; t1ckps0 := 0 bcf t1ckps0__byte,t1ckps0__bit ; t1ckps1 := 0 bcf t1ckps1__byte,t1ckps1__bit ; t1oscen := 0 bcf t1oscen__byte,t1oscen__bit ; t1sync := 1 ; tmr1cs := 0 bcf tmr1cs__byte,tmr1cs__bit ; tmr1on := 0 bcf tmr1on__byte,tmr1on__bit ; Make sure all interrupts are off : ; intcon := 0 clrf intcon ; Turn off CCP : ; ccp1con := 0 clrf ccp1con ; loop_forever ... start main__402loop__forever: ; Wait for command : ; command := get_byte {{ }} call get_byte movf get_byte__0return__byte,w movwf main__command ; Dispatch on command : ; switch { command >> 6 } movlw HIGH switch__407block_start movwf pclath___register swapf main__command,w movwf main__407byte0 rrf main__407byte0,f rrf main__407byte0,w andlw 3 ; case 0 ; case 1 2 ; case 3 switch__407block_start: addwf pcl___register,f goto switch__407block408 goto switch__407block504 goto switch__407block504 goto switch__407block507 switch__407block_end: ; switch_check 407 switch__407block_start switch__407block_end switch__407block408: ; Command = 00 xx xxxx : ; switch { command >> 3 } movlw HIGH switch__410block_start movwf pclath___register rrf main__command,w movwf main__410byte0 rrf main__410byte0,f rrf main__410byte0,w andlw 31 ; case 0 ; case 1 switch__410block_start: addwf pcl___register,f goto switch__410block411 goto switch__410block475 goto switch__410default499 goto switch__410default499 goto switch__410default499 goto switch__410default499 goto switch__410default499 goto switch__410default499 switch__410block_end: ; switch_check 410 switch__410block_start switch__410block_end switch__410block411: ; Command = 0000 0 xxx : ; switch { command & 7 } movlw HIGH switch__413block_start movwf pclath___register movlw 7 andwf main__command,w ; case 0 1 ; case 2 ; case 3 ; case 4 ; case 5 ; case 6 ; case 7 switch__413block_start: addwf pcl___register,f goto switch__413block414 goto switch__413block414 goto switch__413block418 goto switch__413block435 goto switch__413block442 goto switch__413block446 goto switch__413block451 goto switch__413block456 switch__413block_end: ; switch_check 413 switch__413block_start switch__413block_end switch__413block414: ; Set Laser Enable < Command = 0000 000 z > : ; laser_enable_pin := command @ 0 ; Alias variable for select command @ 0 main__command__416select0 equ main__command+0 main__command__416select0__byte equ main__command+0 main__command__416select0__bit equ 0 btfss main__command__416select0__byte,main__command__416select0__bit bcf laser_enable_pin__byte,laser_enable_pin__bit btfsc main__command__416select0__byte,main__command__416select0__bit bsf laser_enable_pin__byte,laser_enable_pin__bit goto switch__413end switch__413block418: ; Read Laser < Command = 0000 0010 > : ; temporary := capture_count & 0xf movlw 15 andwf capture_count,w movwf main__temporary ; if { ! laser_in_pin } start ; expression=`laser_in_pin' exp_delay=0 true_delay=0 false_delay=1 true_size=0 false_size=1 btfss laser_in_pin__byte,laser_in_pin__bit ; if { ! laser_in_pin } body start ; temporary @ 4 := 1 ; Select temporary @ 4 main__temporary__422select0 equ main__temporary+0 main__temporary__422select0__byte equ main__temporary+0 main__temporary__422select0__bit equ 4 bsf main__temporary__422select0__byte,main__temporary__422select0__bit ; if { ! laser_in_pin } body end ; if exp=`laser_in_pin' true skip delay=2 ; Other expression=`laser_in_pin' delay=2 ; if { ! laser_in_pin } end ; if { low_in_pin } start ; expression=`{ low_in_pin }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 btfsc low_in_pin__byte,low_in_pin__bit ; if { low_in_pin } body start ; temporary @ 5 := 1 ; Select temporary @ 5 main__temporary__425select0 equ main__temporary+0 main__temporary__425select0__byte equ main__temporary+0 main__temporary__425select0__bit equ 5 bsf main__temporary__425select0__byte,main__temporary__425select0__bit ; if { low_in_pin } body end ; if exp=`low_in_pin' false skip delay=2 ; Other expression=`{ low_in_pin }' delay=2 ; if { low_in_pin } end ; if { high_in_pin } start ; expression=`{ high_in_pin }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 btfsc high_in_pin__byte,high_in_pin__bit ; if { high_in_pin } body start ; temporary @ 6 := 1 ; Select temporary @ 6 main__temporary__428select0 equ main__temporary+0 main__temporary__428select0__byte equ main__temporary+0 main__temporary__428select0__bit equ 6 bsf main__temporary__428select0__byte,main__temporary__428select0__bit ; if { high_in_pin } body end ; if exp=`high_in_pin' false skip delay=2 ; Other expression=`{ high_in_pin }' delay=2 ; if { high_in_pin } end ; if { sweeping } start ; expression=`{ sweeping }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 btfsc sweeping__byte,sweeping__bit ; if { sweeping } body start ; temporary @ 7 := 1 ; Select temporary @ 7 main__temporary__431select0 equ main__temporary+0 main__temporary__431select0__byte equ main__temporary+0 main__temporary__431select0__bit equ 7 bsf main__temporary__431select0__byte,main__temporary__431select0__bit ; if { sweeping } body end ; if exp=`sweeping' false skip delay=2 ; Other expression=`{ sweeping }' delay=2 ; if { sweeping } end ; call send_byte {{ temporary }} movf main__temporary,w movwf send_byte__data call send_byte goto switch__413end switch__413block435: ; Read last caputure < Command = 0000 0011 > : ; call send_byte {{ capture_high ~~ {{ capture_index }} }} movlw LOW capture_high addwf capture_index,w movwf fsr___register bcf irp___register,irp___bit movf indf___register,w movwf send_byte__data call send_byte ; call send_byte {{ capture_middle ~~ {{ capture_index }} }} movlw LOW capture_middle addwf capture_index,w movwf fsr___register bcf irp___register,irp___bit movf indf___register,w movwf send_byte__data call send_byte ; call send_byte {{ capture_low ~~ {{ capture_index }} }} movlw LOW capture_low addwf capture_index,w movwf fsr___register bcf irp___register,irp___bit movf indf___register,w movwf send_byte__data call send_byte ; capture_index := capture_index + 1 incf capture_index,f goto switch__413end switch__413block442: ; Disable Servo < Command = 0000 0100 > : ; servo_enable := 0 bcf servo_enable__byte,servo_enable__bit goto switch__413end switch__413block446: ; Enable Servo Low < Command = 0000 0101 > : ; servo_enable := 1 bsf servo_enable__byte,servo_enable__bit ; servo := servo_low movf servo_low,w movwf servo goto switch__413end switch__413block451: ; Enable Servo High < Command = 0000 0101 > : ; servo_enable := 1 bsf servo_enable__byte,servo_enable__bit ; servo := servo_high movf servo_high,w movwf servo goto switch__413end switch__413block456: ; Sweep < Command = 0000 0111 > : ; call reset {{ }} call reset ; sweeping := 1 bsf sweeping__byte,sweeping__bit ; servo_enable := 1 bsf servo_enable__byte,servo_enable__bit ; servo := servo_low movf servo_low,w movwf servo ; state := state_forward_up1 movlw 1 movwf state ; Turn on CCP : ; ccp1con := 4 movlw 4 movwf ccp1con ; ccp1if := 0 bcf ccp1if__byte,ccp1if__bit ; Clear timer 1 : ; tmr1l := 0 clrf tmr1l ; tmr1h := 0 clrf tmr1h ; high := 0 clrf high switch__413end: goto switch__410end switch__410block475: ; Undefinded command ; do nothing : ; switch { command & 7 } movlw HIGH switch__477block_start movwf pclath___register movlw 7 andwf main__command,w ; case 0 ; case 1 ; case 2 ; case 3 switch__477block_start: addwf pcl___register,f goto switch__477block478 goto switch__477block482 goto switch__477block486 goto switch__477block490 goto switch__477default494 goto switch__477default494 goto switch__477default494 goto switch__477default494 switch__477block_end: ; switch_check 477 switch__477block_start switch__477block_end switch__477block478: ; Set Servo Low < Command = 0000 1000 > ; servo_low := get_byte {{ }} call get_byte movf get_byte__0return__byte,w movwf servo_low goto switch__477end switch__477block482: ; Set Servo High < Command = 0000 1001 > ; servo_high := get_byte {{ }} call get_byte movf get_byte__0return__byte,w movwf servo_high goto switch__477end switch__477block486: ; Read Servo Low < Command = 0000 1010 > ; call send_byte {{ servo_low }} movf servo_low,w movwf send_byte__data call send_byte goto switch__477end switch__477block490: ; Read Servo Low < Command = 0000 1011 > ; call send_byte {{ servo_high }} movf servo_high,w movwf send_byte__data call send_byte goto switch__477end switch__477default494: ; < Command = 0000 11 xx > switch__477end: goto switch__410end switch__410default499: ; Do Nothing : switch__410end: goto switch__407end switch__407block504: ; Do nothing < Command = 01 xx xxxx or 10 xx xxxx > : goto switch__407end switch__407block507: ; Command = 11 xx xxxx : ; switch { {{ command >> 3 }} & 7 } movlw HIGH switch__509block_start movwf pclath___register rrf main__command,w movwf main__509byte0 rrf main__509byte0,f rrf main__509byte0,w andlw 7 ; case 5 ; case 6 ; case 7 switch__509block_start: addwf pcl___register,f goto switch__509end goto switch__509end goto switch__509end goto switch__509end goto switch__509end goto switch__509block510 goto switch__509block524 goto switch__509block542 switch__509block_end: ; switch_check 509 switch__509block_start switch__509block_end switch__509block510: ; Command = 1110 1 xxx : ; if { {{ command & 7 }} = 7 } start movlw 7 andwf main__command,w movwf main__512byte0 movlw 7 subwf main__512byte0,w ; expression=`{ {{ command & 7 }} = 7 }' exp_delay=5 true_delay=6 false_delay=0 true_size=8 false_size=0 btfss z___byte,z___bit goto label512__1end ; if { {{ command & 7 }} = 7 } body start ; Return Interrupt Bits < Command = 1110 1111 > : ; temporary := 0 clrf main__temporary ; if { interrupt_enable } start ; expression=`{ interrupt_enable }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 btfsc interrupt_enable__byte,interrupt_enable__bit ; if { interrupt_enable } body start ; temporary @ 1 := 1 ; Select temporary @ 1 main__temporary__516select0 equ main__temporary+0 main__temporary__516select0__byte equ main__temporary+0 main__temporary__516select0__bit equ 1 bsf main__temporary__516select0__byte,main__temporary__516select0__bit ; if { interrupt_enable } body end ; if exp=`interrupt_enable' false skip delay=2 ; Other expression=`{ interrupt_enable }' delay=2 ; if { interrupt_enable } end ; if { interrupt_pending } start ; expression=`{ interrupt_pending }' exp_delay=0 true_delay=1 false_delay=0 true_size=1 false_size=0 btfsc interrupt_pending__byte,interrupt_pending__bit ; if { interrupt_pending } body start ; temporary @ 0 := 1 ; Select temporary @ 0 main__temporary__519select0 equ main__temporary+0 main__temporary__519select0__byte equ main__temporary+0 main__temporary__519select0__bit equ 0 bsf main__temporary__519select0__byte,main__temporary__519select0__bit ; if { interrupt_pending } body end ; if exp=`interrupt_pending' false skip delay=2 ; Other expression=`{ interrupt_pending }' delay=2 ; if { interrupt_pending } end ; call send_byte {{ temporary }} movf main__temporary,w movwf send_byte__data call send_byte ; if { {{ command & 7 }} = 7 } body end label512__1end: ; if exp=` {{ command & 7 }} = 7 ' empty false ; Other expression=`{ {{ command & 7 }} = 7 }' delay=-1 ; if { {{ command & 7 }} = 7 } end goto switch__509end switch__509block524: ; Shared Interrupt commands < Command = 1111 0 xxx > : ; switch { command & 7 } movlw HIGH switch__526block_start movwf pclath___register movlw 7 andwf main__command,w ; case 0 1 2 3 ; case 4 5 ; case 6 7 switch__526block_start: addwf pcl___register,f goto switch__526block527 goto switch__526block527 goto switch__526block527 goto switch__526block527 goto switch__526block532 goto switch__526block532 goto switch__526block536 goto switch__526block536 switch__526block_end: ; switch_check 526 switch__526block_start switch__526block_end switch__526block527: ; Set interrupt enable and pending < Command = 1111 00 ep > : ; interrupt_enable := command @ 1 ; Alias variable for select command @ 1 main__command__529select0 equ main__command+0 main__command__529select0__byte equ main__command+0 main__command__529select0__bit equ 1 bcf interrupt_enable__byte,interrupt_enable__bit btfsc main__command__529select0__byte,main__command__529select0__bit bsf interrupt_enable__byte,interrupt_enable__bit ; interrupt_pending := command @ 0 ; Alias variable for select command @ 0 main__command__530select0 equ main__command+0 main__command__530select0__byte equ main__command+0 main__command__530select0__bit equ 0 bcf interrupt_pending__byte,interrupt_pending__bit btfsc main__command__530select0__byte,main__command__530select0__bit bsf interrupt_pending__byte,interrupt_pending__bit goto switch__526end switch__526block532: ; Set Interrupt pending bit only < Command = 1111 010 p > : ; interrupt_pending := command @ 0 ; Alias variable for select command @ 0 main__command__534select0 equ main__command+0 main__command__534select0__byte equ main__command+0 main__command__534select0__bit equ 0 bcf interrupt_pending__byte,interrupt_pending__bit btfsc main__command__534select0__byte,main__command__534select0__bit bsf interrupt_pending__byte,interrupt_pending__bit goto switch__526end switch__526block536: ; Set Interrupt pending bit only < Command = 1111 011 e > : ; interrupt_enable := command @ 0 ; Alias variable for select command @ 0 main__command__538select0 equ main__command+0 main__command__538select0__byte equ main__command+0 main__command__538select0__bit equ 0 bcf interrupt_enable__byte,interrupt_enable__bit btfsc main__command__538select0__byte,main__command__538select0__bit bsf interrupt_enable__byte,interrupt_enable__bit switch__526end: goto switch__509end switch__509block542: ; Shared commands . ; switch { command & 7 } movlw HIGH switch__544block_start movwf pclath___register movlw 7 andwf main__command,w ; case 0 ; case 1 ; case 2 ; case 3 ; case 4 ; case 5 ; case 6 ; case 7 switch__544block_start: addwf pcl___register,f goto switch__544block545 goto switch__544block549 goto switch__544block553 goto switch__544block557 goto switch__544block561 goto switch__544block572 goto switch__544block576 goto switch__544block581 switch__544block_end: ; switch_check 544 switch__544block_start switch__544block_end switch__544block545: ; Clock Decrement < Command = 1111 1000 > : ; Do nothing : goto switch__544end switch__544block549: ; Clock Increment < Command = 1111 1001 > : ; Do nothing : goto switch__544end switch__544block553: ; Clock Read < Command = 1111 1010 > : ; call send_byte {{ 0 }} clrf send_byte__data call send_byte goto switch__544end switch__544block557: ; Clock Pulse < Command = 1111 1011 > : ; call send_byte {{ 0 }} clrf send_byte__data call send_byte goto switch__544end switch__544block561: ; ID Next < Command = 1111 1100 > : ; if { id_index >= id . size } start movlw 48 subwf main__id_index,w ; expression=`{ id_index >= id . size }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 btfsc c___byte,c___bit ; if { id_index >= id . size } body start ; id_index := 0 clrf main__id_index ; if { id_index >= id . size } body end ; if exp=` id_index >= id . size ' false skip delay=4 ; Other expression=`{ id_index >= id . size }' delay=4 ; if { id_index >= id . size } end ; call send_byte {{ id ~~ {{ id_index }} }} incf main__id_index,w clrf pclath___register call id movwf send_byte__data call send_byte ; id_index := id_index + 1 incf main__id_index,f ; if { id_index >= id . size } start movlw 48 subwf main__id_index,w ; expression=`{ id_index >= id . size }' exp_delay=2 true_delay=1 false_delay=0 true_size=1 false_size=0 btfsc c___byte,c___bit ; if { id_index >= id . size } body start ; id_index := 0 clrf main__id_index ; if { id_index >= id . size } body end ; if exp=` id_index >= id . size ' false skip delay=4 ; Other expression=`{ id_index >= id . size }' delay=4 ; if { id_index >= id . size } end goto switch__544end switch__544block572: ; ID Reset < Command = 1111 1101 > : ; id_index := 0 clrf main__id_index goto switch__544end switch__544block576: ; Glitch Read < Command = 1111 1110 > : ; call send_byte {{ glitch }} movf main__glitch,w movwf send_byte__data call send_byte ; glitch := 0 clrf main__glitch goto switch__544end switch__544block581: ; Glitch < Command = 1111 1111 > : ; if { glitch != 0xff } start incf main__glitch,w ; expression=`{ glitch != 0xff }' exp_delay=1 true_delay=1 false_delay=0 true_size=1 false_size=0 btfss z___byte,z___bit ; if { glitch != 0xff } body start ; glitch := glitch + 1 incf main__glitch,f ; if { glitch != 0xff } body end ; if exp=` glitch != 0xff ' false skip delay=3 ; Other expression=`{ glitch != 0xff }' delay=3 ; if { glitch != 0xff } end switch__544end: switch__509end: switch__407end: goto main__402loop__forever ; loop_forever ... end ; procedure main end ; Register bank 0 used 44 bytes of 96 available bytes ; Register bank 1 used 0 bytes of 80 available bytes ; Register bank 2 used 0 bytes of 48 available bytes ; Register bank 3 used 0 bytes of 0 available bytes end