You are on page 1of 33

Microprocessor Systems

Chapter 1 INTRODUCTION TO MICROPROCESSORS A microprocessor is a data processing unit. Data processing includes both computations and data handling. The data processing is done by the ALU. It must have logic to process and handle data and control logic. The control logic tells the microprocessor how to decode and execute the program. Microprocessors operates on the following steps: The microprocessors fetches or gets an instruction The control logic decodes what the instruction says to do. After decoding the microprocessor executes the instruction. These steps are called the fetch and execute cycle. Microcomputer The microcomputer is a complete computing system based on a microprocessor. It has a microprocessor, memory and input/output functions. It also has a power supply and is enclosed in a packaging. A bus connects all the cards in the microcomputer. The bus consists of many single lines that let the different cards talk to one another. The microprocessor is on the CPU card. The CPU card has a clock generator that generates timing signal for the microprocessor Power of a Microprocessor This is the capacity of the microprocessor to process data. Three Main Measures of the Power of a Microprocessor: 1. The length of the microprocessors data word Word lengths of 4, 8, 16, 32 are common.

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

An 8-bit word is called a byte, 16-bit word = 2 bytes, 32-bit word = 4 bytes

15

14

13

12

11

10

Hi byte

Low byte

A 16-bit word The larger the microprocessors word length, the more powerful the microprocessor becomes. 2. The number of memory locations addressed by the microprocessor. The length of the data word in the memory is the same as the length of the data word used by the microprocessor. Each word in a memory is assigned a location number or address. The larger the number of memory addresses, the greater the power of the microprocessor. Word size & memory addressing range & some commonly available microprocessors:
DATA WORD 4-bit 4096 (4K) 8192 (8K) 65,536 (64K) Memory Range address 32,768 (32K) 65,536 (64K) 1,048,576 2,097,152 (1M) 4,194,304 (2M) (4M) 4,294,967,296 34,359,738,367 (46) (326) 8-bit 16-bit 32-bit

3. Speed of the microprocessor. Measured by how long it takes to fetch and execute an instruction. Instruction time and clock frequency are used to describe a microprocessor speed.
AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

Measured by the time it takes to execute a standard or benchmark program. Benchmark programs are short programs. BASIC MICROPROCESSOR ARCHITECTURAL CONCEPTS Three Major Architectural Differences: 1. Length of data 2. Size of addressable memory 3. Microprocessors instruction speed Additional Architectural Differences: Number of registers available to the programmer Different types of instructions available to the programmer Different types of registers available to the programmer Different types of memory addressing modes available to the programmer Different types of support circuits available to the system designer Compatibility with readily available development, system & application software Compatibility with hardware development systems 4-bit Microprocessor Typically used for low-cost consumer applications such as toys, calculators and power tool controllers 8-bit Microprocessor Typically used in more expensive commercial products such as video games and computer peripherals 16-bit, 32-bit, 64-bit Microprocessor features very fast operation, extreme computing power can be found on CAD and CAM systems

Speed may be measured in two different ways:


AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

1. Microprocessors Clock Speed This is the frequency at which the microprocessors clock oscillator operates It is expressed in MHz, GHz 2. Number of Instructions it can execute per speed expressed in millions of instructions per second (MIPS) Two Semi-conductor Technologies commonly used to make Microprocessors: 1. NMOS (N-Channel Metal-Oxide Semi-conductor) Lowest cost because the device is simple to build, however, they consume the most power. 2. CMOS (Complementary Metal-Oxide Semi-conductor) More complex and therefore more expensive to build, but draws less power can stand the widest variation in temperature and operating voltage and has the greatest operating speed. Some other Microprocessor Architectural Techniques being used to increase Speed: Parallel Processing An architectural feature which allows two parts of the computation to be performed at the same time. Co-Processing An architectural feature that provides another processor to handle a special function while the microprocessor is doing general-purpose computing. Example: math co-processor Cache Memory Special memory, which is used to store a section of data so that it can be accessed quickly by the processor. The effectiveness of cache memory depends on how many times the processor is able to make a hit in the cache memory. Pipelining

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

