chiark / gitweb /
adding debugging stuff...
authorceb <ceb>
Tue, 4 Jan 2005 23:16:13 +0000 (23:16 +0000)
committerceb <ceb>
Tue, 4 Jan 2005 23:16:13 +0000 (23:16 +0000)
cebpic/Makefile
cebpic/nmra-stream.asm
detpic/nmra-stream.asm

index 11620f4159f72eb3fc3e0fc95ea52d33394115be..127ee2abf5690c0afe67251067298459f7dd7278 100644 (file)
@@ -1,4 +1,4 @@
-PROGRAMS=      led-flash send-serial reply-serial nmra-stream
+PROGRAMS=      led-flash send-serial reply-serial nmra-stream booster-output-low
 
 include ../pic.make
 
index 39bbb4a676bc62d84bcbab1578ee8f6758535e69..f6a3471fe68f34cc035e3b268bfa03481f257566 100644 (file)
@@ -47,14 +47,14 @@ macros
 debug macro debugvalue
        movlw   debugvalue
        call    debug_serial_transmit
-waitfortsr
-       btfss   TXSTA,1,0
-       bra     waitfortsr
        endm
 
 debug_serial_transmit
        movwf   TXREG,0         ; move contents of W (i.e. debugvalue)
                                ;       to TXREG for transmission
+waitfortsr
+       btfss   TXSTA,1,0
+       bra     waitfortsr
        return
 
 ;****************************************************************************
@@ -79,6 +79,8 @@ initialise
        bsf     SPBRG,7,0
        bsf     SPBRG,0,0
 
+
+       debug   'a'     ; write 'a' to serial port
 ;----------------------------------------------------------------------------
 
 
@@ -100,6 +102,7 @@ initialise
         bcf     T0CON,1,0       ; } prescale value 1:32
         bsf     T0CON,0,0       ; } (testing)
        
+       debug   'b'     ; write 'b' to serial port
 ;----------------------------------------------------------------------------
 
 ; initialise buffers (for BSR5, for nmra from-serial/to-track buffers)
@@ -113,6 +116,7 @@ initialise
                                ; all in access bank
 
 
+       debug   'c'     ; write 'c' to serial port
 ;----------------------------------------------------------------------------
 
 
@@ -125,14 +129,15 @@ initialise
        movwf   TOTRACKBIT,0    ; make bit mask be 1000 0000
 
 ; initialise booster direction
-       bsf     TRISC,0,0       ; make pin 0 (booster direction) output
+       bcf     TRISC,0,0       ; make pin 0 (booster direction) output
        bcf     PORTC,0,0       ; set low initially
 
 ; set booster pwm high
-       bsf     TRISC,1,0       ; make pin 1 (booster pwm) output
+       bcf     TRISC,1,0       ; make pin 1 (booster pwm) output
        bsf     PORTC,1,0       ; booster pwm high
 
 
+       debug   'd'     ; write 'd' to serial port
 ;----------------------------------------------------------------------------
 
 ; interrupt set-up
@@ -151,6 +156,7 @@ initialise
        bsf     INTCON,5,0      ; enable timer0 interrupts
 
 
+       debug   'e'     ; write 'e' to serial port
 ;****************************************************************************
 
        call    led_green
@@ -169,8 +175,10 @@ interrupt_low
 
 ; check which interrupt. Branch to serial_receive or timer or return
 
+       debug   146     ; write 'f' to serial port
         btfss   PIR1,5,0        ; check whether serial recv interrupt bit set
        goto    serial_receive
+       debug   147     ; write 'g' to serial port
        btfss   INTCON,2,0      ; check whether timer0 interrupt set
        goto    timer0_interrupt
        goto    panic
@@ -183,6 +191,7 @@ interrupt_low
 ;****************************************************************************
 
 serial_receive
+       debug   148     ; write 'h' to serial port
        movff   FROMSERIAL,FSR0L        ; set low byte of INDF0 pointer
        movlw   5
        movwf   FSR0H,0                 ; set high byte of INDF0 pointer
