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

📄 ad.asm

📁 max125采集芯片在tms320vc33上的联合应用汇编原创代码
💻 ASM
📖 第 1 页 / 共 2 页
字号:
                         .copy "c3x.inc"
                         .def  _c_int01
                         .def  _c_int02
                         
                         .global _Max125_start
                         .global _Max125_init
                         .global _Max125_states
                         .global _Max125_end
BUFFERSIZE    .set     010H
FP          .set  AR3             ;frame pointer
********************************************************************************
*ADstate_Buffer:?                                                              *
*                第0个参数:  第一个MAX125的通路数                              *
*                第1个参数:  第二个MAX125的通路数                              *
*                第2个参数:  第三个MAX125的通路数                              *
*                第3个参数:  第四个MAX125的通路数                              *
*                第4个参数:  AD采样的次数                                  *
*                第5个参数:  AD采样的地址                                      *
*                第6个参数:  AD已经采过的次数                                  *
*                第7个参数:  ADBUFFERR的未地址                                 *
*                第8个参数:  ADBUFFERR的满                                     *
*                第9个参数:  AD采样的完成                                      *
*                第10个参数: AD采样方式                                        *
*                第11个参数: A部还是B部启动                                    * 
*                第12个参数: AD是否继续启动                                    *
*                第13个参数: ADBUFFERR半满                                     *
*                第14个参数: ADBUFFERR的半满地址                               *                           
*                第15个参数: 满或半满判断位                                    *
********************************************************************************
ADstate_Buffer   .usect  ".buffer3",BUFFERSIZE
Command_Buffer   .usect  ".command",BUFFERSIZE
Hostset_Buffer   .usect  ".hostset",BUFFERSIZE   
addatabsize      .set   0200H
addatabhsize     .set   0100H
ADdata_Buffer   .usect  ".buffer1",(addatabsize+01000H)                        
                          
             .data
max1251         .set   0900000H
dac11           .word   0a00000H
ldac            .word   0900004H
;HMAILBOX        .set     04e8H   ;  only read
;pcibase         .word    0400000H
zero		    .word  000000000H    ;the zero
max1252         .word    0900001H
max1253         .word    0900002H
max1254         .word    0900003H
adstart         .word    0b00004H
mask14l         .word    0003fffH
mask1l          .word    0000001H
adcmd           .word    0b00006H
syscmd          .word    0b00003H
wdst            .word    0b00002H
vc33mmr         .word    C3x_MMR
adstate         .word    ADstate_Buffer
addata          .word    ADdata_Buffer
commandb        .word    Command_Buffer
MAX125          .word    max1251
htolmailbox     .word    040013Ah
lint            .word    040013Dh
              
                         
                         .text
*********************************************************************************
*										                    *
* 函数定义:Max125_init					   		                  *
* 功  能:初始化MAX125				                                        *
*										                                        *
* 入口参数:AR2	  ---- 第一个MAX125的通路数					           		    *		       
*      R2	  ---- 第二个MAX125的通路数                                     *
*           R3    ---- 第三个MAX125的通路数                                     *
*           RC    ---- 第四个MAX125的通路数			                            *
*           RS    ---- AD中断选择                                               *
* 出口参数:无						                                            *
*		      						                                            *
* 资源使用:AR0,R1								                                *
*										                                        *
*********************************************************************************
_Max125_init:
         .if .REGPARM = 0        ;standard runtime model
                PUSH FP          ;save the old FP
                LDI  SP,FP       ;point to top of stack
                LDI *-FP(2),AR2  ;load the first argument to ar2
                LDI *-FP(3),R2   ;load the sencond argument to  r2
                LDI *-FP(4),R3   ;load the third argument to r3
                LDI *-FP(5),RC   ;load the fourth argument to rc
                LDI *-FP(6),RS   ;load the fifth argument to rs
         .endif                  ;both runtime models 
         .if .BIGMODEL
                PUSH DP
                LDP  max1251
         .endif      
              PUSH ST
              PUSH AR0
              PUSH R1
              PUSHF R1
              LDI @vc33mmr,AR0
              LDI (INT_RDY+WAIT_3+BANK_8M),R1
              STI R1,*+AR0(STRB0)              ;为系统加入3个等待
              LDI AR2,R1
              LDI @adstate,AR0
              LDI *+AR0(10),R1
              BNZ bpart
              
              LDI AR2,R1
              STI R1,*+AR0(0)                  ;保存第一个MAX125的通路数
              STI R2,*+AR0(1)                  ;保存第二个MAX125的通路数
              STI R3,*+AR0(2)                  ;保存第三个MAX125的通路数
              STI RC,*+AR0(3)                  ;保存第四个MAX125的通路数
              B  adset
