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