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

📄 sar10.asm

📁 带触摸按键的高端电磁炉设计 该方案采用CYPRESS的新器件CY8C22545,是一款专门针对中高端的家电触摸产品设计。除了集成触摸按键功能外
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;     Returns last converted data.
;     SAR_DL will be read first, then the SAR_DH
;     The MSB is returned in X and the LSB in A
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:   None
;  RETURNS:     fastcall16 INT iGetData(void)
;  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.
;
   Temp_offs:         equ  -2
   DL_REG_offs:       equ  -1
        
 SAR10_iGetData:
_SAR10_iGetData:
   RAM_PROLOGUE RAM_USE_CLASS_2
   mov   A, 0x00                              ; Init local var
   push  A                                    ; Reserve one byte in stack
   mov   A, reg[SAR10_SAR_DL_REG]  ; Get 2 lowest bits
   push  A                                    ; Store 2 lowest bits in stack
   mov   X, SP                                ; Set SP in X
   mov   A, reg[SAR10_SAR_DH_REG]  ; Read 8 highest bits
   asl   A                                    ; Determine two highest bits and store it in stack
   rlc   [X+Temp_offs]
   asl   A
   rlc   [X+Temp_offs]
   or    A, [X+DL_REG_offs]                    ; Form LSB of result
   pop   X                                     
   pop   X                                     ; Get MSB of result
   RAM_EPILOGUE RAM_USE_CLASS_2
   ret

.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR10_GetDataMSB8
;
;  DESCRIPTION:
;    Returns last converted data.
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    Nothing
;  RETURNS:          fastcall16 char GetDataMSB8(void)
;  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.
;
 SAR10_bGetDataMSB8:
_SAR10_bGetDataMSB8:
   RAM_PROLOGUE RAM_USE_CLASS_1
   mov   A,reg[SAR10_SAR_DH_REG]
   RAM_EPILOGUE RAM_USE_CLASS_1
   ret

.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR10_SelectADCChannel
;
;  DESCRIPTION:
;    Select the SAR input from 14 optional input channels.
;   Set ADC_CHS bits in SAR_CR0 register
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    fastcall16 void SelectADCChannel(passed in A)
;  RETURNS:    None
;  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.
;
 SAR10_SetADCChannel:
_SAR10_SetADCChannel:
   RAM_PROLOGUE RAM_USE_CLASS_2
   and   A, SAR10_CHN_SEL_MASK
   mov   X, SP
   push  A                                     ; store value in stack
   M8C_SetBank1
   mov   A, reg[SAR10_SAR_CR0_REG]  ; get register value
   and   A, ~SAR10_CHN_SEL_MASK     ; clear ADC_CHS bits
   or    A, [X]                                ; set ADC_CHS bits
   mov   reg[SAR10_SAR_CR0_REG], A  ; set new register value
   M8C_SetBank0
   pop   A
   RAM_EPILOGUE RAM_USE_CLASS_2
   ret

.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR10_SelectTriggerSrc
;
;  DESCRIPTION:
;    Select the SAR10 auto-trigger source 
;    by setting TIGSEL in SAR_CR1
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    fastcall16 void SelectTriggerSrc(passed in A)
;  RETURNS:    None
;  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.
;
 SAR10_SetTriggerSrc:
_SAR10_SetTriggerSrc:
   RAM_PROLOGUE RAM_USE_CLASS_2
   and   A, SAR10_TRG_SEL_MASK 
   mov   X, SP
   push  A                                    ; store value in stack
   M8C_SetBank1
   mov   A, reg[SAR10_SAR_CR1_REG]  ; get register value
   and   A, ~SAR10_TRG_SEL_MASK     ; clear TIGSEL bits
   or    A, [X]                                ; set TIGSEL bits
   mov   reg[SAR10_SAR_CR1_REG], A  ; set new register value
   M8C_SetBank0
   pop   A
   RAM_EPILOGUE RAM_USE_CLASS_2
   ret

.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR10_EnableAutoTrigger
;
;  DESCRIPTION:
;    Global enable CR of the SAR10 auto-trigger function by setting 
;    by setting ALIGN_EN in SAR_CR1
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    fastcall16 void EnableAutoTrigger(passed in A)
;  RETURNS:    None
;  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.
;
 SAR10_EnableAutoTrigger:
_SAR10_EnableAutoTrigger:
   RAM_PROLOGUE RAM_USE_CLASS_2
   and   A, SAR10_ALIGN_EN_MASK
   mov   X, SP
   push  A                                    ; store value in stack
   M8C_SetBank1
   mov   A, reg[SAR10_SAR_CR1_REG]  ; get register value
   and   A, ~SAR10_ALIGN_EN_MASK    ; clear ALIGN_EN bits
   or    A, [X]                                ; set ALIGN_EN bits
   mov   reg[SAR10_SAR_CR1_REG], A  ; set new register value
   M8C_SetBank0
   pop   A
   RAM_EPILOGUE RAM_USE_CLASS_2
   ret

.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR10_SetClk
;
;  DESCRIPTION:
;    Set SAR Sample Rate and Clock Selection 
;    by setting CLKSEL bits in SAR_CR1
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    fastcall16 void SetClk(passed in A)
;  RETURNS:    None
;  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.
;
 SAR10_SetClk:
_SAR10_SetClk:
   RAM_PROLOGUE RAM_USE_CLASS_2
   and   A, SAR10_CLK_SEL_MASK
   mov   X, SP
   push  A                                    ; store value in stack
   M8C_SetBank1
   mov   A, reg[SAR10_SAR_CR1_REG]  ; get register value
   and   A, ~SAR10_CLK_SEL_MASK     ; clear CLKSEL bits
   or    A, [X]                                ; set CLKSEL bits
   mov   reg[SAR10_SAR_CR1_REG], A  ; set new register value
   M8C_SetBank0
   pop   A
   RAM_EPILOGUE RAM_USE_CLASS_2
   ret

.ENDSECTION

.SECTION
;-----------------------------------------------------------------------------
;  FUNCTION NAME: SAR10_SetRunMode
;
;  DESCRIPTION:
;    Set free-running mode for SAR
;    by setting FREERUN bits in SAR_CR2
;
;-----------------------------------------------------------------------------
;
;  ARGUMENTS:    fastcall16 void SetRunMode(passed in A)
;  RETURNS:    None
;  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.
;
 SAR10_SetRunMode:
_SAR10_SetRunMode:
   RAM_PROLOGUE RAM_USE_CLASS_2
   and   A, SAR10_FREE_RUN_MASK
   mov   X, SP
   push  A                                    ; store value in stack
   M8C_SetBank1
   mov   A, reg[SAR10_SAR_CR2_REG]  ; get register value
   and   A, ~SAR10_FREE_RUN_MASK    ; clear FREERUN bits
   or    A, [X]                                ; set FREERUN bits
   mov reg[SAR10_SAR_CR2_REG], A   ; set new register value   
   M8C_SetBank0
   pop   A
   RAM_EPILOGUE RAM_USE_CLASS_2
   ret

.ENDSECTION
; End of File SAR10.asm

⌨️ 快捷键说明

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