From d18bf8731bba5ffcd9005e0ec71b1c13ef0bb15d Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 13 May 2006 00:38:12 +0000 Subject: [PATCH] new workable OFF behaviour implemented and it compiles but is not tested --- detpic/energy.asm | 64 ++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/detpic/energy.asm b/detpic/energy.asm index bf34bf0..edd472a 100644 --- a/detpic/energy.asm +++ b/detpic/energy.asm @@ -79,13 +79,11 @@ power_polarising_tick @ ; ; Off shutdown off none off On ; On power-up on none off Stopping,FAULT Off -; Stopping shutdown on 500ms 50% 1/100ms Retry +; Stopping shutdown on 500ms 50% 1/100ms Retry ; Retry power-up off 50ms off Persists Off,FIXED Off -; Persists shutdown off 90ms on Retry Off +; Persists shutdown off 90ms on Retry Off ; ; (no notation: event ignored) - make code correspond to new - get rid of Clearing state. ; ; shutdown LAT stop_wait retry_wait ; @@ -128,15 +126,14 @@ command_power_on @ ;---------- command_power_off @ -; On -> Off; noop in other states - pinlat_ifh p0_booster_shutdown - return ; Off, Stopping or Persists - ; might be On or Retry: - - tst_f_ifnz retry_wait - return ; that deals with Retry - ; must be On: +; On, Retry, Persists -> Off; noop in Off or Stopping + tst_f_ifnz stop_wait + return ; that deals with Stopping + ; must be On, Off, Retry or Persists: + ; (it's harmless to do this if we were already Off) power_off_now + clr_f retry_wait + pin_vh p0_booster_userfault pin_vh p0_booster_shutdown goto cdu_off @@ -148,33 +145,41 @@ power_fault_intrl @ ; we have a fault: bc_f INTCON3, INT1IF - call power_off_now - mov_fw retry_wait - bra_z power_fault_newshort ; we were Off or On - ; must be Stopping, Retry or Persists: - - tst_f_ifnz stop_wait - bra power_fault_stopmore ; we were already Stopping; restart timer - ; might be Retry or Persists, goto Persists (restarting any timer): + pinlat_ifh p0_booster_shutdown + return ; Off, Stopping or Persists - must have lost the race + ; or flapped while we faffed. Well, never mind, it's + ; off now and we're taking care of it. (If the host + ; caused Off by OFF they can at worst send an OFF and + ; immediate ON in about 2ms, so worst-case duty cycle + ; for a short (if the host is perversely timed) is + ; (our interrupt latency) / 2ms + ; and if they ever don't manage to get the OFF through + ; in time then we go into Stopping.) + ; must be On or Retry: - mov_lw persist_timeout / tick_us - mov_wf retry_wait - pin_vl p0_booster_userfault -faultintrl_noop - intrl_handled_nostack + pin_vh p0_booster_shutdown + tst_f_ifnz retry_wait + bra fault_persists ; that deals with Retry + ; must be On: -;----- -power_fault_newshort mov_lw b'00000111' call serial_addbyte -power_fault_stopmore + mov_lw stop_timeout / tickdiv_us mov_wf stop_wait pin_vl p0_booster_userfault rcall power_stop_doflash intrl_handled_nostack +;----- +fault_persists ; Retry -> Persists (booster was shut down just a moment ago) + mov_lw persist_timeout / tick_us + mov_wf retry_wait + pin_vl p0_booster_userfault +faultintrl_noop + intrl_handled_nostack + ;-------------------- power_fault_tick @ tst_f_ifnz retry_wait @@ -184,7 +189,7 @@ power_fault_tick @ ; we were in Stopping, Retry or Persists: tst_f_ifnz stop_wait - bra power_stop_doflash ; that was Stopping, just flash the LED + bra power_stop_doflash ; that deals with Stopping (just flash) ; must be Retry or Persists: pinlat_ifh p0_booster_shutdown @@ -210,6 +215,7 @@ power_fault_tickdiv @ return ; stop_wait was running but has just reached zero; ; we were in Stopping, now we can Retry: + call cdu_off power_retry mov_lw retry_timeout / tickdiv_us mov_wf retry_wait -- 2.30.2