@@ -199,6 +208,7 @@ serial_receive
 
 advance_write_buffer
 
+       debug   149     ; write 'i' to serial port
 ; check if on 1st byte of new buffer anyway (i.e. last 4 bits = 0)
        movf    FROMSERIAL,0,0  ; copy FROMSERIAL pointer location to W
        andlw   0xF             ; investigate last 4 bits
@@ -225,12 +235,14 @@ fromserial_overflow
 
 timer0_interrupt
        
+       debug   150     ; write 'j' to serial port
        bcf     INTCON,2,0      ; clear interrupt-set bit
        movlw   0x01    ; (testing)
 ;      movlw   0x6E    ; (not-testing)
        movwf   TMR0L,0         ; set timer0 to 0x6E (so interrupt takes 58us)
 
 
+       debug   151     ; write 'k' to serial port
 ; check next action - if 0, change to 1 and return
        btfsc   NMRACTRL,NEXTACTION,0
        goto    toggle_output
@@ -241,6 +253,7 @@ timer0_interrupt
 ; if next action = 1, then toggle output
 
 toggle_output
+       debug   152     ; write 'l' to serial port
        btg     PORTC,0,0       ; toggle booster output pin
        btfss   PORTC,0,0       
        goto    decide_next_bit
@@ -251,6 +264,7 @@ toggle_output
 ; nextaction in preparation for 2nd half of bit and then return
 
 mid_bit                
+       debug   153     ; write 'm' to serial port
        btfsc   NMRACTRL,TRANSMITBIT,0
        bsf     NMRACTRL,NEXTACTION,0
        btfss   NMRACTRL,TRANSMITBIT,0
@@ -260,6 +274,7 @@ mid_bit
 
 decide_next_bit
 
+       debug   154     ; write 'n' to serial port
 ; check whether current to-track buffer = current from-serial buffer
 ; if yes, transmit 1s (set transmitbit=1, nextaction=1 and return)
 
@@ -273,6 +288,7 @@ decide_next_bit
 
 
 read_from_buffer
+       debug   155     ; write 'o' to serial port
 
 ; if currently on bit 7, want to skip to bit 6
 ;*** wouldn't it be easier to start on bit 6 ? :-)  -iwj
@@ -284,6 +300,7 @@ read_from_buffer
 ; set na=cb=bit value, advance bit (i.e. rotate TRANSMITBIT right), 
 ; check if bit7, if so, advance byte, return
 
+       debug   156     ; write 'p' to serial port
        movff   TOTRACK,FSR1L           ; set low byte of IND1 pointer
        movlw   5
        movwf   FSR1H,0                 ; set high byte of IND1 pointer
@@ -298,11 +315,13 @@ read_from_buffer
        bra     one_bit_to_track
        
 zero_bit_to_track
+       debug   157     ; write 'q' to serial port
        bcf     NMRACTRL,TRANSMITBIT,0
        bcf     NMRACTRL,NEXTACTION,0
        goto    advance_bit
        
 one_bit_to_track
+       debug   158     ; write 'r' to serial port
        bsf     NMRACTRL,TRANSMITBIT,0
        bsf     NMRACTRL,NEXTACTION,0
        goto    advance_bit
@@ -312,6 +331,7 @@ one_bit_to_track
 advance_bit
 ; rotate transmitbit to next position 
 
+       debug   159     ; write 's' to serial port
        rrncf   TOTRACKBIT,1,0          ; rotate mask right
 ;*** surely rrnc (`rotate right not through carry' I assume)
 ;*** will leave a copy of the top bit in the N flag ?  Then you
@@ -325,6 +345,7 @@ advance_bit
 
 advance_pointer
 
+       debug   160     ; write 't' to serial port
 ; currently on bit 7 of the byte, after having read rest of byte to
 ; track; check whether it is 1 or 0
 
@@ -341,6 +362,7 @@ advance_pointer
 
 
 advance_read_buffer
+       debug   161     ; write 'u' to serial port
 ;*** I suggest swapping this and advance_read_byte round, since
 ;*** advance_read_byte is a more `inner' bit of the `loop' -iwj
 
@@ -373,6 +395,7 @@ totrack_overflow
 
        
 advance_read_byte
+       debug   'v'     ; write 'v' to serial port
 ; advance to next byte of buffer (increment TOTRACK)
 ; (will be on bit 7 at this point anyway so no need to change TOTRACKBIT)
 
index 39bbb4a676bc62d84bcbab1578ee8f6758535e69..f6a3471fe68f34cc035e3b268bfa03481f257566 100644 (file)
@@ -47,14 +47,14 @@ macros
 debug macro debugvalue
        movlw   debugvalue
        call    debug_serial_transmit
-waitfortsr
-       btfss   TXSTA,1,0
-       bra     waitfortsr
        endm
 
 debug_serial_transmit
        movwf   TXREG,0         ; move contents of W (i.e. debugvalue)
                                ;       to TXREG for transmission
+waitfortsr
+       btfss   TXSTA,1,0
+       bra     waitfortsr
        return
 
 ;****************************************************************************
@@ -79,6 +79,8 @@ initialise
        bsf     SPBRG,7,0
        bsf     SPBRG,0,0
 
+
+       debug   'a'     ; write 'a' to serial port
 ;----------------------------------------------------------------------------
 
 
@@ -100,6 +102,7 @@ initialise
         bcf     T0CON,1,0       ; } prescale value 1:32
         bsf     T0CON,0,0       ; } (testing)
        
+       debug   'b'     ; write 'b' to serial port
 ;----------------------------------------------------------------------------
 
 ; initialise buffers (for BSR5, for nmra from-serial/to-track buffers)
@@ -113,6 +116,7 @@ initialise
                                ; all in access bank
 
 
+       debug   'c'     ; write 'c' to serial port
 ;----------------------------------------------------------------------------
 
 
@@ -125,14 +129,15 @@ initialise
        movwf   TOTRACKBIT,0    ; make bit mask be 1000 0000
 
 ; initialise booster direction
-       bsf     TRISC,0,0       ; make pin 0 (booster direction) output
+       bcf     TRISC,0,0       ; make pin 0 (booster direction) output
        bcf     PORTC,0,0       ; set low initially
 
 ; set booster pwm high
-       bsf     TRISC,1,0       ; make pin 1 (booster pwm) output
+       bcf     TRISC,1,0       ; make pin 1 (booster pwm) output
        bsf     PORTC,1,0       ; booster pwm high
 
 
+       debug   'd'     ; write 'd' to serial port
 ;----------------------------------------------------------------------------
 
 ; interrupt set-up
@@ -151,6 +156,7 @@ initialise
        bsf     INTCON,5,0      ; enable timer0 interrupts
 
 
+       debug   'e'     ; write 'e' to serial port
 ;****************************************************************************
 
        call    led_green
@@ -169,8 +175,10 @@ interrupt_low
 
 ; check which interrupt. Branch to serial_receive or timer or return
 
+       debug   146     ; write 'f' to serial port
         btfss   PIR1,5,0        ; check whether serial recv interrupt bit set
        goto    serial_receive
+       debug   147     ; write 'g' to serial port
        btfss   INTCON,2,0      ; check whether timer0 interrupt set
        goto    timer0_interrupt
        goto    panic
@@ -183,6 +191,7 @@ interrupt_low
 ;****************************************************************************
 
 serial_receive
+       debug   148     ; write 'h' to serial port
        movff   FROMSERIAL,FSR0L        ; set low byte of INDF0 pointer
        movlw   5
        movwf   FSR0H,0                 ; set high byte of INDF0 pointer
@@ -199,6 +208,7 @@ serial_receive
 
 advance_write_buffer
 
+       debug   149     ; write 'i' to serial port
 ; check if on 1st byte of new buffer anyway (i.e. last 4 bits = 0)
        movf    FROMSERIAL,0,0  ; copy FROMSERIAL pointer location to W
        andlw   0xF             ; investigate last 4 bits