Describes an architectural feature, which allows the process to be worked on an assembly line fashion. This means that the process is broken up into sub-steps, which are then worked on by multiple processors.

Chapter 2

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

INSIDE THE MICROPROCESSOR The Microprocessor Block Diagram and Programming Model Microprocessor Block Diagram Shows a microprocessors logic functions foe data processing and data handling. Shows how each of these logic functions are connected to all the others. Makes it easier to understand the architecture of a microprocessor.

Instruction Register 8 bit Internal Data Bus

Temp 1

IN

ALU

Temp 2

IN OUT

Control Logic

Instruction Decoder

PC SP

MAR

Accumulator Status Register

Microprocessor Basic Block Diagram

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

Programming Model
7 Accumulator A Reg B Reg D Reg H SP PC 15 0 07 Status Reg Reg C Reg E Reg L 0

Assists in the programming process Shows only those parts of the microprocessor, which the programmer can change. Makes it easier to understand the microprocessor in a programming environment. Three Major Logic Functions of the Microprocessor: 1. ALU 2. Registers 3. Control Logic The ALU or Arithmetic Logic Unit Contains the Microprocessors data processing logic Contains two input ports and one output port. An input port is made up of the logic circuits used to get a data word into a logic device. An output port is made up of the logic circuits used to get a data word out of a logic device. Used to arithmetically or logically change or test data. Both of the input ports are buffered by a temporary register, each port has a register that temporarily stores one data word holding the word for the ALU.

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

The Microprocessors Registers Lets you temporarily store a word or a data. Some registers serve a special purpose that is they hold data used in a specific job. Others are a general-purpose register. All Microprocessors have the following basic Registers: 1. Accumulator 2. Program Counter 3. Status Register 4. Stack Pointer Accumulator Microprocessors major register to hold data for manipulation. Accumulators content is usually one half of an arithmetic or logic operation. Accumulators length is the same as that of the microprocessors data word. Some of the microprocessors have an accumulator, which is twice as long as their data word and have two accumulators that let you do accumulator-toaccumulator arithmetic and logic operations. The Program Counter Keeps track of what instruction is being used and what the next instructions will be. The program counters length must be long enough to address any memory location. The pc has to be loaded up with a number. This number is the address of the memory location containing the first program instruction. a. When a microprocessor first starts up, it always gets its first instruction from the same memory location. b. Each program instruction step is then executed in sequence unless a special instruction changes the sequence. 5. General Purpose Register 6. Memory Address Reg. & Logic 7. Instruction Register 8. Temporary Register

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

c. The program counter points to a memory location. The control logic fetches an instruction from the memory location. d. Once the instruction is fetched, the microprocessor increments the pc and executes an instruction. e. The incremented program counter now points to the next program instruction f. The memory address register points to each memory location that the microprocessor wants to use when it wants to use it. g. The memory address register drives the microprocessors address bus. h. The memory address register is long enough to address every memory location in the microprocessors main memory. The Status Register Used to store the results of certain tests performed during the execution of a program. Sometimes called a flag register. Often the data in the status register is used to control how the rest of the program will execute. Some of the Common Status Register Bits are: 1. Carry/Borrow This bit indicates that the last operation caused either a carry or a borrow. The carry bit is set when two binary numbers are added and generate a carry from the eight bit. A borrow is generated when a larger number is subtracted from a smaller number. 2. Zero The zero bit is set when the operation causes all of the registers bit to be logic zero. This happens not only when you decrement the register, but also when any operation causes the registers bit all to become logic zero. 3. Negative

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

10

