II.D· INTERRUPT SYSTEM

There are two basic types of interrupts defined on the microprocessor: NMI (non-maskable interrupt) and IRQ (interrupt request). It is recommended that a thorough understanding of these interrupt types be acquired by reading all chapters concerning interrupts in the 6502 microprocessor programming and hardware manuals.

In this system NMI interrupts are used for video display and reset. IRQ interrupts are used for serial port communication, peripheral devices, timers, and keyboard inputs.


NMI interrupts

Even though NMI interrupts are "unmaskable" on the microprocessor, this system has interrupt enable (mask) bits for NMI function (Bits 6 and 7 of NMIEN). When these bits are zero NMI interrupts are disabled (masked) and prevented from causing a microprocessor NMI interrupt. (see NMIEN register description) The 3 types of NMI interrupts are:

  1. D7 = Instruction Interrupt
    (during display time any display instruction with bit 7=1 will cause this interrupt to occur (if enabled) at the start of the last video line displayed by that instruction.)
  2. D6 = Vertical Blank Interrupt
    (interrupt occurs (if enabled) at the beginning of the vertical blank time interval.)
  3. D5 = Reset Button Interrupt
    (pushing the SYSTEM RESET button will cause this interrupt to occur.)

Since any of these interrupts will cause the processor to jump to the same NMI address, the system also has NMI status bits which may be examined by the processor to determine which source caused the NMI interrupt. Bits 5, 6, and 7 of NMIST serve this function (see NMIST register description). These status bits are set by the corresponding interrupt function (even if the interrupt is masked from the processor by NMIEN). The status bits may be reset together by writing to the address NMIRES.

Two of the interrupt enable bits (bits 6 and 7 of NMIEN) are cleared automatically during system power turn on and therefore these NMI interrupts are initially disabled (masked), preventing any power turn on service routine from being interrupted before proper initialization of registers and pointers*. They can then be enabled by the processor whenever desired, by writing into bits 6 and 7 of NMIEN. Except for the reset button interrupt, they can also be disabled by the processor by writing a zero into bits 6 or 7 or NMIEN.

The reset button cannot be disabled, allowing an unstoppable escape from any possible "hangup" condition.

These NM interrupt functions are each separated in time (to prevent overlaps) and converted to pulses by the system hardware, in order to supply NMI transitions required by the microprocessor logic.

NOTE: Bit 5 is never disabled and therefore the Reset Button should not be pressed during power turn on.


IRQ Interrupts

IRQ interrupts are all "maskable" together by one bit of the status register on the microprocessor. This bit is set to the disable condition automatically by power turn on to prevent interrupt of power turn on service routines**. In addition to this processor IRQ mask bit, there are separate system IRQ interrupt enable bits for each IRQ interrupt function (bits 0 to 7 of IRQEN). These bits are not initialized by power turn on, and must be initialized by the program before enabling the processor IRQ. The 8 types of IRQ interrupts are:

D7 = BREAK KEY (depression of the break key)

D6 = OTHER KEY (depression of any other key)

D5 = SERIAL INPUT READY (Byte of serial data has been received and is ready to be read by the processor in SERIN register).

D4 = SERIAL OUTPUT NEEDED (Byte of serial data is being transmitted and SEROUT is ready to be written to again by the processor).

D3 = TRANSMISSION FINISHED (serial data transmission is finished. Output shift register is empty).

D2 = TIMER #4 (audio divider #4 has counted down to zero)

D1 = TIMER #2 (audio divider #2 has counted down to zero)

D0 = TIMER #1 (audio divider #1 has counted down to zero)

In addition to the above IRQ interrupts (enabled by bits 0 through 7 of IRQEN and identified by status bits 0 thru 7 of IRQST) there are two more system IRQ interrupts which are generated over the serial bus Proceed and Interrupt lines.

D7 of PACTL = peripheral "A" interrupt status bit

D0 of PACTL = peripheral "A" interrupt enable bit

D7 of PBCTL = peripheral "B" interrupt status bit

D0 of PBCTL = peripheral "B" interrupt enable bit

These last two interrupts are automatically disabled by power turn on, and their status bits are reset by reading from port A register and port B register. See PORTA, PACTL, PORTB, and PBCTL Register descriptions.

The IRQEN register, like the NMIEN register, enables interrupts when its bits are 1 (logic true). The IRQST however (unlike the NMIST) has interrupt status bits that are normally logic true, and go to zero to indicate an interrupt request. The IRQST status bits are returned to logic true only by writing a zero into the corresponding IRQEN bit. This will disable the interrupt and simultaneously set the interrupt status bit to one. Bit 3 of IRQST is not a latch and does not get reset by interrupt disable. It is zero when the serial out is empty (out finished) and true when it is not.

** NOTE: An NMI also disables the I bit.


INTERRUPT SUMMARY

NAME FUNCTIONS ENABLE STATUS STATUS RESET
NMI
INTERRUPTS
Display
Instruction
Vert. Blank

Reset Button
NMIEN
(Bits 6 thru 7)
Normally Zero
(Disabled)
NNIST
(Bits 5 thru 7)
Normally Zero
(no interrupt)
Address NMIRES (Resets all NMI status together)
IRQ interrupts KEYS
Serial ports
Timers
IRQIEN
(Bits 0 thru 7)
zero is
(Disabled*)
IRQST
(Bits 0 thru 7)
Normally True
(no interrupt)
Reset (to true) by zero in corresponding bit of IRQEN (except bit 3)
Peripheral A D0 of PACTL
Normally Zero
(Disabled)
D7 of PACTL
Normally Zero
(no interrupt)
Reset by reading PORTA Register
Peripheral B D0 of PBCTL
Normally Zero
(Disabled)
D7 of PBCTL
Normally Zero
(no interrupt)
Reset by reading PORTB Register