From: ian Date: Fri, 30 Dec 2005 03:03:02 +0000 (+0000) Subject: move manipulation of flags_polarising into energy; debugging of this and of bugs... X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=4f8b395eee641fce518c97752bf21d455b139feb;p=trains.git move manipulation of flags_polarising into energy; debugging of this and of bugs found at same time --- diff --git a/detpic/energy.asm b/detpic/energy.asm index 5f3032c..bb4c3f4 100644 --- a/detpic/energy.asm +++ b/detpic/energy.asm @@ -47,22 +47,30 @@ power_polarising_begin @ return ;-------------------- -power_polarising_settling @ +power_polarising_nonetodo @ ; idempotent + bs_f xdebug+6, 2 + bt_f_if0 flags, flags_polarising + return + bs_f xdebug+6, 3 tst_f_ifnz settling return mov_lw settling_timeout / tick_us mov_wf settling + bs_f xdebug+6, 4 return ;-------------------- power_polarising_tick @ + bs_f xdebug+6, 6 tst_f_ifnz settling dec_f_ifnz settling ; decrement if not zero return ; return if not dec'd, or if decrement didn't make zero ; settle timeout complete: + bs_f xdebug+6, 7 bc_f flags, flags_polarising + pin_vh p0_booster_pwm call nmra_restartmessage bs_f INTCON, TMR0IE ; reenables NMRA interrupt goto i2c_consider_restartread diff --git a/detpic/i2clib.asm b/detpic/i2clib.asm index efd3ae4..7c7fbdf 100644 --- a/detpic/i2clib.asm +++ b/detpic/i2clib.asm @@ -117,6 +117,7 @@ i2cm_interrupt ; We have an interrupt: ;... i2cm_interrupt_definite + bs_f xdebug+0, 5 mov_ff SSPSTAT, sspstat mov_ff SSPCON1, sspcon1 mov_ff SSPCON2, sspcon2 @@ -169,6 +170,7 @@ m_start ; W slave number any ; slave any slave_number ; expects to return directly to main program (caller) + bs_f xdebug+0, 2 mov_wf slave bs_f SSPCON2, SEN m_start_or_restart @@ -235,9 +237,7 @@ i2cm_write_start ; At call On return ; State Idle/Reading-Wait Writing-Setup ; W slave number any - mov_wf xdebug+3 - mov_ff st, xdebug+4 - set_f xdebug+5 + bs_f xdebug+0, 1 tst_f_ifnz st bra m_write_start_busy @@ -364,13 +364,11 @@ m_event_done_acking mov_fw slave_next bra_z m_stop ; ok, we want to read another: - mov_wf xdebug+2 mov_wf slave clr_f slave_next bt_f_if0 st, st_writing ; because of i2cm_write_start ? bs_f st, st_reading ; no, then we will want to read bs_f SSPCON2, RSEN - set_f xdebug+0 bra m_start_or_restart ;---------- diff --git a/detpic/program.asm b/detpic/program.asm index 0126bdf..ab538d4 100644 --- a/detpic/program.asm +++ b/detpic/program.asm @@ -83,6 +83,7 @@ master_init call tick_init call power_polarising_init call power_fault_init + clr_f xdebug+0 return ;---------------------------------------- @@ -91,10 +92,15 @@ master_interrupt_low @ call tick_intrl call nmra_serialrx_intrl call power_fault_intrl + mov_ff PIR1, xdebug+2 + mov_ff PIE1, xdebug+3 + mov_ff IPR1, xdebug+4 + mov_ff INTCON, xdebug+5 call serialtxfc_intrl call serialtx_intrl call points_local_intrl call i2cm_intrl + bs_f xdebug+0, 5 panic morse_IL ;---------------------------------------------------------------------- diff --git a/detpic/reverse.asm b/detpic/reverse.asm index d0c40aa..8c9040e 100644 --- a/detpic/reverse.asm +++ b/detpic/reverse.asm @@ -116,6 +116,8 @@ command_polarity @ ; and so on until f for bit 5. (See polarity_do_here, below.) ; ; we accumulate (`gather') the `g' bits in t. + clr_f xdebug+0 + clr_f xdebug+6 mov_lfsr polarity_cmds, 1 mov_fw POSTINC0 ; W = 10010RRR mov_wf t ; t = 10010ggg @@ -229,6 +231,7 @@ polarity_needwrite @ ; if we _do_, it will put the slave no. in W, and then pop ; and branch to i2c_needwrite. See mascan.asm. ; nb register usage may need to be adjusted for wiring into mascan i2cm_... + bs_f xdebug+6, 0 mov_lfsr polarity_cmds, 0 polarity_needwrite_loop rlc_fw PREINC0 ; W = 1RRRRRR? C=1 reverse command @@ -240,11 +243,10 @@ polarity_needwrite_loop bra polarity_needwrite_found ; we found the sentinel: - bt_f_if0 flags, flags_polarising - return - goto power_polarising_settling + goto power_polarising_nonetodo polarity_needwrite_found + bs_f xdebug+6, 1 mov_fw FSR0L add_lw -polarity_cmds pop @@ -268,6 +270,7 @@ polarity_getwritebyte @ clr_f INDF0 ; we're about to write this bra_n i2c_getwritebyte_yes ; no: + bs_f xdebug+0, 7 return ;======================================================================