The status registers negative bit is set when a registers most significant bit is logic 1. In 2s complement arithmetic, a logic 1 in the registers most significant bit means that the number in the register is negative. 4. Intermediate Carry The status registers intermediate carry bit is set when an addition in the first four bits caused a carry into the fifth bit. This is often referred to as the half carry. It is frequently used to assist in the conversion of BCD numbers into binary numbers. 5. Interrupt Flag The status registers interrupt flag is set when the programmer desires to enable the interrupt functions. It is cleared when the programmer wants to disable the interrupt function. If the microprocessor has multiple interrupts, there may be multiple interrupt flags. 6. Overflow Is set when both an arithmetic carry and a signed carry occur in 2s complement arithmetic operations. 7. Parity Is set when the results of an operation leave the indicated register with an odd number of 1s.
Z7 N6 C5 I4 IF
3

O2

P1

10
Parity Overflow Interrupt Flag Intermediate Carry Negative Zero Bit

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

11

Example: Add the following 8-bit binary numbers, indicate how the results sets the bits of the status register. a). 00001111 11110000 e). 01010100 11001100 b). 00111011 11000101 c). 11111111 11111111 d). 00000001 11111110

f). 00000001 01111111

g). 00001111 00010000

h). 11000000 10000001

The Stack Pointer Points to the memory location where temporary data is stored. The stack is used to keep information like the return address The programmer pushes (puts) information onto the stack in order and pops (takes) information from the stack in the reverse order Last-in-First-Out (LIFO) operation Each time the stack is used to store data in the stack pointer, it is decremented so that it points to the next available location General Purpose Registers Simple storage areas Register pairs, BC, DE &HL When used as a register pair, the two registers act as a single 16-bit register. Memory Address Register and Logic Points to the memory location the processor wants to use Hold a binary number, which is the address of a memory location Does not increment Contents of the memory address register depends on the instruction being executed

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

12

Instruction Register Holds the instruction the microprocessor is currently executing a. The instruction register holds the binary word that tells the microprocessor what to do to carry out the current instruction, b. When the instruction is fetched, a copy is taken from the memory location in the program and placed in the instruction register c. During execution, the instruction decoder and control logic read the word in the instruction register. Temporary Data Register Holds data The need for the temporary registers arises because the ALU has no data storage of its own Cannot be used by the programmer and is not a part of the programming model The Microprocessors Control Logic Decodes the instruction and tells the other logic devices what to do and in what order to carry out the instruction. The microprocessors control logic timing comes from the clock The Microprocessors Internal Data Bus Data Bus Data path between all the microprocessors logic devices All the logic devoices are always connected to the bus Logic devices must wait for a signal from the control logic before they can talk to or listen to the bus Data on the bus moves from source to destination

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

13

Chapter 3 MICROPROCESSOR INSTRUCTIONS A Microprocessor Instruction is a unique binary word which, when interpreted by the microprocessor as an instruction, tells it to perform a certain specific operation. The Microprocessors instruction set is the complete collection of all the instructions the instructions the microprocessor knows hoe to perform Its instruction set is unique to that particular model of microprocessor. Instruction Set All the instructions the microprocessor knows how to use It is the complete set of instructions that allows the microprocessor to manipulate data by moving it or processing it and to perform housekeeping functions. The microprocessors instruction word is the same length as its data word. Example: 8-bit microprocessor is 8 bits long 16-bit microprocessor is 16 bits long Any microprocessor may use a number of instruction words to make up a complete instruction. The microprocessors instruction are decoded and carried out when an instruction is loaded into the microprocessors instruction register by the fetch cycle. During the execute cycle, the instruction decodes and the control logic are used to make the microprocessor perform the function indicated by the instruction.

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

14

Get instruction from memory

Decode instruction

Execute instruction

The Microprocessors Fetch/Execute Cycle A microprocessor instruction contains two pieces of information. First, it tells the microprocessor what to do. Second, it tells the microprocessor the address of the data or target with the instruction. It must tell the microprocessor the location of the data to work on. An instruction can be broken into two parts called the op code (operation code) and the address. The op code tells the microprocessor what to do while the address tells the microprocessor where to take the action. Machine Code The actual binary instruction. Mnemonics Is an abbreviation that reminds us of what it stands for Example: CLA LD JMP clear load jump

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

