📄 rampgen.asm.txt
字号:
;=====================================================================
; Filename : rampgen.asm
; Module Name : RAMP_GEN
; Initialization Routine: RAMP_GEN_INIT
; Description : This module generates ramp output of adjustable gain,
; frequency and dc offset.
; |~~~~~~~~~~~~~~~~~ |
; rmp_gain o-------> | |
; rmp_offseto------> | RAMP_GEN |----->o rmp_out
; rmp_freq o-------> | |
; |_________________ |
;=====================================================================
;(To use this Module, copy this section to main system file)
; .ref RAMP_GEN, RAMP_GEN_INIT ;function call
; .ref rmp_gain, rmp_offset, rmp_freq ;Inputs
; .ref rmp_out ;Outputs
;=====================================================================
.def RAMP_GEN, RAMP_GEN_INIT ;function call
.def rmp_gain, rmp_offset, rmp_freq ;Inputs
.def rmp_out ;Outputs
;===========================================================================
STEP_ANGLE_RG_MAX .set 1000 ;corresponds to 306Hz frequency.
.def rmp_gain
.def rmp_offset
.def rmp_freq
.def rmp_out
alpha_rg .usect "rampgen",1
step_angle_rg .usect "rampgen",1
rmp_gain .usect "rampgen",1
rmp_offset .usect "rampgen",1
rmp_freq .usect "rampgen",1
rmp_freq_max .usect "rampgen",1
rmp_out .usect "rampgen",1
RAMP_GEN_INIT:
LDP #alpha_rg
SPLK #0, alpha_rg ;Start at 0 deg.
SPLK #STEP_ANGLE_RG_MAX, rmp_freq_max
SPLK #3FFFh, rmp_gain ;Init amplitude to 50%
SPLK #3FFFh, rmp_offset ;Init offset to 50%
SPLK #3FFFh, rmp_freq ;Init freq to 50%
RET
RAMP_GEN:
;Normalise the freq input to appropriate step angle
LDP #rmp_freq
LT rmp_freq ;rmp_freq is in Q15
MPY rmp_freq_max ;rmp_freq_max is in Q0
PAC ;P = Q0 x Q15 = Q15 (in 32bit word)
SACH step_angle_rg,1 ;shift 1 to restore Q0 format
LACC alpha_rg
ADD step_angle_rg ;Inc angle.
SACL alpha_rg
;scale the output with input gain
LT alpha_rg ;alpha_rg is in Q15
MPY rmp_gain ;rmp_gain is in Q15
PAC ;P = rmp_gain * alpha_rg
SACH rmp_out,1 ;shift 1 to restore Q15 format
;add offset value
LACC rmp_out
ADD rmp_offset
SACL rmp_out
RET
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -