📄 rmp3cntl.asm
字号:
;=====================================================================================
; File name: RMP3CNTL.asm
;
; Originator: Digital Control Systems Group
; Texas Instruments
;
; Description:
; This file contains source for the Ramp3 control module
;=====================================================================================
; History:
;-------------------------------------------------------------------------------------
; 9-15-2000 Release Rev 1.0
;================================================================================
; Applicability: F240,F241,C242,F243,F24xx. (Peripheral Independant).
;
;
;================================================================================
; Routine Name: RMP3CNTL Routine Type: C Callable
;
; Description:
;
; C prototype : void rmp3_calc(RMP3 *p);
;================================================================================
; History Created August 3 ,2000
;
; Definition of RMP3:
;
; typedef struct RMP3 {
; int desired;
; int dly;
; int dly_cntr;
; int min;
; int out;
; int done_flg;
; (int (*) (int))rmp3_calc
; };
;================================================================================
ON .set 1
OFF .set 0
;--------------------------------------------------------------------------
RETURN_ADDRESS_SAVE .set ON ; If this function calls no other functions
; set RETURN_ADDRESS_SAVE to OFF for
; optimization
;--------------------------------------------------------------------------
RMP3_DONE_FLAG .set 07FFFh
CLEAR .set 0
;--------------------------------------------------------------------------
.def _rmp3_calc
;================================================================================
_rmp3_calc:
__RMP3_framesize .set 0001h
;--------------------------------------------------------------------------
.if ( RETURN_ADDRESS_SAVE = ON)
; AR1 is stack pointer (SP)
; AR0 is frame pointer (FP)
; ARP = AR1
POPD *+ ; Save the return address from hardware
; stack into the software stack
.endif
SAR AR0, *+ ; push AR0 (FP). ARP = AR1
SAR AR1, * ; *SP = SP. ARP = AR1
LAR AR0, #__RMP3_framesize ; FP = size of frame. ARP = AR1
LAR AR0, *0+, AR2 ; Allocate frame. AR0 = *AR1
; AR1 = AR1 + AR0. ARP = AR2
;--------------------------------------------------------------------------
.if (RETURN_ADDRESS_SAVE = ON)
LAR AR2, #-3
.endif
.if (RETURN_ADDRESS_SAVE = OFF)
LAR AR2, #-2
.endif
;--------------------------------------------------------------------------
MAR *0+ ; AR2 -> passed parameter
; (i.e. pointer to the structure).
; ARP = AR2. AR2= AR2 + AR0
;--------------------------------------------------------------------------
LAR AR3,* ; AR3 points to the first structure member
; (i.e. AR3 -> desired).
; ARP = AR2. AR2 -> passed parameter.
;--------------------------------------------------------------------------
LAR AR2,* ; AR2 points to the first structure member
; (i.e. AR2 -> desired).
; ARP = AR2 .AR3-> desired
;--------------------------------------------------------------------------
LACC * ; Load accumulator with desired
; ARP = AR2. AR2 -> desired.
; AR3 -> desired
;--------------------------------------------------------------------------
ADRK #4 ; ARP = AR2. AR2 -> out. AR3 -> desired
;--------------------------------------------------------------------------
SUB *,AR3 ; Accumulator = desired - out
; ARP = AR3. AR2 -> out . AR3 -> desired
;--------------------------------------------------------------------------
BCND __RMP3_Set_Flag , EQ
; If (Accumulator = 0)
; goto __RMP3_Set_Flag
; If Set point = target
; ARP = AR3. AR2 -> out. AR3-> desired
;--------------------------------------------------------------------------
__RMP3_Incr_Dly_Cntr:
ADRK #2 ; ARP = AR3. AR3 -> dly_cntr. AR2 -> out
;--------------------------------------------------------------------------
LACC * ; Load accumulator with delay_cntr
; ARP = AR3. AR3 -> dly_cntr. AR2 -> out
;--------------------------------------------------------------------------
ADD #1 ; Update counter
; ARP = AR3 AR3-> dly_cntr.
; AR2-> out
;--------------------------------------------------------------------------
SACL *,AR2 ; Increment dly_cntr
; ARP = AR2 AR2-> out.
; AR3-> dly_cntr
;--------------------------------------------------------------------------
SBRK #3 ; ARP = AR2. AR2-> dly . AR3-> dly_cntr
;--------------------------------------------------------------------------
SUB * ; Accumulator = dly_cntr - dly
; ARP = AR2. AR2-> dly. AR3-> dly_cntr
;--------------------------------------------------------------------------
BCND __rmp3_calc_exit , LT
; If (dly_cntr < dly)
; goto __rmp3_calc_exit
; If No decrement out
; ARP = AR2. AR2-> dly . AR3->dly_cntr
;--------------------------------------------------------------------------
__RMP3_Dec:
ADRK #3 ; ARP = AR2. AR2-> out . AR3-> dly_cntr
;--------------------------------------------------------------------------
LACC * ; Accumulator = out
; ARP = AR2. AR2-> out. AR3-> dly_cntr
;--------------------------------------------------------------------------
SUB #1 ; Accumulator = out - 1
; ARP = AR2. AR2-> out. AR3-> dly_cntr
;--------------------------------------------------------------------------
SACL *- ; update out
; ARP = AR2. AR2-> min. AR3-> dly_cntr
;--------------------------------------------------------------------------
SUB * ; Accumulator = out - min
; ARP = AR2. AR2-> min.
; AR3-> dly_cntr
;--------------------------------------------------------------------------
BCND __RMP3_Clear_Dly_Cntr, GEQ
; If (out >= min) goto
; __RMP3CNTL_Clear_Dly_Cntr
; ARP = AR2. AR2-> min. AR3-> dly_cntr
;--------------------------------------------------------------------------
LACC *+ ; Accumulator = min
; ARP = AR2. AR2-> out.
; AR3-> dly_cntr
;--------------------------------------------------------------------------
SACL *- ; out = min
; ARP = AR2. AR2->min.
; AR3-> dly_cntr
;--------------------------------------------------------------------------
; ARP = AR2. AR2-> min.
; AR3-> dly_cntr
__RMP3_Clear_Dly_Cntr:
;--------------------------------------------------------------------------
SBRK #1 ; ARP = AR2. AR2-> dly_cntr
; AR3-> dly_cntr
;--------------------------------------------------------------------------
SPLK #CLEAR,* ; store dly_cntr
; ARP = AR2. AR2-> dly_cntr
; AR3-> dly_cntr
;--------------------------------------------------------------------------
B __rmp3_calc_exit
; Goto __rmp3cnt_calc_exit
; ARP = AR2
;--------------------------------------------------------------------------
__RMP3_Set_Flag:
ADRK #5 ; ARP = AR3. AR3-> done_flag
;--------------------------------------------------------------------------
SPLK #RMP3_DONE_FLAG,*
; done_flag = 07fff;
; ARP = AR3. AR3-> done_flag
;--------------------------------------------------------------------------
__rmp3_calc_exit:
MAR * ,AR1 ; set ARP = SP before you exit.
SBRK #(__RMP3_framesize+1)
; deallocate frame, point to saved FP
.if (RETURN_ADDRESS_SAVE = ON)
LAR AR0, *- ; restore frame pointer
PSHD * ; push return address on hardware stack
.endif
.if (RETURN_ADDRESS_SAVE = OFF)
LAR AR0, * ; restore frame pointer
.endif
RET
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -