До сих пор я успешно генерировал прерывание после первых 200 циклов.Однако я не могу сгенерировать другое прерывание после выполнения первого.Я считаю, что с моим кодом возврата что-то не так.Помощь или совет будет очень признателен.Моя цель - генерировать прерывание каждые 200 циклов.Нашел эту тему, которая очень полезна, но не ответила на мой вопрос. PLP: процедура обслуживания прерывания по таймеру и кнопке
.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