Interrupts are important features of modern microprocessors, as they facilitate an efficient mechanism for servicing requests from a variety of peripherals.
The example assembly program below uses the external interrupt pin irq1 (ACTIVE LOW), which should be connected to one of the debounced pushbuttons (active low). When the button is pressed, the interrupt handler routine prints the character i and delays for about 2 seconds before another button press will be handled (software pulse catch). The delay is implemented using the pdelay routine used above, and is available in a separate file: pdelayc.c. Download this file and the assembly program irq1as.s:
/* irq1as.s test of external irq 1 (autovectored) connect IRQ1 to a PB (active L) prints 'i' each time an interrupt occurs pulse catching delay of 2 sec */ .text .even .global main main: movea.l #irq1_handler,%a5 /* set up irq 1 vector */ move.l %a5,IRQ1_VECADDR move.l #0x00003F7C,%d0 /* enable irq1 */ move.w %d0,IMR loop: /* infinite loop */ bra loop /* terminate with ABORT button */ rts irq1_handler: /* irq 1 service routine */ move.l #0x00003F7E,%d0 /* disable irq1 to catch 1 irq pulse */ move.w %d0,IMR move.l #'i',%d1 /* print i */ move.l #0x0013,%d0 trap #15 move.l #2000,-(%sp) /* delay for ~2 sec */ jsr pdelay /* a C routine */ addq.l #4,%sp move.l #0x00003F7C,%d0 /* enable irq1 */ move.w %d0,IMR rte MBARx = 0x10000000 /* Module Base Address value */ IMR = MBARx+0x0036 /* interrupt mask register */ IPR = MBARx+0x003A /* interrupt pending register */ IRQ1_VEC = 25 /* irq1 vector number */ IRQ1_VECADDR = 4*IRQ1_VEC /* irq1 vector address */
Exercise.
go 10000
ANU Engineering - ENGN3213