From e5b09092c70c1b36c7c0098e88298acc6865ab20 Mon Sep 17 00:00:00 2001 From: ceb Date: Sat, 8 Jan 2005 21:59:31 +0000 Subject: [PATCH] debug --- cebpic/nmra-stream.asm | 82 +++++++++--------------------------------- detpic/nmra-stream.asm | 82 +++++++++--------------------------------- 2 files changed, 34 insertions(+), 130 deletions(-) diff --git a/cebpic/nmra-stream.asm b/cebpic/nmra-stream.asm index 5384b10..4b0aeee 100644 --- a/cebpic/nmra-stream.asm +++ b/cebpic/nmra-stream.asm @@ -225,17 +225,10 @@ serial_receive ; but this may be something to try in debugging if stuff doesn't work -advance_write_buffer - debug 'i' ; 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 +advance_write_buffer -; if zero (i.e. overflowed to next buffer), branch to overflow check - bz fromserial_overflow - -; if not zero, clear low 4 bits of FROMSERIAL and increment top 4 bits +; clear low 4 bits of FROMSERIAL and increment top 4 bits ; aaaabbbb -> bbbbaaaa -> bbbb(aaaa+1) -> 0000(aaaa+1) -> (aaaa+1)0000 debug '5' ; write 'h' to serial port swapf FROMSERIAL,1,0 @@ -244,7 +237,6 @@ advance_write_buffer andwf FROMSERIAL,1,0 swapf FROMSERIAL,1,0 -fromserial_overflow ; clear bit 6 (will set back to buffer 0 if has overflowed to 4) debug '6' ; write 'h' to serial port bcf FROMSERIAL,6,0 @@ -369,38 +361,32 @@ advance_bit advance_pointer debug 't' ; 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 - movff TOTRACK,FSR1L movlw 5 movwf FSR1H,0 + +; if set, move to next buffer btfsc INDF1,7,0 - bra advance_read_buffer - bra advance_read_byte + debug 'F' + btfsc INDF1,7,0 + call advance_read_buffer +; if not set, move to next byte of samebuffer (increment TOTRACK) +; (will be on bit 7 at this point anyway so no need to change TOTRACKBIT) + btfss INDF1,7,0 + debug 'Y' + btfss INDF1,7,0 + incf TOTRACK,1,0 + return advance_read_buffer - debug 'u' ; 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 ; move pointer to next buffer - -; check if on 1st byte of new buffer anyway (i.e. last 4 bits = 0) - movff TOTRACK,WREG ; copy TOTRACK pointer location to W - andlw 0xF ; investigate last 4 bits - - -; GIONG WRONG HERE - should be klnoopqstu7895, missing out 78 = advance to next buffer -; MUST advance byte before trying to advance buffer -# - -; if zero (i.e. overflowed to next buffer), branch to overflow check - bz totrack_overflow - -; if not zero, clear low 4 bits of TOTRACK and increment top 4 bits +; clear low 4 bits of TOTRACK and increment top 4 bits ; aaaabbbb -> bbbbaaaa -> bbbb(aaaa+1) -> 0000(aaaa+1) -> (aaaa+1)0000 debug '7' ; write 'v' to serial port swapf TOTRACK,1,0 @@ -410,44 +396,10 @@ advance_read_buffer swapf TOTRACK,1,0 debug '8' ; write 'v' to serial port -totrack_overflow ; clear bit 6 (will set back to buffer 0 if has overflowed to 4) bcf TOTRACK,6,0 debug '9' ; write 'v' to serial port - retfie 1 - -; write na=cb=1 and return - -; bra one_bit_to_track -;*** oh, we always introduce a one bit in between ? *confused* -iwj - - - -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) - - incf TOTRACK,1,0 - debug '6' ; write 'v' to serial port - retfie 1 - - -; set na=cb=new bit value - -; movff TOTRACK,FSR1L ; set low byte of IND1 pointer -; movlw 5 -; movwf FSR1H,0 ; set high byte of IND1 pointer -; movff INDF1,WREG -; andwf TOTRACKBIT,0,0 ; mask out bit to be transmitted -;*** This is the same code as the 2nd stanza in read_from_buffer, -;*** above. Surely it should be made common (eg a subroutine) ? -iwj - -; bz zero_bit_to_track -; bra one_bit_to_track -;*** zero_bit_to_track and one_bit_to_track end up calling advance_bit - -;*** is that right ? *confused* -iwj - + return diff --git a/detpic/nmra-stream.asm b/detpic/nmra-stream.asm index 5384b10..4b0aeee 100644 --- a/detpic/nmra-stream.asm +++ b/detpic/nmra-stream.asm @@ -225,17 +225,10 @@ serial_receive ; but this may be something to try in debugging if stuff doesn't work -advance_write_buffer - debug 'i' ; 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 +advance_write_buffer -; if zero (i.e. overflowed to next buffer), branch to overflow check - bz fromserial_overflow - -; if not zero, clear low 4 bits of FROMSERIAL and increment top 4 bits +; clear low 4 bits of FROMSERIAL and increment top 4 bits ; aaaabbbb -> bbbbaaaa -> bbbb(aaaa+1) -> 0000(aaaa+1) -> (aaaa+1)0000 debug '5' ; write 'h' to serial port swapf FROMSERIAL,1,0 @@ -244,7 +237,6 @@ advance_write_buffer andwf FROMSERIAL,1,0 swapf FROMSERIAL,1,0 -fromserial_overflow ; clear bit 6 (will set back to buffer 0 if has overflowed to 4) debug '6' ; write 'h' to serial port bcf FROMSERIAL,6,0 @@ -369,38 +361,32 @@ advance_bit advance_pointer debug 't' ; 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 - movff TOTRACK,FSR1L movlw 5 movwf FSR1H,0 + +; if set, move to next buffer btfsc INDF1,7,0 - bra advance_read_buffer - bra advance_read_byte + debug 'F' + btfsc INDF1,7,0 + call advance_read_buffer +; if not set, move to next byte of samebuffer (increment TOTRACK) +; (will be on bit 7 at this point anyway so no need to change TOTRACKBIT) + btfss INDF1,7,0 + debug 'Y' + btfss INDF1,7,0 + incf TOTRACK,1,0 + return advance_read_buffer - debug 'u' ; 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 ; move pointer to next buffer - -; check if on 1st byte of new buffer anyway (i.e. last 4 bits = 0) - movff TOTRACK,WREG ; copy TOTRACK pointer location to W - andlw 0xF ; investigate last 4 bits - - -; GIONG WRONG HERE - should be klnoopqstu7895, missing out 78 = advance to next buffer -; MUST advance byte before trying to advance buffer -# - -; if zero (i.e. overflowed to next buffer), branch to overflow check - bz totrack_overflow - -; if not zero, clear low 4 bits of TOTRACK and increment top 4 bits +; clear low 4 bits of TOTRACK and increment top 4 bits ; aaaabbbb -> bbbbaaaa -> bbbb(aaaa+1) -> 0000(aaaa+1) -> (aaaa+1)0000 debug '7' ; write 'v' to serial port swapf TOTRACK,1,0 @@ -410,44 +396,10 @@ advance_read_buffer swapf TOTRACK,1,0 debug '8' ; write 'v' to serial port -totrack_overflow ; clear bit 6 (will set back to buffer 0 if has overflowed to 4) bcf TOTRACK,6,0 debug '9' ; write 'v' to serial port - retfie 1 - -; write na=cb=1 and return - -; bra one_bit_to_track -;*** oh, we always introduce a one bit in between ? *confused* -iwj - - - -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) - - incf TOTRACK,1,0 - debug '6' ; write 'v' to serial port - retfie 1 - - -; set na=cb=new bit value - -; movff TOTRACK,FSR1L ; set low byte of IND1 pointer -; movlw 5 -; movwf FSR1H,0 ; set high byte of IND1 pointer -; movff INDF1,WREG -; andwf TOTRACKBIT,0,0 ; mask out bit to be transmitted -;*** This is the same code as the 2nd stanza in read_from_buffer, -;*** above. Surely it should be made common (eg a subroutine) ? -iwj - -; bz zero_bit_to_track -; bra one_bit_to_track -;*** zero_bit_to_track and one_bit_to_track end up calling advance_bit - -;*** is that right ? *confused* -iwj - + return -- 2.30.2