Unit 1. Introduction & HCS12 Overview

forestevanescentΗλεκτρονική - Συσκευές

2 Νοε 2013 (πριν από 4 χρόνια και 6 μέρες)

143 εμφανίσεις

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.

Floyd, Digital Fundamentals, 10
th

ed

EET 2261 Unit 1

Introduction &
HCS12 Overview



Read
Mazidi
, Chapters 0 and 1.



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 Edition

Thomas 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, …

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: 15
10

= 1111
2

= F
16



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


I’ll always use the $ prefix to indicate hex. But
our textbook sometimes uses two other
common conventions to indicate hex:


The letter H after a number means hex.


Example: 55H means 55
16


0x before a number means hex.


Example: 0x55
means 55
16

Other Conventions for Hex


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 F in your textbook (p. 668)


Wikipedia’s article on
ASCII

Review: ASCII Codes

Review: Kilo
-
, Mega
-
, Giga
-


In engineering notation,


Kilo

means 1,000 (the same as 10
3
)


Mega

means 1,000,000 (same as 10
6
)


Giga

means 1,000,000,000 (same as 10
9
)


When talking
about
computer memories
,
these
terms have slightly different meanings:


Kilo

means 1,024 (the same as 2
10
)


Mega

means 1,048,576 (same as 2
20
)


Giga

means 1,073,741,824 (same as 2
30
)

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 Reserved

Floyd, Digital Fundamentals, 10
th

ed

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved

Floyd, Digital Fundamentals, 10
th

ed

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 Reserved

Floyd, Digital Fundamentals, 10
th

ed

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved

Floyd, Digital Fundamentals, 10
th

ed

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.

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 Reserved

Floyd, Digital Fundamentals, 10
th

ed

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved

Floyd, Digital Fundamentals, 10
th

ed

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.

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 2
40
.


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
?


There are
three
main categories (and many
subcategories
) of semiconductor memory:

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

3.
Flash
memory


Read/write


Non
-
volatile


Our textbook considers Flash to be a type of ROM.


Review: Memory
Technologies

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved

Floyd, Digital Fundamentals, 10
th

ed

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved

Floyd, Digital Fundamentals, 10
th

ed


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 Reserved

Floyd, Digital Fundamentals, 10
th

ed

Types of RAM

Latch or flip
-
flop

storage 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 Reserved

Floyd, Digital Fundamentals, 10
th

ed

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved

Floyd, Digital Fundamentals, 10
th

ed

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
difficult to write to).


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 Reserved

Floyd, Digital Fundamentals, 10
th

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.

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved

Floyd, Digital Fundamentals, 10
th

ed

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved

Floyd, Digital Fundamentals, 10
th

ed

Flash Memory

Flash memories are high density read/write memories that
are nonvolatile. They have the ability to retain charge for
years with no applied power.

Flash memory uses a MOS transistor
with a floating gate as the basic storage
cell. The floating gate can store charge
(logic 0) when a positive voltage is
applied to the control gate. With little or
no charge, the cell stores a logic 1.

logic 0 is stored

logic 1 is stored


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
721
of
text or 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


See page 720
of textbook
or
page 23 of
Device User
Guide
.

HCS12 Block Diagram


See page 724
of textbook
or
page 26 of
Device User
Guide
.

HCS12 Memory Map


Please ignore the diagrams on pages 722,
723, 725, 726, and 727 of the textbook.


These aren’t for our chip; they’re for close
relatives of our chip.

Ignore These Pages


See page
719
of textbook.

Comparing Our Chip to Its
Relatives