From: ceb Date: Sat, 8 Jan 2005 19:56:26 +0000 (+0000) Subject: more debugging X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=f8d082137fe98b806e110fcc3c284af13a0d6300;p=trains.git more debugging --- diff --git a/cebpic/booster-output-low.asm b/cebpic/booster-output-low.asm new file mode 100644 index 0000000..d05d7be --- /dev/null +++ b/cebpic/booster-output-low.asm @@ -0,0 +1,20 @@ + + + + include /usr/share/gputils/header/p18f458.inc + + code + +; initialise booster direction + bcf TRISC,0,0 ; make pin 0 (booster direction) output + bcf PORTC,0,0 ; set low initially + + +; set booster pwm high + bcf TRISC,1,0 ; make pin 1 (booster pwm) output + bsf PORTC,1,0 ; booster pwm high + +loop + goto loop + + end diff --git a/cebpic/nmra-stream.asm b/cebpic/nmra-stream.asm index a689473..eee0e68 100644 --- a/cebpic/nmra-stream.asm +++ b/cebpic/nmra-stream.asm @@ -216,9 +216,8 @@ serial_receive debug '3' ; write 'h' to serial port ; *** check for overrun and do something sensible btfss INDF0,7,0 ; check if bit 7 is set - debug '4' ; write 'h' to serial port call advance_write_buffer ; if so, move to next buffer - debug '5' ; write 'h' to serial port + debug '4' ; write 'h' to serial port retfie 1 ; *** I *think* the interrupt bit is cleared by reading out of RCREG @@ -237,6 +236,7 @@ advance_write_buffer ; if not zero, 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 incf FROMSERIAL,1,0 movlw 0xF @@ -245,6 +245,7 @@ advance_write_buffer 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 return @@ -266,6 +267,7 @@ timer0_interrupt btfsc NMRACTRL,NEXTACTION,0 goto toggle_output bsf NMRACTRL,NEXTACTION,0 + debug '1' ; write 'k' to serial port retfie 1 @@ -288,6 +290,7 @@ mid_bit bsf NMRACTRL,NEXTACTION,0 btfss NMRACTRL,TRANSMITBIT,0 bcf NMRACTRL,NEXTACTION,0 + debug '2' ; write 'k' to serial port retfie 1 @@ -303,6 +306,7 @@ decide_next_bit bnz read_from_buffer bsf NMRACTRL,TRANSMITBIT,0 bsf NMRACTRL,NEXTACTION,0 + debug '3' ; write 'k' to serial port retfie 1 @@ -312,6 +316,8 @@ read_from_buffer ; if currently on bit 7, want to skip to bit 6 ;*** wouldn't it be easier to start on bit 6 ? :-) -iwj + btfsc TOTRACKBIT,7,0 + debug '4' ; write 'o' to serial port btfsc TOTRACKBIT,7,0 rrncf TOTRACKBIT,1,0 ; rotate mask right @@ -324,11 +330,7 @@ read_from_buffer movlw 5 movwf FSR1H,0 ; set high byte of IND1 pointer movff INDF1,WREG - andwf TOTRACKBIT,0,0 ; mask out bit to be transmitted -;*** to `mask out' means to clear, eg -;*** if you were to `mask out bit 0 of 0xff' you'd get 0xfe -;*** I suggest `test bit to be transmitted' or `check bit ...' or maybe -;*** `select bit ...' -iwj + andwf TOTRACKBIT,0,0 ; select bit to be transmitted bz zero_bit_to_track bra one_bit_to_track @@ -357,6 +359,7 @@ advance_bit ;*** can use branch if negative. -iwj btfsc TOTRACKBIT,7,0 call advance_pointer + debug '5' ; write 's' to serial port retfie 1 @@ -393,15 +396,19 @@ advance_read_buffer ; if not zero, 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 incf TOTRACK,1,0 movlw 0xF andwf TOTRACK,1,0 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 @@ -416,6 +423,7 @@ advance_read_byte ; (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 diff --git a/detpic/nmra-stream.asm b/detpic/nmra-stream.asm index a689473..eee0e68 100644 --- a/detpic/nmra-stream.asm +++ b/detpic/nmra-stream.asm @@ -216,9 +216,8 @@ serial_receive debug '3' ; write 'h' to serial port ; *** check for overrun and do something sensible btfss INDF0,7,0 ; check if bit 7 is set - debug '4' ; write 'h' to serial port call advance_write_buffer ; if so, move to next buffer - debug '5' ; write 'h' to serial port + debug '4' ; write 'h' to serial port retfie 1 ; *** I *think* the interrupt bit is cleared by reading out of RCREG @@ -237,6 +236,7 @@ advance_write_buffer ; if not zero, 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 incf FROMSERIAL,1,0 movlw 0xF @@ -245,6 +245,7 @@ advance_write_buffer 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 return @@ -266,6 +267,7 @@ timer0_interrupt btfsc NMRACTRL,NEXTACTION,0 goto toggle_output bsf NMRACTRL,NEXTACTION,0 + debug '1' ; write 'k' to serial port retfie 1 @@ -288,6 +290,7 @@ mid_bit bsf NMRACTRL,NEXTACTION,0 btfss NMRACTRL,TRANSMITBIT,0 bcf NMRACTRL,NEXTACTION,0 + debug '2' ; write 'k' to serial port retfie 1 @@ -303,6 +306,7 @@ decide_next_bit bnz read_from_buffer bsf NMRACTRL,TRANSMITBIT,0 bsf NMRACTRL,NEXTACTION,0 + debug '3' ; write 'k' to serial port retfie 1 @@ -312,6 +316,8 @@ read_from_buffer ; if currently on bit 7, want to skip to bit 6 ;*** wouldn't it be easier to start on bit 6 ? :-) -iwj + btfsc TOTRACKBIT,7,0 + debug '4' ; write 'o' to serial port btfsc TOTRACKBIT,7,0 rrncf TOTRACKBIT,1,0 ; rotate mask right @@ -324,11 +330,7 @@ read_from_buffer movlw 5 movwf FSR1H,0 ; set high byte of IND1 pointer movff INDF1,WREG - andwf TOTRACKBIT,0,0 ; mask out bit to be transmitted -;*** to `mask out' means to clear, eg -;*** if you were to `mask out bit 0 of 0xff' you'd get 0xfe -;*** I suggest `test bit to be transmitted' or `check bit ...' or maybe -;*** `select bit ...' -iwj + andwf TOTRACKBIT,0,0 ; select bit to be transmitted bz zero_bit_to_track bra one_bit_to_track @@ -357,6 +359,7 @@ advance_bit ;*** can use branch if negative. -iwj btfsc TOTRACKBIT,7,0 call advance_pointer + debug '5' ; write 's' to serial port retfie 1 @@ -393,15 +396,19 @@ advance_read_buffer ; if not zero, 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 incf TOTRACK,1,0 movlw 0xF andwf TOTRACK,1,0 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 @@ -416,6 +423,7 @@ advance_read_byte ; (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