Difference Between Microprocessor and Microcontroller PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document compares microprocessors and microcontrollers, outlining their key differences in terms of functionality, components, and applications. It also provides a brief history of both.
Full Transcript
DIFFERENCE BETWEEN MICROPROCESSOR Early 80s: Intel released fourth-generation 32-bit AND MICROCONTROLLER processors. 1995: Intel released in fifth-gen...
DIFFERENCE BETWEEN MICROPROCESSOR Early 80s: Intel released fourth-generation 32-bit AND MICROCONTROLLER processors. 1995: Intel released in fifth-generation 64-bit MICROPROCESSOR: A microprocessor is a controlling processors. unit of a micro-computer wrapped inside a small chip. It performs Arithmetic Logical Unit (ALU) operations and HISTORY OF MICROCONTROLLER communicates with the other devices connected with it. 1975: Microcontroller are first used in 1975 (Intel 8048) It is a single Integrated Circuit in which several functions 1993: The introduction of EEPROM in 1993 are combined. 1993: The same year, Atmel introduced the first MICROCONTROLLER: A microcontroller is a chip microcontroller using Flash memory. optimized to control electronic devices. It is stored in a single integrated circuit which is dedicated to Microprocessor Vs Microcontroller: performing a particular task and execute one specific What is the difference? application. It is specially designed circuits for Microprocessor Microcontroller embedded applications and is widely used in Heart of an embedded automatically controlled electronic devices. It contains Heart of Computer system. system. memory, processor, and programmable I/O. It is only a processor, so memory It has a processor along with and I/O components need to be internal memory and I/O connected externally components. KEY DIFFERENCES Memory and I/O has to be Memory and I/O are already Microprocessor Microcontroller connected externally, so the present, and the internal Consists of only a Central Contains CPU, Memory, I/O circuit becomes large. circuit is small. Processing Unit all integrated into one chip. You can't use it in compact You can use it in compact systems systems. Used in Personal Computers Used in Embedded System Cost of entire system is high Cost of entire system is low Uses external bus to interface Uses an internal controlling As external components are to RAM, ROM, and other Due to external components, the bus. low, total power peripherals total power consumption is high. consumption is less. So, it Based on Harvard Therefore, it is not ideal for the Based on Von Neumann model can be used with devices architecture devices running on stored power running on stored power like Complicated and expensive, Inexpensive and like batteries. batteries. with a large number of straightforward with fewer Most of the microprocessors do Most of the microcontrollers instructions to process instructions to process. not have power saving features. offer power-saving mode. It is used mainly in a washing It is mainly used in personal machine, MP3 players, and computers. TYPES embedded systems. Microprocessor Microcontroller Microprocessor has a smaller Microcontroller has more number of registers, so more register. Hence the programs Complex Instruction Set 8 bit Microcontroller operations are memory-based. are easier to write. Microprocessors 16 bit Microcontroller Microprocessors are based on Micro controllers are based The Application Specific 32 bit Microcontroller Von Neumann model on Harvard architecture Integrated Circuit Embedded It is a byproduct of the Reduced Instruction Set Microcontroller It is a central processing unit on a development of Microprocessors External memory single silicon-based integrated microprocessors with a CPU Digital Signal Multiprocessors Microcontroller chip. along with other peripherals. (DSPs) It has no RAM, ROM, Input- It has a CPU along with RAM, Output units, timers, and other ROM, and other peripherals peripherals on the chip. embedded on a single chip. HISTORY OF MICROPROCESSOR It uses an external bus to It uses an internal controlling 1959: Fairchild Semiconductors invented the first IC interface to RAM, ROM, and other bus. peripherals. (Integrated Circuit). Microprocessor-based systems Microcontroller based 1968: Robert Noyce, Gordan Moore, Andrew Grove can run at a very high speed systems run up to 200MHz or found their own company Intel. because of the technology more depending on the 1981: Intel grew from 3 man start-up in 1968 to involved. architecture. industrial giant by 1981. It's used for general purpose It's used for application- 1971: INTEL created the first generation applications that allow you to specific systems. handle loads of data. Microprocessor 4004 that would run at a clock speed of It's complex and expensive, with a It's simple and inexpensive 108 kHz large number of instructions to with less number of 1973 to 1978: second-generation 8-bit process. instructions to process. microprocessors were fabricated like Motorola 6800 and 6801, INTEL-8085, and Zilog's-Z80. 1978: Intel 8008 third-generation process came into the market. FEATURES Microprocessor Microcontroller Offers built-in monitor/debugger Processor reset program with interrupt capability Program and Large amount of instructions Variable Memory each carrying out a different (RAM) I/O pins variation of the same operation Device clocking Offers Parallel I/O central processor Instruction cycle timer External Instruction memory interface cycle timers APPLICATIONS Microprocessor Microcontroller Calculators Mobile phones Accounting system Automobiles Games machine CD/DVD players Complex industrial controllers Washing machines Traffic light Cameras Control data Security alarms Military applications Defense systems Computation systems SUMMARY What is the Difference Between a Microcontroller and Microprocessor? The key difference between a Microprocessor and a Microcontroller is the Microprocessor consists of only a Central Processing Unit, whereas the Microcontroller contains a CPU, Memory, I/O all integrated into one chip. A Microcontroller is an inexpensive, straightforward, and small number of instructions to process, whereas a Microprocessor is complex and expensive, with many instructions. Which is Better Microcontroller or Microprocessor? Both of these processes are good. However, which one you should use depends upon your requirements. Microcontrollers are mainly used for small applications like washing machines, Cameras, Security alarms, Keyboard controllers, etc., Microprocessor is used in Personal Computers, Complex industrial controllers, Traffic light, Defense systems, etc. Which is Faster Microprocessor or Microcontroller? Microprocessors are much faster than microcontrollers. The clock speed of a microprocessor is above 1 GHz. While in the case of the Microcontroller, the clock speed is 200MHz or more, depending on the architecture MICROPROCESSOR FUNDAMENTALS information to upgrade to the new microprocessors as they are introduced. SSI/MSI IC versus Microprocessor Typically, when a new microprocessor is Traffic light controller goes through the sequence introduced, it will have a few new software green–yellow–red. To implement the circuit using instructions available and have some of the I/O combinational and sequential logic, we use: features, previously handled by external support counter ICs for the timing chips, integrated right into the microprocessor chip. shift register for sequencing the lights, Learning the basics on these new microprocessor a D flip-flop if we want to interrupt the sequence upgrades is more difficult, however, because some with a pedestrian cross-walk push button of their advanced features tend to hide the actual A complete design solution is easily within the realm of operation of the microprocessor and may hinder SSI and MSI ICs. your complete understanding of the system. Conversely, think about complexity of electronic control of a modern auto mobile. There are several analog quantities to monitor, such as: 17–1: INTRO TO SYSTEM COMPONENTS AND BUSES engine speed manifold pressure coolant temperature There are several digital control functions to perform, such as: spark plug timing, fuel mixture control radiator circulation control The operation is further complicated by the calculations and decisions that have to be made on a continuing basis. This is definitely an application for a microprocessor-based system A system designer should consider a microprocessor- based solution whenever an application involves making calculations, making decisions based on external stimulus, and maintaining memory of past events. SEVERAL ADVANTAGES OF A MICROPROCESSOR OVER THE HARD-WIRED SSI/MSI IC APPROACH. Figure 17–1 shows a microprocessor with the 1. First, the microprocessor is a general-purpose necessary support circuitry to perform basic input and device output functions. 2. It takes on a unique personality by the software program instructions given by the designer We use this figure to illustrate how the microprocessor 3. Its capacity to perform arithmetic, make acts like a general-purpose device, driven by software, comparisons, and update memory makes it a very to perform a specific task related to the input data powerful digital problem solver. switches and output data LEDs. First, let’s discuss the 4. Making changes to an application can usually be components of the system. done by changing a few program instructions, THE COMPONENTS OF THE SYSTEM unlike the hard-wired system that may have to be Microprocessor totally redesigned and reconstructed. The heart of the system is an 8-bit microprocessor. 5. New microprocessors are introduced every year to It could be any of the popular 8-bit microprocessors fill the needs of the design engineer. However, the such as the Intel 8085, the Motorola 6800, or the theory behind microprocessor technology Zilog Z80. remains basically the same They are called 8-bit microprocessors because It is a general-purpose digital device that is driven by external and internal data movement is per formed software instructions and communicates with several on 8 bits at a time. external support chips to perform the necessary I/O of a It will read program instructions from memory and specific task. execute those instructions that drive the three Once you have a general understanding of one of the external buses with the proper levels and timing to earlier microprocessors that came on the market, such make the connected devices perform specific as the Intel 8080/8085, the Motorola 6800, or the Zilog operations. Z80, it is an easy task to teach yourself the necessary Buses are simply groups of conductors that are routed Memory throughout the system and tapped into by various There will be at least two memory ICs: a ROM or EPROM devices (or ICs) that need to share the information that and a RAM. is traveling on them. The ROM will contain the initialization instructions, Address Bus telling the microprocessor what to do when power Address Bus is 16 bits wide and is generated by the is first turned on. This includes tasks like reading microprocessor to select a particular location or IC to the keyboard and driving the CRT display. It also be active. contains several subroutines that can be called by In the case of a selected memory IC, the low-order the microprocessor to perform such tasks as time bits on the address bus select a particular location delays or I/O data translation. These instructions, within the IC (see Section 16–5). which are permanently stored in ROM, are referred to as the monitor program or operating system. The RAM part of memory is volatile, meaning that it loses its contents when power is turned off and, therefore, is used only for temporary data storage. Input Port The input port provides data to the microprocessor via the data bus. In this case, it is an octal buffer with three-stated outputs. The input to the buffer is provided by some input device like a keyboard or, as in this case, from eight HIGH–LOW toggle switches. The input port will dump its information to the data bus when it receives a Chip Enable (𝐶𝐸 ̅̅̅̅ ) from the address decoder and a Read command Output Port ̅̅̅̅) from the control bus. (𝑅𝐷 Because the address bus is 16 bits wide, it can Output Port actually specify 65,536 (216) different addresses. The output port provides a way for the The input port is one address, the output port is microprocessor to talk to the outside world. It could one address, and the memory in a system of this be sending data to an output device like a printer or, size may be 4K (4096) addresses. as in this case, it could send data to eight LEDs. This leaves about 60K addresses available for future An octal D flip-flop is used as the interface expansion. because, after the microprocessor sends data to it, Data Bus the flip-flop will latch on to the data, allowing the microprocessor to continue with its other tasks. Once the address bus is set up with the particular address that the microprocessor wants to access, the To load the D flip-flop, the microprocessor must microprocessor then sends or receives 8 bits of data to first set up the data bus with the data to be output. or from that address via the bidirectional (two-way) Then, it sets up the address of the output port so that the address decoder will issue a LOW 𝐶𝐸 ̅̅̅̅ to it. data bus. Control Bus Finally, it issues a pulse on its 𝑊𝑅̅̅̅̅̅ (write) line that The control bus is of varying width, depending on the travels the control bus to the clock input of the D microprocessor being used. It carries control signals flip-flop. When the D flip-flop receives the clock that are tapped into by the other ICs to tell what type of trigger pulse, it latches onto the data that are on the operation is being performed. From these signals, the data bus at that time and drives the LEDs. ICs can tell if the operation is a read, a write, an I/O, a memory access, or some other operation. Address Decoder The address decoder is usually an octal decoder like the 74LS138 studied in Chapters 8 and 16. Its function is to provide active-LOW Chip Enables ̅̅̅̅ ) to the external ICs based on information it (𝐶𝐸 receives from the microprocessor via the control and address buses. Because there are multiple ICs on the data bus, the address decoder ensures that only one IC is active at a time to avoid a bus conflict caused by two ICs writing different data to the same bus. 17–2 SOFTWARE CONTROL OF MICROPROCESSOR 17-3 INTERNAL ARCHITECTURE OF A SYSTEMS MICROPROCESSOR Once you have a working prototype, all operational The design for the Intel 8085A microprocessor was changes can then be made with software. derived from its predecessor, the 8080A. Areas such as: address decoding, chip enables, The 8085A is software compatible with the 8080A, instruction timing, and hardware interfacing become meaning that software programs written for the 8080A important when programming microprocessors. can run on the 8085A without modification. BASIC I/O OPERATIONS The 8085A has a few additional features not As a brief introduction to microprocessor software, let’s available on the 8080A. refer back to Figure 17–1 and learn the statements The 8085A also has a higher level of hardware required to perform some basic I/O operations. integration, allowing the designer to develop Accumulator complete microprocessor-based systems with To route the data from the input switches to the output fewer external support ICs than were required by LEDs, the data from the input port must first be read into the 8080A. the microprocessor before they can be sent to the Studying the internal architecture of the 8085A in Figure output port. The microprocessor has an 8-bit internal 17–2 and its pin configuration in Figure 17–3 will give us register called the accumulator that can be used for a better understanding of its operation. this purpose. THE INTERNAL ARCHITECTURE OF 8085A ASSEMBLY LANGUAGE The software used to drive microprocessor-based systems is called assembly language. LDA addr The Intel 8080/8085 assembly language statement to load the contents of the input port into the accumulator is LDA addr. LDA is called a mnemonic, an abbreviation of the operation being performed, which in this case is “Load Accumulator.” The suffix addr will be replaced with a 16-bit address (4 hex digits) specifying the address of the input port. STA addr After the execution of LDA addr, the accumulator will contain the digital value that was on the input switches. Now, to write these data to the output port, we use the command STA addr. STA is the mnemonic for “Store Accumulator,” and addr is the 16-bit address where you want the data stored. Execution of those two statements is all that is necessary to load the value of the switches into the accumulator and then transfer these data to the output LEDs. The microprocessor takes care of the timing on the three buses, and the address decoder takes care of providing chip enables to the appropriate ICs. CPU If the system is based on Motorola or Zilog technology, the The 8085A is an 8-bit parallel central processing unit software in this case will be almost the same. Table 17–1 (CPU). The accumulator discussed in the previous makes a comparison of the three assembly languages. section is connected to an 8-bit internal data bus. Six other general-purpose registers labeled B, C, D, E, H, and L are also connected to the same bus. ALU All arithmetic operations take place in the arithmetic logic unit (ALU). The accumulator, along with a temporary register, is used as input to all arithmetic operations. The output of the operations is sent to the internal 17–4 INSTRUCTION EXECUTION WITHIN A data bus and to five flag flip-flops that record the MICROPROCESSOR status of the arithmetic operation. Referring back to the basic I/O system diagram of Figure Instruction Register and Decoder 17–1, let’s follow the flow of LDA and STA instructions as The instruction register and decoder receive the they execute in the block diagram of the 8085A. software instructions from external memory, interpret Figure 17–4 shows the 8085A block diagram with what is to be done, and then create the necessary numbers indicating the succession of events that timing and control signals required to execute the occurs when executing the LDA instruction. instruction. Interrupt control The block diagram also shows interrupt control, which provides a way for an external digital signal to interrupt a software program while it is executing. This is accomplished by applying the proper digital signal on one of the interrupt inputs: INTR, RSTx.x, or TRAP. Serial communication capabilities are provided via the SID and SOD I/O pins (Serial Input Data, Serial Output Data). Register Array The register array contains the six general-purpose 8- bit registers and three 16 bit registers. Sixteen-bit registers are required whenever you need to store Remember, LDA addr and STA addr are assembly addresses. language instructions, stored in an external memory IC, Stack Pointer that tell the 8085A CPU what to do. The stack pointer stores the address of the last entry on LDA addr tells the CPU to load its accumulator with the stack. The stack is a data storage area in RAM used the data value that is at address addr. by certain microprocessor operations. STA addr tells the CPU to store (or send) the 8-bit Program Counter value that is in the accumulator to the output port at The program counter contains the 16-bit address of the address addr. next software instruction to be executed. MACHINE CODE Address Latch The mnemonics LDA and STA cannot be understood by The third 16-bit register is the address latch, which the CPU as they are; they have to be assembled, or contains the current 16-bit address that is being sent to converted, into a binary string called machine code. the address bus. Binary or hexadecimal machine code is what is The six general-purpose 8-bit registers can also be used actually read by the CPU and passed to the instruction in pairs (B–C, D–E, H–L) to store addresses or 16-bit register and decoder to be executed. The Intel 8085A data. Users Manual gives the machine code translation for LDA as 3A16 (or 3AH) and STA as 32H. Before studying the flow of execution in Figure 17–4, we need to make a few assumptions. Let’s assume that the input port is at address 4000H and the output port is at address 6000H. Let’s also assume that the machine code program LDA 4000H, STA 6000H is stored in RAM starting at address 2000H. Load Accumulator Sequence of execution of LDA 4000H in Figure 17–4: 1. The program counter puts the address 2000H on the address bus. 2. The timing and control unit issue a LOW pulse on the ̅̅̅̅ 𝑅𝐷 line. This pulse travels the control bus to the RAM in Figure 17–1 and causes the contents at location 2000H to be put onto the external data bus. RAM (2000H) has the machine code 3AH, which travels across the internal data bus to the instruction register. 3. The instruction register passes the 3AH to the 6. The timing and control unit issues a LOW pulse on instruction decoder, which determines that 3AH is ̅̅̅̅̅ line. Because the 𝑊𝑅 the 𝑊𝑅 ̅̅̅̅̅ line is used as a clock the code for LDA and that a 16-bit (2-byte) address input to the D flip-flop of Figure 17–1, the data from must follow. Because the entire instruction is 3 the data bus will be stored and displayed on the bytes (one for the 3AH and two for the address LEDs. (The 𝑊𝑅 ̅̅̅̅̅ line from the microprocessor is part 4000H), the instruction decoder increments the of the control bus in Figure 17–1.) program counter two more times so that the address latch register can read and store bytes 2 and 3 of the instruction. The complete assembly language and machine code 4. The address latch and address bus now have 4000H program for preceding I/O example is given in Table 17–2. on them, which provides the LOW ̅̅̅̅ 𝐶𝐸 for the input port in Figure 17–1. 5. The timing and control unit again issues a LOW pulse on the ̅̅̅̅ 𝑅𝐷 line. This pulse travels the control bus to the input port, causing the data at the input port (4000H) to be put onto the external data bus. 6. Those data travel across the external data bus in Figure 17–1, to the internal data bus in Figure 17–4, to the accumulator, where they are now stored. The instruction is complete. Store Accumulator 17–5 HARDWARE REQUIREMENTS FOR BASIC I/O PROGRAMMING A good way to start out in microprocessor programming is to illustrate program execution by communicating to the outside world. MEMORY-MAPPED I/O In Section 17–4, we read input switches at memory location 4000H using the LDA instruction and wrote their value to output LEDs at location 6000H using the STA instruction. This was an example of memory- mapped I/O. Using this method, the input and output devices were accessed as if they were memory locations by 1. After the execution of the 3-byte LDA 4000H specifying their unique 16-bit address (4000H or instruction, the program counter has 2003H in it. 6000H). (Instruction LDA 4000H resided in locations 2000H, The other technique used by the 8085A 2001H, 2002H.) microprocessor for I/O mapping is called standard 2. The timing and control unit will issue a LOW pulse I/O or I/O-mapped I/O. on the ̅̅̅̅ 𝑅𝐷 line. This causes the contents of RAM I/O-mapped systems identify their input and location 2003H to be put onto the external data bus. output devices by giving them an 8-bit port RAM (2003H) has the machine code 32H, which number. travels up the internal data bus to the instruction The microprocessor then accesses the I/O ports by register. using the instructions OUT port and IN port, where 3. The instruction register passes the 32H to the port is 00H to FFH. instruction decoder, which determines that 32H is the code for STA and that a 2-byte address must HARDWARE follow. The program counter gets incremented two Special hardware external to the 8085A is required to more times, reading and storing bytes 2 and 3 of the provide the source for the IN instruction and the instruction into the address latch. destination for the OUT instruction. 4. The address latch and address bus now have 6000H Figure 17–6 shows a basic hardware configuration, on them, which is the address of the output port in using standard SSI and MSI ICs, that could be built to Figure 17–1. input data from eight switches and to output data to 5. The instruction decoder now issues the command eight LEDs using I/O mapped I/O to place the contents of the accumulator onto the data bus. OUT FEH The 74LS374 (see Section 13–9) is an octal D flip- flop set up to sink current to illuminate individual LEDs based on the binary value it receives from the data bus. The outputs at Q0 to Q7 will latch onto the binary values at D0 to D7 at the LOW-to-HIGH edge of Cp. U5 and U6b are set up similarly to U4 and U6a, except U5’s output goes LOW when FEH (1111 1110) is input. Therefore, during the execution of OUT FEH, U6b will output a LOW pulse, the same width as the 𝑊𝑅 ̅̅̅̅̅ pulse issued by the microprocessor. The setup time of the 74LS374 latch is accounted for by the microprocessor timing specifications. The microprocessor issues a HIGH-to-LOW edge at ̅̅̅̅̅ that makes its way to Cp. 𝑊𝑅 At the same time, the microprocessor also sends Figure 17–6 is set up to decode the input switches as the value of the accumulator to the data bus. port FFH and the output LEDs as port FEH. After a time period greater than the setup time for The 𝐼𝑂/𝑀 ̅ line from the microprocessor goes HIGH U3, ̅̅̅̅̅ 𝑊𝑅 goes back HIGH, which applies the LOW- whenever an IN or OUT instruction is being to-HIGH trigger edge for U3, latching the data at Q0 executed (I/O-mapped I/O). to Q7. All instructions that access memory and memory- Summary mapped devices will cause the 𝐼𝑂/𝑀 ̅ line to go To summarize, the instruction IN FFH reads the LOW. binary value at port FFH into the accumulator. The ̅̅̅̅ 𝑅𝐷 line from the microprocessor will be pulsed The instruction OUT FEH writes the binary value in LOW when executing the IN instruction, and the ̅̅̅̅̅ 𝑊𝑅 the accumulator out to port FEH. line will be pulsed LOW when executing the OUT Port selection is taken care of by eight-input NAND instruction. gates attached to the high-order address bus and by IN FFH ̅̅̅̅, 𝑊𝑅 use of the 𝑅𝐷 ̅̅̅̅̅ , and 𝐼𝑂/𝑀 ̅ lines. The 74LS244 (see Section 13–9) is an octal three- state buffer that is set up to pass the binary value of 17–6 WRITING ASSEMBLY LANGUAGE AND MACHINE the input switches over to the data bus as soon as ̅̅̅̅ LANGUAGE PROGRAMS 𝑂𝐸1 and ̅̅̅̅ 𝑂𝐸2 are brought LOW. The microprocessor is driven by software instructions To get that LOW, U6a, the inverted-input NAND gate to perform specific tasks. (OR gate), must receive three LOWs at its input. The instructions are first written in assembly We know that the IN instruction will cause the ̅ line to go LOW and the 𝑅𝐷̅̅̅̅ line to go language using mnemonic abbreviations and then inverted 𝐼𝑂/𝑀 converted to machine language so that they can be LOW. interpreted by the microprocessor. The other input is dependent on the output from the The conversion from assembly language to machine right-input NAND gate (U4). language involves translating each mnemonic into Gate U4 will output a LOW because the binary value the appropriate hexadecimal machine code and of the port number (1111 1111) used in the IN storing the codes in specific memory addresses. instruction is put onto the high-order address bus This can be done by a software package called an during the execution of the IN FFH instruction. assembler, provided by the microprocessor All conditions are now met; U6a will output a LOW manufacturer, or it can be done by the programmer pulse (the same width as the LOW 𝑅𝐷 ̅̅̅̅ pulse), which by looking up the codes and memory addresses will enable the outputs of U2 to pass to the data (called hand assembly). bus. ASSEMBLY LANGUAGE After the microprocessor drops the ̅̅̅̅ 𝑅𝐷 line LOW, it Assembly language is classified as a low-level waits a short time for external devices (U2 in this language because the programmer has to take care of case) to respond, and then it reads the data bus and all the most minute details. raises the ̅̅̅̅ 𝑅𝐷 line back HIGH. High-level languages such as Pascal, FORTRAN, C++, The data from the input switches are now stored in and BASIC are much easier to write but are not as the accumulator. memory efficient or as fast as assembly language. All languages, whether Pascal, C++, BASIC, or FORTRAN, get reduced to machine language code before they can be executed by the microprocessor. Compiler The conversion from high-level languages to machine code is done by a compiler. The compiler makes memory assignments and converts the English language-type instructions into executable machine code. On the other hand, assembly language translates directly into machine code. This allows the programmer to write the most streamlined and memory-efficient and BASIC fastest programs possible on the specific hardware BASIC uses the variable COUNT to hold the counter configuration that is being used. value. Line 30 checks the count. If COUNT is equal to Assembly language and its corresponding machine zero, then the program goes back to the beginning. code differ from processor to processor. The Otherwise, it goes back to subtract 1 from COUNT and fundamentals of the different assembly languages are checks COUNT again. the same. The 8085A version of the program is first written in assembly language, and then it is either hand assembled into machine language or computer BASIC COMPUTER LANGUAGE assembled using a per sonal computer with an Let’s start off our software training by studying a assembler software package. completed assembly language program and comparing it to the same program written in the BASIC computer language. BASIC is a high-level language that uses ASSEMBLY LANGUAGE English-language-type commands that are fairly easy to Assembly language is written using mnemonics: MVI, figure out, even by the inexperienced programmer. DCR, JZ, and the like. The term mnemonics is defined as Program Definition: Write a program that will function “abbreviations used to assist the memory.” as a down-counter, counting 9 to 0 repeatedly. First 1. MVI: The first mnemonic, MVI, stands for “Move draw a flowchart, and then write the program Immediate.” The instruction MVI A,09H will move statements in the BASIC language, assembly language, the data value 09H into register A (register A and the and machine language. accumulator are the same). Solution: The flowchart in Figure 17–7 is used to show 2. DCR A: The next instruction, DCR A, decrements the sequence of program execution, including the register A by 1. branching and looping that takes place. 3. JZ START: The third instruction, JZ START, is called a conditional jump. The condition that it is checking for is the zero condition. As the A register is decremented, if A reaches 0, then a flag bit, called the zero flag, gets set (a set flag is equal to 1). The instruction JZ START is interpreted as “jump to statement label START if the zero flag is set.” 4. JMP LOOP: If the condition is not met (zero flag not set), then control passes to the next instruction, JMP LOOP, which is an unconditional jump. This instruction is interpreted as “jump to label LOOP regardless of any condition flags.” At this point, you should see how the assembly language program functions exactly like the BASIC language program. MACHINE LANGUAGE Machine language is the final step in creating an executable program for the microprocessor. In this step, According to the flowchart, the counter is decremented we must determine the actual hexadecimal codes that repeatedly until zero is reached, at which time the counter will be stored in memory to be read by the is reinitialized to 9 and the cycle repeats. The instructions microprocessor. used to implement the program are given in Table 17–3. First, we have to determine what memory locations will be used for our program. This depends on the memory-map assignments made in the system hardware design. We have 64K of addressable memory locations (0000H to 17–7 SURVEY OF MICROPROCESSORS AND FFFFH). MANUFACTURERS We’ll make an assumption that the user program First Microprocessors: Since its introduction in the area was set up in the hardware design to start at early 1970s, the microprocessor has had a huge location 2000H. The length of the program memory impact on electronics industry. The first area depends on the size of the ROM or RAM microprocessors had a 4-bit internal data width. memory IC being used. 8008: In 1974, Intel introduced the first 8-bit A 256 X 8 RAM memory is usually sufficient for microprocessor, the 8008. Within a year it offered an introductory programming assignments and is upgrade, the 8080, which served as a point of commonly used on educational microprocessor comparison for all other manufacturers. trainers. Motorola 6800: The first challenger to the 8080 was the Motorola 6800. Other IC manufacturers (National The machine language program listed in Table 17–3 Semiconductor, Texas Instruments, Zilog, RCA, and fills up 9 bytes of memory (2000H to 2008H). Fairchild) soon introduced their own versions of the The first step in the hand assembly is to determine the microprocessor. The race had begun. Since then, 16-, code for MVI A. This is known as the opcode (operation 32-, and 64-bit architectures have been developed and code) and is found in an 8085A Assembly Language are finding their way into most new high-end Reference Chart. applications. The opcode for MVI A is 3E. The programmer will Microcontroller: Along the way, manufacturers store the binary equivalent for 3E (0011 1110) into started integrating whole multichip systems with RAM, memory location 2000H. ROM, and I/O into a single package called a Instructions for storing your program into memory microcontroller. are given by manufacturer of the microprocessor Embedded Control Applications: Today, the trainer you are using. microcontroller is the most popular choice for If you are using an assembler software package, embedded control applications such as those found in then the machine code that is generated will usually automobiles, home entertainment systems, and data be saved on a computer disk or used to program an acquisition and control systems. EPROM to be placed in a custom microprocessor Intel and Motorola: Each microprocessor and hardware design. microcontroller has its own special niche, but throughout the years, the two most important players The machine language instruction MVI A,09H in have been Intel and Motorola. Table 17–3 requires 2 bytes to complete. The first byte is the opcode, 3E, which identifies the instruction for the microprocessor. Table 17–4 lists most popular processors manufactured by The second byte (called the operand) is the data these two companies. You can identify the manufacturer value, 09H, which is to be moved into register A. by the first two numbers in the part number (68 for The second instruction, DCR A, is a 1-byte instruction. It requires just its op code, 3D, which is found in the Motorola and 80 for Intel). Appendix A lists Web site reference chart. The opcode for the JZ instruction is addresses of several microprocessor manufacturers. CA. It must be followed by the 16-bit (2-byte) address to jump to if the condition (zero) is met. This makes it a 3-byte instruction. Byte 2 of the instruction (location 2004H) is the low- order byte of the address, and byte 3 is the high- order byte of the address to jump to. (Be careful to always enter addresses as low-order first and then high-order.) The opcode for JMP is C3 and must also be followed by a 16-bit (2-byte) address specifying the location to jump to. Therefore, this is also a 3-byte instruction where byte 2–byte 3 gives a jump address of 2002H. REVIEW QUESTIONS SUMMARY OF INSTRUCTIONS 17–1. What are the names of the three buses associated with LDA Addr: (Load Accumulator Direct) Load the microprocessors? Address, data, control accumulator with the contents of memory whose 17–2. How much of the circuitry shown in Figure 17–1 is address (addr) is specified in byte 2–byte 3 of the contained inside a microcontroller IC? All of it instruction. 17–3. Why must the data bus be bidirectional? To use the same path for both input and output data STA Addr: (Store Accumulator Direct) Store the 17–4. The purpose of the address decoder IC in Figure 17–1 is contents of the accumulator to memory whose to enable two or more of the external ICs to be active at the address (addr) is specified in byte 2–byte 3 of the same time to speed up processing. True or false? False instruction. 17–5. The input port in Figure 17–1 must have three-state IN Port: (Input) Load the accumulator with the outputs so that its outputs are floating whenever any other IC contents of the specified port. is writing data to the data bus. True or false? True OUT Port: (Output) Move the contents of the 17–6. What would be the consequence of using an octal buffer accumulator to the specified port. for the output port in Figure 17–1 instead of an octal D flip- ̅̅̅̅̅ returns MVI r,data: (Move Immediate) Move into register r flop? The output to the LEDs would float when 𝑾𝑹 HIGH the data specified in byte 2 of the instruction. 17–7. The suffix addr in the LDA and STA mnemonics is used to DCR r: (Decrement Register) Decrement the value specify the address of the accumulator. True or false? False in register r by 1. 17–8. The LDA command is used by the microprocessor to JMP Addr: (Jump) Transfer control to address addr _________ (read/write) data, and the STA command is used to specified in byte 2–byte 3 of the instruction. _________ (read/write) data. Read, write JZ Addr: (Jump If Zero) Transfer control to address 17–9. The 8085A microprocessor has an internal accumulator addr if the zero flag is set. and six external registers called B, C, D, E, H, and L. True or false? False 17–10. The ALU block inside the 8085A determines the timing SUMMARY and con trol signals required to execute an instruction. True or false? False 1. A system designer should consider using a 17–11. What is the difference between assembly language and microprocessor instead of logic circuitry whenever an machine code? Assembly language, which is written in application involves making calculations, making short mnemonics, needs to be assembled or con verted decisions based on external stimuli, and maintaining into a binary string called a machine code, which is read by memory of past events. the CPU 2. A microprocessor is the heart of a computer system. 17–12. Why is the instruction LDA 4000H called a 3-byte It reads and acts on program instructions given to it by instruction? 1 byte is used to store 3AH; 2 bytes are used to a programmer. store 4000H 3. A microprocessor system has three buses: address, 17–13. When executing the instruction LDA 4000H, the data, and control. microprocessor fetches the machine code from RAM location 4. Microprocessors operate on instructions given to them 4000H. True or false? False in the form of machine code (1s and 0s). The machine 17–14. Which instruction, STA or LDA, issues a pulse on the code is generated by a higher-level language like C or ̅̅̅̅̅ 𝑊𝑅 line? Why? STA, the ̅̅̅̅̅ 𝑾𝑹 is used as the clock input to the assembly language. D flip-flop 5. The Intel 8085A is an 8-bit microprocessor. It has 17–15. How many bytes of RAM does the program in Table 17– seven internal registers, an 8-bit data bus, an 2 occupy? 6 bytes arithmetic logic unit, and several I/O functions. 17–16. Programs written in assembly language must be 6. Program instructions are executed inside the converted to ma chine code before being executed by a microprocessor by the instruction decoder, which microprocessor. True or false? True issues the machine cycle timing and initiates I/O 17–17. Programs written in a high-level language are more operations. memory efficient than those written in assembly language. 7. The microprocessor provides the appropriate logic True or false? False levels on the data and address buses and takes care of 17–18. What is the port number of the input switches and of the timing of all control signals output to the the output LEDs in Figure 17–6? Input is FFH, output is FEH. connected interface circuitry. 17–19. The OUT FEH statement is used to output the switch 8. Assembly language instructions are written using data to the microprocessor, and the IN FFH statement is used to input data to the LEDs. True or false? False mnemonic abbreviations and then converted into 17–20. In Table 17–3, addresses 2000 through 2008 are where machine language so that they can be interpreted by the _________ is stored. Machine code the microprocessor. 17–21. How does the JZ instruction differ from the JMP 9. Higher-level languages like C + + or Pascal are easier instruction? The JZ instruction looks for a zero flag and to write than assembly language, but they are not as jumps to the label START if the flag is set. The JMP memory efficient or as fast. All languages must be instruction jumps to the label LOOP, regardless of any converted into a machine language matching that of flags. the microprocessor before they can be executed. GLOSSARY Machine Code: The binary codes that make up a Accumulator: The parallel register in a microprocessor microprocessor’s program instructions. that is the focal point for all arithmetic and logic Memory-Mapped I/O: A method of input/output that operations. addresses each I/O device as a memory location Address Bus: A group of conductors that are routed selected by a binary (or hex) address. throughout a computer system and used to select a Microprocessor: An LSI or VLSI integrated circuit that is unique memory or I/O location based on their binary the fundamental building block of a digital computer. It value. is controlled by software programs that allow it to do all Architecture: The layout and design of a system. digital arithmetic, logic, and I/O operations. Arithmetic Logic Unit (ALU): The part of a Mnemonic: The abbreviated spellings of instructions microprocessor that performs all the arithmetic and used in assembly language. digital logic functions. Monitor Program: The computer software program Assembler: A software package that is used to convert initiated at power-up that supervises system operating assembly language into machine language. tasks such as reading the keyboard and driving the CRT. Assembly Language: A low-level programming Opcode: Operation code. It is the unique 1-byte code language unique to each microprocessor. It is given to identify each instruction to the microprocessor. converted, or assembled, into machine code before it Operand: The parameters that follow the assembly can be executed. language mnemonic to complete the specification of BASIC Language: A high-level computer programming the instruction. language that uses English language-type instructions Operating System: See Monitor program. that are converted to executable machine code. Port Number: number used to select particular I/O port Bidirectional: Systems capable of transferring digital Program Counter: An internal register that contains the information in two directions. address of the next program instruction to be executed. Central Processing Unit (CPU): The “brains” of a Software: Computer program statements that give computer system. The term is used interchangeably step-by-step instructions to a computer to solve a with microprocessor. problem. Compiler: A software package that converts a high- Stack Pointer: An internal register that contains the level language program into machine language code. address of the last entry on the RAM stack. Control Bus: A group of conductors that is routed Statement Label: A meaningful name given to certain throughout a computer system and used to signify assembly language program lines so that they can be special control functions, such as Read, Write, I/O, referred to from different parts of the program, using Memory, and Ready. statements like JUMP or CALL. Data Bus: A group of conductors that is routed Support Circuitry: The integrated circuits and throughout a computer system and contains the binary electronic devices that assist the microprocessor in data used for all arithmetic and I/O operations. performing I/O and other external tasks. Flowchart: A diagram used by the programmer to map Zero Flag: A bit internal to the microprocessor that, out the looping and conditional branching that a when set (1), signifies the last arithmetic or logic program must make. It becomes the blueprint for the operation had a result of zero. program. Hand Assembly: The act of converting assembly language instructions into machine language codes by hand, using a reference chart. Hardware: The ICs and electronic devices that make up a computer system. Instruction Decoder: The circuitry inside a microprocessor that interprets the machine code and produces the internal control signals required to execute the instruction. Instruction Register: A parallel register in a microprocessor that receives the machine code and produces the internal control signals required to execute the instruction. Interrupt: A digital control signal that is input to a microprocessor IC pin that suspends current software execution and performs another predefined task. I/O-Mapped I/O: A method of input/output that addresses each I/O device as a port selected by a binary (or hex) port number. PROBLEMS 17–8. What two control signals are applied to the input Section 17–1 port in Figure 17–1 to cause it to transfer the switch data 17–1. Describe the circumstances that would prompt to the data bus? 𝑪𝑬̅̅̅̅, 𝑹𝑫 ̅̅̅̅̅ you to use a microprocessor-based design solution 17–9. How many different addresses can be accessed instead of a hard-wired IC logic design. A using a 16-bit address bus? 216 (65,536) microprocessor-based system would be used Sections 17–2 and 17–3 whenever calculations are to be made, decisions 17–10. In the assembly language instruction LDA 4000H, based on inputs are to be made, a memory of events what does the LDA signify and what does the 4000H is needed, or a modifiable system is needed. signify? LDA, load accumulator; 4000H, address 17–2. In an 8-bit microprocessor system, how many where the data to be loaded are lines are in the data bus? The address bus? Data bus, 8 17–11. Describe what the statement STA 6000H does. It lines; address bus, 16 lines stores the contents of the accumulator out to 17–3. What is the function of the address bus? The address 6000H. address bus is used to select a particular location or 17–12. What are the names of the six internal 8085A device within the system. general-purpose registers? B, C, D, E, H, L 17–4. Use a TTL data manual to find an IC that you could 17–13. What is the function of the 8085A’s instruction use for the output port in Figure 17–1. Draw its logic register and instruction decoder? Instruction decoder diagram and external connections. and register: register and circuitry inside the microprocessor that receives the machine language code and produces the internal control signals required to execute the instruction. 17–14. Why is the program counter register 16 bits instead of 8? Because it contains the 16-bit address of the next instruction to be executed. Section 17–4 17–15. During the execution of the LDA 4000 instruction in Figure 17–4, the line goes LOW four times. Describe the activity initiated by each LOW pulse. (1) Pulse: read 17–5. Repeat Problem 17–4 for the input port. memory location 2000 (LDA) (2) and (3) Pulse: read address bytes at 2001, 2002 (4000H) (4) Pulse: read data at address 4000H 17–16. What action does the LOW WR pulse initiate instruction during the STA 6000 in Figure 17–5? The 𝑾𝑹 ̅̅̅̅̅ line is used to clock the data on the data bus to the output port D flip-flop. Section 17–5 17–17. Describe one advantage and one disadvantage of writing programs in a high-level language instead of assembly language. A high-level language (FORTRAN, BASIC, etc.) has the advantage of being easier to 17–6. Repeat Problem 17–4 for the address decoder. write and understand. Its disadvantage is that the Assume that the input port is at address 4000H, the programs are not memory efficient. output port is at address 6000H, and mem ory is at 17–18. Are the following instructions used for memory- address 2000H. (Hint: Use an address decoding scheme mapped I/O or for I/O-mapped I/O? (a) LDA addr (b) STA similar to that found in Section 16–5.) addr (c) IN port (d) OUT port Memory-mapped I/O: (a) LDA addr (b) STA addr I/O-mapped I/O: (c) IN Port (d) OUT Port 17–19. What is the digital level on the microprocessor’s of the following instructions? (a) LDA addr (b) STA addr (c) IN port (d) OUT port D IO/M line for each (a) LOW (b) LOW (c) HIGH (d) HIGH 17–7. Why does the input port in Figure 17–1 have to 17–20. List the new IN and OUT instructions that would have three-stated outputs? The input port has three- be used to I/O to the switches and LEDs if the following stated outputs so that it can be disabled when it is changes to U4 and U5 were made in Figure 17–6. (a) Add not being read. inverters to inputs A8 and A9 of U4 and to A9 and A10 of U5. (b) Add inverters to inputs A14 and A15 of U4 and to SCHEMATIC INTERPRETATION PROBLEMS A14 and A15 of U5. See Appendix G for the schematic diagrams. 17–30. Locate the 68HC11 microcontroller in the (a) IN FCH; OUT F8H (b) IN 3FH; OUT 3EH HC11D0 schematic. (A microcontroller is a 17–21. U6a and U6b in Figure 17–6 are OR gates. Why microprocessor with built-in RAM, ROM, and I/O ports.) are they drawn as inverted-input NAND gates? U6a and Pins 31–38 are the low-order address bus (A0–A7) U6b are drawn as inverted-input NAND gates to make multiplexed (shared) with the data bus (D0–D7). Pins 9– the logical flow of schematic easier to understand. 16 are the high-order address bus (A8–A15). The low- 17–22. Are the LEDs in Figure 17–6 active-HIGH or order address bus is demultiplexed (selected and active-LOW? The LEDs are active LOW (low on 𝑸𝒏 → latched) from the shared address/data lines by U2 and LED is ON). the AS (Address Strobe) line. (a) Which ICs are 17–23. Is the RD during the: line or the (a) IN instruction? connected to the data bus (DB0–DB7)? (b) Which ICs WR line pulsed LOW by the microprocessor (b) OUT are connected to the address bus (AD0–AD15)? instruction? (a) IN instruction, 𝑹𝑫̅̅̅̅̅ is pulsed LOW. (b) OUT instruction, 𝑾𝑹 ̅̅̅̅̅ is pulsed LOW. (a) U2, U6, U7, U16, M1 17–24. What three conditions must be met to satisfy the (b) U2, U6, U7, U16, U5, U9, U3:C, M1 output enables of U2 in Figure 17–6? 17–31. U9 and U5 in the HC11D0 schematic are used for (1) 𝑨𝟖 to 𝑨𝟏𝟓 = FFH address decod ing. Determine the levels on AD11–AD15 (2) 𝑰𝑶/𝑴 ̅ = HIGH and AD3–AD5 to select (a) the LCD (LCD_SL) and (b) the ̅̅̅̅̅ (3) 𝑹𝑫 = LOW keyboard (KEY_SL). 17–25. What three conditions must be met to provide a LCD_SL KEY_SL pulse to the Cp input of U3 in Figure 17–6? AD3 0 1 (1) 𝑨𝟖 to 𝑨𝟏𝟓 = FEH AD4 0 0 (2) 𝑰𝑶/𝑴 ̅ = HIGH AD5 0 0 ̅̅̅̅̅ is pulsed LOW/HIGH (3) 𝑾𝑹 AD11 1 1 17–26. Which internal data register is used for the IN AD12 1 1 and OUT instructions? The accumulator AD13 0 0 Section 17–6 AD14 0 0 17–27. Write the assembly language instruction that AD15 0 0 would initialize the accumulator to 4FH. MVI A, 4FH 17–32. Locate the microcontroller in the 4096/4196 17–28. Describe in words what the instruction JZ LOOP schematic. (a) What is its grid location and part does. JZ LOOP is a conditional branch that will cause number? (b) Its low-order address is multiplexed like the the processor to jump to the address of the label 68HC11 in Problem 17–30. What IC and control signal LOOP if the zero flag is set. are used to demultiplex the address/data bus (AD0– 17–29. Write the machine language code for the AD7) into the low-order address bus (A0–A7)? (c) What following assembly lan guage program. (Start the IC and control signal are used to demultiplex the machine code at address 2010H.) address/data bus (AD0–AD7) into the data bus (D0–D7)? INIT: MVI A,04H X1: DCR A (a) A2, 8031 (b) U11, ALE (c) U3, PSEN JZ INIT E17–1. Load the circuit file for Section 17–5a. This JMP X1 circuit simulates the Input/Output portion of the microprocessor circuit of Figure 17–6. The object is to 2010 3E INIT: MVI A, O4H load the value of the input port onto Data Bus and then 2011 03 send the data on the Data Bus out to the Output Port. 2012 3D X 1: DCR A 2013 CA JZ INIT (a) The OE’ on the 74LS244 must be _________ 2014 10 (HIGH/LOW) to load the switches to the data bus. 2015 20 (b) Then to transfer the data on the Data Bus over to the 2016 C3 JMP X1 Output Port you must _________. 2017 12 (c) Change OE’ (E) on the 74LS244 back to 1. List the 2018 20 order of opera tions involved to transfer the number 7CH from the Input Port to the Output Port. (a) LOW (b) Press C (c) Put 7C on the switches, Make OE’ = 0 (Data appears on the data bus), Press C (data appears at output port if (G) is LOW.)