;-------------------------------------------------------------------- ; This program is designed to check a cable with six wires list p=16c84, w=0, r=DEC include "p16c84.inc" ;-------------------------------------------------------------------- ; Two macros that switch between register banks bank_0 macro bcf STATUS, RP0 endm bank_1 macro bsf STATUS, RP0 endm ;-------------------------------------------------------------------- ; Program entry point is 0. ; Jump to "start" to avoid address 4. org 0 lgoto start ;-------------------------------------------------------------------- ; Address 4 is entry point for interupt routine. ; Maight be used later for flashing led... org 4 retfie ;-------------------------------------------------------------------- ; The macro "TEST" sets one of six output pins (RA[0..4] and RB6) ; to low, the other five remain in high impedance mode. ; Than it checks the six inputs (RB[0..5]) which have enabled ; weak pull-ups. TEST macro outtris, outpin, in, short1, short2, short3, short4, short5 bank_1 bcf outtris, outpin ; set test-output to low bank_0 nop ; relax nop btfsc PORTB, in ; check if line connected goto broken btfss PORTB, short1 ; check if lines shortened goto short btfss PORTB, short2 goto short btfss PORTB, short3 goto short btfss PORTB, short4 goto short btfss PORTB, short5 goto short bank_1 bsf outtris, outpin ; set test-output back to high impedance bank_0 endm ;-------------------------------------------------------------------- ; Some space for a possibly later inserted interupt routine org 0x100 ;-------------------------------------------------------------------- ; setupled configures RB6 and RB7 as output setupled: bank_1 movlw 0x3F movwf TRISB bank_0 return ;-------------------------------------------------------------------- ; delay waits for about half a second counter1 equ 0x11 counter2 equ 0x12 delay: movlw 200 movwf counter1 outer: movlw 100 movwf counter2 inner: decfsz counter2, F goto inner decfsz counter1, F goto outer return ;-------------------------------------------------------------------- ; The main program tests at program start the connection; ; than it displays the result until power down start: bank_1 bcf OPTION_REG, 7 ; enable weak pull-ups of Port B movlw 0xff movwf TRISA ; high impedance movwf TRISB ; high impedance bank_0 clrf PORTA ; low output pegel clrf PORTB ; low output pegel TEST TRISA, 0, 0, 1, 2, 3, 4, 5 TEST TRISA, 1, 1, 0, 2, 3, 4, 5 TEST TRISA, 2, 2, 0, 1, 3, 4, 5 TEST TRISA, 3, 3, 0, 1, 2, 4, 5 TEST TRISA, 4, 4, 0, 1, 2, 3, 5 TEST TRISB, 6, 5, 0, 1, 2, 3, 4 ok: call setupled bcf PORTB, 6 bsf PORTB, 7 okloop: nop goto okloop short: call setupled shortloop: bsf PORTB, 6 bcf PORTB, 7 call delay bcf PORTB, 6 bcf PORTB, 7 call delay goto shortloop broken: call setupled bsf PORTB, 6 bcf PORTB, 7 brokenloop: nop goto brokenloop end