15

Assembler Computer program, which converts mnemonics into machine executable instructions.

Microprocessors Basic Instruction types 1. Data Transfer Instructions allows the programmer to copy data from register to register and between registers and memory locations. The source data is copied into the destination. Register-to-Register Example: LD r, r r in the source. Register-to-Memory and Memory-to -Register Example 1: LD r, (HL) Tells us that the register r is loaded from the memory location pointed to by the register pair HL. Example 2: LD r, n Tells us that the register r is loaded with the value n, which is the second word on the instruction. 2. The Exchange Instructions are used to swap data between sets of registers. The Block Transfer Instructions are used to move a block of data from one set of locations to another set of locations. The Search Instructions allow the programmer to search a block or memory locations for a particular set of data. Example: EX DE, HL 3. The arithmetic and logical instructions allow the programmer to modify the data in a register or sometimes the data in the memory using the arithmetic or logical operators: add, subtract, add with carry, subtract with carry, AND, OR, and Exclusive-OR (XOR).
AVROCILLO DCEE/CEIT/CvSU

r`

Note: Data in the source is copied into the destination and original data stays

Microprocessor Systems

16

Example: A

ADC (HL) A + (HL) + CY

Sum of the accumulators current contents, the contents of the memory location being pointed to by the HL registered pair, and the contents of the status registers carry bit (CY) The Arithmetic and Logical Instruction Group also includes instructions, which let you, increment or decrement the current value contained in a register or memory location. They also include instructions, which allow the programmer to compare the value of a register or a memory location to the value in another register or memory location. The compare instruction only affects the microprocessor status register. 4. The Rotate and Shift Functions allow the programmer to move data to the right or to the left. A rotate instruction is a closed loop instruction wherein the data is moved out at the end and is put back at the other end the shift instruction loses the data that is moved out of the last location. Example: SLA r = CY 7 0 0 Shift left arithmetic will move the contents of bit 7 (MSB) into the carry bit (CY) 5. General-Purpose and CPU Control Instructions usually address the microprocessor itself. They perform a simple operation on the data in a single register or on one of the microprocessors built in functions. Example: CPL DI EI NOP HLT A A (A 1s complement) Interrupts Disabled Interrupts Enabled No Operation Halt

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

17

6.

The Bit Test, Bit Set, and Bit Reset Instructions give the programmer the ability to work at the bit level with the data, which is in a register, memory location, or other location, this is an important instruction group when you are working with data from external hardware. Example: Set b, r rb 1 Shows us that we can set any bit b in any register r to logic 1.

7.

The Jump Instructions are used to permanently change the program counters value. When you change the program counters value, you start executing a different part of the program. The new starting address is given as part of the jump instruction. Two Kinds of Jump Instructions: a. Unconditional simply changes the program counters value. Example: JMP 101E 101E JMP nn PC PC nn

b. Conditional changes the program counters value if the conditional test is met. Example: JZ nn (if zero bit is 1) PC nn 8.

The Call Instruction is used to start execution of a subroutine. A Subroutine is a short program that runs after the program executes a call instruction. Example: CALL (SP 1) (SP 2) PC nn nn nn nn PCH PCL

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

18

The call instructions are different from the jump instruction because executing the call instructions save the current program counter value on the stack. Two forms of Call Instruction: 1. Unconditional Call instruction first the current value of the PC is saved. Then the program execution begins with the instruction stored in the memory location whose address is located into the PC by the call instruction. 2. Conditional Call instruction PC is only changed if the condition is met. Example: CALL NZ, nn (SP - 1) (SP - 2) PC PCH PCL nn

When the value of the program counter is saved on the stack, executing a return instruction loads the program counter with the value saved on the stack. This allows the program to continue execution from where it left off. Example: RET PCL PCH 9. (SP) (SP + 1)

The Input and Output Instructions are used to move data into and out of the microprocessors I/O ports. I/O instructions are only used on the microprocessors that have separate I/O capability. Example: IN A A, (n) (n)

OUT (n) A (n)A The Microprocessors Addressing Modes


AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

19

Addressing modes Are different ways that the microprocessor uses to access memory locations. 1. Inherent or Implied The address is contained in the instruction itself. The source of the data and the destination of the data are built into the instruction. It only requires one word. Example: MOV A, B NOP ALT 2. Immediate Uses two word instructions. The first word is instructions (op code), the second word is the immediate data to be acted on. Example: 3. Direct Addressing May use 2 or 3 bytes. The first is the op code, the second or third byte are memory address. Some manufacturers call 2-byte direct addressing as direct or page addressing while the 3-byte direct addressing as extended direct addressing. 4. Register Indirect Addressing Another single word instruction. The instruction indicates which register contains the address of the needed data. 5. Indexed Addressing Uses a special register called the index register. It is done by adding the contents of the indexed addressing instructions second byte to the index registers current contents. The resulting sum is used as a pointer to the address of a memory location. This is where the data to be operated on the instruction is stored. Indexed addressing only works in microprocessors, which have an index register. LD A, 05

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

20

8-bit number added to the index register has a range of 60H to FFh is called an offset. This means indexed addressing permits pointing to 256 memory locations without changing the index register value. Example: ADD A, (IX + n)

6. Relative Addressing Mode Is like indexed addressing; however, the data value is added to the program counters current value. The sum is used as the instructions address.

Chapter 4

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

21

COMMUNICATING WITH THE MICROPROCESSOR A port is a hole, which allows things to get into or out of something. Some microprocessor ports are only input ports, and some are only output ports. However, it is common to call them I/O ports. The purpose of the I/O port is to get data into the microprocessor for processing and out of the microprocessor when the processing is complete. One common form of I/O data transfer is called the Programmed Data Transfer. Using a programmed data transfer, data is moved between a data register in the I/O port and a memory location or other storage port. For example, a data word at the I/O port may first be transferred into the accumulator and then transferred from the accumulator to a memory location. 2 Types of I/O Data Transfer 1. Transfer with Human Slow and must use meaningful symbols such as the alphanumeric character sets. 2. Transfer with Machine Can be fast and use coded data. Interface describes the process, hardware and software used to get data into and out of a microprocessor. Interfacing is the process of making two different systems communicate with each other. Connecting the I/O Port to the Microprocessor 2 Ways the I/O Port can be connected to the microprocessor: 1. Memory-mapped Accessed using the same process and hardware used to access a memory location. The I/O port simply replaces memory locations, thus reducing the number of memory locations available, but giving the programmer all of the memory handling instructions for handling I/O transfers.

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

22

2. I/O mapped Use special control lines which memory location or an I/O location. The memory and I/O devices are controlled by this line and only respond when they are addressed. This kind of microprocessor has special instructions to perform I/O data transfers and addressing. Two methods of connecting to and addressing I/O devices
64Kk
I/O Port Empty

Empty RAM RAM RAM I/O I/O mapped Ports

0K

48K RAM 32K RAM 16K ROM

Memory-mapped

Polling and
R /W

Interrupts When the


M /W R 1R 0 /W

asked to communicate with an I/O port, servicing the I/O.


Get I/O 01 status register

Microprocessor Enter I/O polling routine

Microprocessor

microprocessor

is

the microprocessor is

2 Ways on how the Microprocessor can service the I/O devices: 1. Polling RoutineIs service
request bit routine A short program that often checks the I/O port to see if it needs service. It set? checks the I/O ports status register to see if it is requesting for service. If it is Call the I/O service

the microprocessor will conduct an I/O service routine and transfer data with the I/O port. If there is a request for service at the I/O port, the polling routine register moves on to the next I/O port until all I/O ports have been tested and those needing service are serviced. Is service
request bit set? Call the I/O service routine Get I/O 02 status

Example of a Polling Routine:


Get I/O 03 status register

Is service request bit set?

Call the I/O service routine


AVROCILLO DCEE/CEIT/CvSU

Exit

Microprocessor Systems

23

An interrupt signal is received by the processor

Complete current instruction

2. Interrupt
Put interrupt input Uses an interrupt input. An current program is a special I/O port on the counter value on stack

microprocessor. A signal on the interrupt input tells the microprocessor that an external device needs attention. Once an interrupt is received, the microprocessor takes special action tospecial the interrupt. contents of a service
memory address called the interrupt vector Load PC with the

A Flow Diagram showing the Interrupt Process .


The microprocessor executes the interrupt service routine that starts at this vector

Execute return from the interrupt


AVROCILLO DCEE/CEIT/CvSU

Continue where interrupted

Microprocessor Systems

24

The interrupt vector is the starting address for the interrupt service routine that is stored at the two special memory locations. A return instruction is used to exit from the interrupt routine. When multiple devices can interrupt the microprocessor, there are a number of ways the microprocessor can find out that needs service. 1. The microprocessor can have multiple interrupt inputs, one for each interrupting device. 2. The interrupting device, with the help of some special logic circuits, can supply the microprocessor with the interrupt vector.

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

25

3. All interrupting devices can use the same interrupt input, and the microprocessor can poll each of the devices to see which caused the interrupt. Most microprocessors have 3 different kinds of interrupt inputs, each having a different priority. 1. Reset, which is used for initialization. 2. Nonmaskable interrupt, which cannot be turned off. 3. Maskable interrupt, which is controlled by the programmer.

Chapter 5 INPUT/OUTPUT AND COMPUTER INTERFACING

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

26

Interface ICs Microprocessors do not communicate directly with any of the peripheral devices. Instead they use a special purpose interface IC like the 8255 Programmable Peripheral Interface. These ICs act as intermediate between the microprocessor and the peripheral. The bus between the microprocessor and the interface IC is consists of three parts: 1. Data Bus this is the 8 or 16-bit bidirectional data bus connected directly to the microprocessor. It transfers data between the microprocessor and the interface IC. 2. Chip Select (CS) used to select the interface IC and should be LOW. When deselected, it will not respond to any commands from the microprocessor. 3. Control these are the signals that control the operation of the microprocessor and the interface IC. They include the READ and WRITE commands and the M/IO signal ( for Intel microprocessors). The interrupts from the peripheral to the microprocessor also use three lines. The bus between the interface IC and the peripheral is also consists of three parts: 1. Data Bus carries the data between the interface IC and the peripheral. The direction of data flow (IN if coming to the peripheral, OUT if going to the peripheral) is usually declared at the start of operation and not changed. The user can decide which way the data will flow. 2. Control Lines These lines transmit commands to the peripheral, they control the way the peripheral operates. 3. Status Lines these lines transmit status information from the peripheral. Status information tells the microprocessor what is happening within the peripheral.

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

27

Port Addressing A single interface IC contains several ports. These ports must have an address to access them. These interface ICs have address inputs that are connected to the LSBs of the address bus and determine which port is selected. Selecting an Interface IC An interface IC is selected or accessed when its CS line goes low. There must be a decoder on the address lines to determine when the address is for the interface IC. Example: An interface IC has four registers that occupy locations 8008-800B in a 16-bit address space. Assume the IC has only one CS line. Construct a decoder needed to select the IC.

The Intel 8255 The Intel 8255 is called a Programmable Peripheral Interface. It is most commonly used in parallel interface IC. It has 24 lines to connect to external devices

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

28

and an interface to a microprocessor. It has three ports namely port A , port B, port C.

8255 Pin Layout (Source: Intel)

D0-D7 RD and WR -

8-bit bidirectional data bus signals from the microprocessor that indicate whether the 8255 is being read or written

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

29

A0 and A1 CS

the two LSBs of the address bus. They select one of the four registers in the 8255. Chip Select. This pin determines when the port address for the 8255 is present and the 8255 should be accessed.

The 8255 Registers Port A this registers is accessed when A0=0 and A1 = 0. It is the data register for Port A. If port A is an input, the data coming in from the port A lines can be read in this register. If port A is an output, the data to be sent out must be written to the port A register. Port B This register is accessed when A0 =1 and A1 = 0. It controls port B, but functions in the same way as the port A register. Port C This register is accessed when A0=0 and A1 = 1. It controls port C.

Control Register

This register is accessed when A0 = 1 and A1 = 1.

The Control Register for the 8255

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

30

The 8255 operates in one of three modes, 0, 1,2. Mode 0 is the basic I/O mode where all ports are either input or output. Mode 1 is the handshaking mode, and some of the port C lines are reserved for control functions. Mode 2 is the bidirectional data mode. Commands are given to the 8255 by writing to the control register. D7 D6 D5 D4 D3 D2 D1 D0

Bit 5 and 6 Bit 4 Bit 3 and 0 Bit 2 Bit 1-

determine the mode of port A direction bit for port A direction bit for port C mode bit for port B which can only operate in modes 0 or 1 direction bit for port B.

If bit 7 is a 1, the command is in mode set. The reset of the bits in the command, sets the mode of the 8255. If bit 7 of the control register is a 0, the command is a bit set command. It sets or clears a bit in the port C register. This can be used in mode 1 operation. Mode 0 Operation Mode 0 operation is a simple I/O. All lines on all ports are either input or output as determined by the word written to the command register. It is the most commonly used mode.

Example:

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

31

The 8255 uses ports 60-63 and is set-up so that ports A and C are used for input and port B is used for output. a) What control word must be sent to the 8255 to set the ports? b) What instructions must be issued to do this? Mode 1 Operation - Input often called the handshaking mode. Either port A or port B (or both) can operate in this mode. Some bits of port C are reserved for controlling the flow of information between the 8255 and the peripheral device and may not used for data transmission. The configuration for Port A in input handshaking uses three lines of port C (PC4, PC5, PC3) STBA (Strobe A) This signal is sent from the peripheral device to the 8255. It indicates that the peripheral device has a valid byte for the 8255 and has placed it on the port A lines. IBFA (Input Buffer Full A) When the IBF is high, it indicates that the 8255 has received data, but has not processed it. The peripheral should not send another byte of data while IBF is high. INTRA (Interrupt) This signal allows port C to interrupt the microprocessor when data has been received, so it can read in the byte and allow the next byte to be sent.

The pins for mode 1 input to Port B, STRB, IBFB, INTRB are on pins PC2, PC1 and PC0 respectively.

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

32

Mode 1 Operation Output Handshaking on output can occur when the microprocessor is sending data to a peripheral IC via the 8255 interface. Three lines on port C are used to control the data transmission. OBFA (PC7) A write to port A in mode 1 causes OBF to go LOW. This indicates to the peripheral that data is available. ACKA (PC6) A LOW pulse on the ACK line, which is controlled by the peripheral indicates that it has accepted the data and causes OBF to go high. It will remain HIGH until the microprocessor writes the next byte to the port. INTRA (PC3) If interrupts are used, the trailing edge of ACK will cause an port. interrupt. This interrupt will then cause the microprocessor to write the next data byte to the output

REFERENCES

AVROCILLO DCEE/CEIT/CvSU

Microprocessor Systems

33

Greenfield, J.D., Practical Digital Design using ICs 3rd ed., pp. 551-576, Regents Prentice Hall, 1994 Tocci, R.J, Ambrosio, F.J., Microprocessors and Microcomputers, Hardware and Software 5th ed. , Prentice Hall International, Inc., Triebel, W.A., Singh, Avtar., The 8088 and 8086 Microprocessors Programming, Interfacing, Hardware, Software and Applications, 2nd ed., Prentice Hall Intl, Inc., 1997

AVROCILLO DCEE/CEIT/CvSU

You might also like