⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baud.asm

📁 测量脉搏的源码 Cypress公司使用 CY27443 完成相关的功能
💻 ASM
字号:
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME: Baud.asm
;;   Version: 2.2, Updated on 2003/11/10 at 16:38:18
;;  Generated by PSoC Designer ver 4.1 BETA b923 : 11 December, 2003
;;
;;  DESCRIPTION: Counter8 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 "Baud.inc"

;-----------------------------------------------
;  Global Symbols
;-----------------------------------------------
export  Baud_EnableInt
export _Baud_EnableInt
export  Baud_DisableInt
export _Baud_DisableInt
export  Baud_Start
export _Baud_Start
export  Baud_Stop
export _Baud_Stop
export  Baud_WritePeriod
export _Baud_WritePeriod
export  Baud_WriteCompareValue
export _Baud_WriteCompareValue
export  Baud_bReadCompareValue
export _Baud_bReadCompareValue
export  Baud_bReadCounter
export _Baud_bReadCounter

; The following functions are deprecated and subject to omission in future releases
;
export  bBaud_ReadCompareValue  ; deprecated
export _bBaud_ReadCompareValue  ; deprecated
export  bBaud_ReadCounter       ; deprecated
export _bBaud_ReadCounter       ; deprecated


AREA bss (RAM,REL)

;-----------------------------------------------
;  Constant Definitions
;-----------------------------------------------

INPUT_REG_NULL:                equ 0x00    ; Clear the input register


;-----------------------------------------------
; Variable Allocation
;-----------------------------------------------


AREA UserModules (ROM, REL)

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: Baud_EnableInt
;
;  DESCRIPTION:
;     Enables this counter'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!
;
 Baud_EnableInt:
_Baud_EnableInt:
   Baud_EnableInt_M
   ret

.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: Baud_DisableInt
;
;  DESCRIPTION:
;     Disables this counter'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!
;
 Baud_DisableInt:
_Baud_DisableInt:
   Baud_DisableInt_M
   ret


.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: Baud_Start
;
;  DESCRIPTION:
;     Sets the start bit in the Control register of this user module.  The
;     counter will begin counting on the next input clock as soon as the
;     enable input is asserted high.
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    None
;  RETURNS:      Nothing
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
 Baud_Start:
_Baud_Start:
   Baud_Start_M
   ret


.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: Baud_Stop
;
;  DESCRIPTION:
;     Disables counter 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!
;
 Baud_Stop:
_Baud_Stop:
   Baud_Stop_M
   ret


.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: Baud_WritePeriod
;
;  DESCRIPTION:
;     Write the 8-bit period value into the Period register (DR1).
;-----------------------------------------------------------------------------
;
;  ARGUMENTS: fastcall BYTE bPeriodValue (passed in A)
;  RETURNS:   Nothing
;  SIDE EFFECTS:
;     If the counter user module is stopped, then this value will also be
;     latched into the Count register (DR0).
;     REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
 Baud_WritePeriod:
_Baud_WritePeriod:
   mov   reg[Baud_PERIOD_REG], A
   ret


.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: Baud_WriteCompareValue
;
;  DESCRIPTION:
;     Writes compare value into the Compare register (DR2).
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    fastcall BYTE bCompareValue (passed in A)
;  RETURNS:      Nothing
;  SIDE EFFECTS: REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
 Baud_WriteCompareValue:
_Baud_WriteCompareValue:
   mov   reg[Baud_COMPARE_REG], A
   ret


.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: Baud_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!
;
 Baud_bReadCompareValue:
_Baud_bReadCompareValue:
 bBaud_ReadCompareValue:                         ; this name deprecated
_bBaud_ReadCompareValue:                         ; this name deprecated
   mov   A, reg[Baud_COMPARE_REG]
   ret


.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: Baud_bReadCounter
;
;  DESCRIPTION:
;     Returns the value in the Count register (DR0), preserving the value in
;     the compare register (DR2). Interrupts are prevented during the transfer
;     from the Count to the Compare registers by holding the clock low in
;     the PSoC block.
;-----------------------------------------------------------------------------
;
;  ARGUMENTS: None
;  RETURNS:   fastcall BYTE bCount (value of DR0 in the A register)
;  SIDE EFFECTS:
;     1) If running, the user module is stopped momentarily and one or more
;        counts may be missed.
;     2) REGISTERS ARE VOLATILE: THE A AND X REGISTERS MAY BE MODIFIED!
;
 Baud_bReadCounter:
_Baud_bReadCounter:
 bBaud_ReadCounter:                              ; this name deprecated
_bBaud_ReadCounter:                              ; this name deprecated

   bOrigCompareValue:      EQU   0               ; Frame offset to temp Compare store
   bOrigControlReg:        EQU   1               ; Frame offset to temp CR0     store
   bOrigClockSetting:      EQU   2               ; Frame offset to temp Input   store
   wCounter:               EQU   3               ; Frame offset to temp Count   store
   STACK_FRAME_SIZE:       EQU   4               ; max stack frame size is 4 bytes

   mov   X, SP                                   ; X <- stack frame pointer
   mov   A, reg[Baud_COMPARE_REG]                ; Save the Compare register on the stack
   push  A                                       ;
   mov   A, reg[Baud_CONTROL_REG]                ; Save CR0 (running or stopped state)
   push  A                                       ;
   Baud_Stop_M                                   ; Disable (stop) the Counter if running
   M8C_SetBank1                                  ;
   mov   A, reg[Baud_INPUT_REG]                  ; save the clock input setting
   push  A                                       ;   on the stack (now 2 bytes) and ...
                                                 ;   hold the clock low:
   mov   reg[Baud_INPUT_REG], INPUT_REG_NULL
   M8C_SetBank0
                                                 ; Extract the Count via DR2 register
   mov   A, reg[Baud_COUNTER_REG]                ; DR2 <- DR0
   mov   A, reg[Baud_COMPARE_REG]                ; Stash the Count on the stack
   push  A                                       ;  -stack frame is now 3 bytes
   mov   A, [X+bOrigCompareValue]                ; Restore the Compare register
   mov   reg[Baud_COMPARE_REG], A
   M8C_SetBank1                                  ; Restore the counter operation:
   mov   A, [X+bOrigClockSetting]                ;   First, the clock setting...
   mov   reg[Baud_INPUT_REG], A                  ;
   M8C_SetBank0                                  ;   then re-enable (start) the counter
   mov   A, [X+bOrigControlReg]                  ;     if it was running when
   mov   reg[Baud_CONTROL_REG], A                ;     this function was first called
   pop   A                                       ; Setup the return value
   ADD   SP, -(STACK_FRAME_SIZE-1)               ; Zap remainder of stack frame
   ret

.ENDSECTION

; End of File Baud.asm

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -