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

📄 adcinc_1.asm

📁 陀螺仪程序
💻 ASM
字号:
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME: ADCINC_1.asm
;;   Version: 1.1, Updated on 2005/09/29 at 13:17:03
;;  Generated by PSoC Designer ver 4.2  b1013 : 02 September, 2004
;;
;;  DESCRIPTION: Assembler source for the ADCINC A/D Converter
;;               User Module with 2nd-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_1.inc"


;-----------------------------------------------
;  Global Symbols
;-----------------------------------------------
export  ADCINC_1_Start
export _ADCINC_1_Start
export  ADCINC_1_SetPower
export _ADCINC_1_SetPower
export  ADCINC_1_Stop
export _ADCINC_1_Stop
export  ADCINC_1_GetSamples
export _ADCINC_1_GetSamples
export  ADCINC_1_StopADC
export _ADCINC_1_StopADC
export  ADCINC_1_fIsDataAvailable
export _ADCINC_1_fIsDataAvailable
export  ADCINC_1_iClearFlagGetData
export _ADCINC_1_iClearFlagGetData
export  ADCINC_1_wClearFlagGetData
export _ADCINC_1_wClearFlagGetData
export  ADCINC_1_cClearFlagGetData
export _ADCINC_1_cClearFlagGetData
export  ADCINC_1_bClearFlagGetData
export _ADCINC_1_bClearFlagGetData
export  ADCINC_1_iGetData
export _ADCINC_1_iGetData
export  ADCINC_1_wGetData
export _ADCINC_1_wGetData
export  ADCINC_1_bGetData
export _ADCINC_1_bGetData
export  ADCINC_1_cGetData
export _ADCINC_1_cGetData
export  ADCINC_1_fClearFlag
export _ADCINC_1_fClearFlag
export  ADCINC_1_WritePulseWidth
export _ADCINC_1_WritePulseWidth

AREA bss (RAM,REL)

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

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


AREA UserModules (ROM, REL)

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: ADCINC_1_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.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;
 ADCINC_1_Start:
_ADCINC_1_Start:
   RAM_PROLOGUE RAM_USE_CLASS_1
   or    reg[DEC_CR1],c0h
   call  ADCINC_1_SetPower
   ADCINC_1_RESET_INTEGRATOR_M
   mov   reg[ADCINC_1_PWMdr1],ffh
   or    reg[ADCINC_1_PWMcr0],01h                    ; start PWM
   RAM_EPILOGUE RAM_USE_CLASS_1
 ret
.ENDSECTION

   
.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: ADCINC_1_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.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;
 ADCINC_1_SetPower:
_ADCINC_1_SetPower:
   RAM_PROLOGUE RAM_USE_CLASS_2
   and  A,03h                                    ; Ensure value is legal
   push A
   push A
   mov  X,SP                                     ; Set up Stack frame
   mov  A,reg[ADCINC_1_AtoD1cr3]                 ; First SC block:
   and  A,~03h                                   ;   clear power bits to zero
   or   [ X - 2 ],A                              ;   save new va;ue on stack
   mov  A,reg[ADCINC_1_AtoD2cr3]                 ; Second SC block:
   and  A,~03h                                   ;   clear power bits to zero
   or   [ X - 1 ],A                              ;   save new va;ue on stack
   pop  A
   mov  reg[ADCINC_1_AtoD2cr3],A                 ; Write Second SC block
   pop  A
   mov  reg[ADCINC_1_AtoD1cr3],A                 ; Write First SC block
   RAM_EPILOGUE RAM_USE_CLASS_2
   ret
.ENDSECTION


.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: ADCINC_1_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.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;
 ADCINC_1_Stop:
_ADCINC_1_Stop:
   RAM_PROLOGUE RAM_USE_CLASS_1
   ADCINC_1_STOPADC_M 
   and  reg[ADCINC_1_AtoD1cr3], ~03h
   and  reg[ADCINC_1_AtoD2cr3], ~03h
   and  reg[ADCINC_1_PWMcr0], ~01h ; stop PWM
   RAM_EPILOGUE RAM_USE_CLASS_1
   ret
.ENDSECTION


.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: ADCINC_1_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.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
 ADCINC_1_GetSamples:
_ADCINC_1_GetSamples:
   RAM_PROLOGUE RAM_USE_CLASS_4
   RAM_SETPAGE_CUR >ADCINC_1_fMode
   ADCINC_1_ENABLE_INTEGRATOR_M
   mov [ADCINC_1_fMode],0
   mov [ADCINC_1_bState],0
   mov [ADCINC_1_bNumSamples],A
   mov A, reg[ADCINC_1_PWMdr2]
   jnz  .SkipPulseWrite
   mov reg[ADCINC_1_PWMdr2], 1
.SkipPulseWrite:
   ADCINC_1_STARTADC_M  ;enable interrupt
   RAM_EPILOGUE RAM_USE_CLASS_4 
   ret
.ENDSECTION


.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: ADCINC_1_StopAD
;
;  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.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;
 ADCINC_1_StopADC:
_ADCINC_1_StopADC:
   RAM_PROLOGUE RAM_USE_CLASS_1
   ADCINC_1_STOPADC_M
   ADCINC_1_RESET_INTEGRATOR_M
   RAM_EPILOGUE RAM_USE_CLASS_1 
   ret
.ENDSECTION


.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: ADCINC_1_fIsDataAvailable
;
;  DESCRIPTION: Returns the status of the A/D Data
;-----------------------------------------------------------------------------
;  ARGUMENTS:    None.
;  RETURNS:      fastcall BOOL DataAvailable returned in the A register
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
 ADCINC_1_fIsDataAvailable:
_ADCINC_1_fIsDataAvailable:
   RAM_PROLOGUE RAM_USE_CLASS_4
   ADCINC_1_fIsDataAvailable_M     
   RAM_EPILOGUE RAM_USE_CLASS_4
   ret
.ENDSECTION


.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME:  ADCINC_1_iClearFlagGetData
;                  ADCINC_1_iClearFlagGetData
;
;  DESCRIPTION:    Clears the fStatus and places ADC data in iResult A/D.
;                  Flag is checked after trandfer to insure valid data.
;                  available. Also clears the DATA_READY flag. 
;-----------------------------------------------------------------------------
;  ARGUMENTS:    None.
;  RETURNS:      fastcall int iResult returned in the X and A register
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
 ADCINC_1_iClearFlagGetData:
_ADCINC_1_iClearFlagGetData:
 ADCINC_1_wClearFlagGetData:
_ADCINC_1_wClearFlagGetData:
   RAM_PROLOGUE RAM_USE_CLASS_4
   ADCINC_1_iClearFlagGetData_M    
   RAM_EPILOGUE RAM_USE_CLASS_4
   ret

.ENDSECTION


.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME:  ADCINC_1_cClearFlagGetData
;                  ADCINC_1_bClearFlagGetData
;
;  DESCRIPTION:    Clears the fStatus and places ADC data in iResult A/D.
;-----------------------------------------------------------------------------
;  ARGUMENTS:    None.
;  RETURNS:      fastcall int iResult returned in the X and A register
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
 ADCINC_1_cClearFlagGetData:
_ADCINC_1_cClearFlagGetData:
 ADCINC_1_bClearFlagGetData:
_ADCINC_1_bClearFlagGetData:
   RAM_PROLOGUE RAM_USE_CLASS_4
   ADCINC_1_bClearFlagGetData_M    
   RAM_EPILOGUE RAM_USE_CLASS_4
   ret
.ENDSECTION


.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME:  ADCINC_1_iGetData
;                  ADCINC_1_wGetData
;
;  DESCRIPTION:     Returns the data from the A/D.  Does not check if data is
;                   available.
;-----------------------------------------------------------------------------
;  ARGUMENTS:    None.
;  RETURNS:      fastcall int iResult is returned in the X,A registers
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
 ADCINC_1_iGetData:
_ADCINC_1_iGetData:
 ADCINC_1_wGetData:
_ADCINC_1_wGetData:
   RAM_PROLOGUE RAM_USE_CLASS_4
   ADCINC_1_wGetData_M              
   RAM_EPILOGUE RAM_USE_CLASS_4
   ret
.ENDSECTION


.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME:  ADCINC_1_bGetData
;                  ADCINC_1_cGetData
;
;  DESCRIPTION:     Returns the data from the A/D.  Does not check if data is
;                   available.
;-----------------------------------------------------------------------------
;  ARGUMENTS:    None.
;  RETURNS:      fastcall CHAR cData returned in the A register
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
 ADCINC_1_bGetData:
_ADCINC_1_bGetData:
 ADCINC_1_cGetData:
_ADCINC_1_cGetData:
   RAM_PROLOGUE RAM_USE_CLASS_4
   ADCINC_1_cGetData_M              
   RAM_EPILOGUE RAM_USE_CLASS_4
   ret
.ENDSECTION


.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: ADCINC_1_ClearFlag
;
;  DESCRIPTION: Clears the data ready flag.
;-----------------------------------------------------------------------------
;  ARGUMENTS:    None.
;  RETURNS:      Nothing.
;  SIDE EFFECTS: 
;    The DATA_READY flag is cleared.
;
;    The A and X registers may be modified by this or future implementations
;    of this function.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;          
 ADCINC_1_fClearFlag:
_ADCINC_1_fClearFlag:
   RAM_PROLOGUE RAM_USE_CLASS_4
   ADCINC_1_fClearFlag_M              
   RAM_EPILOGUE RAM_USE_CLASS_4
   ret
.ENDSECTION


.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: ADCINC_1_WritePulseWidth
;
;  DESCRIPTION:
;     Write the 8-bit period value into the compare register (DR2).
;-----------------------------------------------------------------------------
;
;  ARGUMENTS: fastcall BYTE bPeriodValue (passed in A)
;  RETURNS:   Nothing
;  SIDE EFFECTS:
;    The A and X registers may be modified by this or future implementations
;    of this function.  When necessary, it is the calling function's
;    responsibility to perserve their values across calls to fastcall16 
;    functions.
;
 ADCINC_1_WritePulseWidth:
_ADCINC_1_WritePulseWidth:
   RAM_PROLOGUE RAM_USE_CLASS_1
   ADCINC_1_WritePulseWidth_M
   RAM_EPILOGUE RAM_USE_CLASS_1
   ret
.ENDSECTION

; End of File ADCINC_1.asm

⌨️ 快捷键说明

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