chiark / gitweb /
new serialloop serial loopback test program
authorian <ian>
Thu, 28 Oct 2004 00:01:31 +0000 (00:01 +0000)
committerian <ian>
Thu, 28 Oct 2004 00:01:31 +0000 (00:01 +0000)
iwjpictest/Makefile
iwjpictest/serialloop.asm

index 25207b72ffe8afe9ab1114243f1a49d669537e36..9c26fe45e1b76d72c0945e05755cd3a9d9175794 100644 (file)
@@ -1,6 +1,7 @@
 TARGETS=       config.hex                                      \
-               flasher.hex             copybits.hex            \
-               flasher-full.hex        copybits-full.hex
+               flasher.hex             flasher-full.hex        \
+               copybits.hex            copybits-full.hex       \
+               serialloop.hex          serialloop-full.hex
 
 include ../pic.make
 
index 2efab6be2ceb811f1e2bd0274626062e37c3e5db..91d1f5decf7ec6a0f5a9fc104c74b9f69cbb6035 100644 (file)
@@ -1,21 +1,20 @@
 ; -*- fundamental -*-
 
 ; This program:
-;   * copies input signals from input pins to output pins, as shown in
-;     the `TEST-LEFT' and `TEST-RIGHT' PIC pinout diagrams;
-;   * flashes PER-PIC-LED (pin 21) and FLASHER (pin 2) in the
-;     pattern [high-low] with 50% duty cycle with period approx 660ms
-;     (assuming 20MHz clock input).
+;   * copies serial port flow control and data straight through,
+;     as a serial port loopback test
+;   * copies a few bits about
+;   * flashes PER-PIC-LED
 ;   * leaves all other pins set to their default states (usually Z).
-
+; as shown in diagram SERIAL LOOP TEST
+; 
        include         /usr/share/gputils/header/p18f458.inc
-
-ACCSFR         equ             0x0f00
+       include         onecopybit.inc
 
 COUNTINNER     equ             0x00
 COUNTOUTER     equ             0x02
 
-OUTEREXP               equ             7       ; 2^7 * 2.6ms = 332ms
+OUTEREXP               equ             7       ; 2^7 * 1.4ms = 177ms
 
 ; we always leave each loop when its counter has reached 0, so on
 ; entry we assume it's already 0.  For the loops which want to
@@ -24,16 +23,13 @@ OUTEREXP            equ             7       ; 2^7 * 2.6ms = 332ms
        code
 
 start
-       bcf             TRISA, 0, 0     ; enable flasher pin output
        bcf             TRISD, 2, 0     ; enable per-pic led output
-       movlw           0x07            ; turn off A-to-D so we get
-       movwf           ADCON1, 0       ;  digital inputs on RA0-3 (AN0-3)
+       bcf             TRISC, 6, 0     ; enable TXD output (RC6)
+       bcf             TRISC, 5, 0     ; enable FCO output (RC5)
        bcf             TRISD, 4, 0     ; enable output D
-       movlw           0x1f            ; enable outputs E,F,G
-       movwf           TRISC, 0        ;  (RC7,6,5)
+       bcf             TRISD, 3, 0     ; enable output E
 
 loop
-       btg             LATA, 0, 0      ; toggle flasher pin output
        btg             LATD, 2, 0      ; toggle per-pic led output
 
        ; set a bit which says how fast the led
@@ -42,45 +38,20 @@ loop
 delayouter_loop
 
 delayinner_loop
-
-copybit_mi macro sourcereg, sourcebitno, destreg, destbitvals, xorinv
-       movf    destreg, 0, 0                   ; read output latch
-       andlw   ~destbitvals                    ; mask out output bit
-       btfsc   sourcereg, sourcebitno, 0       ; skip if input clear
-       iorlw   destbitvals                     ;    add output bit
-       xorlw   xorinv                          ; invert?
-       movwf   destreg, 0                      ; write output latch
-       endm                                            ; (6cy total)
-
-copybiti macro sreg, sbitno, dreg, dbitvals
-       copybit_mi      sreg, sbitno, dreg, dbitvals, dbitvals
-       endm
-
-copybit macro sreg, sbitno, dreg, dbitvals
-       copybit_mi      sreg, sbitno, dreg, dbitvals, 0
-       endm
-
-       copybiti        PORTB, 5, TRISA, 0x06           ; C enable
-       copybit         PORTB, 4, LATA,  0x06           ; C data
-       copybiti        PORTB, 3, TRISA, 0x18           ; B enable
-       copybit         PORTB, 2, LATA,  0x18           ; B data
-       copybiti        PORTB, 1, TRISA, 0x20           ; A enable
-       copybiti        PORTB, 1, TRISE, 0x01           ; A enable
-       copybit         PORTB, 0, LATA,  0x20           ; A data
-       copybit         PORTB, 0, LATE,  0x01           ; A data
-
+       copybiti        PORTB, 3, LATA,  0x08           ; A data
+       copybit         PORTD, 7, TRISA, 0x08           ; A enable
        copybiti        PORTA, 6, LATD,  0x10           ; D
-       copybiti        PORTC, 0, LATC,  0x80           ; E
-       copybiti        PORTC, 1, LATC,  0x40           ; F
-       copybiti        PORTC, 2, LATC,  0x20           ; G
-                                               ; 12 x copybit @6 = 48cy
+       copybiti        PORTD, 0, LATD,  0x08           ; E
+       copybit         PORTB, 4, LATC,  0x20           ; serial FC
+       copybit         PORTC, 7, LATC,  0x40           ; serial data
+                                               ; 6 x copybit @6 = 24cy
 
        decfsz          COUNTINNER, 1, 0        ; 1 cycle
        goto            delayinner_loop         ; 2 cycles (skipped or not)
-; exited delayinner_loop                       ; total: 51cy * 256 = 13056cy
+; exited delayinner_loop                       ; total: 27cy * 256 = 6912cy
 
                                                ; each cycle 0.2us
-                                               ; so each inner loop is ~2.6ms
+                                               ; so each inner loop is ~1.4ms
 
        decfsz          COUNTOUTER, 1, 0
        goto            delayouter_loop