📄 pga_out.asm
字号:
;;**********************************************************************
;;**********************************************************************
;;
;; PGA_A.ASM
;;
;; Assembler source for Programmable Gain Amplifier PGA_A
;;
;; Rev B, 2002 Mar 30
;;
;; Copyright (c) 2001-2002 Cypress Microsystems, Inc. All rights reserved.
;;
;;**********************************************************************
;;**********************************************************************
;;
export PGA_OUT_Start
export _PGA_OUT_Start
export PGA_OUT_SetPower
export _PGA_OUT_SetPower
export PGA_OUT_SetGain
export _PGA_OUT_SetGain
export PGA_OUT_Stop
export _PGA_OUT_Stop
;; -----------------------------------------------------------------
;; 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_OUT.inc"
include "m8c.inc"
POWERMASK: equ 03h
GAINMASK: equ f8h
;;---------------------------------------------------------------------
;; StartSetPower: Applies power setting to the module's PSoC block
;; SetPower: Applies power setting to the module's PSoC block
;; INPUTS: A contains the power setting 0=Off, 1=Low, 2=Med, 3=High
;; Value is loaded from .inc file
;; OUTPUTS: None
;;---------------------------------------------------------------------
PGA_OUT_Start:
_PGA_OUT_Start:
PGA_OUT_SetPower:
_PGA_OUT_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_OUT_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_OUT_GAIN_CR2], A ; move complete value back to register
pop A
ret
;;---------------------------------------------------------------------------------
;; SetGain:
;; INPUTS: Gain value and GAIN/ATTEN setting
;; Use gain set values from .inc file
;; OUTPUTS: None
;;
;; Gain values shown are for example
;; 16.0 1 0 0 0 0
;; 8.00 1 0 0 0 1
;; ....
;; 1.00 1 1 1 1 1
;; 0.93 0 1 1 1 0
;; ....
;; 0.12 0 0 0 0 1
;; 0.06 0 0 0 0 0
;;--------------------------------------------------------------------------------
PGA_OUT_SetGain:
_PGA_OUT_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_OUT_GAIN_CR0] ; read power value
and A, ~GAINMASK ; clear gain bits in A
or A, [X] ; combine gain value with balance of reg.
mov reg[PGA_OUT_GAIN_CR0], A ; move complete value back to register
pop A
ret
;;---------------------------------------------------------------------
;; Stop: Cuts power to the user module
;;
;; INPUTS: None
;; OUPTUTS: None
;;---------------------------------------------------------------------
PGA_OUT_Stop:
_PGA_OUT_Stop:
and REG[PGA_OUT_GAIN_CR2], ~POWERMASK
ret
;;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -