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

📄 f243ilg2.asm

📁 TI的digital motor control lib的源代码。了解TI的编程规范
💻 ASM
字号:
;=====================================================================================================================
; File name:       F243ILG2.ASM                     
;                    
; Originator:	Digital Control Systems Group
;			Texas Instruments
; Description:                                   
; This file contains source for a the F243 Two leg current measurement driver.
;=====================================================================================
; History:
;-------------------------------------------------------------------------------------
; 9-15-2000	Release	Rev 1.0
;================================================================================
;                            
; Applicability: F241,F243 : Peripheral Dependant
;                            ____________________
;
;================================================================================
; Routine Name: Generic function.        Routine Type: C Callable
;
; Description:
;  
;  C prototype : int F243_leg2_drv_read(ILEG2MEAS *p)
;
;
; typedef struct {      int gain_a,
;                       int offset_a,
;                       int out_a,
;                       int gain_b,
;                       int offset_b,
;                       int out_b,
;                       int ch_a,
;                       int ch_b,
;                       int (*init)(),
;                       int (*read)(); 
;               } ILEG2MEAS ;
;================================================================================
                .def        _F243_leg2_drv_read
;================================================================================
                .include ..\include\x24x.h
;================================================================================

__F243_leg2_drv_read_framesize .set 0001h
;================================================================================
_F243_leg2_drv_read:
                     POPD        *+
                SAR        AR0,*+
                SAR        AR1,*
                LARK        AR0,__F243_leg2_drv_read_framesize
                LAR        AR0,*0+,AR0
;================================================================================
                SBRK        #3        ; Point AR0 to the first argument.
;--------------------------------------------------------------------------------
                LAR     AR2,*        ; get the argument.
;--------------------------------------------------------------------------------
                ADRK    #3      ; Restore AR0
                                ; ARP=AR0, AR0->FR1, AR2->gain_a
;--------------------------------------------------------------------------------
                MAR     *,AR3   ; ARP=AR3, AR0->FR1, AR2->gain_a 
;--------------------------------------------------------------------------------
                LAR     AR3,#ADCTRL1
                                ; ARP=AR3, AR0->FR1, AR2->gain_a, AR3->ADC_CNTL1 
;--------------------------------------------------------------------------------
WAIT_ADC        BIT     *,BIT7  ; poll ADC Flag to wait for compl. of conv.
                                ; ARP=AR3, AR0->FR1, AR2->gain_a, AR3->ADC_CNTL1 
;--------------------------------------------------------------------------------
                BCND    WAIT_ADC,TC
                                ; ARP=AR3, AR0->FR1, AR2->gain_a, AR3->ADC_CNTL1 
                                ; Loop on the ADC Flag for completion 
;--------------------------------------------------------------------------------
                ADRK    #4      ; ARP=AR3, AR0->FR1, AR2->gain_a, AR3->ADCFIFO1
;--------------------------------------------------------------------------------
                LACC    *,AR0   ; Get the result of the conversion1.
                                ; ARP=AR0, AR0->FR1, AR2->gain_a, AR3->ADCFIFO1
;--------------------------------------------------------------------------------
                XOR     #8000h  ; Convert result to Q15.
                                ; ARP=AR0, AR0->FR1, AR2->gain_a, AR3->ADCFIFO1
;--------------------------------------------------------------------------------
                SACL    *       ; Store Q15 number in FR1
                                ; ARP=AR0, AR0->FR1, AR2->gain_a, AR3->ADCFIFO1
;--------------------------------------------------------------------------------
                LT      *,AR2   ; TREG= (out_a in q15 format).
                                ; ARP=AR2, AR0->FR1, AR2->gain_a, AR3->ADCFIFO1
;--------------------------------------------------------------------------------
                MPY     *+      ; Multiply by the gain in Q13 format.
                                ; Q15 x Q13 = Q28.
                                ; ARP=AR2, AR0->FR1, AR2->offset_a,AR3->ADCFIFO1
;--------------------------------------------------------------------------------
                PAC             ; PREG->ACC. 
                                ; ARP=AR2, AR0->FR1, AR2->offset_a,AR3->ADCFIFO1
;--------------------------------------------------------------------------------
                ADD     *+,13   ; Add in the offset to Q28 number.
                                ; ARP=AR2, AR0->FR1, AR2->out_a,   AR3->ADCFIFO1
;--------------------------------------------------------------------------------
          		NEG				; Positive direction, current flows to motor
;--------------------------------------------------------------------------------
                SACH    *+,3,AR3 ; ARP=AR3, AR0->FR1, AR2->gain_b, AR3->ADCFIFO1
;--------------------------------------------------------------------------------
                ADRK    #2      ;  ARP=AR3, AR0->FR1, AR2->gain_b, AR3->ADCFIFO2
;--------------------------------------------------------------------------------
                LACC    *,AR0   ; Get the result of the conversion2.
                                ; ARP=AR0, AR0->FR1, AR2->gain_b, AR3->ADCFIFO2
;--------------------------------------------------------------------------------
                XOR     #8000h  ; Convert result to Q15.
                                ; ARP=AR0, AR0->FR1, AR2->gain_b, AR3->ADCFIFO2
;--------------------------------------------------------------------------------
                SACL    *       ; Store Q15 number in FR1
                                ; ARP=AR0, AR0->FR1, AR2->gain_b, AR3->ADCFIFO2
;--------------------------------------------------------------------------------
                LT      *,AR2   ; TREG= (out_b in q15 format).
                                ; ARP=AR2, AR0->FR1, AR2->gain_b, AR3->ADCFIFO2
;--------------------------------------------------------------------------------
                MPY     *+      ; Multiply by the gain in Q13 format.
                                ; Q15 x Q13 = Q28.
                                ; ARP=AR2, AR0->FR1, AR2->offset_b, AR3->ADCFIFO2
;--------------------------------------------------------------------------------
                PAC             ; PREG->ACC. 
                                ; ARP=AR2, AR0->FR1, AR2->offset_b, AR3->ADCFIFO2
;--------------------------------------------------------------------------------
                ADD     *+,13   ; Add in the offset to Q28 number.
                                ; ARP=AR2, AR0->FR1, AR2->out_b,  AR3->ADCFIFO2
;--------------------------------------------------------------------------------
          		NEG				; Positive direction, current flows to motor
;--------------------------------------------------------------------------------
                SACH    *,3,AR1 ; ARP=AR1, AR0->FR1, AR2->out_b, AR3->ADCFIFO2
;--------------------------------------------------------------------------------
__F243_leg2_drv_read_exit:

                SBRK        #(__F243_leg2_drv_read_framesize+1)
                LAR        AR0,*-
                PSHD        *
                RET


⌨️ 快捷键说明

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