1

我正在尝试在带有 NIOS II 处理器的 DE2 板上生成 PS2 中断。下面的汇编代码是一个非常简单的中断服务程序,但它永远不会被执行。我已经检查并检查了代码,但我无法找出问题所在。附上PS2接口的链接。

任何建议表示赞赏。

问候。

NIOS II PS2 文档

.text

.global _start

_start:

  .equ ADDR_PS2, 0x10000100
  .equ ADDR_PS2_CONTROL, 0x10000104

  /* Enable interrupts for PS2 by writing to bit 0 of the control register */
  movia r2, ADDR_PS2_CONTROL
  movia r3, 0x1
  stw r3, (r2)

  /* Set the PIE bit */
  movia r2, 0x1
  wrctl ctl0, r2

  /* Configure ienable: PS2 IRQ = 7 */
  movia r2, 0x80
  wrctl ienable, r2

  MAIN:
    br MAIN

  .section .exceptions, "ax"

  ISR:
    subi sp, sp, 56
    stw r14, 52(sp)
    stw r13, 48(sp)
    stw r12, 44(sp)
    stw r11, 40(sp)
    stw r10, 36(sp)
    stw r9, 32(sp)
    stw r8, 28(sp)
    stw r7, 24(sp) 
    stw r6, 20(sp)
    stw r5, 16(sp)
    stw r4, 12(sp)
    stw r3, 8(sp)
    stw r2, 4(sp)
    stw r1, 0(sp)
    rdctl r2, ipending
    movia r3, 0x80
    and r2, r2, r3
    bne r0, r2, PS2_HANDLER
    br ISR_RETURN

 PS2_HANDLER:
   /* Acknowledge the interrupt */
   movia r2, ADDR_PS2
   ldb r3, (r2)

   /* Turn on the green LEDs */
   .equ ADDR_GREEN_LEDS, 0x10000010
   movia r2, ADDR_GREEN_LEDS
   movi  r3, 0xff
   stwio r3, (r2)

   /* Wait for a moment */
   movia r2, 25000000
   PS2_WAIT:
   subi r2, r2, 1
   bne r0, r2, PS2_WAIT

   /* Turn off the green LEDs */
   movia r2, ADDR_GREEN_LEDS
   movi  r3, 0x0
   stwio r3, (r2)
   br ISR_RETURN

 ISR_RETURN:
   ldw r14, 52(sp)
   ldw r13, 48(sp)
   ldw r12, 44(sp)
   ldw r11, 40(sp)
   ldw r10, 36(sp)
   ldw r9, 32(sp)
   ldw r8, 28(sp)
   ldw r7, 24(sp)
   ldw r6, 20(sp)
   ldw r5, 16(sp)
   ldw r4, 12(sp)
   ldw r3, 8(sp)
   ldw r2, 4(sp)
   ldw r1, 0(sp)
   addi sp, sp, 56
   subi ea, ea, 4
   eret
4

0 回答 0