1 / 48

EEE237 Introduction to Microprocessors

EEE237 Introduction to Microprocessors. Week 1 Course overview İntroduction to Microprocessor, microcontroller and programming basics . Course objectives. to develop an in- depth understanding of the operation of microprocessors and microcontrollers

seda
Download Presentation

EEE237 Introduction to Microprocessors

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EEE237 IntroductiontoMicroprocessors Week 1 Course overview İntroduction to Microprocessor, microcontroller and programming basics

  2. Course objectives • todevelop an in-depthunderstanding of • theoperation of microprocessorsandmicrocontrollers • Assembly languageprogrammingandusing C language. • microprocessorinterfacingtechniques • to be abletouse PIC16F877 microcontroller

  3. Course objectives • to be able to design and implement microprocessor-based systems in both hardware and software • Ultimate goal: to be able to apply this knowledge to more advanced structures

  4. Outline • Microcontroller Basics and Programming Concepts • PIC microcontroller Architecture • Programming Model, AddressingModesandInstruction Set • Programming examples • TheStack, SubroutinesandInterrupts

  5. Outline • Timer Operations • Analog toDigital Conversion • Data acquisitionandcontrolexamples • InterfacingConcepts • ParallelInput/Output • Serial Communications

  6. Common computer organization (simplified view) • ALU (Arithmetic Logic Unit) is a circuitry, which is capable of doing various operations (for example ADD, SHIFT, AND, OR, etc) on certain on-chip registers. • CPU (Central Processing Unit) is the combination of the control logic, associated registers and the arithmetic logic unit.

  7. Common computer organization (simplified view) Memory Input/Output (I/O) ALU Control CPU

  8. Common computer organization (1/2)

  9. Common computer organization (2/2)

  10. Computer Buses • Address bus: carries the address of a unique memory or input/output (I/O) device • Data bus: carries data stored in memory (or an I/O device) to the CPU or from the CPU to the memory (or I/O device) • Control bus: is a collection of control signals that coordinate and synchronize the whole system

  11. Block diagram of a typical CPU

  12. CPU Structure • The main functions are • data transfer • arithmetic and logic operations • decision making (instructional flow control) • The register array consists of at least one accumulator, program counter and stack pointer • The control unit controls all the operations in a CPU and basically it puts the CPU in one of the fetch and execution phases

  13. Memory (1/2) • The memory in a computer system stores the data and instructions of the programs. Adress decoder Storage Area Data bus Adress bus Other signals (Vcc,Gnd, CS, etc.)

  14. Memory (2/2)

  15. Main memory types • ROM (read-only memory) • programmed permanently at the factory, cannot be altered • RAM (random-access memory) • read and write memory • EPROM (erasable programmable ROM) • nonvolatile, written electrically but erased optically • EEPROM (electrically ROM) • nonvolatile, both written and erased electrically

  16. Operation of the CPU (1/2) • Fetch cycle (phase): • The CPU puts the address of the instruction to be executed on the address bus. The address info comes from the program counter (PC) maintained by the control unit. • The control bus holds the info. for reading the memory location and the data bus holds the instruction from the memory which is stored into the instruction register (IR) • PC is updated to point to the next instruction.

  17. Operation of the CPU (2/2) • Execute cycle (phase): • Instruction in the IR is decoded • The required data transfer and the required logical and arithmetic operation are performed • The result is written back either to one of the registers or memory or I/O device • Common operations performed in ALU are: • addition, subtraction, • logical AND, OR, XOR, NOT • increment, decrement, shift, clear, etc.

  18. Operation of the CPU (2/2)

  19. Detailed Block Diagram

  20. Microcomputer (1/2) • CPU on a single IC microprocessor (µP). • the terms CPU, µP and MPU (microprocessor unit) are synonymous. • CPU is the combination of the ALU and control unit of any computer. • When the CPU is a single IC; it is called a µP and is also referred to as the MPU. • When the MPU ‘s connected to memory and I/O, the arrangement becomes a MICROCOMPUTER.

  21. Microcomputer (2/2) • Many different MPUs are produced by many different IC vendors (e.g., Motorola, Intel, Texas Instruments, Zilog, National Semiconductors, etc.). • Major differences are in • word size, • the number and types of instructions that can be performed, • the types of external control signals available, • the amount of memory that can be addressed.

  22. Microcontroller • A microcontroller unit (MCU) contains an MPU, memory, and I/O circuitry on a single chip. • Such a chip can perform control operations without the need for any external circuitry. • e.g. PIC16F877 • e.g. Intel 8051

  23. Microprocessor vs microcontroller (1/3) • Microprocessors: high performance, general purpose “brains” for PCs and workstations • Instruction decode and control, arithmetic/logicoperations, registers, timing, external control • Typical cost: $75 -- $500 • Annual demand: 10s of millions • Microcontrollers: devices with high levels ofintegration for embedded control • Microprocessor functions plus on-chip memory andperipheral functions (e.g. ports, timers) • "Swiss army knife" of microprocessor technology • Typical cost: $1-- $25 • Annual demand: billions!

  24. Microprocessor vs microcontroller (2/3) Microprocessor ALU Memory I/O Peripheral functions Control Address Data Control Microcontroller

  25. Microprocessor vs microcontroller (3/3) Not always a clear distinction: today’s mP may be tomorrow’smC • Microprocessor • Includes memory management unit, lots of cache • Performance is the most important feature(cost is important, but secondary) • Used mainly in desktop machines • Microcontroller • Integrated RAM and ROM, no cache • Includes lots of peripherals • Used mainly in “embedded” applications • Often involves real-time control • Important features include: low cost, low power consumption, number of integrated peripherals, interrupt response time, amount of RAM and ROM

  26. Bottom-up view of microcontroller systems (1/3)

  27. Bottom-up view of microcontroller systems (2/3)

  28. Bottom-up view of microcontroller systems (3/3)

  29. Microcontroller Use

  30. Whatwillyoustudy in EEE237? • PIC16F877 is the MCU choice in EEE237 • Why? • Much easier to use, have attractive features and suitable for wide range applications • Harward architecture makes PICs faster • You will be studying • how it is programmed to perform various operations

  31. EmbeddedSystem • Microcontrollers are sometimes called embedded microcontrollers, which just means that they are part of an embedded system -- that is, one part of a larger device or system. • The majority of microcontrollers in use today are embedded in other machinery, such as automobiles, telephones, appliances, and peripherals for computer systems. These are called embedded system.

  32. Typical input and output devices include switches, relay, solenoids, LEDs, small or custom LCD displays, radio frequency devices, and sensors for data such as temperature, humidity, light level etc. • Embedded systems usually have no keyboard, screen, disks, printers, or other recognizable I/O devices of a personal computer, and may lack human interaction devices of any kind.

  33. Microchip PIC • PIC is a family of Harvard architecture microcontroller made by Microchip Technology. The name PIC initially referred to "Peripheral Interface Controller“ . PIC microcontrollers were the first RISC microcontroller. • PICs are popular with both industrial developers and hobbyists alike due to their low cost, wide availability, large user base, extensive collection of application notes, availability of low cost or free development tools, and serial programming (and re-programming with flash memory) capability.

  34. Two Different Architectures

  35. Fetch & Execution Cycles / Pipelining • There are 35 single word instructions. A two-stage pipeline overlaps fetch and execution of instructions. As a result, all instructions execute in a single cycle except for program branches. These take two cycles since the fetch instruction is “flushed” from the pipeline while the new instruction is being fetched and then executed. • A typical picture of the pipeline is shown below.

  36. Clock And Instruction Cycles • Clock from the oscillator enters a microcontroller via OSC1 pin where internal circuit of a microcontroller divides the clock into four even clocks Q1, Q2, Q3 and Q4 which do not overlap. • These four clocks make up one instruction cycle (also called machine cycle) during which one instruction is executed.

  37. Execution of instruction starts by calling an instruction that is next in string. • Instruction is called from program memory on every Q1 and is written in Instruction Register (IR) on Q4. • Decoding and execution of instruction are done between the next Q1 and Q4 cycles. The following diagram shows the relationship between instruction cycle and clock of the oscillator (OSC1) as well as that of internal clocks Q1 – Q4. • Program Counter (PC) holds information about the address of the next instruction.

  38. Why use PIC16F877? • Why PIC16F877A is very popular? • This is because PIC16F877A is very cheap. Apart from that it is also very easy to be assembled. Additional components that you need to make this IC work is just a 5V power supply adapter, a 20MHz crystal oscillator and 2 units of 22pF capacitors. • What is the advantages of PIC16F877A? • This IC can be reprogrammed and erased up to 10,000 times. Therefore it is very good for new product development phase. • What is the disadvantages of PIC16F877A? • This IC has no internal oscillator so you will need an external crystal of other clock source.

  39. Features of PIC16F877 8

  40. Bubble diagram of PIC16F877 As you can see the PIC16F877A is rich in peripherals so you can use it for many different projects.

  41. Pin Diagram of PIC16F877 • Plastic dual in-line package (DIP)

  42. Pin Diagram of PIC16F877 • Quad FlatPackage (QFP) • Plastic Leaded Chip CarrierPackage (PLCC)

  43. PIC16F877 Internal Block Diagram • The basic architecture of PIC16F877 consists of Program memory, file registers and RAM, ALU and CPU registers. PIC16F877 Internal Block Diagram

  44. Memory of the PIC16F877 • divided into 3 types of memories: • Program Memory– A memory that contains the program (which we had written), after we've burned it. As a reminder, Program Counter executes commands stored in the program memory, one after the other. • Data Memory – This is RAM memory type, which contains a special registers like SFR (Special Function Register) and GPR (General Purpose Register). The variables that we store in the Data Memory during the program are deleted after we turn of the micro. These two memories have separated data buses, which makes the access to each one of them very easy. • Data EEPROM (Electrically Erasable Programmable Read-Only Memory) – A memory that allows storing the variables as a result of burning the written program.

  45. Each one of them has a different role. Program Memory and Data Memory two memories that are needed to build a program, and Data EEPROM is used to save data after the microcontroller is turn off.

  46. PIC16F877A Program Memory • Is Flash Memory • Used for storing compiled code (user’s program) • Program Memory capacity is 8K x 14 bit  Each location is 14 bits long  Every instruction is coded as a 14 bit word • PC can address up to 8K addresses • Addresses H’000’ and H’004’ are treated in a special way

  47. PIC16F877A Data Memory (RAM) • Memory storage for variables • Data Memory is also known as Register File and consists of two components. • General purpose register file (same as RAM). • Special purpose register file (similar to SFR in 8051). • Addresses range from 0 to 511 and partitioned into 4 banks  each bank extends up to 7Fh (128 bytes). • The user can only access a RAM byte in a set of 4 banks and only one bank at a time.The default bank isBANK0. • To access a register that is located in another bank, one should access it inside the program. There are special registers which can be accessed from any bank, such as STATUS register.

More Related