bpart:        LDI AR2,R1
              SUBI 4,R1
              STI R1,*+AR0(0)                  ;保存第一个MAX125的通路数
              LDI R2,R1
              SUBI 4,R1
              STI R1,*+AR0(1)                  ;保存第二个MAX125的通路数
              LDI R3,R1
              SUBI 4,R1
              STI R1,*+AR0(2)                  ;保存第三个MAX125的通路数
              LDI RC,R1
              SUBI 4,R1
              STI R1,*+AR0(3)                  ;保存第四个MAX125的通路数
              
              
adset:        LDI AR2,R1
			  LDI @MAX125,AR0
              SUBI 1,R1
              STI R1,*AR0++                    ;设置第一个MAX125的通路数
              SUBI 1,R2
              STI R2,*AR0++                    ;设置第二个MAX125的通路数
              SUBI 1,R3
              STI R3,*AR0++                    ;设置第三个MAX125的通路数
              SUBI 1,RC
              STI RC,*AR0++                    ;设置第四个MAX125的通路数
              
              LDI @adstate,AR0
              LDI @addata,R1              	   ;设定ADdata_Buffer的首地址
              STI R1,*+AR0(5)
              ADDI (addatabsize),R1
              STI R1,*+AR0(7)                  ;设定ADdata_Buffer的未地址
              LDI @addata,R1
              ADDI (addatabhsize),R1           ;设定ADdata_Buffer的半满地址
              STI R1,*+AR0(14)
              STI R1,*+AR0(15)                 ;设定ADdata_Buffer的判断地址 
              LDI 0,R1
              STI R1,*+AR0(6)                  ;设置AD已经采过的次数为"0"
              STI R1,*+AR0(8)                  ;设定ADdata_Buffer未満
               
              ;OR (GIE),ST 					   ;使能全局中断
              
              PUSH RS
              LDI @MAX125,AR0                   ;重读AD
              LDI 04,RC  
              RPTB adread
              LDI *AR0,R1
              LDI *+AR0(1),R1
              LDI *+AR0(2),R1
              LDI *+AR0(3),R1
adread:       NOP
			  POP RS
			  LDI @vc33mmr,AR0
              LDI (INT_RDY+WAIT_5+BANK_8M),R1
              STI R1,*+AR0(STRB0)              ;为系统加入3个等待
              
              LDI @adcmd,AR0                   ;AD中断选择
              LDI RS,R1
              STI R1,*AR0
              NOP
              NOP
              
              LDI @vc33mmr,AR0
              LDI (INT_RDY+WAIT_1+BANK_8M+HLD),R1
              STI R1,*+AR0(STRB0)              ;为系统加入1个等待
              POPF R1
              POP R1
              POP AR0
              POP ST                      
	     .if .BIGMODEL
              POP DP
         .endif
         .if .REGPARM = 0                      ;standard runtime model 
              POP FP                           ;restore FP
         .endif	        
              RETS                         
