;---------------------------------------------------------------------- ; EX84.ASM Generating Periodic Interrupts using the DECE Timer ; ; C.P. Diduch, 2001 ; ; This program uses the DECE Timer and DECE Interrupt Controller ; to generate periodic interrupts. Each interrupt request branches ; control to an interrupt handler where LED's connected to ; port-3 are toggled. The main program displays the Timer Count ; value. ;---------------------------------------------------------------------- ; .ORG 0x0000 ; "assign to RAM" .DS 1 ; "interrupt vector 0" .DS 1 ; "interrupt vector 1" ; ; MAIN PROGRAM ; void main(void) { ; .ORG 0x8000 ; "assign the following to ROM" ; ADD R1, NULL, NULL ; R1 = 0 ; ADDL R0, NULL, IH ; "initialize interrupt vector" STOREM 0, R0 ; ADDL R0, NULL, 0x00F4 ; "write Interrupt Controller STOREP 0x001A, R0 ; Control Word to clear all ; Irq's and unmask Timer ADDL R0, NULL, 0xFFFF ; "write Timer maximum count value" STOREP 0x0014, R0 ; ADDL R0, NULL, 0x0007 ; "write Timer Control Word : STOREP 0x0015, R0 ; interrupt enabled & unmasked, ; continuous" ; interrupts ORL# FL, FL, 0x0040 ; "set DECE IF" ; do { M0: LOADP R0, 0x0014 ; "read timer count and STOREP 0x0002, R0 ; write to port-2" JMP M0 ; } ;---------------------------------------------------------------------- ; void interrupt IH(void) ; ; Each time the interrupt handler, IH, is invoked it toggles the ; state of LED-15 and LED-0 at output port-3. ; IH: ; void interrupt IH(void) { ; XORL R1, R1, 0x8001 ; R1 = R1 ^ 0x8001; STOREP 0x0003, R1 ; outport(3, R2) ; ; LOADP R0, 0x0015 ; "read Timer Status to clear ; interrupt at Timer" ADDL R0, NULL, 0x0044 ; "write Interrupt Controller STOREP 0x001A, R0 ; Control Word to clear ; interrupt at Interrupt ; Controller Timer interrupts ; unmasked" RETI ; } ;----------------------------------------------------------------------