From: ian Date: Fri, 30 Dec 2005 17:57:37 +0000 (+0000) Subject: detection seems to work now, yay X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=10b178d319e216d739854a04635c96c671c81f06;p=trains.git detection seems to work now, yay --- diff --git a/TODO b/TODO index 9f91b42..445a43d 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,8 @@ -trying to send nmra doesn't work: - 8a 67 8a 67 - ff ff 7f no response - 8a 55 8a 55 - etc. +nmra watchdog seems to lose a byte of idle from the beginning somehow + (don't know if this happens with host-supplied data) -led is wrong when we just run the program ? surely it should be red + +watchdog should disable CDU residual stuff from CDU is present and changes pt0 when you diff --git a/detpic/energy.asm b/detpic/energy.asm index 8939fc5..e196fb0 100644 --- a/detpic/energy.asm +++ b/detpic/energy.asm @@ -121,6 +121,9 @@ command_power_on @ ; must be Off: pin_vl p0_booster_shutdown + D 0x60 + bt_f_if1 xdebug+6, 0 + bs_f xdebug+6, 1 goto cdu_on ;---------- diff --git a/detpic/mascan.asm b/detpic/mascan.asm index 754f278..34bc159 100644 --- a/detpic/mascan.asm +++ b/detpic/mascan.asm @@ -66,6 +66,8 @@ i2cmu_read_got_byte mov_wf b ; W = b = received byte D 0x70 + mov_fw cslot + call debugbyte mov_fw cbyte call debugbyte mov_fw b @@ -87,6 +89,7 @@ read_got_first_detectors ; b = MdBBdddd mov_fw POSTINC1 ; W = detbasel; FSR1 -> lastd0 rcall read_got_detectbyte_prep ; b = 0d00dddd ; u = 0C00CCCC + ;mov_ff b, xdebug+5 bt_f_if1 b, 6 ; b bit .d...... bs_f b, 4 ; b = 0d0ddddd ; ^ ^ copies of same bit @@ -112,19 +115,23 @@ read_got_bad_first_reversers panic morse_MR ;---------- read_got_detectors_b1 ; b = dddddddd +; ; W = detbasel; FSR1 -> detbasel + add_lw 5 ; W = adjdetbasel + bs_f FSR1L, 2 ; FSR1L -> lastd1 bc_f cbyte, 4 ; cbyte = M0B00000 - mov_fw POSTINC1 ; W = detbasel; FSR1 -> lastd0 - inc_f FSR1L ; FSR1 -> lastd1 - add_lw 5 ; W = detbasel+8 + mov_ff xdebug+4, xdebug+5 + mov_ff xdebug+3, xdebug+4 + mov_ff b, xdebug+3 rcall read_got_detectbyte_prep goto addmsgs_all ;---------- read_got_detectors_b2 ; b = dddddddd +; ; W = detbasel; FSR1 -> detbasel + add_lw 13 ; W = adjdetbasel + inc_f FSR1L ; FSR1 -> lastd0 + inc_f FSR1L ; FSR1 -> lastd2 bc_f cbyte,5 ; cbyte = M0000000 - mov_fw POSTDEC1 ; W = detbasel; FSR1 -> flags - bs_f FSR1L, 2 ; FSR1L -> lastd2 - add_lw 13 ; W = detbasel+16 rcall read_got_detectbyte_prep goto addmsgs_all @@ -144,19 +151,23 @@ read_got_detectbyte_prep_ifsomething ; lastd [o0]* ; FSR1 -> lastd ; - mov_wf xdebug+0 mov_wf u ; u = [C0]* - mov_ff INDF1, xdebug+1 + D 0x74 + mov_fw FSR1L + call debugbyte + mov_fw u + call debugbyte xor_wff INDF1 ; lastd = [d0]* ; to force test of repeated detection notification, ; comment out previous line - mov_ff INDF1, xdebug+2 mov_lw 0x07 ior_wff FSR1L ; FSR1L -> detmsgh return ; to addmsgs_, very shortly ;---------------------------------------- read_got_notfirst +; ; FSR1 -> flags + mov_fw PREINC1 ; W = detbasel; FSR1 -> detbasel bt_f_if1 cbyte, 4 bra read_got_detectors_b1 bt_f_if1 cbyte, 5 @@ -193,7 +204,11 @@ read_got_detectbyte_prep ; NOS return address for i2cmu_read_got_byte ; mov_wf t ; t = adjdetbasel + D 0x73 + mov_fw INDF1 + call debugbyte mov_fw b ; W = [d0]* + call debugbyte xor_wfw INDF1 ; W = [C0]*, Z iff same ; where C set iff change to that detection segment bra_nz read_got_detectbyte_prep_ifsomething @@ -248,21 +263,25 @@ nextslave_nowrite ; Ok, we have a slave: D 0x71 - mov_fw cslot - call debugbyte mov_fw INDF1 ; W = new slave number goto i2cm_read_start nextslave_looparound + bt_f_if1 xdebug+6,2 + goto boom2 + + bt_f_if1 xdebug+6,1 + bs_f xdebug+6,2 + ; now we do our own detection mov_lw (slavetable + ste_flags) & 0xff ; select our own slot mov_wf cslot D 0x72 - mov_fw cslot - call debugbyte call read_detection_head_master goto i2cmu_read_got_byte +boom2 + panic morse_TI1 ;---------------------------------------- i2c_needwrite @ @@ -309,7 +328,7 @@ mascan_init_loop mov_fw TABLAT ; W = EOOOOSSS, N = E tblrd_postinc_fixup ; TABLAT = DSSSSSSS, N (still) = E - bra_nn mascan_init_ifabsent + bra_nn mascan_init_ifabsent ; E....... mov_ff t, POSTINC0 ; ste_slave = slave mov_wf u ; u = 1OOOOSSS @@ -327,9 +346,9 @@ mascan_init_loop mov_wf POSTINC0 ; detbasel clr_f POSTINC0 ; lastd0 - clr_f POSTINC0 ; lastd1 clr_f POSTINC0 ; lastd2 set_f POSTINC0 ; unused + clr_f POSTINC0 ; lastd1 mov_fw u ; W = 10000SSS xor_lw b'10011000' ^ 0x80 ; W = detmsgh @@ -452,35 +471,42 @@ addmsgs_dethead addmsg_testbit 0 ;---------- addmsg_one -; TOS - 4 -> bt_f_if1 w, b'bbb' +; TOS - 4 -> bt_f_if1 u, b'bbb' ; TOSL ???bbb00 ; other conditions on entry and exit as for entry to addmsgs_, above ;dec_f_ifz xdebug+7 ;bra boom - - mov_ff t, xdebug+1 + D 0x75 + mov_fw TOSL + call debugbyte rr_fw TOSL ; W = 0???bbb0 - mov_wf xdebug+2 rr_w ; W = 00???bbb ior_lw 0xf8 ; W = 11111bbb mov_wf FSR0L ; FSR0L = 11111bbb - mov_wf xdebug+3 clr_f FSR0H ; FSR0 -> bitnum2bit[bbb] add_wfw t ; W = adjdetbasel + 11111bbb ; ie = 0 SSSSSSS (det msg low byte) mov_wf v ; v = 0 SSSSSSS (det msg low byte) + bra_n addmsg_bad mov_fw b ; W = [d0]* and_wfw INDF0 ; train: W = 0x00, Z=1; none: W = 0*d0*, Z=0 bt_f_if0 STATUS, Z mov_lw 0x08 ; train: W = 0 000 0 000; none: W = 0 000 1 000 xor_wfw INDF1 ; W = 1 001 Y SSS (det msg high byte) + call debugbyte call serial_addbyte + ;bt_f_if1 xdebug+6, 0 + ;bra boom + mov_fw v ; W = 0 SSSSSSS (det msg low byte) + call debugbyte goto serial_addbyte_another -boom panic morse_TI5 +addmsg_bad panic morse_DJ +boom + panic morse_TI5 ;====================================================================== include final.inc diff --git a/detpic/morse.messages b/detpic/morse.messages index 3966c7b..204d421 100644 --- a/detpic/morse.messages +++ b/detpic/morse.messages @@ -75,6 +75,7 @@ DX ::t ; slave received wrong message byte DB detect:message_buffer ; slave_add_short_message overrun DF ::t ; slave pic2detinfo[0] invalid bits DG ::t ; too many slaves in pic2detinfo +DJ mascan:cslot,mascan:cbyte,::v ; det msg 2nd byte has top bit set DM detect:buf0 ; master has MM bit set in buf0 # Messages for specific peripherals: diff --git a/detpic/panic.asm b/detpic/panic.asm index 829de2a..befce3a 100644 --- a/detpic/panic.asm +++ b/detpic/panic.asm @@ -21,7 +21,7 @@ panicst_acked equ 5 panicst_ferroerr equ 4 panicst_writeslave equ 3 panicst_i2cmours equ 2 -panicst_i2cmenable equ 2 +panicst_i2cmenable equ 1 panic_valcount res 1 diff --git a/detpic/program.asm b/detpic/program.asm index 557e316..c4ea72d 100644 --- a/detpic/program.asm +++ b/detpic/program.asm @@ -60,6 +60,7 @@ master_init call memory_erase clr_f flags set_f xdebug+7 + clr_f xdebug+6 call serial_init call i2cm_init call serialtxbuf_init @@ -82,17 +83,17 @@ master_interrupt_low @ enter_interrupt_low D 0x80 call tick_intrl - D 0x01 + ;Dl 0x01 call nmra_serialrx_intrl - D 0x02 + ;Dl 0x02 call power_fault_intrl - D 0x03 + ;Dl 0x03 call serialtxfc_intrl - D 0x04 + ;Dl 0x04 call serialtx_intrl - D 0x05 + ;Dl 0x05 call points_local_intrl - D 0x06 + ;Dl 0x06 call i2cm_intrl bs_f xdebug+0, 5 panic morse_IL @@ -155,6 +156,7 @@ command_ping call serial_addbyte mov_fw t bra_n command_ping_bad + mov_wf xdebug+6 goto serial_addbyte_another command_ping_bad panic morse_HP diff --git a/detpic/variables.asm b/detpic/variables.asm index afcba6e..302b805 100644 --- a/detpic/variables.asm +++ b/detpic/variables.asm @@ -70,8 +70,8 @@ ste_slave equ 0 ; Gk slave number ste_flags equ 1 ; ** flags (stf_...), see below ste_detbasel equ 2 ; dk added to 11111bbb to make 0SSSSSSS; ie first-0xf8 ste_lastd0 equ 3 ; d } [o0]* ie every bit is either 0 (for an -ste_lastd1 equ 4 ; d } irrelevant bit) or o, meaning the -ste_lastd2 equ 5 ; d } previously seen detection data bit +ste_lastd2 equ 4 ; d } previously seen detection data bit +ste_lastd1 equ 6 ; d } irrelevant bit) or o, meaning the ste_detmsgh equ 7 ; dk 1 001 1 000 being 1 001 Y SSS ; offset^ ^which module(s) use this data: ; G global - for use by any code