📄 cmpprg_1.asm
字号:
;;************************************************************************
;;************************************************************************
;;
;; CMPPRG.asm
;;
;; Assembler source for Continuous Time Programmable Comparator
;;
;; Rev B, 2002 MAR 30
;;
;; Copyright (c) 2000 Cypress Microsystems, Inc. All rights reserved.
;;
;;************************************************************************
;;************************************************************************
;;
export CMPPRG_1_Start
export _CMPPRG_1_Start
export CMPPRG_1_SetPower
export _CMPPRG_1_SetPower
export CMPPRG_1_SetRef
export _CMPPRG_1_SetRef
export CMPPRG_1_Stop
export _CMPPRG_1_Stop
;; -----------------------------------------------------------------
;; Register Definitions
;; -----------------------------------------------------------------
;;
;; Uses 1 Continuous Time Block configured as shown. This API depends
;; on knowing the exact personalization of CR0 and CR2 bitfields
;; for time efficiency.
;;
;; * 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
;; ----------------- ----- --------------------
;; COMP_CR0.RES_RATIO_T2B F0/* User Parameter (by table)
;; COMP_CR0.GAIN_ATTEN 08/0 Gain
;; COMP_CR0.RES_SOURCE 04/0 Res source VDD
;; COMP_CR0.RES_REF 03/* User Parameter
;;
;; COMP_CR1.A_OUT 80/0 Output bus disabled
;; COMP_CR1.COMP_EN 40/* User Parameter (init: ENABLE)
;; COMP_CR1.CT_NEG_INPUT_MUX 38/4 Neg mux to analog f.b. tap
;; COMP_CR1.CT_POS_INPUT_MUX 07/* User Parameter (Input selection)
;;
;; COMP_CR2.CP_COMP 80/0 Latch transparent on PH1
;; COMP_CR2.CK_COMP 40/0 Latch transparent
;; COMP_CR2.CC_COMP 20/0 Mode Comparator (not OP-amp)
;; COMP_CR2.BYPASS_OBUS 1C/0 Bypass OFF
;; COMP_CR2.PWR_SELECT 03/0 Power OFF at start-up
include "CMPPRG_1.inc"
include "m8c.inc"
POWERMASK: equ 03h
REFMASK: equ f0h
;; -----------------------------------------------------------------
;; Start/SetPower - Applies power setting to the module's PSoC blocks
;;
;; INPUTS: A contains the power setting 0=Off, 1=Low, 2=Med, 3=High
;; OUTUTS: None
;; -----------------------------------------------------------------
CMPPRG_1_Start:
_CMPPRG_1_Start:
CMPPRG_1_SetPower:
_CMPPRG_1_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[CMPPRG_1_COMP_CR2] ; read power value
and A, ~POWERMASK ; clear power bits in A
or A, [X] ; combine power value with balance of reg.
mov reg[CMPPRG_1_COMP_CR2], A
pop A
ret
;;---------------------------------------------------------------------------------
;; SetRef: Sets comparator threshold at specified ratio between Low Limit and Vcc
;; INPUTS: Reference Value from .inc file
;; OUTPUTS: None
;; Side Effects: Momentary gain glitch while Ref set to 1.0, then to new value
;;
;; Ref values shown are for example
;; 1.000 0 0 0 0
;; 0.937 0 0 0 1
;; ....
;; 0.500 0 1 1 1
;; ....
;; 0.062 0 0 0 0
;;--------------------------------------------------------------------------------
CMPPRG_1_SetRef:
_CMPPRG_1_SetRef:
and A, REFMASK ; mask A to protect unchanged bits
mov X, SP ; define temp store location
;
push A ; put reference value in temp store
mov A, reg[CMPPRG_1_COMP_CR0] ; read reference value and balance of reg
and A, ~REFMASK ; clear reference bits in A
or A, [X] ; combine reference value with balance of reg
mov reg[CMPPRG_1_COMP_CR0], A ; move complete value back to register
pop A
ret
;; -----------------------------------------------------------------
;; Stop - Cuts power to the user module.
;;
;; INPUTS: None
;; OUTPUTS: None
;; -----------------------------------------------------------------
CMPPRG_1_Stop:
_CMPPRG_1_Stop:
and reg[CMPPRG_1_COMP_CR2], FCh
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -