📄 in_pga.asm
字号:
;;*****************************************************************************
;;*****************************************************************************
;; FILENAME: In_PGA.asm ( PGA )
;; Version: 3.1, Updated on 2003/11/18 at 15:01:43
;; Generated by PSoC Designer ver 4.1 BETA b923 : 11 December, 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 "In_PGA.inc"
include "m8c.inc"
;-----------------------------------------------
; Global Symbols
;-----------------------------------------------
export In_PGA_Start
export _In_PGA_Start
export In_PGA_SetPower
export _In_PGA_SetPower
export In_PGA_SetGain
export _In_PGA_SetGain
export In_PGA_Stop
export _In_PGA_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: In_PGA_Start
; FUNCTION NAME: In_PGA_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:
;
;-----------------------------------------------------------------------------
In_PGA_Start:
_In_PGA_Start:
In_PGA_SetPower:
_In_PGA_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[In_PGA_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[In_PGA_GAIN_CR2], A ; move complete value back to register
pop A
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: In_PGA_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:
;
;-----------------------------------------------------------------------------
In_PGA_SetGain:
_In_PGA_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[In_PGA_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[In_PGA_GAIN_CR3],~EXGAIN ; Clear High Gain bit.
or A, [X] ; combine gain value with balance of reg.
mov reg[In_PGA_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[In_PGA_GAIN_CR0], A ; move complete value back to register
or reg[In_PGA_GAIN_CR3], EXGAIN ; Set High Gain bit.
pop A
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: In_PGA_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:
;
;-----------------------------------------------------------------------------
In_PGA_Stop:
_In_PGA_Stop:
and REG[In_PGA_GAIN_CR2], ~POWERMASK
ret
.ENDSECTION
; End of File In_PGA.asm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -