Download presentation
Presentation is loading. Please wait.
Published byGriffin Pierce Modified over 8 years ago
1
1 Microprocessors CSE – 341 Basic I/O Interfacing
2
2 Overview A Microprocessor is a great tool for solving problem but is of little or no use if it can’t communicate with other devices. Today we are going to learn some basic concepts about I/O Interfacing of the microprocessor. We will learn a device 82C55 which is very widely used in microprocessor interfacing. This lecture and the next will serve as a prerequisite to the Computer Interfacing course. In that course you will do interfacing in details and will need knowledge of the 82C55 that we may do today.
3
3 I/O Instructions IN is the instruction that reads information from an I/O device. We saw in the labs that to read data from a port/device we used the IN instruction. OUT is the instruction that writes/sends data to an I/O device. We also used this instruction in the labs to send data to various devices that were interface with the microprocessor. What is the instruction to read/write data from memory? Further instructions such as INS and OUTS is also available on modern microprocessor to send strings of data.
4
4 I/O Instructions Remember we used a simulator in the labs which only simulated a subset of functions, registers and instructions of the microprocessor. In the labs we used OUT 01 - To send the contents of AL to device connected to Port 1 IN 01 – To read data from device connected to Port 1 and store in AL. In the real microprocessor this structure is slightly different.
5
5 I/O Instructions In reality the data transfer takes place between the microprocessor accumulator and the I/O device. AL, AX or EAX registers can be used as the accumulator depending on which processor and how many bits are in use. The I/O device may be identified using two methods: Fixed address – A byte called p8 immediately following the opcode stores an 8 bit I/O address. This is called fixed because this is stored with the opcode in the ROM Variable address – Register DX holds a 16 bit I/O address. Because this can be changed it is called variable.
6
6 I/O Instructions IN AL, p8 - A byte is input from port p8 into AL IN AX, p8 - A word is input from port p8 into AX IN EAX, p8 - A double word is input from port p8 into EAX IN AL, DX - A byte is input from the port addressed by DX into AL IN AX, DX - A word is input from the port addressed by DX into AX IN EAX, DX - A double word is input from the port addressed by DX into AX
7
7 I/O Instructions Whenever we used IN and OUT instructions, the I/O address is often called a port number. The port numbers appear on the address lines just as addresses of memory would when we access memory. Remember memory decoding ? Port numbers are also decoded to enable I/O devices the same way. If we use p8 only 8 bits are used thus the address or port number appears on lines A0-A7 If we use DX we used16 bits thus the address or port number appears on lines A0-A15
8
8 I/O Instructions This also means that the first 256 I/O port addresses (00H – FFH) are accessed by both fixed and variable I/O instructions. But addresses 0100H-FFFFH are only accessed by variable I/O Address instructions. The other thing that you need to note is INS and OUTS transfers data between memory and the I/O device. The memory location for INS instruction is obtained by ES:DI The memory location for OUTS instruction is obtained by DS:SI
9
9 Isolated and Memory Mapped I/O There are two types of I/O interfacing Isolated I/O Memory Mapped I/O This where a device is mapped to a memory location. Sending data to the particular location causes interaction with the device. IN, OUT, INS and OUTS do not need to be used. Simple MOV instructions does the trick. Advantages: Less complication, less circuitry, less decoding and no need to use special signal.
10
10 Memory Mapped I/O I/O Memory + I/O 00000 FFFFF Disadvantage: A portion of the memory system is used as the I/O Map. Can you think of any examples for this system from the labs?
11
11 Isolated I/O This is the most common form of I/O transfer technique used with Intel processors. The term isolated means that the memory is separate from the I/O addresses. The isolated I/O addresses are thus referred to as Ports So in this system no memory is wasted for I/O mapping. Name one of the devices that was interfaced to the microprocessor in the lab simulator which used ports and didn’t waste and memory space.
12
12 Isolated I/O A disadvantage is special instructions such as IN, OUT, INS and OUTS need to be used to perform data transfer. Separate signals are also needed to interact with the I/O devices which separate it from normal memory access instructions. M/IO – Used to select Memory or I/O I/O read – IORC I/O write - IOWC On Personal computers Isolated I/O is used. 8 bit port addresses are used to access devices located on system board. 16 bit port address are used to access serial and parallel ports as well as video and disk drive systems.
13
13 Isolated I/O 1M X 8 FFFFF 00000 Memory 64K X 8 0000 FFFF I/O Page 390 of the book shows the I/O for an PC.
14
14 The basic Input Interface The basic input device is a set of three state buffers. The basic output device is a set of data latches. Remember last week we spoke about why we need buffering? The instruction IN moves data from I/O device and the instruction OUT moves data to the I/O device Please copy basic input Interface example being done on the board. This example as we see is a part of the basic input circuit and is not optional. It appears either as a discrete part of the circuit or is embedded into the actual I/O device circuitry.
15
15 The basic Output Interface Please copy basic output interface example being done on the board. This example shows connection of 8 simple LED to the microprocessor. The latch stores the number that is being output my the microprocessor. Latches need to hold data because when the microprocessor executes OUT instruction, the data is only present on the data bus for less than 1.0 s. Without a latch a viewer would never see the LED turn on. Data are retained by the latch until it gets the next OUT instruction.
16
16 This buffering is not only important for LED but for many I/O devices. This is because they accept or release information at a much slower rate than the microprocessor. Another method of I/O control to perform synchronization of the processor with slower devices is called handshaking or polling. An example of this could be printing through a parallel printer that can print at 100 characters per second. Microprocessor can obviously send data at a faster rate than the 100 CPS of the printer. There has to be ways to slow the microprocessor down to match the printers printing speed.
17
17 Certain parts of interfacing requires you to have knowledge of electronics and components. Current and voltages have to be dealt with and measured accurately to ensure that devices in the system are not damaged. Remember we did TTL. The voltages that the microprocessor interprets as 1 and 0. These voltages need to adhered by for the system to work. Remember the concept of switch bouncing. Electronic hardware using gates can be used to debounce switches which frees the programmer from writing delay routines. However, we are not interested in the complexities of electronics for this course. You will learn more in the interfacing course.
18
18 I/O Port Address Decoding This uses the same concept as memory decoding. Memory mapped I/O is the same as memory decoding. Hence, we only discuss isolated I/O decoding. In Memory decoding we decoded the entire set of pins. A0 – A19/A23/A31 In Isolated I/O Addressing we only need to decode A0-A15. (Remember they are either 8 bit or 16 bit) If the system only employs Fixed I/O Addressing we only need to decode A0-A7. For personal computers we always decode all 16 bits.
19
19 8 bit I/O Addresses Fixed I/O uses 8 bit I/O port addresses that appears on A0-A15 as 0000H – 00FFH. If a system will never have more than 256 I/O Devices we can get away with decoding only A0-A7. The rest can be ignored. The variable system can also employ 8 bits if necessary and can address 00H – FFH. If address is decoded as a 8 bit address we can never include I/O Devices that use 16 bit I/O Addresses. Please Copy the eight bit I/O address decoding example done of the board Ignored pins that don’t matter or are not used are said to be in “Don’t Care” state in microprocessor terms.
20
20 16 bit I/O Addresses Modify the circuit so that 16 bit addresses are decoded to give the range EFF8H - EFFFH An alternative approach is to use more than one decoder device such as 138 or 16L8. Both approaches are shown on page 397/399 of the text book.
21
21 The programmable peripheral Interface The 82C55 programmable peripheral interface (PPI) is a very popular low-cost interfacing component that is used found in many applications. Applications range from 7-segment display, stepper motor connection, counters to key pad management. This device is still in use today in P4 Computers and is used to interface and detect key presses on modern keyboards, parallel printers and other interfacing chipsets. For those of you who are doing computer interfacing course you will be extensively using this device to interface various devices with the PC.
22
22 82C55 This device has slightly different structure to the microprocessors we have done so far. I will only go through this device briefly but am not really going to teach you how to use this in depth. For students who are interested this is covered in section 11-3 of the book.
23
23 82C55 This devices has 24 pins for I/O. There are three distinct modes of operation Mode 0, Mode 1 and Mode 2. Group A connections consists of Port A(PA0-PA7) and the upper half of port C (PC4-PC7) Group B connections consists of Port B (PB0-PB7) and the upper half of port C (PC0-PC3) The I/O pins can be programmed in groups of 12 pins.
24
24 82C55 CS pin is used to select the device for reading or writing. Control lines A0 and A1 are used to select the Port that requires interaction. A1A0Function 00Port A 01Port B 10Port C 11Command Registers
25
25 Questions Questions on anything that we have done today or before? We will start with 8255 next week and after discussing its modes in details we will move on to Interrupt Control and Direct Memory Access. I don’t want to lump you with stuff that’s why I went a bit slow today and didn’t cover a lot of material. Please make sure you catch up on your studies if you are lagging behind. Also please make it on time for the labs next week. I will be doing lectures during the first hour of the labs.
26
26 Modes Port A Port B Port C Mode 0 InOut InOut INOut
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.