Interrupts in more detail

5 things must happen to make this work correctly:

  1. Know where to go → 0x20
  2. Where to return → stored ea register (r29)
  3. Don’t mess up stuff like the registers in the main program
  4. Enable interrupts in the processor
  5. Enable interrupts from the device (i.e., push buttons)

4. Enabling Interrupts from the Processor Side:

There a 4 new registers in Nios II related to this

Register Bit Information
crtl0: status register
crtl1: estatus register
crtl3: ienable register
crtl3: ienable register

ctl0: control/status register

Holds flags to indicate the current state of the processor. Enabling interrupts globally in the processor is done by setting the appropriate bit in this register

Example privilege for supervisor mode:

ctli registers (crtl0, crtl1, …)

movi r8, 0b01 ; PIE bit = 1 (enabled)
                ; U/S = 0 (Supervisor)
wrct1 ctl0, r8 ; crtl0 <- r8

ctl1: estatus