impulse.asm

来自「TI公司24X系列DSP控制无刷直流电机」· 汇编 代码 · 共 72 行

ASM
72
字号
;===========================================================================
; File Name:	impulse.asm
;
; Module Name: 	IMPULSE				     
;
; Initialization Routine: IMPULSE_INIT
;
; Originator:	Digital Control Systems Group
;			Texas Instruments
;
; Description:	This module implements a periodic impulse function. The 
;		output variable ig_out is set to 7FFF for 1 sampling period. 
;		The period of the output signal ig_out is specified by the 
;		input ig_period.
;
;			|~~~~~~~~~~~~~~~|
;			| 		|
;    ig_period	o------>|   IMPULSE	|----->o  ig_out
;			|		|
;			|_______________|
;
;
;
;=====================================================================================
; History:
;-------------------------------------------------------------------------------------
; 9-15-2000	Release	Rev 1.00
;=============================================================================
;(To use this Module, copy this section to main system file)
;		.ref	IMPULSE, IMPULSE_INIT			;function call
;		.ref	ig_period, ig_out			;Input/output
;=============================================================================
;Module definitions for external reference.
		.def	IMPULSE, IMPULSE_INIT			;function call
		.def	ig_period, ig_out			;Input/output

;=============================================================================
		.include	x24x_app.h
;=============================================================================
;Variable Definitions for impulse module
;-----------------------------------------------------------------------------

ig_skp_cnt	.usect	"impulse",1	;
ig_period	.usect	"impulse",1	;Time period for ig_out 
ig_out		.usect	"impulse",1	;Impulse output ig_out

;=============================================================================
IMPULSE_INIT:
;=============================================================================
		LDP	#ig_out
		SPLK	#0h, ig_skp_cnt
		SPLK	#1000h, ig_period		;default value
		RET

;=============================================================================
IMPULSE:
;=============================================================================
		LDP	#ig_out
		SPLK	#0h, ig_out	;always clear Impulse output on entry
		LACC	ig_skp_cnt	;check skip counter
		ADD	#1		;increment & store
		SACL	ig_skp_cnt
		SUB	ig_period
		BCND	IG_END, LT	;Skip setting Impulse high.
		SPLK	#7FFFh, ig_out
		SPLK	#0, ig_skp_cnt	;reset skip counter.
IG_END
		RET



⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?