In the previous lesson, we discussed the different kinds of expansion buses. The purpose of these buses is to accept expansion cards. Internal and external computer hardware, such as disk drives and monitors, can be connected to the computer's motherboard by means of these expansion cards. As we learned in earlier lessons, the expansion buses connect to an external data bus. All devices are connected to the same communication bus. In this lesson, we look at how the computer keeps track of each device and controls the flow of data.
After this lesson, you will be able to:Estimated lesson time: 30 minutes
- Define addresses.
- Describe the attributes and limitations of an IRQ.
- Identify the causes of conflicts within a computer.
- Locate and resolve hardware conflicts.
The bus system establishes a connection between the CPU and expansion devices and provides a path for the flow of data. The computer needs a way to track and control which device is sending data and which device is receiving; without such a means—the bus system—there would be complete chaos. The first step to establishing orderly communication is to assign a unique I/O address to each device.
NOTE
Everything in a computer, whether hardware or software, requires a unique name and address for the CPU to be able to identify what is going on. Bus-mastering devices might seem to get around this requirement, but they have their own controllers that track local traffic and "talk" to the CPU as needed.
I/O addresses are patterns of 1s and 0s transmitted across the address bus by the CPU. The CPU must identify the device before any data is placed on the bus. The CPU uses two bus wires—the IOR (Input/Output Read) wire and the IOW (Input/Output Write) wire—to notify the devices that the address bus is not being used to specify an address in memory, but rather to read to or write from a particular device. The address bus has at least 20 wires. However, when the IOW or IOR wire has voltage, only the first 16 wires are monitored.
To allow communication directly between the CPU and a device, each device responds to unique patterns or code built into it. If the CPU needs to check the error status of a hard disk drive controller, for instance, it activates the IOW wire and puts the correct pattern of 1s and 0s onto the address bus. The controller then sends back a message describing its error status.
All I/O addresses define the range of patterns assigned to each device's command set. The device ignores all commands outside its range. All devices must have an I/O address, and no two devices can have overlapping ranges. Basic devices on the address list have preset I/O addresses that cannot be changed. Other devices must be assigned to the open addresses, and they must be configured at installation. The following table lists standard PC I/O port address assignments.
PC/XT Port | Used By | PC/XT Port | Used By |
---|---|---|---|
000h-00Fh | DMA chip 8237A | 2F0h-2F7h | Reserved |
020h-021h | PIC 8259A | 2F8h-2FFh | COM2 |
040h-043h | PIT 8253 | 300h-31Fh | Prototype adapter |
060h-063h | PPI 8255 | 320h-32Fh | Hard disk controller |
080h-083h | DMA page register | 378h-37Fh | Parallel interface |
0A0h-0AFh | NMI mask register | 380h-38Fh | SDLC adapter |
0C0h-0CFh | Reserved | 3A0h-3AFh | Reserved |
0E0h-0EFh | Reserved | 3B0h-3BFh | Monochrome adapter/ parallel interface |
100h-1FFh | Unused | 3C0h-3CFh | EGA |
200h-20Fh | Game adapter | 3D0h-3DFh | CGA |
210h-217h | Extension unit | 3E0h-3E7h | Reserved |
220h-24Fh | Reserved | 3F0h-3F7h | Floppy disk controller |
278h-27Fh | Parallel printer | 3F8h-3FFh | COM1 |
AT Port | Used By | AT Port | Used By |
000h-00Fh | First DMA chip 8237A | 278h-27Fh | Second Parallel interface |
020h-021h | First PIC 8259A | 2B0h-2DFh | EGA |
040h-043h | PIT 8253 | 2F8h-2FFh | COM2 |
060h-063h | Keyboard controller 8042 | 300h-31Fh | Prototype adapter |
070h-071h | Real-time clock | 320h-32Fh | Available |
080h-083h | DMA page register | 378h-37Fh | First parallel interface |
0A0h-0AFh | Second PIC 8259A | 380h-38Fh | SDLC adapter |
0C0h-0CFh | Second DMA chip 8237A | 3A0h-3AFh | Reserved |
0E0h-0EFh | Reserved | 3B0h-3BFh | Monochrome adapter/parallel interface |
0F0h-0FFh | Reserved for coprocessor 80287 | 3c0h-3CFh | EGA |
100h-1FFh | Available | 3D0h-3DFh | CGA |
200h-20Fh | Game adapter | 3E0h-3E7h | Reserved |
210h-217h | Reserved | 3F0h-3F7h | Floppy disk controller |
220h-26Fh | Available | 3F8h-3FFh | COM1 |
I/O addresses have several important characteristics to remember:
Run the jumpers video located in the demos folder on the CD accompanying this book to view a presentation of how jumpers are used to configure expansion cards.
As mentioned, each device in a computer must have an I/O address. If a device qualifies as a basic device, it will have a standard, preset I/O address. The default setting for the I/O address will work and no changes are required.
If a device is not a basic device, and does not conform to the PCI Plug and Play specification on a Plug and Play-compatible system, read the manual that came with it. The manual will explain how to set the I/O address and define the limits for that device. I/O addresses are set by changing jumpers, switches, or through use of software.
On Plug and Play systems, PCI cards are self-configuring, and usually no intervention is needed to set I/O addresses for those cards. It is possible for Plug and Play cards to conflict with older ISA cards, which don't recognize the Plug and Play devices. If you are confronted with this problem, refer to the cards and the motherboard manual for possible resolution.
Devices assigned overlapping I/O addresses usually do not respond to commands and stop functioning. In such a scenario, a modem will dial but not connect; a sound card will start to play but will stop; a mouse pointer will appear but the mouse will not move. I/O overlaps can sometimes cause the machine to lock up intermittently.
I/O overlaps never happen independently. They usually appear immediately after a new device is installed. The best way to prevent I/O address overlaps is to document all I/O addresses. There are many commercially available programs that will check the I/O addresses for every device on your computer. You can also use Microsoft Diagnostics (MSD), a program provided with MS-DOS.
NOTE
If you are running Windows 95 or Windows 98 or the Windows NT operating system, you can use the Device Manager or System Information to locate and resolve IRQ and address conflicts. (See Chapter 16, "Windows 95 and Beyond," for more information on the Device Manager.)
The I/O address and the address bus establish a method of communication. The next step is to prevent multiple devices from "talking" at the same time. If the CPU needs to communicate with a device, BIOS routines or device drivers can use I/O addresses to initiate conversations over the external data bus.
Controlling the flow of communication is called interruption. Every CPU has a wire called the INT wire. If voltage is applied to the wire, the CPU interrupts what it is doing and attends to the device. For example, when a mouse button is pressed, the CPU attends to the interrupt request, invoking the necessary BIOS routine to query the mouse.
Because the CPU has only one interrupt wire and must handle many peripheral devices, a specific type of chip, called the 8259 chip, is present on the system to help the CPU detect which device is asking for attention. Every device that needs to interrupt the CPU is provided with a wire called an IRQ (interrupt request). If a device needs to interrupt the CPU, it goes through the following steps:
The 8088 computers used only one 8259 chip (see Figure 10.8), which limited these computers to using only eight available IRQs. Because a keyboard and system timer were fixtures on all computers, these IRQs were permanently wired into the motherboard. The remaining six wires were then made part of the expansion bus and were available for use by other devices.
Figure 10.8 8259 chip with IRQ assignments
Starting with the generation of computers based on the 286 chip, two 8259 chips were used to add eight more available IRQs (see Figure 10.9). These new wires were run to the extension on the 16-bit ISA expansion slot (the 8-bit XT slot was extended to a 16-bit XT slot). Because the CPU has only one IRQ wire, one of the IRQs is used to cascade the two 8259 chips together. This gives a total of 15 available IRQs.
NOTE
When a device is cascaded, this means that data is passed through a common path between two devices, usually on to another destination. The term denotes a situation much like water cascading over a waterfall on its journey to the sea.
Figure 10.9 Cascading 8259 chips
Notice that the cascade removes IRQ 2. IRQ 9 is directed to the old IRQ 2 wire. Any older device designed to run on IRQ 2 will now run on IRQ 9. Some important facts to remember about IRQs include the following:
NOTE
The 8259 chips no longer exist on a motherboard. Their functions have become part of the multifunction chips called chip sets that perform all the functions of the 8259 chips and more. However, the information provided in the preceding section is still useful for understanding how this portion of the chip set operates. Also, the IRQ assignments generally are the same.
The following table provides typical IRQ assignments.
IRQ | Function | Available for Change |
---|---|---|
IRQ 0 | System timer | No |
IRQ 1 | Keyboard controller | No |
IRQ 2/9 | Available | Yes |
IRQ 3 | COM2, COM4 | Usually |
IRQ 4 | COM1, COM3 | Usually |
IRQ 5 | LPT2 | Usually |
IRQ 6 | Floppy disk controller | No |
IRQ 7 | LPT1 | Usually |
IRQ 8 | Real-time clock | No |
IRQ 10 | Available | Yes |
IRQ 11 | SCSI/available | Yes |
IRQ 12 | Available | Yes |
IRQ 13 | Math coprocessor | If there is no math coprocessor |
IRQ 14 | Primary IDE controller | No |
IRQ 15 | Secondary IDE controller | Usually |
Devices lacking a fixed or standard IRQ (except for newer PCI cards in compatible PCs) must have their IRQs set during installation. Read the accompanying manuals to learn about these. Setting IRQs is one of the first topics discussed in any device's installation instructions. The manual will tell you not only how to set the IRQ, but also the limits, if any, of the device.
Just like I/O addresses, IRQs can be set using hardware, software, or a combination of both. The best way to ensure that no two devices share the same IRQ is to document the IRQs for each device you install in a computer and file that documentation in a location in which you can find it easily if it is needed. As an example, suppose one of your customers has recently installed a sound card that now locks up when a parallel-port tape backup unit is used on the system. This strongly indicates an IRQ conflict. You need merely to check the sound card and the tape backup IRQ settings you have on file and change one if necessary.
IMPORTANT
Some devices have a limited number of IRQ settings; you might need to change the IRQs of other devices in order to free one of these IRQs.
The CPU runs the BIOS, operating system, and applications, as well as handling interrupts and accessing I/O addresses. This requires the CPU to move a lot of data. This data movement is necessary, requiring considerable CPU power and time, but it is also very simple. Moving data is a waste of the CPU's resources.
To reduce this waste, another chip is installed to work with the system CPU. It is called a direct memory access (DMA) chip. The only function of the DMA chip (the 8237 chip) is to move data. It handles all the data passing from peripherals to RAM and vice versa.
DMA transfers are not automatic. Hardware and device drivers must be designed to take advantage of this chip. Originally, DMA was used only to transfer data between floppy disk drives and RAM; early computers had only four wires and one DMA chip. Any device requiring DMA had to send a request, just like an IRQ.
DMA channels use the same rules as IRQs. Just as with the 8259 chip, DMA availability soon became a problem because an insufficient number of channels was available. A second DMA chip was added for 286-based computers. Just like the second IRQ chip, these two are cascaded, allowing a total of eight DMA channel assignments (usually referred to simply as DMA channels). The floppy disk drives on all computers use DMA channel 2.
Fortunately, not many devices use DMA. Sound cards, a few SCSI controllers, and some CD-ROM drives and network cards do require DMA. Just as with IRQs and I/O addresses, DMA can be set by means of either hardware or software. However, manufacturers started using DMA for devices other than the floppy disk drive only recently. As a result, almost all devices set DMA through software (although some still use jumpers). If two devices share the same DMA channel and "talk" at the same time, the computer will lock up. The following table provides DMA channel assignments.
DMA Channel | Function |
---|---|
0 | Available |
1 | Available |
2 | Floppy disk controller |
3 | ECP parallel/available |
4 | First DMA controller |
5 | Second sound card |
6 | SCSI/available |
7 | Available |
DMA and IRQ work in the same way; therefore, DMA conflicts look and act exactly like IRQ conflicts. Always check for IRQ conflicts first. (It is possible for a computer professional to spend hours trying to solve IRQ problems when the source of the problem is actually the DMA.) If you are sure all IRQs are correct, yet the computer continues to experience a problem, check the DMA. There is very little diagnostic software for resolving DMA problems, so it is important to maintain careful documentation.
IBM created preset combinations of IRQs and I/O addresses for serial and parallel devices. These preset combinations are called ports. The word "port" simply means a portal or two-way access. The preset combinations are called COM ports for serial devices and LPT ports for parallel devices.
The purpose of a port is to make installation easier. Modems and printers, therefore, do not require IRQ or I/O settings. When assigned to an active port (as long as no other device is using that port), they will work. The following table lists standard ports.
Port | I/O Address | IRQ |
---|---|---|
COM1 | 3F8 | 4 |
COM2 | 2F8 | 3 |
COM3 | 3E8 | 4 |
COM4 | 2E8 | 3 |
LPT1 | 378 | 7 |
LPT2 | 278 | 5 |
Most computers are manufactured to offer built-in physical ports with cable connections available either directly to the motherboard or in an expansion slot. In this case, the standard port addresses and IRQs are assigned to them. This makes it possible to install an external device simply by plugging in the port and assigning addresses to the device. If necessary, these ports can be disabled (by using CMOS setup), freeing their I/O addresses and IRQs for another device.
For example, suppose you want to install a new internal modem on a machine that has two external serial ports on the motherboard. By disabling one of these ports, you have made its address and IRQ available for use by the internal device. Simply assign the device to the now-free port.
Assume you have a modem set to COMl. You buy a network card that comes out of the box with a default setting of IRQ 4. You realize the network card and the modem will conflict, and the computer will lock up. What do you do?
You will have to change the IRQ on one of the devices. The network card is probably the best choice, because the modem is installed and already working.
The original 8088-based IBM PCs were equipped with two serial ports: COMl, set to IRQ4, and COM2, set to IRQ3. While those two IRQs are still the standard for COM ports 1 and 2, many BIOS routines will allow different IRQ assignments or even allow an unused port to be disabled. Because of the limited number of IRQ addresses available, any additional COM ports would have to share IRQs with existing ports. COM3 shared the interrupt of COM1 (IRQ4), and COM4 shared the interrupt of COM2 (IRQ3). To enable use of these additional ports, COM3 was assigned I/O address 3E8-3EF, and COM4 was assigned I/O address 2E8-2EF. This sharing was possible because the IRQ-sharing devices would be unlikely to use them at the same time.
Today we have many other ways of adding printers and other peripherals to PCs, but such conflicts can still be a problem with modems and UPS (uninterruptible power supply) devices that might need simultaneous access.
NOTE
The first rule for setting IRQs is to ensure that two devices never share the same IRQ. The only exception is that two (or more) devices can share an IRQ if they never "talk" at the same time! Common IRQ conflicts occur between a serial mouse, sound card, modem, and/or serial printer. (Remember that PCI devices can share an IRQ if it is managed by the same PCI controller.)
LPT ports are for parallel data connections. The name is derived from their original use with printers (LPT—line printer). The original IBM standard LPT port did not provide bidirectional communications (talkback) and was designed solely for one-way data streams to a printer. The standard addresses are IRQ 7 for LPT1 and IRQ 5 assigned to LPT2, if it is present. IRQ 5 quickly became the favorite for devices like sound cards and other add-ons. Today, many devices are made that can use the parallel plug in the back of a computer, thus reducing costs. These devices (tape backups, SCSI drives, or modems) use bidirectional communication and, therefore, need an interrupt. This situation is easing as USB connections replace many of the parallel designs.
The rules for installing expansion cards are simple:
Windows 95, Windows 98, and Windows 2000 support Plug and Play. In most cases, you can insert a Plug and Play card into the proper type of expansion slot and turn on the computer. Windows will find the card and guide you through the setup. The savvy computer professional documents and keeps track of the IRQ, DMA, and I/O addresses, in case a conflict arises with a Plug and Play device on the system.
Windows 95 and Windows 98 use Hardware Properties, under the System Information/Device Manager option in the Control Panel, which does a good job of identifying (and allowing) changes to these settings.
TIP
A good way to document a computer is to print a complete list of the computer's hardware settings from this Hardware Properties dialog box.
NOTE
For Plug and Play to work, the computer must have a Plug and Play BIOS, and the operating system and the device card must be Plug and Play-compliant.
The following points summarize the main elements of this lesson: