Microcontroller vs. General Purpose Microprocessor PDF

Document Details

DazzledBarium8425

Uploaded by DazzledBarium8425

Tags

microcontroller microprocessor embedded systems electronics

Summary

This document compares microcontrollers and general-purpose microprocessors, highlighting the differences in their functionalities and applications. It also discusses embedded systems and their uses in various contexts. This resource could be helpful for students studying computer architecture and embedded systems.

Full Transcript

Microcontroller vs. General Purpose Microprocessor General-purpose Microcontroller has : microprocessors contains : 8051 Microcontroller No RAM No ROM...

Microcontroller vs. General Purpose Microprocessor General-purpose Microcontroller has : microprocessors contains : 8051 Microcontroller No RAM No ROM CPU (microprocessor) RAM No I/O ports ROM I/O ports Timer ADC and other peripherals 38 … General-purpose microprocessors Microcontroller Must add RAM, ROM, I/O ports, and The fixed amount of on-chip ROM, timers externally to make them RAM, and number of I/O ports makes functional them ideal for many applications in Make the system bulkier and much which cost and space are critical more expensive In many applications, the space it Have the advantage of versatility on takes, the power it consumes, and the the amount of RAM, ROM, and I/O price per unit are much more critical ports considerations than the computing power 39 40 Microcontrollers for Embedded Systems Examples of Applications An embedded product uses a microprocessor (or microcontroller) to Home Appliances: Basic control systems in microwaves, washing do one task and one task only machines, and other household devices. There is only one application software that is typically burned into ROM Toys and Gadgets: Many simple electronic toys and handheld devices A PC, in contrast with the embedded system, can be used for any use 8-bit microcontrollers. number of applications Automotive: Used in various low-complexity automotive applications, It has RAM memory and an operating system that loads a variety of such as sensor monitoring. applications into RAM and lets the CPU run them A PC contains or is connected to various embedded products Industrial Control: Basic automation and control tasks in industrial Each one peripheral has a microcontroller inside it that performs only one task settings. 41 42 x86 PC Embedded Applications … Many manufactures of general-purpose microprocessors have One of the most critical needs of an embedded system is to decrease targeted their microprocessor for the high end of the embedded power consumption and space market In high-performance embedded processors, the trend is to integrate There are times that a microcontroller is inadequate for the task more functions on the CPU chip and let designer decide which When a company targets a general purpose microprocessor for the features he/she wants to use embedded market, it optimizes the processor used for embedded In many cases using x86 PCs for the high-end embedded applications systems Saves money and shortens development time Very often the terms embedded processor and microcontroller are A vast library of software already written used interchangeably Windows is a widely used and well understood platform 43 44 Choosing a Microcontroller Criteria for Choosing a Microcontroller 8-bit microcontrollers Meeting the computing needs of the task at hand efficiently and cost Motorola’s 6811 effectively Intel’s 8051 Speed Zilog’s Z8 Packaging Microchip’s PIC Power consumption There are also 16-bit and 32-bit microcontrollers made by various The amount of RAM and ROM on chip chip makers The number of I/O pins and the timer on chip How easy to upgrade to higher performance or lower power-consumption versions Cost per unit 45 46 … 8051 Availability of software development tools, such as compilers, Intel introduced 8051, referred as MCS-51, in 1981 assemblers, and debuggers The 8051 is an 8-bit processor Wide availability and reliable sources of the microcontroller The CPU can work on only 8 bits of data at a time The 8051 family has the largest number of diversified (multiple The 8051 had source) suppliers o 128 bytes of RAM o 1 serial port Intel (original) o 4K bytes of on-chip ROM o 4 I/O ports, each 8 bits wide o 2 timers o 6 interrupt sources Atmel AMD The 8051 became widely popular after allowing other manufactures Infineon to make and market any flavor of the 8051, but remaining code- compatible 47 48 8051 Family Block Diagram of the Original 8051 /INT0 /INT1 T0 T1 The 8051 is a subset of the 8052 Other interrupts The 8031 is a ROM-less 8051 128 bytes Timer/Counter Data Memory 4K byte Program Memory (ROM) (Timer 0 & Add external ROM to it (RAM) Timer 1) You lose two ports, and leave only 2 ports 8051 CPU for I/O operations 64 K Bus I/O ports Serial Port Oscillator Expansion Control &Timing From Crystal Oscillator or RC ALE /PSEN P3 P2 P1 P0 TxD RxD network (Address/data) 49 50 Is 8-bit Still Relevant? Eg: Remote Control Car Antenna Antenna Yes, 8-bit microcontrollers are still relevant and widely used today, Front Electric Forward RF RF Receiver Microcontroller Motor (Left/Right) Microcontroller Transmitter despite the availability of more advanced microcontrollers with higher Reverse Rear Electric Motor Power Power bit architectures (like 16-bit, 32-bit, and beyond). Left Voltage Regulator Voltage Regulator (Fwd/Reverse) Right Reasons: Controls Batteries Batteries Car lights (LEDs) Simplicity and Ease of Use - lower complexity, basic applications Cost-Effectiveness - lower cost, reduced component count Power Consumption - energy efficiency Established Ecosystem - proven technology, availability Sufficient Performance for Many Applications - suitable for control tasks Educational Use - learning tool 51 52 Harvard and von Neumann Architectures Fetch operation - retrieves an instruction MCU Fetch-Execute from the location in code memory pointed Cycle to by the program counter (PC) Harvard Architecture - a type of computer architecture where the instructions (program code) and data are stored in separate memory Program Execute operation - executes the spaces Counter instruction that was fetched during the (PC) Example: Intel 8051 architecture fetch operation. In addition to executing von Neumann Architecture - another type of computer architecture + the instruction, the CPU also adds the F e appropriate number to the PC to point it to where the instructions and data are stored in the same memory Code Memory t the next instruction to be fetched. c space h Example: Intel x86 architecture (Intel Pentium, AMD Athlon, etc.) CPU To other peripherals 53 54 8051 - architecture Inside the 8051 Registers Program Counter Flag Bits / PSW (program status word) Register Register Banks and Stack 55 56 Registers … Register are used to store information temporarily, while the The 8 bits of a register are shown from information could be MSB D7 to the LSB D0 a byte of data to be processed, or With an 8-bit data type, any data larger than 8 bits must be broken into 8-bit an address pointing to the data to be fetched chunks before it is processed The vast majority of 8051 register are 8-bit registers There is only one data type, 8 bits 57 58 … The Accumulator The most widely used registers The Accumulator is used as a general register to accumulate the A (Accumulator): For all arithmetic and logic instructions results of a large number of instructions. B, R0, R1, R2, R3, R4, R5, R6, R7 It can hold an 8-bit (1-byte) value and is the most DPTR (data pointer), and PC (program counter) versatile register the 8051 has due to the shear number of instructions that make use of the accumulator. More than half of the 8051’s 255 instructions manipulate or use the accumulator in some way. 59 60 The Data Pointer (DPTR) The Program Counter (PC) DPTR is the 8051’s only user-accessible 16-bit (2-byte) register. PC is a 2-byte address which tells the 8051 where the next instruction The Accumulator, "R" registers, and "B" register are all 1-byte values. to execute is found in memory. DPTR, as the name suggests, is used to point to data. It is used by a number of When the 8051 is initialized PC always starts at 0000h commands which allow the 8051 to access external memory. and is incremented each time an instruction is executed. It is When the 8051 accesses external memory it will access external memory at the important to note that PC isn’t always incremented by one. address indicated by DPTR. Since some instructions require 2 or 3 bytes the PC will be While DPTR is most often used to point to data in external memory, many incremented by 2 or 3 in these cases. programmers often take advantage of the fact that it’s the only true 16-bit register available. The Program Counter is special in that there is no way to directly It is often used to store 2-byte values which have nothing to do with memory modify it’s value. locations. 61 62 … The Stack Pointer (SP) All 8051 members start at memory address 0000 when they’re The Stack Pointer, like all registers except DPTR and PC, may hold an powered up 8-bit (1-byte) value. Program Counter has the value of 0000 The Stack Pointer is used to indicate where the next value to be The first opcode is burned into ROM address 0000H, since this is where the removed from the stack should be taken from. 8051 looks for the first instruction when it is booted When you push a value onto the stack, the 8051 first increments the value of SP and then stores the value at the resulting memory location. When you pop a value off the stack, the 8051 returns the value from the memory location indicated by SP, and then decrements the value of SP. 63 64 ROM Memory Map in … 8051 Family This order of operation is important. No member of 8051 family can access more than 64K bytes of opcode When the 8051 is initialized SP will be initialized to 07h. If you The program counter is a 16-bit register immediately push a value onto the stack, the value will be stored in Internal RAM address 08h. This makes sense taking into account what was mentioned two paragraphs above: First the 8051will increment the value of SP (from 07h to 08h) and then will store the pushed value at that memory address (08h). SP is modified directly by the 8051 by six instructions: PUSH, POP, ACALL, LCALL, RET, and RETI. It is also used intrinsically whenever an interrupt is triggered 65 66 Data Type PSW Register 8051 microcontroller has only one data The PSW register, also type - 8 bits referred to as the flag The size of each register is also 8 bits register, is an 8 bit register It is the job of the programmer to break down data larger than 8 bits (00 to The PSW register contains FFH, or 0 to 255 in decimal) status bits that reflect the The data types can be positive or negative current CPU state. 67 68 RAM Memory Space Allocation There are 128 bytes of RAM in the 8051 Assigned addresses 00 to 7FH The 128 bytes are divided into three different groups as follows: A total of 32 bytes from locations 00 to1F hex are set aside for register banks and the stack A total of 16 bytes from locations 20H to 2FH are set aside for bit-addressable read/write memory A total of 80 bytes from locations 30H to 7FH are used for read and write storage, called scratch pad 69 70 Register Banks These 32 bytes are divided into 4 banks of registers in which each bank has 8 registers, R0-R7 RAM location from 0 to 7 are set aside for bank 0 of R0-R7 where R0 is RAM location 0, R1 is RAM location 1, R2 is RAM location 2, and so on, until memory location 7 which belongs to R7 of bank 0 It is much easier to refer to these RAM locations with names such as R0, R1, and so on, than by their memory locations Register bank 0 is the default when 8051 is powered up 71 72 … Stack We can switch to other banks by use of the PSW register The stack is a section of RAM used by the CPU to store information Bits D4 and D3 of the PSW are used to select the desired register bank temporarily Use the bit-addressable instructions SETB and CLR to access PSW.4 and PSW.3 This information could be data or an address The register used to access the stack is called the SP (stack pointer) register The stack pointer in the 8051 is only 8 bit wide, which means that it can take value of 00 to FFH When the 8051 is powered up, the SP register contains value 07 RAM location 08 is the first location begin used for the stack by the 8051 73 74 Special Function Registers (SFRs) Summary of SFRs SFRs provide control and data exchange with the microcontroller’s Accumulator (ACC) and B register resources and peripherals ACC (also referred to as A) is used implicitly by several instructions Some registers are not bit-addressable. These include the stack B is used implicitly in multiply and divide operations pointer (SP) and data pointer register (DPTR) These registers are the input/output of the arithmetic and logic unit (ALU) Program status word - PSW Shows the status of arithmetic and logical operations using multiple bits such as Carry Selects the Register Bank (Bank 0 - Bank 3) Stack pointer - SP 75 76 … Data pointer - DPTR (DPH and DPL) 16-bit register used to access external code or data memory Timer Registers - TH0, TL0, TH1, TL1, TMOD, TCON Used for timing intervals or counting events Parallel I/O Port Registers - P0, P1, P2 and P3 Serial Communication Registers- SBUF and SCON Interrupt Management Registers - IP and IE Power Control Register - PCON 77 78 Important to know: Comparison with microprocessor - 8051 architecture - Criteria of selection - Registers in 8051 79

Use Quizgecko on...
Browser
Browser