Documente Academic
Documente Profesional
Documente Cultură
Port A be in a PC, and port B be its modem input which puts the characters on
the telephone line.
Let In_A_Out_B be a routine that receives an input-character from Port A and
retransmits the character to Port B output.
Has to cyclically call the following steps a to e and executes the cycles of
functions i to v, thus ensuring the modem port A does not miss reading the
character
Types of interrupt
1. Hardware interrupt
2. Software interrupt
Hardware interrupt:
Examples of interrupts
1. When a device or port is ready
2. a device or port generates an interrupt
3. when it completes the assigned action
4. when a timer overflows
5. when a time at the timer equals a preset time in a compare register or on
setting a status flag (for
6. example, on timer overflow or compare or capture of time)
7. on click of mouse in a computer
Hardware interrupt generates call to an ISR
Software Interrupt:
When software run-time exception condition (for examples, In 8086 processor-
division by 0 or overflow or illegal opcode detected) the processor-hardware
generates an interrupt, called trap, which calls an ISR
When software run-time exception condition defined in a program occurs, then
a software instruction (SWI) is executed called software interrupt or exception or
signal, which calls an ISR
When a device function is to be invoked, for example, open (initialize/configure)
or read or write or close , then a software instruction (SWI) is executed called
software interrupt to execute the required device driver function for open or read
or write or close operations
Software can execute the software instruction (SWI) or Interrupt n (INT n) to
signal execution of ISR (interrupt service routine). The n is as per the handler
address.
Signal interrupt [The signal differs from the function in the sense that
execution of signal handler (ISR) can be masked and till mask is reset, the
handler will not execute on interrupt. Function on the other hand always
executes on the call after a call-instruction.]
read.
Software Interrupts and Interrupt Service routines:
Software Interrupt (Throw an Exception) Concept:
A program needs to detect error condition or run time exceptional condition encountered during
the running
In a program either the hardware detects this condition or in a program
detects this condition, then an instruction SWI (software interrupt) is used
Called throwing an exception by the program.
An interrupt service routine (exceptional handler routine) executes, which is
called catch function as it executes on catching the exception thrown.
Executes on detecting the exceptional runtime condition during computations or communication
For example, on detecting that the square root of a negative number is being calculated or
detecting illegal argument in the function or detecting that connection to network not found.
The SWI (software interrupt) instructions in 8086 microprocessor , SWI a1 and SWI a2 will be
inserted for trapping (A- B) as ve number and trapping y > 100 or less than 0
Program:
Try{
If(A-B) <0.1) {
throw a1;
X=y+sqrt(A-B);
y = . // calculate y
}
If ( ( y > 100) | | ( y<0 ) ) {
throw a2;
}
}
Software instruction SWI a1
Causes processor interrupt.
In response, the software ISR function catch (Exception_1 a1) { } executes on throwing of the
exception a1 during try block execution.
SWI a1 is used after catching the exception a1 whenever it is thrown
DEVICE DRIVER:
A device driver has a set of routines (functions) used by a high-level language
programmer, which does the interaction with the device hardware, sends control
commands to the device, communicates data to the device and runs the codes for
reading device data
Each device in a system needs device driver routine with number of device
functions.
An ISR relates to a device driver command (device-function). The device driver
uses SWI to call the related ISR (device-function routine)
The device driver also responds to device hardware interrupts.
A programmer uses generic commands for device driver for using a device. The
operating system provides these generic commands.
Each command relates to an ISR. The device driver command uses an SWI to call
the related ISR device-function routine)
Generic functions used for the commands to the device are device create ( ), open ( ),
connect ( ), bind ( ), read ( ), write ( ), ioctl () [for IO control], delete ( ) and close ( ).
Device driver code is different in different operating system.
Same device may have different code for the driver when system is using different
operating system
Does the interrupt service for any event related to the device and use the system and
IO buses required for the device service.
Device driver can be considered software layer between an application program and
the device
An Interrupt service routine (ISR) accesses a device for service (configuring,
initializing, activating, opening, attaching, reading, writing, resetting, deactivating or
closing).
Interrupt service routines thus implements the device functions of the device driver
INTERRUPT SOURCES:
HARDWARE SOURCES OF INTERRUPTS:
Hardware sources can be internal or external for interrupt of ongoing routine.
The internal sources from devices differ in different processor or
microcontroller families
External sources and ports also differ in different processors or
microcontrollers
1. Parallel Port
2. UART Serial Receiver Port - [Noise, Overrun, Frame-Error, IDLE, RDRF in 68HC11]
3. Synchronous Receiver byte Completion
4. UART Serial Transmit Port-Transmission Complete [e.g. TDRE (transmitter data
register Empty]
5. Synchronous Transmission of byte completed
6. ADC Start of Conversion
7. ADC End of Conversion
8. Pulse-Accumulator overflow
9. Real Time Clock time-outs
10. Watchdog Timer Reset
11. Timer Overflow on time-out
12. Timer comparison with Output compare Registers
13. Timer capture on inputs
SOFTWARE INTERRUPTS:
Software interrupt is interrupt-generated
For example,
software instruction Int n in 80x86 processor
software instruction SWI m in ARM7 processor , where m is 24 bits
Interrupt Vector
System software designer puts the bytes at a ISR_VECTADDR address.
The bytes are for either
o The ISR short code or jump instruction to ISR instruction or
o ISR short code with call to the full code of the ISR at an ISR address or
o Bytes points to an ISR address
A memory address to which processor vectors (transfers into program counter
or IP and CS registers in case of 80x86) a new address on an interrupt for
servicing that interrupt.
The memory addresses for vectoring by the processor are processor or
microcontroller specific.
Vectoring is as per interrupt handling mechanism, which the processor
provides