radix dec global__variables__bank0 equ 8 global__variables__bank1 equ 48 global__variables__bank2 equ 80 global__variables__bank3 equ 112 global__bit__variables__bank0 equ 18 global__bit__variables__bank1 equ 48 global__bit__variables__bank2 equ 80 global__bit__variables__bank3 equ 112 indf___register equ 0 pcl___register equ 2 c___byte equ 3 c___bit equ 0 z___byte equ 3 z___bit equ 2 ; On 12-bit PIC's, RP0 is actually bit 5 in FSR (=4) rp0___byte equ 4 rp0___bit equ 5 ; On 12-bit PIC's, RP1 is actually bit 6 in FSR (=4) rp1___byte equ 4 rp1___bit equ 6 ; On 12-bit PIC's, PA0 is actually bit 5 in STATUS (=3) pa0___byte equ 3 pa0___bit equ 5 fsr___register equ 4 org 0 start: ; Use oscillator calibration value already in register W movwf 5 ; Initialize TRIS registers movlw 200 tris 6 movlw 0 tris 7 goto main ; comment ############################################################################# ; comment {} ; comment {Copyright < c > 2002 by Wayne C . Gramlich and Bill Benson} ; 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 the code that implements the LED10 RoboBrick . Basically} ; comment {it just waits for commands that come in at 2400 baud and responds} ; comment {to them . See} ; comment {} ; comment {http : / / web . gramlich . net / projects / robobricks / led10 / index . html} ; comment {} ; comment {for more details .} ; comment {} ; comment ############################################################################# ; processor pic16c505 cp = off wdte = on mclre = off fosc = intrc_no_clock ; 4052=0xfd4 4095=0xfff __config 4052 configuration___address equ 4095 ; comment {Define processor constants :} ; constant clock_rate 4000000 clock_rate equ 4000000 ; constant clocks_per_instruction 4 clocks_per_instruction equ 4 ; constant instruction_rate clock_rate / clocks_per_instruction instruction_rate equ 1000000 ; comment {Define serial communication control constants :} ; constant baud_rate 2400 baud_rate equ 2400 ; constant instructions_per_bit instruction_rate / baud_rate instructions_per_bit equ 416 ; constant delays_per_bit 3 delays_per_bit equ 3 ; constant instructions_per_delay instructions_per_bit / delays_per_bit instructions_per_delay equ 138 ; constant extra_instructions_per_bit 9 extra_instructions_per_bit equ 9 ; constant extra_instructions_per_delay extra_instructions_per_bit / delays_per_bit extra_instructions_per_delay equ 3 ; constant delay_instructions instructions_per_delay - extra_instructions_per_delay delay_instructions equ 135 ; comment {Register definitions :} ; 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 {OSCCAL register :} osccal equ 5 ; constant osccal_lsb 4 osccal_lsb equ 4 ; comment {Define pin assignments and directions :} ; constant led0_bit 5 led0_bit equ 5 ; constant led1_bit 0 led1_bit equ 0 ; constant led2_bit 1 led2_bit equ 1 ; constant led3_bit 2 led3_bit equ 2 ; constant led4_bit 0 led4_bit equ 0 ; constant led5_bit 1 led5_bit equ 1 ; constant led6_bit 3 led6_bit equ 3 ; constant led7_bit 4 led7_bit equ 4 ; constant led8_bit 4 led8_bit equ 4 ; constant mode_bit 5 mode_bit equ 5 ; constant serial_out_bit 2 serial_out_bit equ 2 ; constant serial_in_bit 3 serial_in_bit equ 3 ; constant led0_mask {{ 1 << led0_bit }} led0_mask equ 32 ; constant led1_mask {{ 1 << led1_bit }} led1_mask equ 1 ; constant led2_mask {{ 1 << led2_bit }} led2_mask equ 2 ; constant led3_mask {{ 1 << led3_bit }} led3_mask equ 4 ; constant led4_mask {{ 1 << led4_bit }} led4_mask equ 1 ; constant led5_mask {{ 1 << led5_bit }} led5_mask equ 2 ; constant led6_mask {{ 1 << led6_bit }} led6_mask equ 8 ; constant led7_mask {{ 1 << led7_bit }} led7_mask equ 16 ; constant led8_mask {{ 1 << led8_bit }} led8_mask equ 16 portb equ 6 portc equ 7 led0__byte equ 6 led0__bit equ 5 led1__byte equ 6 led1__bit equ 0 led2__byte equ 6 led2__bit equ 1 led3__byte equ 7 led3__bit equ 2 led4__byte equ 7 led4__bit equ 0 led5__byte equ 7 led5__bit equ 1 led6__byte equ 7 led6__bit equ 3 led7__byte equ 6 led7__bit equ 4 led8__byte equ 7 led8__bit equ 4 mode__byte equ 7 mode__bit equ 5 serial_out__byte equ 6 serial_out__bit equ 2 serial_in__byte equ 6 serial_in__bit equ 3 b_on equ global__variables__bank0+0 c_on equ global__variables__bank0+1 b_off equ global__variables__bank0+2 c_off equ global__variables__bank0+3 ; procedure main start main: main__variables__base equ global__variables__bank0+4 main__bytes__base equ main__variables__base+0 main__bits__base equ main__variables__base+6 main__total__bytes equ 6 main__117byte1 equ main__bytes__base+5 main__108byte1 equ main__bytes__base+5 main__111byte1 equ main__bytes__base+5 ; arguments_none main__command equ main__bytes__base+0 main__glitch equ main__bytes__base+1 main__index equ main__bytes__base+2 main__count1 equ main__bytes__base+3 main__count2 equ main__bytes__base+4 ; loop_forever ... start main__103loop__forever: ; Strobe the LED ' s for 600 uS at 40 kHz : ; `count_down count1 20 ...' start movlw 20 movwf main__count1 main__105_loop: ; portb := 0xff movlw 255 movwf portb ; portc := 0xff movlw 255 movwf portc ; nop {{ 13 - 4 }} ; Delay 9 cycles movlw 2 movwf main__108byte1 main__108delay0: decfsz main__108byte1,f goto main__108delay0 nop nop ; portb := 0 clrf portb ; portc := 0 clrf portc ; nop {{ 12 - 2 - 3 }} ; Delay 7 cycles movlw 2 movwf main__111byte1 main__111delay0: decfsz main__111byte1,f goto main__111delay0 decfsz main__count1,f goto main__105_loop main__105_done: ; `count_down count1 20 ...' end ; Leave everything off for 100 mS : ; `count_down count2 200 ...' start movlw 200 movwf main__count2 main__115_loop: ; `count_down count1 20 ...' start movlw 20 movwf main__count1 main__116_loop: ; nop {{ 25 - 3 }} ; Delay 22 cycles movlw 7 movwf main__117byte1 main__117delay0: decfsz main__117byte1,f goto main__117delay0 decfsz main__count1,f goto main__116_loop main__116_done: ; `count_down count1 20 ...' end decfsz main__count2,f goto main__115_loop main__115_done: ; `count_down count2 200 ...' end goto main__103loop__forever ; loop_forever ... end ; procedure main end ; Register bank 0 used 10 bytes of 24 available bytes ; Register bank 1 used 0 bytes of 16 available bytes ; Register bank 2 used 0 bytes of 16 available bytes ; Register bank 3 used 0 bytes of 16 available bytes end