Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

EPE2206 Computer Systems and

Microprocessors

 Input / Output Examples

Dr Kwee Hiong Lee


kweehiong.lee@singaporetech.edu.sg
Review - Polling
 Polling is simple and responds quickly. It waits for the
I/O device to become ready to send or receive data,
then actions it immediately.
 While waiting, the processor stays in a wait loop.

Example:
An analogue-to-digital convertor has an 8-bit data register that
holds the result of the conversion, and a status bit that
becomes active when the conversion is finished. A processor
repeatedly reads the status bit until it is active. Then the
processor reads the 8 bits of data.
Note: it is sometimes possible to program the processor to do
other work instead of waiting idle in a loop. The program must
periodically return to check the I/O device.
Review - Interrupts
 Interrupts allow the processor to divide its time between
different tasks.
 It can do a separate task while waiting for an I/O device.
 But interrupts are complicated. They may arrive at random
times, changing the execution time of the background task
unpredictably, and possibly making the system difficult to
debug.
Does the processor need to multitask? If not, don't use
interrupts.
Example:
A word processing program is running at the same time
as a document is printing. The printer interrupts the word
processor briefly whenever it is ready for more data.
Review – Simple reading /
writing
 Some simple I/O devices are always ready.
 They do not have facilities to support polling (e.g. a status
indication) and can be read from or written to at any time.

If an I/O device fits this description, this is the only option.

Example:
A processor needs to set the state of an LED. It does nothing
more than write to a flip-flop whenever necessary.
Tutorial Question 1
On a factory production line, a microprocessor system
counts items passing on a conveyor belt. As each item
passes, it pulses a digital input to the system. The system
indicates the count on a 7-segment display.
Draw a block diagram of the system.
How would the input / output be arranged? Explain why.
Using assembly-level pseudo-code, write the programme
for this application.
Assuming that the processor is clocked at 10MHz, and
that every instructions execute in 6 clock cycles, calculate
the maximum rate at which items can be counted.
Tutorial Question 2
In a microprocessor-controlled Geiger counter, the input is
connected to a device that generates a pulse every time a
particle of ionising radiation is detected. The system also
contains a timer that can be read when required by the
processor. The processor does statistical calculations on the
particle arrival rate, and indicates the result on a 7-segment
display.
Draw a block diagram of the system.
How would the input / output be arranged? Explain why.
Using assembly-level pseudo-code, describe the programming
of this application. (Omit the calculation).
Assuming that all instructions execute in 1 µs, comment on the
maximum rate at which this system could count the particles.
Questions
a) A microprocessor system includes the following devices:
Four 32k x 8 SRAM
A 8-bit flip-flop
(i) Suggest a suitable memory map for this system.
(ii) Show with a circuit diagram how you might arrange the
decoding logic
(iii) Write an instruction that will put data into the flip-flop
b) Microprocessor A has a 16-bit data bus. Each bus cycle
occupies 5 clock cycles and the clock frequency is 8MHz.
Its instructions are 32 bits, and it operates on 32-bit data.
How long will the following instruction take ?
Assume that register r1 stores the address for the variable x
(i.e. ldr r1,=varX)
ldrb r2,[r1]
Questions
c) Using a waveform diagram, illustrate a read and write cycle
on a typical microprocessor bus.
d) Present a method to access the contents of the status
register of a UART using a pointer. Give an example of how
you would clear and set a particular bit in the register.
e) A microprocessor system is required to generate an
analogue waveform, which repeats continuously every
second. If the DAC requires 20 us to perform a conversion,
and the output is required to be generated as precisely as
possible, calculate the necessary size of the device (e.g.
ROM) that stores the waveform.

You might also like