Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Single- and Multi-Chip Microcontroller Interfacing For the Motorola 68HC12 (G.J. Lipovski, 1999).pdf
Скачиваний:
112
Добавлен:
12.08.2013
Размер:
41.97 Mб
Скачать

5

Interrupts and Alternatives

The computer has to be synchronized with the fast or slow I/O device. The two main areas of concern are the amount of data that will be input or output and the type of error conditions that will arise in the I/O system. Given varying amounts of data and different I/O error conditions, we need to decide the appropriate action to be taken by the microcomputer program. This is studied in this chapter.

One of the most important problems in I/O systems design is timing. In §4.3.2, we saw how data can be put into a buffer from an input device. However, we ignored the problem of synchronizing with the source of the data so that we get a word from the source when it has a word to give us. I/O systems are often quite a bit slower, and occasionally a bit faster, than the computer. A typewriter may type a fast 30 characters per second, but the 6812 can send a character to be typed only once every 266,667 memory cycles. So the computer often waits a long time between outputting successive characters to be typed. Behold the mighty computer, able to invert a matrix in a single bound, waiting patiently to complete some tedious I/O operation. On the other hand, some I/O systems, such as hard disks, are so fast that a microcomputer may not take data from them fast enough. Recall that the time from when an I/O system requests service (such as to output a word) until it gets this service (such as having the word removed) is the latency. If the service is not completed within a maximum latency time, the data may be overwritten by new data and lost before the computer can store them.

Synchronization is the technique used to supply data to an output device when the device needs data, to get data from an input device when the device has some data available, or to respond promptly to an error if ever it occurs. Over ten techniques are used to match the speed of the I/O device to that of the microprocessor. Real-time synchronization is conceptually quite simple; in fact we have already written a real-time program in the previous chapter to synchronize to a traffic light. Gadfly synchronization requires a bit more hardware, but has advantages in speed and software simplicity. Gadfly was actually used in synchronizing the SPL Three more-powerful interrupt synchronization techniques - polled, vectored, and real-time - require more hardware. Direct-memory access and context switching are faster synchronization mechanisms. Shuttle, indirect, time-multiplexed, and video memories can be used for very fast I/O devices. These synchronizationtechniques are also discussed in this chapter.

193