📄 _pi_asm.asm
字号:
;/*****************************************************************************/
;/* */
;/* Author : Alann Denais */
;/* Infineon Technologies */
;/* */
;/*****************************************************************************/
;/* */
;/* Date : 02-2001 */
;/* */
;/* Execution Time 2.05us @ 40 MHz */
;/* */
;/* */
;/*****************************************************************************/
$MACRO
$CASE
$SEGMENTED
$include (Math.inc)
$MODINF (43)
NAME _PI_ASM
NCODE CGROUP ?PR?_PI_ASM
ASSUME DPP3 : SYSTEM
REGDEF R0 - R15
?PR?_PI_ASM SECTION CODE WORD 'NCODE'
; #include "PI.h"
;__________________________________________________________
; Function name :
; PI_Controller
;__________________
; Prototype :
; void PI_Controller(TPI * PI, int NewInput, int * Result);
;__________________
; Inputs:
; - PI structure
; - New input
;__________________
; Restriction :
; - the two coeficient must be bigger than 0x8001 and smaller 0x7FFF
;__________________
; Execute the PI controller
; NewError = SetValue - NewInput
; Integral = Integral + A0 * NewError + A1*Error
; Error = NewError
; if (High(Integral <<4)>Limit )
; *Result=Limit;
; else if (High(Integral <<4)<-Limit )
; *Result=-Limit;
; else
; *Result=High(Integral << 4);
; Return the PI output
;__________________
;__________________________________________________________
PI_Controller PROC NEAR
PUBLIC PI_Controller
MOV R3,[R8+] ; SetValue
MOV R4,[R8+] ; A0
MOV R5,[R8+] ; A1
MOV R6,[R8+] ; Limit
MOV R1,[R8+] ; Integral low
MOV R11,[R8+] ; Integral high
MOV R12,[R8] ; Error
%SUBS_Q15 (R3,R9) ; R3 = New error
%MADDS_Q31(R11, R1, R4, R3, R5, R12) ; (R11,R1) = Integral + A0 * NewError + A1*Error
MOV [R8],R3
MOV [-R8],R11
MOV [-R8],R1
%LSHIFTS_Q31(R11,R1)
%LIMIT_16 (R11,R6,R1)
MOV [R10],R11
RET
PI_Controller ENDP
?PR?_PI_ASM ENDS
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -