📄 rfft_magc.asm
字号:
;============================================================================
;
; File Name : rfft_magc.asm
;
; Originator : Digital Control Systems Group
; Texas Instruments
;
; Description : This file contains source code to compute the magnitude square
; of complex spectral bins for Real FFT modules
;
; Date : 26/4/2001 (dd/mm/yyyy)
;===========================================================================
; Routine Type : C Callable
;
; Description :
; void FFTR_win(FFTxxxR_handle)
; This function computes magnitude square of the complex spectral bins, produced by
; the Real FFT modules. Allows in-place and off-place storage of the magnitude square results.
;======================================================================
; REAL FFT MODULES
;----------------------------------------------------------------------
;typedef struct {
; int *ipcbptr;
; int *magptr;
; int peakmag;
; int peakfrq;
; int normflag;
; int size;
; int *winptr;
; void (*init1)(void);
; void (*init2)(void);
; void (*calc)(void *);
; void (*split)(void *);
; void (*mag)(void *);
; void (*win)(void *);
; }FFTxxxR;
;======================================================================
; Function Local Frame
;======================================================================
; |_______|
; |_______|<- Stack Pointer (FP+1) <---AR1
; |_______|<- Reg to Reg Tfr (FP) <---AR0
; |_______|<- Old FP (AR0) (FP-1)
; |_______|<- Return Address of the Caller (FP-2)
; |_______|<- Module Handle (FP-3)
;
;======================================================================
MAGQFMT .set 14 ; Magnitude Q Format (15 or 14)
__FFT_mag_frs .set 00001h ; Local frame size for this routine
.def _FFTR_mag ;
_FFTR_mag:
POPD *+ ; Store the Return Address in stack
SAR AR0,*+ ; Store the Caller's Frame Pointer
SAR AR1,*
LAR AR0,#__FFT_mag_frs
LAR AR0,*0+,AR2 ; Create Local frame
SETC SXM
SPM #0
LAR AR2,#0FFFDh ; ARP=AR2, AR2=-3
MAR *0+ ; ARP=AR2, AR2=FP-3->FFTxxxC_handle
LAR AR2,* ; ARP=AR2, AR2=FFTxxxC_handle->ipcbptr
LAR AR4,*+ ; ARP=AR2, AR2->magptr, AR4=ipcbptr
LAR AR3,* ; ARP=AR2, AR2->magptr, AR3=magptr
ADRK #4h ; ARP=AR2, AR2->size
LAR AR5,* ; ARP=AR2, AR2->size, AR5=size
SBRK #4h ; ARP=AR2, AR2->magptr
MAR *,AR4 ; ARP=AR4, AR4=ipcbptr, AR5=size
; Compute the magnitude square of N+1 Spectral bins
MAG_LP: LACC #0000 ; Clear ACC
MPY #0 ; Clear PREG
SQRA *+ ; Q15*Q15=Q30
SQRA *+,AR3 ; Q15*Q15+Q30=Q30
APAC ; Q15*Q15+Q30=Q30
SACH *+,(MAGQFMT-14),AR5 ; Store in MAGQFMT
BANZ MAG_LP,*-,AR4
;---------------------------------------------------------------------------------------------
; The results from FFT may be very small, if the signal power is less. As a result, the
; magnitudes of the FFT are normalised so that the maximum magnitude is represented as 0x7fffh
;---------------------------------------------------------------------------------------------
MAR *,AR2 ; ARP=AR2, AR2->magptr
LAR AR3,*+ ; ARP=AR2, AR2->peakmag, AR3=magptr
SPLK #0000h,* ; ARP=AR2, AR2->peakmag, peakmag=0
ADRK #3 ; ARP=AR2, AR2->size
LAR AR5,* ; ARP=AR2, AR2->size, AR5=size
SBRK #3 ; ARP=AR2, AR2->peakmag
MAR *,AR3 ; ARP=AR3, AR3=magptr, AR5=size
LAR AR4,#0FFFFh ; ARP=AR3, AR3=magptr, AR4=FFFF
;Following section finds the maximum value among the FFT Magnitudes
FINDMAX: LACC *+,0,AR2
SUB *,AR4
MAR *+,AR5
BCND NEXTCMP,LEQ ;
MAR *,AR2 ; ARP=AR2, AR2->peakmag
ADD * ; ARP=AR2, AR2->peakmag
SACL *+ ; ARP=AR2, AR2->peakfrq
SAR AR4,*-,AR5 ; ARP=AR5, AR2->peakmag
NEXTCMP: BANZ FINDMAX,*-,AR3
MAR *,AR2 ; ARP=AR2, AR2->peakmag
ADRK #2 ; ARP=AR2, AR2->normflag
LACL *+ ; ARP=AR2, AR2->size, ACCL=normflag
BCND SKIPNORM,EQ ; Check normflag==0?
;Following Section normalizes the FFT amplitudes
LAR AR5,* ; ARP=AR2, AR2->size, AR5=size
SBRK #4 ; ARP=AR2, AR2->magptr
LAR AR3,*+,AR3 ; ARP=AR3, AR3=magptr, AR5=size, AR2->peakmag
NEXTNORM: LACC *,15,AR2 ; ARP=AR2, AR2->peakmag
RPT #15
SUBC *
MAR *,AR3
SACL *+,0,AR5
BANZ NEXTNORM,*-,AR3
;The following section corrects the value obtained when the maximum value is divided
;by itself. change 8000h to max Q15 value of 7fffh
MAR *,AR2 ; ARP=AR2, AR2->peakmag
SBRK #1 ; ARP=AR2, AR2->magptr
LAR AR3,* ; ARP=AR2, AR2->magptr, AR3=magptr
ADRK #4 ; ARP=AR2, AR2->size
LAR AR5,*,AR3 ; ARP=AR3, AR3=magptr, AR5=size
NEXTVAL: LACC *
SUB #8000h
BCND POSSAT,NEQ
LACC #0FFFFh
POSSAT: ADD #8000h
SACL *+,0,AR5
BANZ NEXTVAL,*-,AR3
SKIPNORM: MAR *,AR1
SBRK #(__FFT_mag_frs+1) ; Clear the local frame
LAR AR0,*- ; Retrive Caller's frame pointer
PSHD * ; Push the return address to TOS
RET
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -