APPENDIX A PROGRAM LIST
EI
;
Enable
vector
interrupt
;*****************************************************************************
;
; Main
loop
;
;*****************************************************************************
MAIN_LOOP:
;----- Reverse LED1 -----
XOR
P2,
#00000001B ; Reverse output of LED1
MOV
CNT120,
#120 ; Assign the 120 ms wait count value
;----- 120 ms wait -----
WAIT_120MS:
CALL !WAIT_1MS
; Subroutine call for a 1 ms wait
DBNZ CNT120,
$WAIT_120MS ; 1[ms] x 120[count] = 120[ms]
;----- Clear the watchdog timer -----
MOV
WDTE, #0ACH
; Clear the watchdog timer
BR
$MAIN_LOOP
; Go to the MAIN_LOOP
;*****************************************************************************
;
;
External interrupt INTP1
;
;*****************************************************************************
INTERRUPT_P1:
PUSH AX
; Save the AX register data to the stack
MOV
CNT10,
#10
; Assign the 10 ms wait count value
;----- 10 ms wait to handle chattering -----
WAIT_10MS:
CALL !WAIT_1MS
; Subroutine call for a 1 ms wait
DBNZ CNT10,
$WAIT_10MS ; 1[ms] x 10[count] = 10[ms]
CLR1 PIF1
; Clear the INTP1 interrupt request
;----- Identification of chattering detection -----
BT
P4.3, $END_INTP1 ; Branch if there is no switch input
SW_ON:
;----- Reverse LED1 -----
XOR
P2,
#00000001B ; Reverse output of LED1
MOV
CNT60,
#60
; Assign the 60 ms wait count value
;----- 60 ms wait -----
WAIT_60MS:
CALL !WAIT_1MS
; Subroutine call for a 1 ms wait
DBNZ CNT60,
$WAIT_60MS ; 1[ms] x 60[count] = 60[ms]
;----- Clear the watchdog timer -----
MOV
WDTE, #0ACH
; Clear the watchdog timer
;----- Identification of switch input status -----
BF
P4.3, $SW_ON
; Branch if the switch input continues
END_INTP1:
POP
AX
; Restore the AX register data
Application Note U18847EJ1V0AN
28