sin-cos.asm
来自「此源代码用于电力电子逆变器的同步锁相实现」· 汇编 代码 · 共 51 行
ASM
51 行
;===========================================================================
; File Name: sin_cos.asm
;
; Module Name: SIN_COS
;
;
;===========================================================================
;(To use this Module, copy this section to main system file)
;===========================================================================
.ref SINTAB_360
;===========================================================================
.include "x24x_app.h"
t_ptr .usect "sin_cos" ,1
sin_theta .usect "sin_cos" ,1
cos_theta .usect "sin_cos" ,1
;=================================================================================
SIN-COS:
;-----------------------------------
;Calculate Cos(theta_p)
;Normal precision with simple 1024 word look-up
ldp #theta_ip
LACC theta_ip
ADD #8192 ;add 90 deg, i.e. COS(A)=SIN(A+90)
AND #07FFFh ;Force positive wrap-around
SACL GPR0_ipark ;here 90 deg = 7FFFh/4
LACC GPR0_ipark,9
SACH t_ptr
LACC #SINTAB_360
ADD t_ptr
TBLR cos_theta ;cos_theta = Cos(theta_p) in Q15
;-----------------------------------
;Calculate Sin(theta_p)
;Lower precision simple 1024 word look-up
LACC theta_ip,9
SACH t_ptr
LACC #SINTAB_360
ADD t_ptr
TBLR sin_theta ;sin_theta = Sin(theta_p) in Q15
;-----------------------------------
RET
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?