(**********************************************************************) (* *) (* Function: PMA_PMM *) (* Period Measurement with Additional/Missing transition. *) (* *) (* Creation Date: Pre 89 From: NEW *) (* *) (* Author: Motorola *) (* *) (* Description: *) (* ------------ *) (* Combined functions for period measurement from a toothed wheel,with*) (* additional or missing tooth detection. For simplicity, this func *) (* is described as 2 seperate functions in TPU ref manual. *) (* Selection between modes (functions) is made via HSQ bit 1 *) (* PMA: Measure up to 16 bits period time. Clear TCR2 after a *) (* number of additional transition detections. *) (* PMM: Measure up to 16 bits period time. Clear TCR2 after a *) (* number of missing transition detections. *) (* *) (* NOTES : *) (* 1. MAX_SPECIAL and SPECIAL_COUNT should be accessed *) (* coherently *) (* *) (* *) (* Updates: By: Modification: *) (* -------- --- ------------- *) (* 28/Feb/92 JW Cleaned up for inclusion in Library *) (* 6/Oct/93 JL Converted to TPUMASM syntax and unused link *) (* entries changed to End_of_link. *) (*--------------------------------------------------------------------*) (* Standard Exits Used:- End_Of_Phase: Y End_Of_Link: N *) (* *) (* External Files %included: NONE. *) (* *) (* CODE SIZE excluding standard exits = 88 LONG WORDS *) (*--------------------------------------------------------------------*) (* *) (* *) (********** This Revision: 2.0 *********) (* *) (* Functionally identical to 68332 TPU ROM of masks D33F, D87M, 2D87M *) (* *) (********** LAST MODIFIED: 6/Oct/93 BY: Jeff Loeliger ********) (* *) (**********************************************************************) (***************************************************************************) (*Motorola reserves the right to make changes without further notice to any*) (*product herein. Motorola makes no warranty, representation or guarantee *) (*regarding the suitability of its products for any particular purpose, nor*) (*does Motorola assume any liability arising out of the application or use *) (*of any product or circuit, and specifically disclaims any and all *) (*liability, including without limitation consequential or incidental *) (*damages. "Typical" parameters can and do vary in different applications. *) (*All operating parameters, including "Typical",must be validated for each *) (*customer application by customer's technical experts. Motorola does not *) (*convey any license under its patent rights nor the rights of others. *) (*Motorola products are not designed, intended, or authorized for use as *) (*components in systems intended for surgical implant into the body, or *) (*other applications intended to support or sustain life, or for any other *) (*application in which the failure of the Motorola product could create a *) (*situation where injury or death may occur. Should Buyer purchase or use *) (*Motorola products for any such unintended or unauthorized application, *) (*Buyer, shall indemnify and hold Motorola and its officers, employees, *) (*subsidiaries, affiliates, and distributors harmless against all claims, *) (*costs, damages, and expenses, and reasonable attorney fees arising out *) (*of, directly or indirectly, any claim of personal injury or death *) (*associated with such unintended or unauthorized use, even if such claim *) (*alleges that Motorola was negligent regarding the design or manufacture *) (*of the part. *) (*Motorola and the Motorola logo are registered trademarks of Motorola Inc.*) (*Motorola is an Equal Opportunity/Affirmative Action Employer. *) (*Copyright Motorola Inc. 1993 *) (***************************************************************************) (* Parameters *) %macro CHANNEL_CONTROL_PM 'prm0'. %macro REF_TIME_PM 'prm0'. %macro MAX_SPECIAL 'prm1'.(* 15..08 *) %macro NUM_OF_TEETH 'prm1'.(* 07..00 *) %macro BANK_SIGNAL 'prm2'.(* 15..08 *) %macro SPECIAL_COUNT 'prm2'.(* 15..08 *) %macro ROLLOVER_COUNT 'prm2'.(* 07..00 *) %macro RATIO_PM 'prm3'.(* 15..08 *) %macro TCR2_MAX_VALUE 'prm3'.(* 07..00 *) %macro PERIOD_PM_HIGH 'prm4'. %macro PERIOD_PM 'prm5'. %macro TCR2_VALUE '(15,6)'. %macro PMA_MODE 'HSQ1 = 0'. %macro PMM_MODE 'HSQ1 = 1'. %macro BANK_MODE 'HSQ0 = 0'. %macro COUNT_MODE 'HSQ0 = 1'. %macro PERIOD_REG 'sr'. (**********************************************************************) (* *) (* STATE : Init *) (* *) (* PRELOAD PARAMETER : CHANEL_CONTROL_PM *) (* *) (* ENTER WHEN : issued host service request 01 *) (* *) (* TCR2 := $C000 *) (* TCR2_VALUE := $C000 *) (* SPECIAL_COUNT, ROLLOVER_COUNT := $0080 *) (**********************************************************************) %entry ram p <- @CHANNEL_CONTROL_PM ; start_address Init_PMA_PMM; name = init_pmam; cond hsr1 = 0,hsr0 = 1. Init_PMA_PMM : (* rollover count := 2 *) au diob :=<< 1; ram diob -> @ROLLOVER_COUNT. au a := max. if TRUE then goto error_3; chan config := p, enable_mtsr. au p := !0; chan neg_tdl,neg_mrl, neg_LSL. (**********************************************************************) (* *) (* PROCEDURE : Measure_period *) (* *) (* CALLED BY : Measure_period_pma, Measure_priod_pmm *) (* *) (* ACTION : increment ROLLOVER_COUNT (if needed) *) (* *) (* PARAMETERS & REGISTERS : *) (* p - rollover_count *) (* flag1 - determines if period is to be divided by 2 *) (**********************************************************************) %entry start_address *; ram p <- @ROLLOVER_COUNT; name = measure_per; cond hsr1=0,hsr0=0,m/tsr=1,lsr=0,flag0=0. Measure_period : if MRL = 0 then goto New_period, flush. Inc_rollover : nil := p_low + immed_1, ccl. if Z = TRUE then goto no_inc, flush. au p_low := p_low + 1; ram p -> @ROLLOVER_COUNT. (* if transition then do not check rollover limit *) (* it will be checked in New_period *) no_inc : if TDL = 1 then goto New_period, flush. (* check rollover have not exceeded limit *) (* if (flag1=0 & roll>1 ³ flag1=1 & roll>3 then error *) if flag1 = 0 then goto check_roll. au a :=>> p_low, ccl. au a :=>> a, ccl. check_roll : if Z = FALSE then goto period_error, flush. gen_match_8000 : au ert := ert + max; chan write_mer, neg_mrl; end. New_period : (* save ref_time in diob, rollover_count in acc, *) au a := p_low; ram diob <- @REF_TIME_PM. (* clear rollover count, update ref_time *) au p_low := 0; ram p -> @ROLLOVER_COUNT. au p := ert ; ram p -> @REF_TIME_PM. (* calculate the period *) (* acc:= period high *) (* sr := period low *) chan neg_tdl; au sr :=<< ert - diob. if flag1 = 0 then goto no_division, flush. au a :=>> a, shift, ccl. no_division : au a :=>> a, shift, ccl; chan clear flag1. (* update period *) au diob := a; ram diob -> @PERIOD_PM_HIGH. au diob := sr; ram diob -> @PERIOD_PM. (* check TCR2 overflow *) check_tcr2_ovf : ram p <- @TCR2_MAX_VALUE. (* p - ratio : tcr2_max_value *) au p_low := tcr2 - p, ccl; (* plow for byte status *) ram p <- @TCR2_VALUE. (* inc tcr2_value *) au p_low := p_low + 1; ram p -> @TCR2_VALUE. if LOW_SAME = FALSE then goto Tcr2_error. (* acc : period high *) (* sr : period low *) (* diob : period low *) (* check that period < 10000 hex *) nil := a, ccl. if Z = FALSE then goto period_error, flush. ram p <- @RATIO_PM; (* and TCR2_MAX_VALUE *) au a := 0. multiply_by_ratio : (* RESULT := PERIOD * RATIO *) (* acc := diob * sr *) au dec := 7. au sr := p_high. repeat; au a :=>> a + diob, shift. au sr :=<< a, ccl. check_match_time : if N = TRUE then goto period_error, flush. if C = TRUE then goto period_error, flush. period_ok : au ert := ert + sr; chan write_mer, neg_mrl; chan set flag0; end. (* ERROR routine *) (* ============= *) (* p - tcr2_value *) (* acc - 0000 for error condition 80 *) (* acc - 8000 for error condition C0 *) period_error : (* period_error *) (* prepare max in acc *) (* gen match on ERT + 8000 *) (* if TCR2(.15.) = 0 generate error *) (* else if TDL = 1 then generate error *) (* else end. *) ram p <- @TCR2_VALUE; au a := max. nil := p, ccl. if N = FALSE then goto error_2, flush. if TDL = 0 then goto gen_match_8000, flush. goto error_2, flush. PMM_tdl_err : (* (tdl_err) *) (* set REF_TIME_PM *) au diob := ert; ram diob -> @REF_TIME_PM. Tcr2_error : (* (tcr2_error) *) (* clear special_count *) (* clear acc *) au a := 0. au diob := 0; ram diob -> @SPECIAL_COUNT. (* gen match on ERT + 8000 *) error_2 : au ert := ert + max; chan write_mer, neg_mrl. (* prepare FF in sr *) (* write error code to tcr2 *) (* write error code to tcr2_value *) (* clear special_count, rollover_count *) (* assert interrupt *) (* negate flags *) error_3 : au sr := $FF. au a :=R> a + 1; chan clear flag1. au p := p_low + a; ram p -> @TCR2_VALUE. au tcr2 := a + sr; chan clear flag0; chan cir; end. (**********************************************************************) (* *) (* PHASE : special_transition *) (* *) (* PRELOAD PARAMETER : REF_TIME_PM *) (* *) (* ENTER WHEN : a match/transition has occured and flag0 = 1 *) (* *) (* ACTION : prepare a match on REF_TIME_PMA + 8000 *) (* check for an special transition *) (* *) (* SEQ1 = 0 PMA *) (* SEQ1 = 1 PMM *) (* *) (**********************************************************************) %entry start_address *; ram diob <- @REF_TIME_PM; name = special_trans; cond hsr1=0,hsr0=0,m/tsr=1,lsr=0,flag0=1. Special_transition : chan clear flag0; if @PMM_MODE then goto check_mrl_pmm, flush. (* PMA MODE *) check_mrl_pma : if MRL = 0 then goto special_detected_pma, flush. if TDL = 1 then goto check_rollover, flush. match_ref_time_8000 : au ert := diob + max; chan write_mer, neg_mrl; end. (* PMM MODE : *) (* *) (* MRL=0 TDL=1 : no special tooth *) (* check_rollover *) (* MRL=1 TDL=0 : special tooth *) (* MRL=1 TDL=1 : events overflow *) (* inc TCR2_VALUE *) (* neg_tdl *) (* gen TCR2_error *) check_mrl_pmm : if MRL = 0 then goto check_rollover, flush. if TDL = 0 then goto special_detected_pmm, flush. (* SPECIAL TOOTH DETECTED *) (* if this section is entered *) (* because of events overflow *) (* (pmm mode) then gen tcr2_error*) special_detected_pma : ram p <- @TCR2_VALUE. au p_low := p_low + 1; ram p -> @TCR2_VALUE. if @PMM_MODE then goto PMM_tdl_err. chan neg_tdl. special_detected_pmm : (* check for TCR2 validity *) (* TCR2 =? NUM_OF_TEETH *) ram p <- @NUM_OF_TEETH. (* max_special, num_of_teeth *) au p_low := tcr2 - p, ccl. (* plow for byte status *) if Z = TRUE then goto special_tooth_ok, flush. tcr2_err_spec : goto Tcr2_error; ram p <- @TCR2_VALUE. au ert := diob. (* HANDLE "REAL" SPECIAL TOOTH *) special_tooth_ok : (* inc special_count *) (* check for "last" special *) (* bank : BANK ª= 0 *) (* count : count > max_count - 1*) au sr := p_high - 1; (* save max_special *) ram p <- @SPECIAL_COUNT. (* special_count, rollover_count *) if @BANK_MODE then goto check_if_last. au nil := p_high, ccl. au p_high := p_high + 1; ram p -> @SPECIAL_COUNT. au nil := p_high - sr, ccl. check_if_last : if LOW_SAME = TRUE then goto what_next, flush. (* TCR2 := $FFFF *) (* TCR2_VALUE := $00FF *) (* BANK/COUNT, ROLLOVER_CNT := $00XX *) au p_high := 0; ram p -> @SPECIAL_COUNT. au p_low := !0; ram p -> @TCR2_VALUE. au tcr2 := !0. what_next : if @PMA_MODE then goto match_reftime_8000ir, flush. (* PMA - special tooth detected (cir) *) (**************************************) (* PMM - special tooth detected (cir) *) (* set CFLG1 *) chan set flag1. match_reftime_8000ir : au ert := diob + max; chan write_mer, neg_mrl; chan cir; end. (* check_rollover *) (* ERT - REF_TIME >=? $8000 *) check_rollover : au nil := ert - diob, ccl. ram p <- @ROLLOVER_COUNT; goto NEW_PERIOD. if N = TRUE then goto Inc_rollover, flush. (************************************************************************) (* UNUSED ENTRIES - EXECUTE AN END INSTRUCTION *) (************************************************************************) %entry start_address End_of_phase; name = pmam_undef; cond hsr1 = 1. %entry start_address End_of_Link; name = pmam_undef; cond hsr1 = 0,hsr0 = 0,lsr = 1.