*********************************************************************************
*										                    *
* 函数定义:Max125_start					   		             ?*?
* 功  能:初始化MAX125与定时器				                                *
*										                                        *
* 入口参数:AR2	  ----?AD启动的工作方式 					           		    *		       
*      R2	  ---- 定时采样的周期值                                         *
*           R3    ----  采样次数                                                *
* 出口参数:无						                                            *
*		      						                                            *
* 资源使用:AR1,R1								                                *
*										                                        *
*********************************************************************************
_Max125_start:
         .if .REGPARM = 0        ;standard runtime model
                PUSH FP          ;save the old FP
                LDI  SP,FP       ;point to top of stack
                LDI *-FP(2),AR2  ;load the first argument to ar2
                LDI *-FP(3),R2   ;load the sencond argument to  r2
                LDI *-FP(4),R3   ;load the third argument to r3
         .endif                  ;both runtime models 
         .if .BIGMODEL
                PUSH DP
                LDP  max1251
         .endif
         	   PUSH ST      
               PUSH AR1
               PUSH AR2
               PUSH R1
               PUSHF R1
               PUSH AR0
               LDI @adstate,AR1                ;设定采样次数
               STI R3,*+AR1(4)
               LDI AR2,R1
               STI R1,*+AR1(10)                ;设定采样方式
               LDI @vc33mmr,AR0
               LDI (INT_RDY+WAIT_3+BANK_8M),R1
               STI R1,*+AR0(STRB0)              ;为系统加入1个等待
               LDI AR2,R1
               BNZ adsoft
               LDI @vc33mmr,AR1                 ;启动定时器
               STI R2,*+AR1(TIM0_PD)
               LDI 0,R1
               STI R1,*+AR1(TIM0_CT)
               STI R1,*+AR1(TIM0_CTRL)
               LDI (FUNC+CP+GO+CLKSRC+HLD),R1
               STI  R1,*+AR1(TIM0_CTRL)
                           
               OR (EINT0_CPU),IE  				
               ;OR	(ETINT0_CPU),IE        		;我认为应该是启动定时器0
               IACK @zero
               nop
               nop
               nop
               nop
               nop
*               b $                        
               POP AR0
               POPF R1
               POP  R1
               POP  AR2
               POP  AR1
               POP  ST 
         .if .BIGMODEL
              POP DP
         .endif
          .if .REGPARM = 0                      ;standard runtime model 
         POP FP                                 ;restore FP
         .endif	       
               RETS     
adsoft:       LDI @syscmd,AR1                 ;设定工作方式              
              LDI AR2,R1
              NOP
              NOP
              NOP
              NOP
              STI R1,*AR1
              LDI @vc33mmr,AR0
              LDI (INT_RDY+WAIT_3+BANK_8M),R1
              STI R1,*+AR0(STRB0)              ;为系统加入3个等待
*              LDI @wdst,AR0
*              STI R1,*AR0
*              NOP
*              NOP
*             NOP
              LDI @adstart,AR1                 ;软件单次启动AD
              STI R1,*AR1
*              b $-2
              OR (EINT0_CPU),IE 
*              XOR IF,IF
*
               POP AR0
               POPF R1
               POP  R1
               POP  AR2
               POP  AR1
               POP  ST
         .if .BIGMODEL
              POP DP
         .endif
          .if .REGPARM = 0                      ;standard runtime model 
         POP FP                                 ;restore FP
         .endif	
         RETS                             
*********************************************************************************
*										                    *
* 函数定义:Max125_states					   		              *
* 功  能:初始化MAX125		1		                                        *
*										                                        *
*                                                                               *
* 出口参数:AD的工作状态                                                        *
*		      						                                            *
* 资源使用:AR0,R1								                                *
*										                                        *
*********************************************************************************
_Max125_states:
            .if .REGPARM = 0        ;standard runtime model
                PUSH FP          ;save the old FP
                LDI  SP,FP       ;point to top of stack
         .endif                  ;both runtime models 

⌨️ 快捷键说明

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