(**********************************************************************) (* *) (* Function: SM *) (* Stepper Motor Control *) (* *) (* Creation Date: Pre 89 From: NEW *) (* *) (* Author: Motorola *) (* *) (* Description: *) (* ------------ *) (* Use a sequential group of up to 8 channels to drive a stepper M. *) (* CPU specifies desired position and func accerlerates/deccelerates *) (* the motor to that position. Up to 14 programmable step rates. *) (* *) (* *) (* Updates: By: Modification: *) (* -------- --- ------------- *) (* 02/Mar/92 JW Cleaned up for inclusion in Library *) (* 11/Apr/93 JL Converted to new syntax. *) (* *) (*--------------------------------------------------------------------*) (* Standard Exits Used:- End_Of_Phase: N End_Of_Link: N *) (* *) (* External Files %included: NONE. *) (* *) (* CODE SIZE excluding standard exits = 71 LONG WORDS *) (*--------------------------------------------------------------------*) (* *) (* *) (********** This Revision: 2.0 *********) (* *) (* Functionally identical to 68332 TPU ROM of masks D33F, D87M, 2D87M *) (* *) (********** LAST MODIFIED: 11/Apr/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 CHN_CNTL 'prm0'. %macro PIN_CNTL 'prm1'. %macro CUR_POS 'prm2'. %macro STEP_CNTL_0 'prm2'. %macro DES_POS 'prm3'. %macro STEP_CNTL_1 'prm3'. %macro MOD_CNT 'prm4'. %macro CUR_STEP_RATE 'prm4'. %macro STEP_RATE_CNT 'prm5'. %macro SEC_CHAN_CNT 'prm5'. (**********************************************************************) (* *) (* STATE : Init *) (* *) (* PRELOAD PARAMETER : CHN_CNTL *) (* *) (* ENTER WHEN : host request 10 *) (* *) (* ACTION : configure channel latches of all step motor channels. *) (**********************************************************************) %entry ram p <- @CHN_CNTL; start_address *; name = init_sm; cond hsr1 = 1, hsr0 = 0. init_sm : chan config := p, disable_mtsr. ram p <- @PIN_CNTL. ram p -> @CHN_CNTL. irq_req : chan neg_lsl, neg_mrl, neg_tdl; chan clear flag1; chan cir; end. (**********************************************************************) (* *) (* STATE : STEP_REQUEST *) (* *) (* PRELOAD PARAMETER : DES_POS *) (* *) (* ENTER WHEN : host request 11 *) (* *) (* ACTION : *) (**********************************************************************) %entry ram p <- @DES_POS; start_address *; disable_match; name = step_request; cond hsr1 = 1,hsr0 = 1. chan enable_mtsr; if flag1 = 1 then goto End_abcd, flush. au ert := tcr1 + 0; chan set flag1. (*access tcr1 if NOT stepping *) test_step_dir : ram diob <- @CUR_POS. au a := diob - p, ccl; ram p <- @MOD_CNT. if Z = 1 then goto irq_req, flush. (* is DES_POS and*) (* CUR_POS equal? *) if LOW_SAME = 0 then goto left_rot, flush; (*is CUR_POS greater*) chan clear flag0. (* than DES_POS? *) (**********************************************************************) (* *) (* STATE : RIGHT_ROT_PIN_CNTL *) (* *) (* PRELOAD PARAMETER : MOD_CNT *) (* *) (* ENTER WHEN : a match when CHN_CNTL was previously rotated right *) (* to ascertain the desired pin response. *) (* ACTION : *) (**********************************************************************) %entry ram p <- @MOD_CNT; start_address *; name = right_rot_pin_cntl; cond hsr1 = 0,hsr0 = 0,m/tsr = 1,lsr = 0,pin = x,flag0 = 1. right_rot : au dec := p_high + 1; (* increment modulo counter *) ram p <- @CUR_POS. goto common; ram diob <- @DES_POS. au sr := p + 1; chan set flag0. (* increment cur_pos *) (**********************************************************************) (* *) (* STATE : LEFT_ROT_PIN_CNTL *) (* *) (* PRELOAD PARAMETER : MOD_CNT *) (* *) (* ENTER WHEN : a match when CHN_CNTL was previously rotated left *) (* to ascertain the desired pin response. *) (* ACTION : *) (**********************************************************************) %entry ram p <- @MOD_CNT; start_address *; name = left_rot_pin_cntl; cond hsr1 = 0,hsr0 = 0,m/tsr = 1,lsr = 0,pin = x,flag0 = 0. left_rot : au dec := p_high - 1; (* decrement modulo counter *) ram diob <- @CUR_POS. au sr := diob - 1; (* decrement cur_pos *) ram p <- @DES_POS. (**********************************************************************) (* *) (* PROCEDURE : COMMON *) (* *) (* PARAMETERS & REGISTERS : *) (* *) (* On entry from RIGHT_ROT_PIN_CNTL and exit *) (* *) (* Register³ Entry ³ Exit *) (* ----------------------------------------- *) (* p ³ CUR_POS ³ STEP_RATE_CNT (phi) *) (* diob ³ DES_POS ³ DES_POS *) (* acc ³ x ³ CUR_POS *) (* sr ³ CUR_POS + 1 ³ CUR_POS + 1 *) (* dec ³ MOD_CNT + 1 ³ MOD_CNT + 1 *) (* *) (* On entry from LEFT_ROT_PIN_CNTL and exit *) (* *) (* Register³ Entry ³ Exit *) (* ----------------------------------------- *) (* p ³ DES_POS ³ STEP_RATE_CNT (phi) *) (* diob ³ CUR_POS ³ CUR_POS *) (* acc ³ x ³ DES_POS *) (* sr ³ CUR_POS - 1 ³ CUR_POS - 1 *) (* dec ³ MOD_CNT - 1 ³ MOD_CNT - 1 *) (* *) (**********************************************************************) common : au a := p; ram p <- @STEP_RATE_CNT. au p := p_high + a. (* add step_rate_cnt *) au nil := diob - p, ccl; ram p <- @STEP_RATE_CNT. (**********************************************************************) (* *) (* PROCEDURE : TRAJECTORY_TRACKING *) (* *) (* EXECUTED IN PHASE : LEFT_ROT_PIN_CNTL *) (* RIGHT_ROT_PIN_CNTL *) (* *) (**********************************************************************) if LOW_SAME = 1 then goto check_step_rate, flush. (* are (step_rate_cnt - 1) or fewer steps required? *) (* NO, more than cur_step_rate steps are required *) au diob := p_high - 1; ram p <- @CUR_STEP_RATE. au p_high := p_low - diob, ccl; ram diob <- @CUR_STEP_RATE. if LOW_SAME = 0 then goto chan_setup, flush. (* increment cur_step_rate if it is less *) (* than step_rate_cnt *) goto chan_setup. au p_low := p_low + 1. check_step_rate : (*YES ,(step_rate_cnt-1) or fewer are required *) ram p <- @CUR_STEP_RATE. au p_high := p_low - 1, ccl. if LOW_SAME = 0 then goto decrement_step_rate, flush. (* what is the step rate? *) au nil := diob - a, ccl; (* step rate is MINIMUM *) ram diob <- @CUR_STEP_RATE. if LOW_SAME = 0 then goto chan_setup, flush. (* if not greater than, test step direction *) goto test_step_dir, flush; ram p <- @DES_POS. decrement_step_rate : (* step rate is NOT MINIMUM *) ram diob <- @CUR_STEP_RATE; au p_low := p_low - 1. (* reduce step rate *) (**********************************************************************) (* *) (* ROUTINE : CHAN_SETUP *) (* *) (* ACCESSED IN : TRAJECTORY_TRACKING *) (* *) (* PARAMETERS & REGISTERS : *) (* *) (* On entry sr = adjusted value of cur_pos *) (* p_low = adjusted value of cur_step_rate *) (* diob = cur_step_rate *) (* *) (**********************************************************************) chan_setup : au p_high := dec; ram p -> @MOD_CNT. (* update mod_cnt *) au dec := diob. (* update dec with cur_step_rate *) au diob := sr; ram diob -> @CUR_POS. au sr := p_high. (* load mod_cnt into sr *) au diob := chan_reg + #$15.(* form address of step_cntl_0 *) au diob := diob + 1; (* form address of step_cntl_1 *) ram p <- by_diob. (* access step_cntl_0 *) ram diob <- by_diob; (* access step_cntl_1 *) au a := 0. au a := a + p; repeat. (* calculate offset *) au p := diob - a. (* sub offset from step_cntl_1 *) ram p <- @SEC_CHAN_CNT; au a := ert + p. (* load match time into a *) au p_low :=<< p_low + p. au p_low :=<< p_low + p. if flag0 = 0 then goto setup_loop. (* copy flag0 to dec *) au dec := 0. au dec := 1. setup_loop : au dec := dec + 0, ccl; ram diob <- @CHN_CNTL. if Z = 1 then goto left_shift, flush; (* configure pac *) chan pac := high_low. goto check_for_l_h. au diob :=R> diob, ccl. left_shift : au diob :=<< diob, ccl. if C = 0 then goto check_for_l_h, flush. au diob := diob + 1. check_for_l_h : if N = 0 then goto check_for_mod_cnt, flush. chan pac := low_high. check_for_mod_cnt : au nil := sr, ccl. if Z = 0 then goto update_pin_cntl, flush. ram diob <- @PIN_CNTL. update_pin_cntl : ram diob -> @CHN_CNTL; au p_high := chan_reg - p, ccl.(*compare sec_chan_cnt and chan*) au ert := a; chan neg_lsl, neg_mrl, neg_tdl, write_MER. au chan_reg := chan_reg + #$10. if Z = 0 then goto setup_loop, flush. end_abcd : chan neg_lsl; end. (**********************************************************************) (* UNUSED ENTRIES - execute an end. *) (**********************************************************************) %entry ram p<-prm0; start_address end_abcd; name = sm_undef; cond hsr1 = 0,hsr0 = 1. %entry ram p<-prm0; start_address end_abcd; name = sm_undef; cond hsr1 = 0,hsr0 = 0,lsr = 1.