@@ -225,12 +235,14 @@ fromserial_overflow
 
 timer0_interrupt
        
+       debug   150     ; write 'j' to serial port
        bcf     INTCON,2,0      ; clear interrupt-set bit
        movlw   0x01    ; (testing)
 ;      movlw   0x6E    ; (not-testing)
        movwf   TMR0L,0         ; set timer0 to 0x6E (so interrupt takes 58us)
 
 
+       debug   151     ; write 'k' to serial port
 ; check next action - if 0, change to 1 and return
        btfsc   NMRACTRL,NEXTACTION,0
        goto    toggle_output
@@ -241,6 +253,7 @@ timer0_interrupt
 ; if next action = 1, then toggle output
 
 toggle_output
+       debug   152     ; write 'l' to serial port
        btg     PORTC,0,0       ; toggle booster output pin
        btfss   PORTC,0,0       
        goto    decide_next_bit
@@ -251,6 +264,7 @@ toggle_output
 ; nextaction in preparation for 2nd half of bit and then return
 
 mid_bit                
+       debug   153     ; write 'm' to serial port
        btfsc   NMRACTRL,TRANSMITBIT,0
        bsf     NMRACTRL,NEXTACTION,0
        btfss   NMRACTRL,TRANSMITBIT,0
@@ -260,6 +274,7 @@ mid_bit
 
 decide_next_bit
 
+       debug   154     ; write 'n' to serial port
 ; check whether current to-track buffer = current from-serial buffer
 ; if yes, transmit 1s (set transmitbit=1, nextaction=1 and return)
 
@@ -273,6 +288,7 @@ decide_next_bit
 
 
 read_from_buffer
+       debug   155     ; write 'o' to serial port
 
 ; if currently on bit 7, want to skip to bit 6
 ;*** wouldn't it be easier to start on bit 6 ? :-)  -iwj
@@ -284,6 +300,7 @@ read_from_buffer
 ; set na=cb=bit value, advance bit (i.e. rotate TRANSMITBIT right), 
 ; check if bit7, if so, advance byte, return
 
+       debug   156     ; write 'p' to serial port
        movff   TOTRACK,FSR1L           ; set low byte of IND1 pointer
        movlw   5
        movwf   FSR1H,0                 ; set high byte of IND1 pointer
@@ -298,11 +315,13 @@ read_from_buffer
        bra     one_bit_to_track
        
 zero_bit_to_track
+       debug   157     ; write 'q' to serial port
        bcf     NMRACTRL,TRANSMITBIT,0
        bcf     NMRACTRL,NEXTACTION,0
        goto    advance_bit
        
 one_bit_to_track
+       debug   158     ; write 'r' to serial port
        bsf     NMRACTRL,TRANSMITBIT,0
        bsf     NMRACTRL,NEXTACTION,0
        goto    advance_bit
@@ -312,6 +331,7 @@ one_bit_to_track
 advance_bit
 ; rotate transmitbit to next position 
 
+       debug   159     ; write 's' to serial port
        rrncf   TOTRACKBIT,1,0          ; rotate mask right
 ;*** surely rrnc (`rotate right not through carry' I assume)
 ;*** will leave a copy of the top bit in the N flag ?  Then you
@@ -325,6 +345,7 @@ advance_bit
 
 advance_pointer
 
+       debug   160     ; write 't' to serial port
 ; currently on bit 7 of the byte, after having read rest of byte to
 ; track; check whether it is 1 or 0
 
@@ -341,6 +362,7 @@ advance_pointer
 
 
 advance_read_buffer
+       debug   161     ; write 'u' to serial port
 ;*** I suggest swapping this and advance_read_byte round, since
 ;*** advance_read_byte is a more `inner' bit of the `loop' -iwj
 
@@ -373,6 +395,7 @@ totrack_overflow
 
        
 advance_read_byte
+       debug   'v'     ; write 'v' to serial port
 ; advance to next byte of buffer (increment TOTRACK)
 ; (will be on bit 7 at this point anyway so no need to change TOTRACKBIT)