📄 adcinc.asm
字号:
;;*****************************************************************************
;;*****************************************************************************
;; FILENAME: ADCINC.asm
;; Version: 1.1, Updated on 2005/03/07 at 14:27:56
;; Generated by PSoC Designer ver 4.2 b1013 : 02 September, 2004
;;
;; DESCRIPTION: Assembler source for the ADCINC A/D Converter
;; User Module with 1st-order modulator.
;;
;; NOTE: User Module APIs conform to the fastcall16 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 2000-2004. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
include "m8c.inc"
include "memory.inc"
include "ADCINC.inc"
;-----------------------------------------------
; Global Symbols
;-----------------------------------------------
export ADCINC_Start
export _ADCINC_Start
export ADCINC_SetPower
export _ADCINC_SetPower
export ADCINC_Stop
export _ADCINC_Stop
export ADCINC_GetSamples
export _ADCINC_GetSamples
export ADCINC_StopADC
export _ADCINC_StopADC
export ADCINC_fIsDataAvailable
export _ADCINC_fIsDataAvailable
export ADCINC_iClearFlagGetData
export _ADCINC_iClearFlagGetData
export ADCINC_wClearFlagGetData
export _ADCINC_wClearFlagGetData
export ADCINC_cClearFlagGetData
export _ADCINC_cClearFlagGetData
export ADCINC_bClearFlagGetData
export _ADCINC_bClearFlagGetData
export ADCINC_iGetData
export _ADCINC_iGetData
export ADCINC_wGetData
export _ADCINC_wGetData
export ADCINC_bGetData
export _ADCINC_bGetData
export ADCINC_cGetData
export _ADCINC_cGetData
export ADCINC_fClearFlag
export _ADCINC_fClearFlag
export ADCINC_WritePulseWidth
export _ADCINC_WritePulseWidth
AREA bss (RAM,REL)
;-----------------------------------------------
; Constant Definitions
;-----------------------------------------------
;-----------------------------------------------
; Variable Allocation
;-----------------------------------------------
AREA UserModules (ROM, REL)
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: ADCINC_Start
;
; DESCRIPTION: Applies power setting to the module's analog PSoc block.
; and starts the PWM
;-----------------------------------------------------------------------------
;
; ARGUMENTS: The A register contains the power setting.
; RETURNS: Nothing.
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
ADCINC_Start:
_ADCINC_Start:
RAM_PROLOGUE RAM_USE_CLASS_1
call ADCINC_SetPower
ADCINC_RESET_INTEGRATOR_M
mov reg[ADCINC_PWMdr1],ffh
or reg[ADCINC_PWMcr0],01h ; start PWM
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: ADCINC_SetPower
;
; DESCRIPTION: Applies power setting to the module's analog PSoc block.
;-----------------------------------------------------------------------------
;
; ARGUMENTS: The A register contains the power setting.
; RETURNS: Nothing.
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
ADCINC_SetPower:
_ADCINC_SetPower:
RAM_PROLOGUE RAM_USE_CLASS_2
mov X,SP ; Set up Stack frame
and A,03h ; Ensure value is legal
push A
mov A,reg[ADCINC_AtoDcr3] ; First SC block:
and A,~03h ; clear power bits to zero
or A,[ X ] ; establish new value
mov reg[ADCINC_AtoDcr3],A ; change the actual setting
pop A
RAM_EPILOGUE RAM_USE_CLASS_2
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: ADCINC_Stop
;
; DESCRIPTION: Removes power from the module's analog PSoc block.
; and turns off PWM
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None.
; RETURNS: Nothing.
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
ADCINC_Stop:
_ADCINC_Stop:
RAM_PROLOGUE RAM_USE_CLASS_1
ADCINC_STOPADC_M
and reg[ADCINC_AtoDcr3], ~03h
and reg[ADCINC_PWMcr0], ~01h ; stop PWM
RAM_EPILOGUE RAM_USE_CLASS_1
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: ADCINC_GetSamples
;
; DESCRIPTION: Activates interrupts for this user module and begins sampling.
;-----------------------------------------------------------------------------
;
; ARGUMENTS: A register contain number of samples
; RETURNS: Nothing.
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
; the Large Memory Model. When necessary, it is the calling function's
; responsibility to perserve their values across calls to fastcall16
; functions.
;
; Currently only the page pointer registers listed below are modified:
; CUR_PP
;
ADCINC_GetSamples:
_ADCINC_GetSamples:
RAM_PROLOGUE RAM_USE_CLASS_4
RAM_SETPAGE_CUR >ADCINC_fMode
ADCINC_ENABLE_INTEGRATOR_M
mov [ADCINC_fMode],0
mov [ADCINC_bState],0
mov [ADCINC_bNumSamples],A
mov A, reg[ADCINC_PWMdr2]
jnz .SkipPulseWrite
mov reg[ADCINC_PWMdr2], 1
.SkipPulseWrite:
M8C_SetBank1
and reg[E7h], 3Fh ; if we are in 29xxx or 24x94
or reg[E7h], 40h ; then set to incremental Mode
M8C_SetBank0
ADCINC_STARTADC_M ;enable interrupt
RAM_EPILOGUE RAM_USE_CLASS_4
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: ADCINC_StopADC
;
; DESCRIPTION: Shuts down the A/D is an orderly manner. The interrupt
; is disabled but the PWM output is still active.
; Integrator is reset
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None.
; RETURNS: Nothing.
; SIDE EFFECTS:
; The A and X registers may be modified by this or future implementations
; of this function. The same is true for all RAM page pointer registers in
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -