?? cursample.asm
字號(hào):
;-----------------------------------------------------------
;重慶大學(xué)DSP實(shí)驗(yàn)室
;函數(shù)名:void cursample(cursample_struct *p)
;函數(shù)功能:采樣電機(jī)相電流ia,ib,并轉(zhuǎn)換為Q12格式
;(以額定電流為基準(zhǔn))
;數(shù)字濾波方式:平均值濾波
;轉(zhuǎn)換公式:
; ix=Kcurrent*((result>>6)-512) (Q12)
; ;result 為電流平均值
; ;x=a, b
; Kcurrent=(4096*imax)/(512*ib) (Q0)
; ;選擇imax=(1.5V*33.33)/(27*50e-3)
; ;ib為額定電流峰值
;入口條件:
; result8--result11
; ;電流ia的AD轉(zhuǎn)換結(jié)果寄存器
; result12--result15
; ;電流ib的AD轉(zhuǎn)換結(jié)果寄存器
;出口條件:
; typedef struct
; { int zeropoint_ib;B相電流采樣提升零點(diǎn)
; int ib; ;B相電流值,Q12
; int zeropoint_ia;A相電流采樣提升零點(diǎn) Q0
; int ia; ;A相電流值,Q12
; }cursample_struct;
;請(qǐng)用戶在主程序中聲明以下函數(shù)和全局變量:
; typedef struct
; { int zeropoint_ib;B相電流采樣提升零點(diǎn)
; int ib; ;B相電流值,Q12
; int zeropoint_ia;A相電流采樣提升零點(diǎn) Q0
; int ia; ;A相電流值,Q12
; }cursample_struct;
; extern void cursample(cursample_struct *p);
;2002.4.16.
;-----------------------------------------------------------
.def _cursample
Kcurrent .set 1h ;Q0
cursample_frame .set 02h
.text
_cursample:
POPD *+
SAR AR0,*+
SAR AR1,*
LAR AR0,#cursample_frame
LAR AR0,*0+,AR0
LAR AR2,*,AR2
SBRK #3h
LAR AR3,*,AR2 ;AR3:zeropoint_ib
LAR AR2,#70B0h ;STACK:*p/address/AR0/AR1
;ARP:AR2, AR0:AR1, AR2:RESULT8
CLRC SXM
LACC #0
RPT #3
ADD *+,8 ;CALCULATE AVERAGE OF AD RESULT
MAR *,AR0 ;ARP:AR0
SACH *+,AR2 ;STACK:*p/ADDRESS/AR0/ia/y
;ARP:AR2, AR0:y, AR2:RESULT12
LACC #0
RPT #3
ADD *+,8 ;CALCULATE AVERAGE OF AD RESULT
MAR *,AR3
SETC SXM
SUB *+,16,AR0 ;STACK:*p/ADDRESS/AR0/ia/ib
;ARP:AR0, AR0:ib,
SACH *
LT *-,AR3 ;STACK:*p/ADDRESS/AR0/ia/ib
;ARP:AR0, AR0:ia, AR2:RESULT17
MPY #Kcurrent ;Kcurrent*ib
SPL *+,AR0 ;ib=Kcurrent*ib
LACC *,AR3
SUB *+,AR0
SACL * ;GETTING POSITIVE OR NEGATIVE VALUES OF ia
LT *,AR3 ;ARP:AR3
MPY #Kcurrent ;Kcurrent*ia
SPL *,AR1 ;ia=Kcurrent*ia
SBRK #(cursample_frame+1)
LAR AR0,*-
PSHD *
RET
.end
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -