⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svgen_mf.asm

📁 TI的digital motor control lib的源代码。了解TI的编程规范
💻 ASM
📖 第 1 页 / 共 4 页
字号:
;=====================================================================================
; File name:        SVGEN_MF.ASM                       
;                    
; Originator:	Digital Control Systems Group
;			Texas Instruments
;
; Description:                                 
; This file contains source for the Space Vector generation routine.
;=====================================================================================
; History:
;-------------------------------------------------------------------------------------
; 9-15-2000	Release	Rev 1.0
;================================================================================
; Applicability: F240,F241,C242,F243,F24xx.  (Peripheral Independant).
;
;
;================================================================================
; Routine Name: Space Vector Function Generator.        Routine Type: C Callable
;
; Description:
;  
;  C prototype : int Space_Vector_Gen (SVGEN *p)
;================================================================================
; History     Created Dec 29, 1999.
;
; Definition of SVGENMF:
;
; typedef struct SVGENMF {   int gain;
;                       int freq;
;                       int freq_max;
;                       int alpha;
;                       int sector_ptr
;                       int va;
;                       int vb;
;                       int vc;
;                       (int (*)(int))Space_Vector_Gen_MF
;                       };
;
;       Frame Usage Details:
;            |      a      |      b                     |   c           d     
;____________|_____________|____________________________|_______________________
;       FR0  |  step_angle |                            |
;       FR1  |  entry_old  |  (sector_routine_ address) |
;       FR2  |  entry_new  |                            |
;       FR3  |  dy         |                            |
;       FR4  |  dx         |                            |

;================================================================================                       

                .def        _svgenmf_calc
;================================================================================
_svgenmf_calc:

__SVGEN_framesize .set 0005h
;================================================================================
                     POPD        *+
                SAR        AR0,*+
                SAR        AR1,*
                LARK        AR0,__SVGEN_framesize
                LAR        AR0,*0+,AR0
;--------------------------------------------------------------------------------
                SPM     1       ; set product mode to shift left one bit.
                SETC        SXM
;================================================================================
                SBRK        #3        ; Point AR0 to the first argument.
                                ; This is a pointer to the SVGEN_DATA.
;--------------------------------------------------------------------------------
                LAR        AR2,*        ; get the pointer in AR2.
;--------------------------------------------------------------------------------
                ADRK    #3      ; point AR0 back to FR0
;--------------------------------------------------------------------------------
                MAR     *,AR2   ; ARP=AR2. AR0->FR0 and AR2->gain.
;--------------------------------------------------------------------------------
                ADRK    #1      ; point AR2 to freq.
                                ; ARP=AR2. AR0->FR0 and AR2->freq.
;--------------------------------------------------------------------------------
                LT      *+      ; get freq
                                ; also incr AR2 to point to freq_max
                                ; ARP=AR2. AR0->FR0 and AR2->freq_max.
;--------------------------------------------------------------------------------
                MPY     *+,AR0  ; product reg = freq*freq_max
                                ; P = Q0 x Q15 = Q15 in 32 bits.
                                ; also incr AR2 to point to alpha
                                ; ARP=AR0. AR0->FR0 and AR2->alpha.
;--------------------------------------------------------------------------------
                PAC             ; get product in ACC.
                                ; ARP=AR2. AR0->FR1 and AR2->alpha.
;--------------------------------------------------------------------------------
                SACH    *+,AR2  ; store the product = step_angle in FR0.
                                ; Also incr AR0 to point to FR1.
                                ; ARP=AR2. AR0->FR1 and AR2->alpha.
;--------------------------------------------------------------------------------
                LACC    *,8,AR0 ; create entry_old from alpha_previous.
                                ; ARP=AR0. AR0->FR1 and AR2->alpha.
                AND     #00ffh,16
;--------------------------------------------------------------------------------
                SACH    *-      ; store the entry_old in FR1.
                                ; also decrement AR0 to point to FR0.
                                ; ARP=AR0. AR0->FR0 and AR2->alpha.
;--------------------------------------------------------------------------------
                LACC    *,AR2   ; get step_angle
                                ; ARP=AR2. AR0->FR0 and AR2->alpha.
                                ; Alpha still previous value.
;--------------------------------------------------------------------------------
                ADD     *       ; add to get new alpha.
                SACL    *       ; store to alpha.
                                ; ARP=AR2. AR0->FR0 and AR2->alpha (new value).
;--------------------------------------------------------------------------------
                LACC    *+,8,AR0 ; create entry_new from alpha_new.
                                ; increment AR2 to point to sector_ptr.
                                ; ARP=AR0. AR0->FR0 and AR2->sector_ptr.
                AND     #00ffh,16
;--------------------------------------------------------------------------------
                ADRK    #2      ; increment AR0 to point to FR2. 
                                ; ARP=AR0. AR0->FR2 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                SACH    *       ; store entry_new.
                                ; ARP=AR0. AR0->FR2 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                LACC    #_SINE_TABLE_60
                ADD     *+      ; get base+offset to sine table for dy.
                                ; also incr AR0 to point to FR3.
                                ; ARP=AR0. AR0->FR3 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                TBLR    *-      ; get dy in FR3. dy=sin(ALPHA)
                                ; also decrement AR0 to point back to entry_new.
                                ; ARP=AR0. AR0->FR2 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                LACC    #0ffh   ; get end of table offset.
;--------------------------------------------------------------------------------
                SUB     *       ; get ACC = 0ffh - entry_new
                                ; AR0 still pts to entry_new.

                                ; ARP=AR0. AR0->FR2 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                ADD    #_SINE_TABLE_60
                                ; add the base of the table.
                                ; ARP=AR0. AR0->FR2 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                ADRK    #2      ; incr AR0 to point to FR4
                                ; ARP=AR0. AR0->FR4 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                TBLR    *       ; get dx in FR4. dx=sin(60-ALPHA).
                                ; ARP=AR0. AR0->FR4 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                SBRK    #2      ; point AR0 back to FR2 (entry_new).
                                ; ARP=AR0. AR0->FR2 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                LACC    *-      ; ACC=entry_new.
                                ; also decrement AR0 to point to entry_old.
                                ; ARP=AR0. AR0->FR1 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                SUB     *,AR2   ; ACC=entry_new-entry_old.
                                ; ARP=AR2. AR0->FR1 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                BCND    __SVGEN_Branch_Sr, GEQ
                                ; if greater than or eq. to 0 skip sector incr.
;--------------------------------------------------------------------------------
__SVGEN_Modify_Sr_Ptr:
                                ; AR2 points to sector_ptr.
                LACC    *       ; get sector_ptr.
                                ; ARP=AR2. AR0->FR1 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                SUB     #05h    ; 
                                ; ARP=AR2. AR0->FR1 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                BCND    __SVGEN_Reset_Sr_Ptr,EQ
                                ; ARP=AR2. AR0->FR1 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                LACC    *       ; get sector_ptr.
                                ; ARP=AR2. AR0->FR1 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                ADD     #1      ; increment sector_ptr.
                                ; ARP=AR2. AR0->FR1 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                SACL    *       ; store sector_ptr.
                                ; ARP=AR2. AR0->FR1 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                B       __SVGEN_Branch_Sr
                                ; ARP=AR2. AR0->FR1 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
__SVGEN_Reset_Sr_Ptr:
                SPLK    #0,*    ; sector_ptr=0.
                                ; ARP=AR2. AR0->FR1 and AR2->sector_ptr.
;--------------------------------------------------------------------------------
                ; On getting here ARP=AR2. AR0->FR1 and AR2->sector_ptr.
__SVGEN_Branch_Sr:   
               
                LACC    #_SVGEN_SECTOR_TABLE
;--------------------------------------------------------------------------------
                ADD     *,AR0   ; add sector_ptr and
                                ; ARP=AR0. AR0->FR1 and AR2->sector_ptr
;--------------------------------------------------------------------------------
                TBLR    *       ; get sector routine address in FR1.
                                ; ARP=AR0. AR0->FR1 and AR2->sector_ptr
;--------------------------------------------------------------------------------
                LACC    *       ; get sector routine address in FR1.
                                ; ARP=AR0. AR0->FR1 and AR2->sector_ptr
;--------------------------------------------------------------------------------
                ADRK    #2      ; move AR0 to point to FR3
                                ; ARP=AR0. AR0->FR3 and AR2->sector_ptr
;--------------------------------------------------------------------------------

⌨️ 快捷键说明

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