到目前为止,在前200个周期之后,我已经成功地产生了一个中断。但是,在执行第一个中断后,我无法生成另一个中断。我相信我的返回码可能有问题。帮助或建议将不胜感激。 我的目标是每200个周期产生一次中断。 发现此主题非常有帮助,但没有回答我的问题。 PLP: Timer and Button Interrupt Service Routine
.org 0x10000000
li $sp, 0x10fffffc # Stack pointer initialization
li $s0, sseg_lut # Lookup table address used by sseg_display
lui $s1, 0xf070 # Interrupt controller register
lui $s2, 0xf0a0 # Seven segment display
# ****************************
# TODO: enable interrupts below
# ****************************
init:
li $a1, 0x00000000
li $a3, 0xf0200000 #memory of led
li $t2, 0b1011 #value used to enable the used interrupts
li $t4, 0b00000000 #value used to check if LEDs are off
li $t5, 0b11111111 #value used to check if LEDs are on
li $t6, 0xf0600000 #address of the Timer
li $t7, 0xffffffff
li $t8, 0xC8 #indicate 200 cycle
#Interrupt occurs every 200 cycle
subu $t7,$t7,$t8
sw $t7,0($t6)
sw $t2, 0($s1) #set mask register to enable the used interrupts including Global Interrupt Enable
li $iv, isr #interrupt vector
###################
# NOTE: Do not add or modify any code within this main loop
main:
jal sseg_display
nop
addiu $a0, $a0, 1
j main
nop
# ****************************************
# TODO: add interrupt service routine below
# ****************************************
isr:
lw $i0, 0($t8) #check what is stored currently on LEDs
lw $i1, 4($s1) #load what value is in the status register
#li $i0, 0xf0700000
#lw $i1, 4($i0) # read the status register
beq $t4, $i0, on #if led off then on
nop
bne $t4, $i0, off #if led on then off
nop
on:
addu $t7, $t7, $t8 #calculate input for led on
sw $t7, 0($a3) #turn on the led
li $i1, 0
j end
nop
off:
li $t7, 0
sw $t7, 0($a3) #turn off the led
li $i1, 0
j end
nop
end:
#return from interrupt, set Global Interrupt Enable bit in delay slot of returning jump instruction
sw $i1, 4($i0) # clear any handled interrupts in the status register
lw $i1, 0($i0) # get the mask register
ori $i1, $i1, 0
jr $ir
sw $i1, 0($s1) # store the mask register in the delay slot to guarantee proper exit