2 Interrupts
2 Interrupts
Interrupt is a process where an external device can get the attention of the microprocessor.
The process starts from the I/O device The process is asynchronous.
Classification of Interrupts
Interrupts can be classified into two types:
Maskable Interrupts (Can be delayed or Rejected) Non-Maskable Interrupts (Can not be delayed or Rejected)
Microprocessor Non-vectored The device will have to supply the address of the subroutine to the Microprocessor
RST 5.5, RST 6.5, RST 7.5 are all automatically vectored.
RST 5.5, RST 6.5, and RST 7.5 are all maskable.
6. Microprocessor Performs the ISR. 7. ISR must include the EI instruction to enable the further interrupt within the program. 8. RET instruction at the end of the ISR allows the MP to retrieve the return address from the stack and the program is transferred back to where the program was interrupted.
8085 recognizes 8 RESTART instructions: RST0 - RST7. each of these would send the execution to a predetermined
hard-wired memory location
Write a program to count continuously in binary with one second delay between each Count. Service routine at XX70H to flush FFH five times when the interrrupt occurs with some appropriate delay between flash
Main program
Service routine XX70: SERV: PUSH B PUSH PSW MVI B, 0AH MVI A, 00H OUT PORT1 CALL DELAY CMA DCR B JNZ FLASH POP PSW POP B EI RET
LXI SP, XX99H EI MVI A, 00H OUT PORT1 MVI C,01H CALL DELAY INR A JMP L1
FLASH:
Therefore, the INTR must remain active for 17.5 T-states. If f= 3MHZ then T=1/f and so, INTR must remain active for [ (1/3MHZ) * 17.5 5.8 micro seconds].
Therefore, INTR should be turned off as soon as the INTA signal is received.
Can the microprocessor be interrupted again before the completion of the ISR?
As soon as the 1st interrupt arrives, all maskable interrupts are disabled. They will only be enabled after the execution of the EI instruction.
Therefore, the answer is: only if we allow it to. If the EI instruction is placed early in the ISR, other interrupt may occur before the ISR is done.
The 3 outputs carry the index of the highest priority active input
The one draw back to this scheme is that the only way to change the priority of the devices connected to the 74366 is to reconnect the hardware.
TRAP
TRAP is the only non-maskable interrupt. It does not need to be enabled because it cannot be disabled. It has the highest priority amongst interrupts. It is edge and level sensitive. It needs to be high and stay high to be recognized. Once it is recognized, it wont be recognized again until it goes low, then high again. TRAP is usually used for power failure and emergency shutoff.
The vectors for these interrupt fall in between the vectors for the RST instructions. Thats why they have names like RST 5.5 (RST 5 and a half).
Through individual mask flip flops that control the availability of the individual interrupts.
These flip flops control the interrupts individually.
0 - Available 1 - Masked
Mask Set Enable 0 - Ignore bits 0-2 1 - Set the masks according to bits 0-2
Not Used
Force RST7.5 Flip Flop to reset If it is 1, RST 7.5 flip flop is reset,OFF
Bit 3 (Mask Set Enable - MSE) is an enable for setting the mask.
If it is set to 0 the mask is ignored and the old settings remain. If it is set to 1, the new setting are applied. The SIM instruction is used for multiple purposes and not only for setting interrupt masks.
It is also used to control functionality such as Serial Data Transmission. Therefore, bit 3 is necessary to tell the microprocessor whether or not the interrupt masks should be modified
Bit 4 of the accumulator in the SIM instruction allows explicitly resetting the RST 7.5 memory even if the microprocessor did not respond to it. Bit 5 is not used by the SIM instruction
- Enable 5.5 - Disable 6.5 - Enable 7.5 - Allow setting the masks - Dont reset the flip flop - Bit 5 is not used - Dont use serial data - Serial data is ignored
EI MVI A, 0A SIM
; Enable interrupts including INTR ; Prepare the mask to enable RST 7.5, and 5.5, disable 6.5 ; Apply the settings RST masks
Assuming the MP is completing an RST 7.5 interrupt request, check to see if RST 6.5 is pending, enable RST 6.5 without affecting any other interrupts; otherwise return to main program.
No Yes Yes
No No Yes
DI / EI SIM
None
Edge Sensitive
Level & Edge Sensitive
TRAP
No
Yes
No
PROBLEM STATEMENT Implement a breakpoint facility at RST 5 for user. When the user writes RST 5 in the program the program should 1. be interrupted at the instruction RST 5 . 2. display the accumulator content and the flags when Hex key A(1010) is pressed. 3. Exit the breakpoint routine and continue execution when the Zero key(0000) is pressed.
PUSH B PUSH D
POP D POP B POP PSW RET