
396
CHAPTER 14 DTP/EXTERNAL INTERRUPT CIRCUIT
14.7 Sample Programs for the DTP/External Interrupt Circuit
This section contains sample programs for the external interrupt function and the DTP
function.
s Sample Program for the External Interrupt Function
r Processing
The rising edge of the pulse input to the INT0 pin is detected, and an external interrupt is
generate.
r Coding example
ICR07
EQU
0000B7H
;Interrupt control register for the DTP/
external interrupt circuit
DDR1
EQU
000011H
;Port 1 direction register
ENIR
EQU
000030H
;DTP/interrupt enable register
EIRR
EQU
000031H
;DTP/interrupt cause register
ELVRL EQU
000032H
;Request level setting register
ELVRH EQU
000033H
;Request level setting register
ER0
EQU
EIRR:0
;INT0 interrupt flag bit
EN0
EQU
ENIR:0
;INT0 interrupt enable bit
;-------Main program------------------------------------------------
DE
CSEG
START:
;
:
;Assumes that stack pointer (SP) has
already been initialized.
MOV
I:DDR1,#00000000B;Sets DDR1 as an input port.
AND
CCR,#0BFH
;Disables interrupts.
MOV
I:ICR07,#00H
;Interrupt level:0 (highest).
Disables EI2OS.
CLRB EN0
;Disables INT0, using ENIR.
MOV
I:ELVR,#00000010B;Selects the rising edge for INT0.
CLRB I:ER0
;Clears the cause for INT0 using EIRR.
SETB I:EN0
;Enables INT0 using ENIR.
MOV
ILM,#07H
;Sets ILM in PS to level 7.
OR
CCR,#40H
;Enables interrupts.
LOOP: MOV
A,#00H
;Endless loop
MOV
A,#01H
BRA
LOOP
;-------Interrupt program-------------------------------------------
WARI
CLRB ER0
;Clears the interrupt request flag.
;
:
;
User processing
;
:
RETI
;Returns from interrupt.
CODE
ENDS
;-------Vector setting----------------------------------------------