📄 senseint.asm
字号:
;;*****************************************************************************
;;*****************************************************************************
;; FILENAME: SENSEINT.asm
;; Version: 1.1, Updated on 2005/10/13 at 09:13:22
;; Generated by PSoC Designer ver 4.2 b1013 : 02 September, 2004
;;
;; DESCRIPTION: SENSE User Module ISR implementation file for the
;; 21xxx PSoC family of devices.
;;-----------------------------------------------------------------------------
;; Copyright (c) Cypress MicroSystems 2000-2005. All Rights Reserved.
;;*****************************************************************************
;;*****************************************************************************
include "m8c.inc"
include "memory.inc"
include "SENSE.inc"
MSB: equ 0
LSB: equ 1
;-----------------------------------------------
; Global Symbols
;-----------------------------------------------
export _SENSE_SCAN_ISR
;-----------------------------------------------------------------------------
; FUNCTION NAME: SENSE_CAPTURE_ISR
;
; DESCRIPTION:
; Interrupt Service Routine for the 16 bit counter in the CSR. If the interrupt
; is enabled and the comparator trips or the counter reaches terminal count (as
; selected by user parameter) the code execution will vector to this ISR.
;
;-----------------------------------------------------------------------------
;
;
_SENSE_SCAN_ISR:
SENSE_Stop_CMP_M ; Disable power of comparator
SENSE_Stop_M ; Stop PWM, then counter
push A
push X
mov A, [SENSE_bSwitchNum] ; Get Counter Counter value
asl A
mov X,A
mov A, reg[SENSE_CTR_COUNTER_LSB_REG] ; Dummy Read
mov A, reg[SENSE_CTR_COMPARE_LSB_REG] ; Get Counter LSB
mov [X+(SENSE_iaSwResult+LSB)],A
mov A, reg[SENSE_CTR_COUNTER_MSB_REG] ; Dummy Read
mov A, reg[SENSE_CTR_COMPARE_MSB_REG] ; Get Counter MSB
mov [X+(SENSE_iaSwResult+MSB)],A
; Reset Counter period to 0xFFFF
mov reg[SENSE_CTR_PERIOD_LSB_REG], 0xFF
mov reg[SENSE_CTR_PERIOD_MSB_REG], 0xFF
; Subtract result from 0xFFFF
mov A,0xFF
sub A,[X+(SENSE_iaSwResult+LSB)]
mov [X+(SENSE_iaSwResult+LSB)],A
mov A,0xFF
sbb A,[X+(SENSE_iaSwResult+MSB)]
mov [X+(SENSE_iaSwResult+MSB)],A
; Disconnect the switch (place in reset state)
mov A,[SENSE_bSwitchNum]
lcall SENSE_iGetPortPin ; Get switch port and mask
lcall SENSE_DisableSwitch ; Enable first switch
; Determine if scanning should continue
; If still in scan mode select next switch to scan
inc [SENSE_bSwitchNum] ; Advance to next switch
mov A, [SENSE_bScanEnd] ; Check to see if it is out of range
cmp A,[SENSE_bSwitchNum] ; Move new value to A
jnc .KeepScanning ; Not end of scan list yet
; At end of scan list, determine if this is a one time scan or continuous
or [SENSE_bfStatus],SENSE_SCAN_SET_COMPLETE ; Set Scan complete flag
tst [SENSE_bfStatus],SENSE_SCAN_CONTINUOUS ; Continuous scan mode?
jz .STOP_SCANNING ; Stop scanning
.TAKE_IT_FROM_TOP:
mov [SENSE_bSwitchNum],[SENSE_bScanStart] ; Reset scan at top of list.
.KeepScanning:
mov A, [SENSE_bPWMPeriod]
mov reg[SENSE_PWM_PERIOD_REG], A ; Set PWM period
SENSE_Start_M ; Start counter and scan pwm
mov A,[SENSE_bSwitchNum] ; Enable the next switch
lcall SENSE_iGetPortPin ; Get switch port and mask
lcall SENSE_EnableSwitch ; Enable first switch
jmp .END_SCAN_ISR
.STOP_SCANNING:
and [SENSE_bfStatus],~(SENSE_SCAN_ACTIVE|SENSE_SCAN_CONTINUOUS) ; Clear scan active flag
SENSE_Stop_M ; Disable counter and scan PWM
SENSE_Stop_CMP_M ; Disable power of comparator
SENSE_DisableInt_M ; Disable scan PWM interrupt
.END_SCAN_ISR:
pop X
pop A
.SCAN_RETURN:
;@PSoC_UserCode_BODY_TERMINAL@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom code below this banner
;---------------------------------------------------
; NOTE: interrupt service routines must preserve
; the values of the A and X CPU registers.
;---------------------------------------------------
; Insert your custom code above this banner
;---------------------------------------------------
;@PSoC_UserCode_END@ (Do not change this line.)
reti
; End of File SENSEINT.asm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -