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

📄 pga_adc.asm

📁 测量脉搏的源码 Cypress公司使用 CY27443 完成相关的功能
💻 ASM
字号:
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME:   PGA_ADC.asm  ( PGA )
;;  Version: 3.0, Updated on 2003/08/27 at 14:03:13
;;  Generated by PSoC Designer ver 4.0 b865 : 27 August, 2003
;;
;;  DESCRIPTION:  PGA User Module software implementation file for the
;;                22/24/27xxx PSoC family of devices.
;;
;;  NOTE: User Module APIs conform to the fastcall convention for marshalling
;;        arguments and observe the associated "Registers are volatile" policy.
;;        This means it is the caller's responsibility to preserve any values
;;        in the X and A registers that are still needed after the API
;;        function returns. Even though these registers may be preserved now,
;;        there is no guarantee they will be preserved in future releases.
;;-----------------------------------------------------------------------------
;;  Copyright (c) Cypress MicroSystems 2003. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************

;; -----------------------------------------------------------------
;;                         Register Definitions
;;
;; Uses 1 Continuous Time Block configured as shown. 
;;
;; * For a Mask/Val pair, this indicates that the value is
;;   determined by the user either through config-time parameteriza-
;;   tion or run-time manipulation.
;;
;; BIT FIELD	         Mask/Val Function
;; -----------------    	----- 	--------------------
;; GAIN_CR0.RES_RATIO_T2B       F0/*    User Parameter (by table)
;; GAIN_CR0.GAIN_ATTEN          08/*    Gain (by table)
;; GAIN_CR0.RES_SOURCE          04/1    Res source to output
;; GAIN_CR0.RES_REF             03/*    Res ref 
;;
;; GAIN_CR1.A_OUT               80/*    User Parameter (Output bus)
;; GAIN_CR1.COMP_EN             40/0    Comparator bus disabled
;; GAIN_CR1.CT_NEG_INPUT_MUX    38/4    Neg mux to analog f.b. tap
;; GAIN_CR1.CT_POS_INPUT_MUX    07/*    Pos mux, typically to col. input mux
;;
;; GAIN_CR2.CP_COMP             80/0    Latch transparent on PH1
;; GAIN_CR2.CK_COMP             40/0    Latch transparent
;; GAIN_CR2.CC_COMP             20/1    Mode OP-AMP (not comparator)
;; GAIN_CR2.BYPASS_OBUS         1C/0    Bypass OFF
;; GAIN_CR2.PWR_SELECT          03/*    Power OFF (0h) at start-up
;;
;; --------------------------------------------------------------------

include "PGA_ADC.inc"
include "m8c.inc"


;-----------------------------------------------
;  Global Symbols
;-----------------------------------------------
export  PGA_ADC_Start
export _PGA_ADC_Start
export  PGA_ADC_SetPower
export _PGA_ADC_SetPower

export  PGA_ADC_SetGain
export _PGA_ADC_SetGain

export  PGA_ADC_Stop
export _PGA_ADC_Stop

;-----------------------------------------------
;  EQUATES
;-----------------------------------------------
POWERMASK:     equ 03h
GAINREGMASK:   equ f8h
GAINMASK:      equ fCh
HIGHGAIN:      equ 04h
HIGHGAINMASK:  equ 18h    
EXGAIN:        equ 01h

AREA UserModules (ROM, REL)
.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: PGA_ADC_Start
;  FUNCTION NAME: PGA_ADC_SetPower
;
;  DESCRIPTION:
;    Applies power setting to the module's PSoC block.
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;  A  Contains the power settings 0=Off, 1=Low, 2=Med, and 3=High
;
;  RETURNS:  NA
;
;  SIDE EFFECTS:
;     RESISTERS ARE VOLATILE:  THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
 PGA_ADC_Start:
_PGA_ADC_Start:
 PGA_ADC_SetPower:
_PGA_ADC_SetPower:

    and  A, POWERMASK                                 ; mask A to protect unchanged bits
    mov  X, SP                                        ; define temp store location
;
    push A                                            ; put power value in temp store
    mov  A, reg[PGA_ADC_GAIN_CR2]                          ; read power value
    and  A, ~POWERMASK                                ; clear power bits in A
    or   A, [X]                                       ; combine power value with balance of reg.
    mov  reg[PGA_ADC_GAIN_CR2], A                     ; move complete value back to register
    pop  A
    ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: PGA_ADC_SetGain
;
;  DESCRIPTION:
;    This function sets the Gain/Atten of the amplifier.  Valid gain settings
;    are defined in the .inc file.
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:
;    A  Contains gain settings.
;
;    Gain values shown are for example. (See .inc file for gain equates)
;
;  RETURNS:  NA
;
;  SIDE EFFECTS:
;     RESISTERS ARE VOLATILE:  THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
 PGA_ADC_SetGain:
_PGA_ADC_SetGain:

    and  A, GAINMASK                                       ; mask A to protect unchanged bits
    mov  X, SP                                             ; define temp store location
;
    push A                                                 ; put gain value in temp store
    mov  A, reg[PGA_ADC_GAIN_CR0]                          ; read mux settings
    and  A, ~GAINREGMASK                                   ; clear gain bits in A
    tst  [X],HIGHGAIN                                      ; See if High Gain is set
    jnz  .SETHIGHGAIN
    and  reg[PGA_ADC_GAIN_CR3],~EXGAIN                     ; Clear High Gain bit.
    or   A, [X]                                            ; combine gain value with balance of reg.
    mov  reg[PGA_ADC_GAIN_CR0], A                          ; move complete value back to register
    pop  A
    ret

.SETHIGHGAIN:
    and  [X],HIGHGAINMASK                                  ; Make sure we have a valid high gain
    or   A, [X]                                            ; combine gain value with balance of reg.
    mov  reg[PGA_ADC_GAIN_CR0], A                          ; move complete value back to register
    or   reg[PGA_ADC_GAIN_CR3], EXGAIN                     ; Set High Gain bit. 
    pop  A
    ret
.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: PGA_ADC_Stop 
;
;  DESCRIPTION:
;    Turns off the power to the amplifier.
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS: None
;
;  RETURNS:  NA
;
;  SIDE EFFECTS:
;     RESISTERS ARE VOLATILE:  THE A AND X REGISTERS MAY BE MODIFIED!
;
;  THEORY of OPERATION or PROCEDURE:
;
;-----------------------------------------------------------------------------
 PGA_ADC_Stop:
_PGA_ADC_Stop:

    and REG[PGA_ADC_GAIN_CR2], ~POWERMASK
    ret
.ENDSECTION
; End of File PGA_ADC.asm

⌨️ 快捷键说明

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