From: ian Date: Sun, 16 Mar 2008 21:57:42 +0000 (+0000) Subject: new SPURIOUS for reporting spurious short circuit interruptes X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=f897ac2ded76da77e3b006331f2a61e2994ebd98;p=trains.git new SPURIOUS for reporting spurious short circuit interruptes --- diff --git a/cebpic/README.protocol b/cebpic/README.protocol index 14938cf..5169771 100644 --- a/cebpic/README.protocol +++ b/cebpic/README.protocol @@ -60,6 +60,7 @@ From PIC to host: < 1 001Y SSS 0 SSSSSSS (9?) DETECT Train is (Y=1) or is not (Y=0) at S < 1 0001 XXX 0 XXXXXXX (88+) PONG Pong `X' (reply to Ping `X') + < 1 100 0001 0 NNNNNNN (ENQ) SPURIOUS Number of spurious fault interrupts < 0 000 1001 (HT) HELLO I am booted < 0 000 1011 (VT) AAARGH Followed by debug chars (only) < 0 000 1101 (CR) WTIMEOUT Watchdog timeout happened diff --git a/detpic/energy.asm b/detpic/energy.asm index 5dab54d..b4229a5 100644 --- a/detpic/energy.asm +++ b/detpic/energy.asm @@ -15,6 +15,8 @@ settling res 1 ; all counters are 0 if stopped stop_wait res 1 ; or otherwise count down retry_wait res 1 +fault_spurious_count res 1 + code ;====================================================================== @@ -103,6 +105,7 @@ power_fault_init @ bs_f INTCON3, INT1IE clr_f stop_wait clr_f retry_wait + clr_f fault_spurious_count pin_h p0_booster_shutdown pin_h p0_booster_userfault ; now we are Off @@ -142,10 +145,30 @@ code2 code power_fault_intrl @ bt_f_if0 INTCON3, INT1IF return - ; we have a fault: + ; we may have a fault: bc_f INTCON3, INT1IF + call portb_read + pin_inw_ifh p0_booster_overload + bra fault_isactual + ; spurious: + + inc_f_ifz fault_spurious_count ; ++f.s._count == 0x00 ? + bs_f fault_spurious_count, 7 ; f.s._count = 0x80 + + intrl_handled_nostack + +;----- +fault_isactual +; call serial_addbyte +; call portb_read +; call serial_addbyte_another +; call portb_read +; call serial_addbyte_another +; call portb_read +; call serial_addbyte_another + pinlat_ifh p0_booster_shutdown bra faultintrl_noop ; Off, Stopping or Persists - must have lost the race @@ -211,6 +234,10 @@ power_stop_doflash ;-------------------- power_fault_tickdiv @ + tst_f_ifnz fault_spurious_count + bra fault_spurious_tickdiv + ; in any case: +fault_tickdiv_rest tst_f_ifnz stop_wait dec_f_ifnz stop_wait return @@ -224,6 +251,24 @@ power_retry pin_vh p0_booster_userfault return +;---------- +fault_spurious_tickdiv +; does not return, instead continues with fault_tickdiv_rest + mov_lw 0xc1 ; SPURIOUS + call serial_addbyte + + mov_fw fault_spurious_count + bra_n fault_spurious_tickdiv_isoverflow +fault_spurious_tickdiv_writeamt + call serial_addbyte_another + clr_f fault_spurious_count + bra fault_tickdiv_rest + +;----- +fault_spurious_tickdiv_isoverflow + mov_lw 0x7f + bra fault_spurious_tickdiv_writeamt + ;-------------------- power_panichook @ pin_vh p0_booster_shutdown