Cse-213 Microcontroller Programming Kopyası PDF
Cse-213 Microcontroller Programming Kopyası PDF
-1-
Introduction
• Overview of Intel microprocessors.
• Discussion of history of computers.
• Function of the microprocessor.
• Terms and jargon (computerese).
HISTORICAL BACKGROUND
Events leading to development of the microprocessor.
80X86, Pentium, Pentium Pro, Pentium III, Pentium 4, and Core2
microprocessors.
While not essential to understand the microprocessor, furnishes:
interesting reading
historical perspective of fast-paced evolution
Programming Advancements
Once programmable machines developed, programs and programming
languages began to appear.
As early practice of rewiring circuits proved too cumbersome, computer
languages began to appear in order to control the computer.
The first, machine language, was constructed of ones and zeros using
binary codes.
stored in the computer memory system as groups of instructions
called a program
More efficient than rewiring a machine to program it.
still time-consuming to develop a program due to sheer number of
program codes required
Mathematician John von Neumann, first modern person to develop a
system to accept instructions and store them in memory.
Computers are often called von Neumann machines in his honor.
Recall that Babbage also had developed the concept long before
von Neumann.
More efficient than rewiring a machine to program it.
still time-consuming to develop a program due to sheer number of
program codes required
Mathematician John von Neumann, first modern person to develop a
system to accept instructions and store them in memory.
Computers are often called von Neumann machines in his honor.
Recall that Babbage also had developed the concept long before von
Neumann.
Assembly language was then used to simplify entering binary code.
Assembler allows programmer to use mnemonic codes…
such as ADD for addition
In place of a binary number.
such as 0100 0111
Assembly language an aid to programming.
Since early days of programming, additional languages have appeared.
FLOWMATIC-FORTRAN-ALGOL-COBOL-RPG
Some common modern programming languages are BASIC, PASCAL,
C/C++, C#, Java, and ADA.
BASIC and PASCAL languages both designed as teaching languages,
but escaped the classroom.
Scientific community uses primarily C/C++.
Recent survey of embedded system developers showed C was used by
60%.
30% used assembly language
remainder used BASIC and JAVA
These languages allow programmer almost complete control over the
programming environment and computer system.
especially C/C++
Assembly language still plays important role.
many video games written almost exclusively in assembly language
Assembly also interspersed with C/C++ to perform machine control
functions efficiently.
some newer parallel instructions found on Pentium and Core2
microprocessors only programmable in assembly language
Reminder
A bit is a binary digit with a value of one or zero
4-bit-wide memory location is often called a nibble
8-bit-wide memory location is called a byte
A word is a collection of 2 bytes (or 16 bits)
1 KB = 1024 Bytes = 2 10 Bytes(1 KB = 1024 bytes)
1 MB = 1024 KB = 2 20 Bytes
1 GB = 2 30 Bytes, 1 TB = 2 40 Bytes
B is used for byte and b is used for bit
8 Mbps = 8 Megabits per second (ADSL speed)
Next Processors
Pentium Pro
Pentium II
Pentium III
Pentium IV
Core2
Quad Core
64-bit microprocessors
…
Some Definitions
Integrated Circuit
a.k.a. IC, microcircuit, microchip, silicon chip, or chip
Integrated Circuit is a miniaturized electronic circuit
consisting mainly of semiconductor devices, as well as
passive components) that has been manufactured in the surface of a
thin substrate of semiconductor material.
Microprocessor
A microprocessor is a programmable digital electronic component
that incorporates the functions of a central processing unit (CPU) on
a single semiconducting integrated circuit (IC).
8-bit, 16-bit, 32-bit, and 64-bit microprocessor: refers to number of
bits manipulated in one operation. It requires external memory to
execute programs. It cannot directly interface to I/O devices,
peripheral chips are needed.
Microcomputer and Microcontroller
A microcomputer is a computer that uses a microprocessor as its
CPU.
A microcontroller (or MCU) is a computer-on-a-chip. It is a type of
microprocessor emphasizing self- sufficiency and cost-effectiveness,
in contrast to a general-purpose microprocessor (the kind used in a
PC).
The only difference between a microcontroller and a microprocessor
is that a microprocessor has three parts - ALU, Control Unit and
registers, while the microcontroller has additional elements like
ROM, RAM, peripherals (timer, I/O ports, etc).
THE MICROPROCESSOR-BASED PERSONAL COMPUTER SYSTEM
Computers have undergone many changes recently.
Machines that once filled large areas reduced to small desktop computer
systems because of the microprocessor.
Figure 1–6 shows block diagram of the personal computer.
Applies to any computer system, from early mainframe computers to the
latest systems.
Diagram composed of three blocks interconnected by buses.
a bus is the set of common connections that carry the same type of
information
The Memory and I/O System
Memory structure of all Intel-based personal computers similar.
Figure 1–7 illustrates memory map of a personal computer system.
This map applies to any IBM personal computer.
also any IBM-compatible clones in existence
simple arithmetic and logic operations Decisions found in the 8086 through core2 microprocessors
Buses
A common group of wires that interconnect components in a computer
system.
Transfer address, data, & control information between microprocessor,
memory and I/O.
Three buses exist for this transfer of information: address, data, and
control.
Figure 1–12 shows how these buses interconnect various system
components.
The address bus requests a memory location from the memory or an I/O
location from the I/O devices.
if I/O is addressed, the address bus contains a 16-bit I/O address
from 0000H through FFFFH.
if memory is addressed, the bus contains a memory address, varying
in width by type of microprocessor (20-bits for 8086).
64-bit extensions to Pentium provide 40 address pins, allowing up to
byte of memory to be accessed.
The data bus transfers information between the microprocessor and it
memory and I/O address space.
Data transfers vary in size, from 8 bits wide to 64 bits wide in various
Intel microprocessors.
8088 has an 8-bit data bus that transfers 8 bits of data at a time
8086, 80286, 80386SL, 80386SX, and 80386EX transfer 16 bits of
data
80386DX, 80486SX, and 80486DX, 32 bits
Pentium through Core2 microprocessors transfer 64 bits of data
Control bus lines select and cause memory or I/O to perform a read or
write operation.
In most computer systems, there are four control bus connections:
MRDC (memory read control)
MWTC (memory write control)
IORC (I/O read control)
IOWC (I/O write control).
overbar indicates the control signal is active- low; (active when logic zero
appears on control line)
The microprocessor reads a memory location by sending the memory an
address through the address bus.
Next, it sends a memory read control signal to cause the memory to
read data.
Data read from memory are passed to themicroprocessor through the
data bus.
Whenever a memory write, I/O write, or I/O read occurs, the same
sequence ensues.
NUMBER SYSTEMS
Use of a microprocessor requires working knowledge of numbering
systems.
binary, decimal, and hexadecimal
This section provides a background for these numbering systems.
Conversions are described.
decimal and binary
decimal and hexadecimal
binary and hexadecimal
Digits
Before converting numbers between bases, digits of a number system
must be understood.
First digit in any numbering system is always zero.
A decimal (base 10) number is constructed with 10 digits: 0 through 9.
A base 8 (octal) number; 8 digits: 0 through 7.
A base 2 (binary) number; 2 digits: 0 and 1.
If the base exceeds 10, additional digits use letters of the alphabet,
beginning with an A.
a base 12 number contains 11 digits: 0 through 9, followed by A for
10 and B for 11
Note that a base 10 number does not contain a 10 digit.
a base 8 number does not contain an 8 digit
Common systems used with computers are decimal, binary, and
hexadecimal (base 16).
many years ago octal numbers were popular
Posiitional Notation
Once digits are understood, larger numbers are constructed using
positional notation.
position to the left of the units position is the tens position
left of tens is the hundreds position, and so forth
An example is decimal number 132.
this number has 1 hundred, 3 tens, and 2 units
Exponential powers of positions are critical for understanding numbers
in other systems.
Exponential value of each position:
the units position has a weight of 10 0 , or 1
tens position a weight of 10 1 , or 10
hundreds position has a weight of 10 2 , or 100
Position to the left of the radix (number base) point is always the units
position in system.
called a decimal point only in the decimal system
position to left of the binary point always 2 0 , or 1
position left of the octal point is 80 , or 1
Any number raised to its zero power is always one (1), or the units
position.
Position to the left of the units position always the number base raised
to the first power.
in a decimal system, this is 10 1 , or 10
binary system, it is 2 1 , or 2
11 decimal has a different value from 11 binary
11 decimal has different value from 11 binary.
decimal number composed of 1 ten, plus 1 unit; a value of 11 units
binary number 11 is composed of 1 two, plus 1 unit: a value of 3
decimal units
11 octal has a value of 9 decimal units
In the decimal system, positions right of the decimal point have negative
powers.
first digit to the right of the decimal point has a value of 10−1 , or
0.1.
In the binary system, the first digit to the right of the binary point has a
value of 2−1, or 0.5.
Principles applying to decimal numbers also generally apply to those in
any other system.
To convert a binary number to decimal, add weights of each digit to
form its decimal equivalent.
Convert to decimal Examples
Conversion to Decimal
To convert from any number base to decimal, determine the weights or
values of each position of the number.
Sum the weights to form the decimal equivalent.
Complements
At times, data are stored in complement form to represent negative
numbers.
Two systems used to represent negative data:
radix
radix − 1 complement (earliest - 1’s complement)
COMPUTER DATA FORMATS
Successful programming requires a precise understanding of data
formats.
Commonly, data appear as ASCII, Unicode, BCD, signed and unsigned
integers, and floating-point numbers (real numbers).
Other forms are available but are not commonly found.
ASCII Codes
Real Numbers
Since many high-level languages use Intel microprocessors, real numbers
are often encountered.
A real, or a floating-point number contains two parts:
a mantissa, significand, or fraction
an exponent.
A 4-byte number is called single-precision.
The 8-byte form is called double-precision.
The assembler can be used to define real numbers in single- & double-
precision forms:
use the DD directive for single-precision 32-bit numbers
use define quadword(s), or DQ to define 64-bit double-precision real
numbers
Optional directives are REAL4, REAL8, and REAL10.
for defining single-, double-, and extended precision real numbers