📄 carrier_timer.asm
字号:
;;*****************************************************************************
;;*****************************************************************************
;; FILENAME: Carrier_Timer.asm
;; Version: 2.2, Updated on 2003/11/10 at 16:40:54
;; Generated by PSoC Designer ver 4.1 BETA b923 : 11 December, 2003
;;
;; DESCRIPTION: Timer8 User Module software implementation file
;; for the 22/24/27/28xxx 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 2000-2003. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
include "m8c.inc"
include "Carrier_Timer.inc"
;-----------------------------------------------
; Global Symbols
;-----------------------------------------------
export Carrier_Timer_EnableInt
export _Carrier_Timer_EnableInt
export Carrier_Timer_DisableInt
export _Carrier_Timer_DisableInt
export Carrier_Timer_Start
export _Carrier_Timer_Start
export Carrier_Timer_Stop
export _Carrier_Timer_Stop
export Carrier_Timer_WritePeriod
export _Carrier_Timer_WritePeriod
export Carrier_Timer_WriteCompareValue
export _Carrier_Timer_WriteCompareValue
export Carrier_Timer_bReadCompareValue
export _Carrier_Timer_bReadCompareValue
export Carrier_Timer_bReadTimer
export _Carrier_Timer_bReadTimer
export Carrier_Timer_bReadTimerSaveCV
export _Carrier_Timer_bReadTimerSaveCV
; The following functions are deprecated and subject to omission in future releases
;
export bCarrier_Timer_ReadCompareValue ; deprecated
export _bCarrier_Timer_ReadCompareValue ; deprecated
export bCarrier_Timer_ReadTimer ; deprecated
export _bCarrier_Timer_ReadTimer ; deprecated
export bCarrier_Timer_ReadTimerSaveCV ; deprecated
export _bCarrier_Timer_ReadTimerSaveCV ; deprecated
export bCarrier_Timer_ReadCounter ; obsolete
export _bCarrier_Timer_ReadCounter ; obsolete
export bCarrier_Timer_CaptureCounter ; obsolete
export _bCarrier_Timer_CaptureCounter ; obsolete
AREA bss (RAM,REL)
;-----------------------------------------------
; Constant Definitions
;-----------------------------------------------
;-----------------------------------------------
; Variable Allocation
;-----------------------------------------------
AREA UserModules (ROM, REL)
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: Carrier_Timer_EnableInt
;
; DESCRIPTION:
; Enables this timer's interrupt by setting the interrupt enable mask bit
; associated with this User Module. This function has no effect until and
; unless the global interrupts are enabled (for example by using the
; macro M8C_EnableGInt).
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None.
; RETURNS: Nothing.
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
Carrier_Timer_EnableInt:
_Carrier_Timer_EnableInt:
Carrier_Timer_EnableInt_M
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: Carrier_Timer_DisableInt
;
; DESCRIPTION:
; Disables this timer's interrupt by clearing the interrupt enable
; mask bit associated with this User Module.
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None
; RETURNS: Nothing
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
Carrier_Timer_DisableInt:
_Carrier_Timer_DisableInt:
Carrier_Timer_DisableInt_M
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: Carrier_Timer_Start
;
; DESCRIPTION:
; Sets the start bit in the Control register of this user module. The
; timer will begin counting on the next input clock.
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None
; RETURNS: Nothing
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
Carrier_Timer_Start:
_Carrier_Timer_Start:
Carrier_Timer_Start_M
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: Carrier_Timer_Stop
;
; DESCRIPTION:
; Disables timer operation by clearing the start bit in the Control
; register.
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None
; RETURNS: Nothing
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
Carrier_Timer_Stop:
_Carrier_Timer_Stop:
Carrier_Timer_Stop_M
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: Carrier_Timer_WritePeriod
;
; DESCRIPTION:
; Write the 8-bit period value into the Period register (DR1). If the
; Timer user module is stopped, then this value will also be latched
; into the Count register (DR0).
;-----------------------------------------------------------------------------
;
; ARGUMENTS: fastcall BYTE bPeriodValue (passed in A)
; RETURNS: Nothing
; SIDE EFFECTS:
; REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
Carrier_Timer_WritePeriod:
_Carrier_Timer_WritePeriod:
mov reg[Carrier_Timer_PERIOD_REG], A
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: Carrier_Timer_WriteCompareValue
;
; DESCRIPTION:
; Writes compare value into the Compare register (DR2).
;
; NOTE! The Timer user module must be STOPPED in order to write the
; Compare register. (Call Carrier_Timer_Stop to disable).
;-----------------------------------------------------------------------------
;
; ARGUMENTS: fastcall BYTE bCompareValue (passed in A)
; RETURNS: Nothing
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
Carrier_Timer_WriteCompareValue:
_Carrier_Timer_WriteCompareValue:
mov reg[Carrier_Timer_COMPARE_REG], A
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: Carrier_Timer_bReadCompareValue
;
; DESCRIPTION:
; Reads the Compare register.
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None
; RETURNS: fastcall BYTE bCompareValue (value of DR2 in the A register)
; SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
Carrier_Timer_bReadCompareValue:
_Carrier_Timer_bReadCompareValue:
bCarrier_Timer_ReadCompareValue: ; this name deprecated
_bCarrier_Timer_ReadCompareValue: ; this name deprecated
mov A, reg[Carrier_Timer_COMPARE_REG]
ret
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: Carrier_Timer_bReadTimerSaveCV
;
; DESCRIPTION:
; Returns the value in the Count register (DR0), preserving the
; value in the compare register (DR2).
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None
; RETURNS: fastcall BYTE bCount (value of DR0 in the A register)
; SIDE EFFECTS:
; 1) May cause an interrupt, if interrupt on Compare is enabled.
; 2) If enabled, Global interrupts are momentarily disabled.
; 3) The user module is stopped momentarily while the compare value is
; restored. This may cause the Count register to miss one or more
; counts depending on the input clock speed.
; 4) REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION:
; 1) Read and save the Compare register.
; 2) Read the Count register, causing its data to be latched into
; the Compare register.
; 3) Read and save the Counter value, now in the Compare register,
; to the buffer.
; 4) Disable global interrupts
; 5) Halt the timer
; 6) Restore the Compare register values
; 7) Start the Timer again
; 8) Restore global interrupt state
;
Carrier_Timer_bReadTimerSaveCV:
_Carrier_Timer_bReadTimerSaveCV:
bCarrier_Timer_ReadTimerSaveCV: ; this name deprecated
_bCarrier_Timer_ReadTimerSaveCV: ; this name deprecated
bCarrier_Timer_ReadCounter: ; this name deprecated
_bCarrier_Timer_ReadCounter: ; this name deprecated
CpuFlags: equ 0
bCount: equ 1
mov X, SP ; X <- stack frame pointer
add SP, 2 ; Reserve space for flags, count
mov A, reg[Carrier_Timer_CONTROL_REG] ; save the Control register
push A
mov A, reg[Carrier_Timer_COMPARE_REG] ; save the Compare register
push A
mov A, reg[Carrier_Timer_COUNTER_REG] ; synchronous copy DR2 <- DR0
; This may cause an interrupt!
mov A, reg[Carrier_Timer_COMPARE_REG] ; Now grab DR2 (DR0) and save
mov [X+bCount], A
mov A, 0 ; Guess the global interrupt state
tst reg[CPU_SCR0], CPU_SCR0_GIE_MASK ; Currently Disabled?
jz .SetupStatusFlag ; Yes, guess was correct
mov A, FLAG_GLOBAL_IE ; No, modify our guess
.SetupStatusFlag: ; and ...
mov [X+CpuFlags], A ; StackFrame[0] <- Flag Reg image
M8C_DisableGInt ; Disable interrupts globally
Carrier_Timer_Stop_M ; Stop the timer
pop A ; Restore the Compare register
mov reg[Carrier_Timer_COMPARE_REG], A
pop A ; restore start state of the timer
mov reg[Carrier_Timer_CONTROL_REG], A
pop A ; Return result stored in stack frame
reti ; Flag Reg <- StackFrame[0]
.ENDSECTION
.SECTION
;-----------------------------------------------------------------------------
; FUNCTION NAME: Carrier_Timer_bReadTimer
;
; DESCRIPTION:
; Performs a software capture of the Count register. A synchronous
; read of the Count register is performed. The timer is NOT stopped.
;
; WARNING - this will cause loss of data in the Compare register.
;-----------------------------------------------------------------------------
;
; ARGUMENTS: None
; RETURNS: fastcall BYTE bCount, (value of DR0 in the A register)
; SIDE EFFECTS:
; May cause an interrupt.
; REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
; THEORY of OPERATION:
; 1) Read the Count register - this causes the count value to be
; latched into the Compare register.
; 2) Read and return the Count register values from the Compare
; registers into the return buffer.
;
Carrier_Timer_bReadTimer:
_Carrier_Timer_bReadTimer:
bCarrier_Timer_ReadTimer: ; this name deprecated
_bCarrier_Timer_ReadTimer: ; this name deprecated
bCarrier_Timer_CaptureCounter: ; this name deprecated
_bCarrier_Timer_CaptureCounter: ; this name deprecated
mov A, reg[Carrier_Timer_COUNTER_REG] ; synchronous copy DR2 <- DR0
; This may cause an interrupt!
mov A, reg[Carrier_Timer_COMPARE_REG] ; Return DR2 (actually DR0)
ret
.ENDSECTION
; End of File Carrier_Timer.asm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -