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

📄 dacrng.s

📁 采用IAR在线调试ADI公司基于ARM7内核的ADUC7026的DAC代码
💻 S
字号:
;Filename: DacRng.s
;Part: ADuC7020,ADuC7024,ADuC7026.
;Created: 15/04/2004
;Updated: 28/06/2005
;Author: Eckart Hartmann.
;This file is in beta sampling.

#include        <ADuC702x.IAR.equ>

; DacRng==========Sets the output range of a DAC.
; C Function prototype: int DacRng(int iChan, int iRange);
;iChan:{0,1,2,3}        //DAC channel.
;iRange:{AVDD_RNG,INTREF_RNG,EXTREF_RNG,TS_RNG,ZERO_RNG}    //Reference.
; Description of Function: Sets the DAC output range.
; User interface: Set iChan to required channel.
;       Set iRange to one of the following symbolic constants:
;           AVDD_RNG    for range 0 to VDD.
;           INTREF_RNG  for internal reference. 
;           EXTREF_RNG  for external reference. 
;           TS_RNG      for tristate output.
;           ZERO_RNG    for output 0.
;           Call DacRng().
;               Selected range is set on selected channel.
;       Returns iRange.
; Robustness:  If iChan is invalid, wrong channel may be set.
;               If iRange is invalid, wrong range may be set.
; Side effects: If ZERO_RNG, clears /DACCLR in DACnCON else sets it.
;               Sets DACn pin to be a DAC output.
;               ZERO_RNG resets the DAC data register.
;               Corrupts r1, r2 and r3.
;

                RSEG CODE
                MODULE DacRng
                PUBLIC DacRng
                CODE32

DacRng: and     r0,r0,#3                ;Isolate channel bits.   
        ldr     r3,=GP0CON              ;Enable DAC pin.
        ldr     r2,[r3]
        mov     r3,#0x10
        mvn     r3,r3,LSL r0
        and     r2,r2,r3
        ldr     r3,=GP0CON
        str     r2,[r3]
        ldr     r3,=DAC0CON             ;r3 = &DACnCON.
        add     r3,r3,r0,LSL#3
        cmp     r1,#0x10                ;if(iRange==0x10)
        moveq   r2,#0                   ; range is zero.
        andne   r2,r1,#3                ;else
        orrne   r2,r2,#0x10             ; range is iRange|0x10.
        str     r2,[r3]                 ;Write to DACnCON.
        bx      lr                      ;return


                 ENDMOD DacRng 

                 END

⌨️ 快捷键说明

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