Lecture 1 Introduction 652021 1 Outline Course assessment




































- Slides: 36
Lecture - 1 Introduction 6/5/2021 1
Outline • Course assessment criteria • Microcontroller vs general purpose microprocessor • Choosing microcontroller • PIC microcontrollers • Basic computer architecture – CPU – Memory – I/O – Buses • Logic gates 6/5/2021 2
Microcomputer system design (14033208 -4) • Instructor: Dr. Omar Sonbul (ossonbul@uqu. edu. sa) • Lecture hrs: 3, Lab hrs: 3, credit hrs: 4 • Catalog description : Microcomputer system design, Hardware and Software design considerations, Selection of Memories, I/O devices and Peripherals. Practice of design of a microcomputer systems using PIC 18, testing, programming, debugging and troubleshooting. • Assessment: Laboratory: 25% Project: 20% Periodical exams: 15% Final exam: 40% 6/5/2021 3
Textbook • Muhammad ali mazidi, Rolin D. mckinlay, Danny causey, "PIC microcontroller and Embedded systems: using assembly and C for PIC 18", Pearson international edition, 2008 6/5/2021 4
Microcontroller vs general purpose microprocessor • The general-purpose microprocessors contain no RAM, no ROM, and no I/O ports on the chip itself. • A system designer using a general-purpose microprocessor must add RAM, ROM, I/O ports, and timers externally to make them functional. • Although this addition makes these systems bulkier and much more expressive, they have the advantage of versatility. • A microcontroller has a CPU in addition to a fixed amount of RAM, ROM, I/O ports and timer all on a single chip. 5
Microcontroller vs general purpose microprocessor (2) 6/5/2021 6
Companies that produce widely used 8 -bit microcontroller 6/5/2021 7
Choosing microcontroller • There are 3 criteria in choosing microcontroller as follows: 1. Meeting the computing needs of the task at hand efficiently and cost effectively. 2. Availability of software and hardware development tools such as compilers, assemblers, debuggers, and emulators. 3. Wide availability and reliable sources of the microcontroller. 6/5/2021 8
PIC microcontrollers • The Pl. C (programmable interface controller) microcontrollers are a series of RISC (reduced instruction set computer) integrated circuits produced by Microchip Technology Incorporated. (http: //www. microchip. com). • Variations are currently available in package sizes of as small as 18 pins and as large as 128 pins. 6/5/2021 9
PIC microcontrollers (2) 6/5/2021 10
Important terminology • • • A bit is a binary digit that can have the value 0 or 1. A byte is defined as 8 bits. A nibble is half a byte, or 4 bits. A word is two bytes, or 16 bits. A kilobytes is 210 bytes, which is 1024 bytes. The abbreviation K is often used to represent kilobytes. A megabyte is 220 bytes (over 1 million). A gigabyte is 230 bytes (over 1 billion). A terabytes is 240 bytes (over 1 trillion). 16 megabytes of memory would be 16*220, or 24*220 which is 224. Therefore, 16 megabytes is 224 bytes. 6/5/2021 11
Basic computer architecture Data Program Memory ALU Control unit Input Output 6/5/2021 I/O Central processing unit (CPU) 12
CPU size • At its core is the CPU (central processing unit) the controlling element of the system. • Central processors can be of any size and have been anything from 4 bits in width to 64 bits. • The size of the CPU is determined by its memory address width and its arithmetic and logic unit, • A 4 -bit microprocessor performs these operations on 4 -bit integers (called nibbles), whereas a 64 -bit microprocessor performs them on integers of a maximum size of 64 -bits. 6/5/2021 13
CPU clock speed • The clock speed varies considerably and is currently a few megahertz for microcontrollers to several gigahertz for more powerful microprocessors. • The exact number of instructions executed per second is based on the internal design of the CPU, the complexity of the instructions that it executes, and the program being executed. • The type of microprocessor can also determine its speed. A RISC (reduced instruction set computer) is a machine that executes one instruction per clock and contains only basic instructions. • A CISC (complex instruction set computer) executes many more different instructions than a RISC machine, but some of the instructions require more than one clock to complete. 6/5/2021 14
CPU task • The CPU is responsible for executing a series of sequential instructions organized into a grouping of instructions called a program. • The program in a computer system is a collection of instructions aligned in a sequential fashion, which is executed by the CPU. • The CPU fetches instructions from the memory system and executes them. • Each step of this simple program is converted to the language that the CPU understands, called machine language which is a series of numbers that represent instructions. 6/5/2021 15
RISK architecture • There are 3 ways to increase the processing power of the CPU: 1. Increase the clock frequency of the chip. 2. Use Harvard architecture by increasing the number of buses to bring more information into the CPU to be processed. 3. Change the internal architecture of the CPU to RISK architecture. • Microchip used all the tree methods to increase the processing power of the PIC 18 microcontroller. 6/5/2021 16
Features of RISK architecture 1. 2. 3. 4. 5. 6. 7. They have a fixed instruction size (the CPU can decode the instructions quickly). They have a large number of registers (no need for large stack to store parameters). They have a small instruction set (PIC 18 has 75 instructions) More than 95% of their instruction are executed with only one clock cycle. They implement Harvard architecture. They implement the instructions using the hardwire method which takes no more than 10% of the transistors (not microinstruction which takes more than 40 -60% of transistors). They use load/store architecture (while in CISC microprocessors data can be manipulated while it is still in memory). 6/5/2021 17
Assembly language • The assembler, which is also a program, converts the symbolic assembly language program into numeric machine code. • It is used to write the program in its symbolic form using mnemonic op-codes such as GET and ADD. • Because an assembly language program can be quite long and challenging to write, modem programming typically uses a highlevel language to generate the machine code. • A high-level language is a program that accepts as its input a pseudo -English-like language and then converts it into numeric machine code. Some of these languages are BASIC, C, C++, or Java. 6/5/2021 18
Assembly adv. and dis. • Assembly advantages: – Programmer can write codes that's really fast. – Programmer can write codes that's consumes relatively little memory. – Programmer will understand the hardware and make it do stuff super-efficiently. – Assembly language does not rely on the compiler vendor. • Assemble disadvantages: – Creating assembly code is time-consuming. – Creating assembly code is error-prone. – Creating assembly code is a maintenance NIGHTMARE. 6/5/2021 19
CPU function • A CPU performs three main tasks in a computer system: (1) Data transfer, (2) Arithmetic and logic, (3) Program flow control. • Data transfers represent the most common CPU task. • Data transfers include fetching an instruction from memory, transferring data between registers or memory locations, and transferring the result from some arithmetic or logic operation between memory and the CPU or between an I/O device and the CPU. 6/5/2021 20
Arithmetic and logic instructions • A CPU spends much less time performing arithmetic and logic operations on numbers than data transfers. • These operations are normally performed by an integer arithmetic unit. • Real numbers cannot be operated on by the CPU without a program or special processing unit called numeric processor. • Microprocessors often contain a numeric processor as well as the integer processor, whereas the microcontroller seldom contains a numeric processor. 6/5/2021 21
Program flow control instructions • Program flow control instructions allow a section or sections of code to be used multiple times in a program. Program flow control instructions also allow the flow of a program to be transferred to a function or procedure. • There are unconditional and conditional program flow control instructions. • The unconditional program flow control instructions are the GOTO and function CALL instructions. • The conditional program flow control instructions allow a number to be tested for a condition to determine if the flow of the program is modified. • Conditional program flow control instructions test a number to determine if it's zero, if a carry occurred after addition, or if the result of an operation is negative or positive. 6/5/2021 22
Memory • The memory is an extremely important component of a computer system because it provides a place to store programs and the data used by a program. • Two types of memory are used: read-only memory (ROM) and read/write memory, typically called random access memory (RAM). • The ROM in a microcontroller-based system stores static data as a program and as constant data used by the program. • Most embedded microcontroller-based systems store only one program in the memory that functions as an operating system. • The RAM in a microcontroller-based system stores dynamic data for the system. 6/5/2021 23
ROM types ROM type Cost Programmability Time to program Time to erase Maskprogrammed ROM Very inexpensive At factory only Weeks N/A PROM Inexpensive Once, by end user Seconds N/A EPROM Moderate Many times Seconds 20 minutes Flash EPROM Expensive Many times 100 ms 1 s, large block 6/5/2021 24
Dynamic RAM (DRAM) • DRAM (Dynamic random-access memory) which uses memory cells consisting of one capacitor and one transistor to store each bit. • This is the cheapest and highest in density, so it is used for the main memory in computers. • However the electric charge that stores the data in the memory cells slowly leaks off, so the memory cells must be periodically refreshed (rewritten), requiring additional circuitry. • The refresh process is automatic and transparent to the user. 6/5/2021 25
Static RAM (SRAM) • SRAM (Static random-access memory) which relies on several transistors forming a digital flip-flop to store each bit. • This is less dense and more expensive per bit than DRAM, • It is faster than DRAM and does not require memory refresh. • It is used for smaller cache memories in computers. 6/5/2021 26
I/O • The input/output (I/O) in a system is a CPU's connection to other machines and humans. • Without I/O, the CPU is able to solve problems, but it cannot provide the result to humans or other machines. • Because of the diversity of I/O devices connected to a CPU, much of the work with microprocessors or microcontrollers involves interfacing and controlling, through software drivers, the I/O devices in a computer system. • Some common I/O devices are keyboards for inputting information and LCD or video displays for outputting data. 6/5/2021 27
Buses • The connections between the blocks in the block diagram of a computer system are called buses. • A bus is a common set of wires that carry a specific type of information. A computer system has three buses: (1) address, (2) data, and (3) control. • The address bus carries address information for selecting a memory location or an I/O location. • The data bus carries the data that is transferred between the memory or I/O and the microcontroller. • The control bus controls whether the memory and I/O is read or written. 6/5/2021 28
Buses (2) 6/5/2021 29
Address bus • All computers have an address bus with signal lines that are almost always labelled A 0, AI, A 2 …… • For example, if a computer has a 16 -bit address bus (numbered from A 0 to A 15), it addresses 64 K of memory or 64 X 1, 024 (65, 536) locations in the memory system. • Memory is numbered in hexadecimal (number base or radix 16) from location zero to the maximum number for the address width. 6/5/2021 30
Data bus • The data bus in a computer system is usually a 2 -way bus or a bidirectional bus that carries data between the CPU and the memory and I/O system. • The width of the data bus, which is numbered from DO to Dn, varies. • The zero bit (DO) is the least significant data bus bit. • An 8 -bit computer usually has an 8 -bit data bus, a 16 -bit computer usually has a 16 -bit data bus. • In some machines, the data bus is twice the width of the CPU to accomplish data transfers at higher speeds. 6/5/2021 31
Control bus • The control bus controls the memory and I/O with the microprocessor through a read signal often called RD and a write signal often called WR. • Note that the over bar indicates a signal is an active low signal. • If the microprocessor fetches an instruction from memory, it places the memory address on the address bus, the read signal is forced low to inform the memory to do a read operation, and the data are then transferred from the memory to the microprocessor through the data bus. • Likewise, the same steps are performed for a write. 6/5/2021 32
Logic gates • Binary logic gates are simple circuits that take one or more input and send out one output signal. • The AND gate takes two or more inputs and performs a logic AND on them. • The output will be only if both inputs to the AND gate are 1. • The output will be only if one or more inputs to the OR gate is 1. 6/5/2021 33
Logic gates (2) • A buffer gates does not change the logic level of the input, it is used to isolate or amplify the signal. • The inverter, also called NOT, outputs the value opposite to that input to the gate. • The XOR gate produces a 1 output if one (but only one) input is 1. This function can be used to compare two bits to see if they are the same. • The NAND gate produces a 0 output when all inputs are 1. • The NOR gate produces a 1 output when all inputs are 0. 6/5/2021 34
Summary • The CPU is the controlling element in a computer system. • The CPU performs data transfers, does simple arithmetic and logic operations, and makes simple decisions. • The CPU executes programs stored in the memory system to perform complex operations in short periods of time. • The address bus is used to request a memory location or I/O device. • The data bus transfers data between the microprocessor and its memory and I/O spaces. • The control bus controls the memory and I/O, and requests the reading or 35 writing of data. 6/5/2021
Questions 1. Select an option that makes the statement TRUE: - The data bus : a. is usually a 2 -way bus b. is usually a 1 -way bus. c. a or b. d. none of the above. 2. Select an option that makes the statement NOT TRUE: - A buffer : a. does not change the logic level of the input. b. can be used to amplify the signal. c. can be used to isolate the signal. d. outputs the value opposite to that input to the gate. 36