UNITS IV & V
The interfacing of an I/O device to an embedded system is always an important task. Generally interfacing means , both the physical connections of the hardware devices and the software routines that effect the data transfer .Due to incompatibility in speeds of the microcontroller and I/O devices ,there is always a problem in data transfer between two devices .This leads to a concept called ‘Latency’. Latency is nothing but the time between the interrupt request from the I/O device and the initiation of service by the microprocessor (or) controller. This latency includes both hardware delays and software delays .The software latency is the time between the availability of new data and the software reading. Another important aspect in I/O interfacing is the throughput (or) bandwidth. The bandwidth is the maximum data flow (bytes per second ) that can be processed by the system .Sometimes the bandwidth is limited by the I/O device while other times it is limited by the software . So to transfer the data synchronously between I/O device and the embedded system , there are two synchronization techniques ,they are a) Blind cycle counting synchronization.
b) Gadfly (or) Busy waiting synchronization.
Blind cycle counting synchronization :
Blind cycle is appropriate for fixed and known I/O delays i.e Blind cycle is a method where the software simply waits a fixed amount of time and assumes that the I/O will complete before that fixed delay has elapsed. For an input device, the software triggers (starts) the external input hardware, wait a specified time, then reads data from device. For an output device, the software writes data to the output device, triggers (starts) the device, then waits a specified time. We call this method blind, because there is no status information about the I/O device reported to the computer software. This type of synchronization is blind because it provides no feed back from the I/O back to the computer .So Blind cycle method ,by the software simply waits a fixed time and assumes that I/O will complete after the fixed delay . This method will be used in situations where the I/O speed is short and predictable.
For example ,let us consider a printer that can print 10 characters every second .With blind cycle counting synchronization , no printer status signal is sent from from the printer to computer. A simple software interface would be enough to output the character, then wait 100ms for it to finish.
The subroutine program that outputs one character follows these steps . 1) Software places the character to be printed on the output port. 2) The software issues a Go pulse and
3) The software waits for 100ms for the character to be printed.
The software program is given below.
Void output (unsigned char LETTER)
Port=LETTER ; / sets ports outputs Pulse (); / pulses go/ Timer_ ms wait(100); / wait for 100ms/
The advantage of blind cycle counting is that it is simple and predictable and in does not have a chance of hanging up. Disadvantages are is the output rate is variable this technique is not suitable. If the input rate is unknown like a keyboard this method is inappropriate. The time delay is wasted . If the delay time is long ,this technique is insufficient. The wait time would be used to perform other useful functions. This blind cycle counting can be appropriate for simple high speed interfaces like ADC.
Gadfly or Busy Waiting...
Please join StudyMode to read the full document