Upload
percival-barber
View
213
Download
0
Embed Size (px)
Citation preview
EET 2261
Microprocessors
Professor Nick Reeder
Reminders
Please turn off cell phones.
No food or soft drinks in the classroom.
Stow water bottles at floor level.
EET 2261 Unit 1Introduction and HCS12 Overview
Read Almy, Chapters 1 & 2.
Homework #1 and Lab #1 due next week.
Quiz next week.
Copyright ©2009 by Pearson Higher Education, Inc.Upper Saddle River, New Jersey 07458
All rights reserved.
Digital Fundamentals, Tenth EditionThomas L. Floyd
Figure 13.1 Basic computer block diagram.
• The microprocessor is the heart of a computer system. It performs the following functions:• Fetches instructions from memory.
• Decodes and executes the instructions. This typically involves:
• Transferring data to/from memory or I/O devices.
• Performing arithmetic or logical operations on data.
• Provides timing and control signals for all other elements in the computer.
• Responds to interrupts (requests from I/O devices).
Roles of the Microprocessor
• Dozens of companies design and manufacture microprocessors. Two of the most successful:
• Intel• 4004, 8008, 8086, 80286, 80386, Pentium,
Celeron, Itanium, Xeon, Core 2, …
• Freescale (formerly Motorola)• 6800, 68000, PowerPC, …
Some Popular Microprocessors
• A microcontroller is a specialized microprocessor with less computational power than general microprocessors.
• Contains ROM, RAM, I/O ports on the same chip as the processor.
• Widely used in embedded applications, where it is dedicated to a specific, unchanging control task.
• Examples: inside cars, smartphones, dishwashers, microwave ovens, toys, ….
Microcontroller
• Dozens of companies design and manufacture microcontrollers. Some of the most successful: • Intel
• 8051
• Freescale (formerly Motorola)• 68HC11, 68HC12, HCS12, …
• Microchip Technology• PIC16, PIC18, PIC32, …
• Atmel• 8-bit AVR, 32-bit AVR, …
Some Popular Microcontrollers
• In this course you'll learn a lot about the following three topics:1. HCS12 microcontroller
2. Dragon12 trainer
3. CodeWarrior software
Three Big Topics
• The HCS12, manufactured by Freescale (formerly Motorola) is a popular microcontroller.
• Freescale makes many variations of this chip. The one we’ll work with is in the HCS12D “family,” and it’s called the MC9S12DG256.
• It’s a 112-pin chip, and it’s far more complicated than any chip you’ve studied in previous courses.
Big Topic #1: HCS12 Microcontroller
• Our HCS12 chip is mounted on a trainer board called the Dragon12-Plus2, manufactured by EVBplus.
• The HCS12 chip on this board is already connected to many peripheral devices:• Switches• LEDs• Keypad• 7-segment displays• Temperature sensor• Speaker• and more.
Big Topic #2: Dragon12 Trainer
• To program the HCS12 chip, we’ll use Freescale’s CodeWarrior IDE, which runs on a personal computer.
• This is very powerful, complex software.
• The professional edition is expensive, but you can download a free “special edition,” intended for students, from Freescale’s website.
Big Topic #3: CodeWarrior
• People who program microcontrollers need to use several computer applications:
• One to type their program
• Another to check for errors and translate their program to machine code
• Another to download the machine code to the chip
• An integrated development environment (IDE), such as CodeWarrior, combines all of these tasks into a single program.
What’s an IDE?
• Datasheets for the HCS12 microcontroller, manufactured by Freescale Semiconductor.
• User’s manual and schematic diagram for the Dragon12-Plus2 board, manufactured by EVBplus.
• Users Guide for CodeWarrior, manufactured by Freescale Semiconductor.
Reference Documents
• Recall that any positive integer can be written in decimal notation, binary notation, or hexadecimal notation.
• Example: 1510 = 11112 = F16
• You must memorize the binary and hex notation for numbers from 0 to 15.
• Use my games page for practice.
• You must also know how to convert between decimal and binary (or vice versa) for larger numbers.
Review: Binary & Hex
• Instead of subscripts, we’ll use prefixes to specify whether a number is in decimal, binary, or hex notation:
• No prefix means decimal
• % prefix means binary
• $ prefix means hex
• Example: 15 = %1111 = $F
Binary & Hex Prefixes
• Bit: The smallest unit of digital data, a single 1 or 0.
• Byte: A group of 8 bits.
• Nibble: A “half-byte”: a group of 4 bits.
• Word: 2 bytes (or 16 bits).
Terms for Units of Data
• Recall that ASCII is a code for representing text using binary numbers. Each character is represented by a 7-bit code:• Example: The ASCII code for A is %100 0001.
• The ASCII code arises often in computer programming.
• For a table of the ASCII codes, refer to one of the following:• Appendix J in your textbook (p. 375)
• Wikipedia’s article on ASCII
Review: ASCII Codes
Review: Signed Versus Unsigned Binary Representation
• As a programmer, you will often have to decide whether to use signed or unsigned binary representation in a program.
• We use unsigned binary representation when we know that the range of numbers we’re dealing with does not include negative numbers.
• We use signed binary representation when the numbers we’re dealing with may be positive or negative. Negative numbers are represented in two’s-complement form.
Review: Two’s-Complement Form• In two’s-complement form, the leftmost
bit (MSB) is the sign bit.• Sign bit = 0 for positive numbers or 0.• Sign bit = 1 for negative numbers.
• Examples:• %0000 0011 = 3• %1000 0011 = 125
Review: Kilo-, Mega-, Giga-
• In engineering notation,
• Kilo means 1,000 (the same as 103)
• Mega means 1,000,000 (same as 106)
• Giga means 1,000,000,000 (same as 109)
• When talking about computer memories, these terms have slightly different meanings:
• Kilo means 1,024 (the same as 210)
• Mega means 1,048,576 (same as 220)
• Giga means 1,073,741,824 (same as 230)
Bytes, Kilobytes, Megabytes, Gigabytes
• There are 1024 bytes in a kilobyte: 1 KB = 1024 bytes
• There are 1024 kilobytes in a megabyte: 1 MB = 1024 KB
• There are 1024 megabytes in a gigabyte: 1 GB = 1024 MB
Making Sense of Windows File Sizes
• Have you ever noticed that when you use Windows to look at a file’s size, it gives two numbers that don’t seem to match each other?
• Example: “Size on disk: 624 KB (638,976 bytes)”
• That’s because 624 x 1024 = 638,976.
• A computer system’s data bus carries data and instructions from one part of the system to another.
• Its address bus carries addresses of memory locations or external devices.
Computer Busses
• In the HCS12, both of these busses are 16 bits wide.
• When people say a “16-bit system” or a “32-bit system,” they’re talking about the width of the data bus.
© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
The location of a unit of data in a memory is called the address. Usually a byte is the smallest unit of data that can be addressed.
Memory Units
For example the blue byte is located in address 6.
© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Write Operations
The two main memory operations are called read and write. A simplified write operation is shown in which new data overwrites the original data. Data moves to the memory.
1. The address is placed on the address bus.
2. Data is placed on the data bus.
3. A write command is issued.
7
6
5
4
3
2
1
0
0 0 0 0 1 1 1 1
1 1 1 1 1 1 1 1
1 0 0 0 1 1 0 1
0 0 0 0 0 1 1 0
1 1 1 1 1 1 0 0
1 0 0 0 0 0 0 1
0
1
0
0
1
1
0
0
1
1
0
1
0
1
1
1
1 0 1
1
0 0 1
2
01 1 0 1
3
Address register Data register
Address bus
Address decoder Byte organized memory array
Write
Data bus
© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Read Operations
The read operation is actually a “copy” operation, as the original data is not changed. The data bus is a “two-way” path; data moves from the memory during a read operation.
1. The address is placed on the address bus.
2. A read command is issued.3. A copy of the data is placed
in the data bus and shifted into the data register.
7
6
5
4
3
2
1
0
0 0 0 0 1 1 1 1
1 1 1 1 1 1 1 1
1 0 0 0 1 1 0 1
0 0 0 0 0 1 1 0
1 1 0 0 0 0 0 1
1 0 0 0 0 0 0 1
0
1
0
0
1
1
0
0
1
1
0
1
0
1
1
1
0 1 1
1
0 0 0
3
11 0 0 1
2
Address register Data register
Address bus
Address decoder Byte organized memory array
Read
Data bus
Some Common Address Bus Widths
• An address bus’s width (in bits) determines the number of locations it can address:
Width of Address Bus Number of locations
8 bits 256
10 bits 1 K
16 bits 64 K
20 bits 1 M
24 bits 16 M
32 bits 4 G
Powers of 2
• Here’s a handy table showing the powers of 2 up to 240.
• You can use a table like this to answer the following questions:
1. How many addressable locations are there in a memory with n address bits?
2. How many rows are there in a truth table with n input variables?
3. What is the MOD of an n-bit counter?
• Most memory chips fall into one of the following two categories (which have many subcategories).
1. RAM (Random Access Memory)• Read/write• Volatile (Loses data when power is removed.)
2. ROM (Read-Only Memory)• Impossible or difficult to write to• Non-volatile
Review: Memory Technologies
© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
• RAM is for temporary data storage. It is read/write memory and can store data only when power is applied, hence it is volatile. Two major categories are static RAM (SRAM) and dynamic RAM (DRAM).
• The memory cells in SRAM are latches or flip-flops.
• The memory cells in Dynamic RAMs (DRAMs) are capacitors. Since the capacitors lose charge, they must be refreshed many times each second.
Random Access Memory (RAM)
© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10th ed
Types of RAM
Latch or flip-flopstorage cell.
Capacitor storage cell. Must be refreshed.
High-density but slow. Used for main memory.
Fast but low-density. Used for cache memory.
© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10th ed © 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Read-Only Memory (ROM)
• Members of the ROM family are all considered non-volatile, because they retain data with power removed.
• Various members can be either permanent memory (truly read-only) or erasable (not truly read-only, but they are more difficult to write to than RAM).
• ROMs are used to store data that is never (or rarely) changed, such as system initialization files.
© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights ReservedFloyd, Digital Fundamentals, 10th ed
Types of ROM
Data written by the manufacturer, and can never be changed.
Data written by the user, and can never be changed.
Data written by the user, and can be changed with some difficulty.
• The HCS12 chip contains some Flash memory, some RAM, and some EEPROM.
• In a final product, typically:
• Flash holds the program that the chip executes.
• RAM holds temporary data.
• EEPROM holds permanent data.
• But in this course we’ll use RAM for everything (program as well as data).
Memory in the HCS12
• See page 26 of Device User Guide.
HCS12 Memory Map
• See page 6 of textbook or page 23 of Device User Guide.
HCS12 Block Diagram
Comparing Our Chip to Its Relatives
• See page 52 of Device User Guide.
• Most pins serve more than one function; we’ll learn later how to specify which function we want them to perform.
HCS12 Pin Diagram