Professional Documents
Culture Documents
CHAPTER 1ed3
CHAPTER 1ed3
MICROCONTROLER SYSTEM
IBB20204
LECTURE 1
Lecturer: MOHD SALLEHIN MOHD KASSIM
Room : 10.11
No Tel : 019-6692935
Email : msallehin@unikl.edu.my
Topics
Introduction
Instruction Set & Assembler Directives
Assembly Language Programming
Basic Peripherals & Their Interfacing
(Data Acquisition Systems)
(Applications)
Assessment
Assessment:
1. Coursework 60%
Test 20%
Lab Assignments 20%
Project and Presentation 10%
(Quiz) 10%
Memory I/O
Processor
Data Bus
Address Bus
Control Bus
Microprocessor – Basic Concept
What is a Computer? – is basically a machine
that consists:
Central Processing Unit (CPU) /microprocessor
To do arithmetic and logic operations and control I/O devices
according to the program stored in memory
Memory
Stores programs and data; RAM (random access memory),
ROM (read-only memory)
Input/output Devices
Allow CPU to communicate with external hardware
System Bus
Connects everything together
Address, Data, Control signals
Basic Computer Concept
Software perspective –
To program the instructions in order to perform
computations /I/O ports logic control
Example:
High level language – C programming, java, VB, MatLab
Low level language - machine language, assembly
language
12
Microprocessor
• Microprocessor is an IC which has only the CPU inside them
i.e. Intel’s Pentium 1,2,3,4, core 2 duo, i3, i5 etc.
• These microprocessors don’t have RAM, ROM, and other
peripheral on the chip.
• Application of microprocessor includes Desktop PC’s, Laptops,
notepads etc.
• Microprocessor performs unspecific tasks like developing
software, games, websites, photo editing, creating documents
etc.
• They need high amount of resources like RAM, ROM, I/O
ports etc.
13
Microcontrollers
• Microcontroller has a CPU, and a fixed amount of RAM, ROM
and other peripherals all embedded on a single chip.
• Microcontrollers are designed to perform specific tasks.
• For example, keyboards, mouse, washing machine, digicam,
pendrive, remote, microwave, cars, bikes, telephone, mobiles,
watches, etc.
• Since the applications are very specific, they need small
resources like RAM, ROM, I/O ports etc. and hence can be
embedded on a single chip.
14
Data Representation
In assembly language the use of the binary and
hexadecimal numbering systems are crucial in order to
represent the data and memory locations/address.
Understanding numbering systems is important because
their use simplifies complex topics including Boolean
algebra and logic design, signed numeric representation,
character codes.
Numbering System
Microprocessor Signal
Vcc Vcc
Vcc, or 1
Gnd, or 0
For example, the two numbers 2AH and 42D might be the same
value, but their representations are different.
Numbering System
Binary 2 01
Octal 8 01234567
Decimal 10 0123456789
Hexadecimal 16 0123456789ABCDEF
Numbering System
23810 = 2 x 100 + 3 x 10 + 8 x 1
2 x ( 10 x 10) + 3 x 10 + 8 x 1
2 x 102 + 3 x 101 + 8 x 100
Numbering System
The Decimal (base 10) System
10 symbols: 0, 1, 2, 3, 4, 5, 6 , 7, 8, 9.
Each number is a digit (from Latin for finger).
b8 b7 b6 b5 b4 b3 b2 b1 b0
MSB LSB
Power of 2
28 27 26 25 24 23 22 21 20
Binary
Counting
Numbering System
Conversions
1. Binary to Decimal
1 0 12
22 21 20
43 / 2 = 21 remainder of 1
LSB
21 / 2 = 10 remainder of 1
10 / 2 = 5 remainder of 0
5 / 2 = 2 remainder of 1
2 / 2 = 1 remainder of 0
MSB
1 / 2 = 0 remainder of 1
4310 = 1 0 1 0 1 1
Ex: Convert 3110 to its binary form.
Numbering System
Binary Arithmetic
1. Binary Addition
Adding two binary numbers are same as addition of decimal
numbers. There are mainly 4 rules should follow in the process of
addition in binary numbers.
Sum Carry
Rule 1 0 + 0=0 0
Rule 2 0 + 1=1 0
Rule 3 1 + 0=1 0
Rule 4 1 + 1=0 1
Numbering System
.
1 1 1
1 0 12 510 1 0 1 12 1110
0 1 02 +210 + 0 1 1 12 0710
1 1 12 710 1 0 0 1 02 1810
Numbering System
2. Binary Subtraction
Rule 1 0 - 0 = 0
Rule 2 0 - 1 = 1 with a borrow of 1
Rule 3 1 - 0 = 1
Rule 4 1 - 1 = 0
To perform Rule 2 you have to borrow 1 from the next column. The
weight of the binary you borrow will be 2.
Numbering System
3. Binary Multiplication
0x0=0
0x1=0
1x0=0
1x1=1
Numbering System
1. 11 x 11
2. 101 x 111
Numbering System
Hexadecimal Number System
Decimal, binary, and hexadecimal numbers
Numbering System
1. Hexadecimal- to -Decimal Conversion
2 B C
Hex. Number
= 70010
Ex: Convert 102A16 to its decimal form.
Numbering System
Hex 0 0 1 C
= 16+12 = 2810
Numbering System
4. Binary to Hexadecimal Conversion
Hex C A 5 7
4 7 F E
1 2 6 C16
Numbering System
Adding Hexadecimal numbers.
Following hexadecimal addition table will help you greatly to handle
Hexadecimal addition.
Numbering System
To use this table, simply follow the directions used in this example −
Add A16 and 516. Locate A in the X column then locate the 5 in the Y
column. The point in 'sum' area where these two columns intersect is
the sum of two numbers.
5 6 716 A B C16
A 0 C16 A 1 116
F 7 316 1 4 C D16
Numbering System
Alphanumeric Codes
• ASCII CODE- American standard code for information interchange.
• Information expressed in ASCII codes can also be directly processed by the 8088/86
microprocessor.
• It is being used for most micro computers. ASCII code is 7-bit code.
• Note that there are also another extended-ASCII codes recorded.
• ASCII is used when interfacing computer’s keyboards, printers and video displays.
• Other Alphanumeric codes you may encounter are:
* 7-bit BCDIC- Binary Coded Decimal Interchange code
* 8-bit EBCDIC-Extended Binary Coded Decimal Interchange code
* 7-bit Selectric, used to control the spinning ball in IBM
typewriters.
* 12-bit Hollerith used on punched cards
Numbering System
ASCII Codes
Numbering System
ASCII Codes
Example: Byte addresses 0110016 through 0110416 contain the ASCII
data 01000001, 01010011, 01000011, 01001001, and 01001001,
respectively.What do the data stand for?
Numbering System
1’s complements
2’s complements
Numbering System
Complements of Binary Numbers
1’s complement
Numbering System
Complements of Binary Numbers
2’s complement
Once 1’s complement is done, to perform 2’s complement, we just
add the binary equivalent of 1 (0000 0001)
Useful when we want to express a negative signed numbers Ex: -5
Data Organization
In pure mathematics a value may take an arbitrary number of
bits.
Computers work with some specific number of bits.
Common collections used in Intel 80x86 chips are :
single bits,
groups of four bits (called nibbles),
groups of eight bits (called bytes),
groups of 16 bits (called words)
Bits
The smallest “unit” of data on a binary computer
A single bit represent only two different values
zero or one (0/1)
true or false,
on or off,
male or female, and
right or wrong.
Computer data structures: data is what you define it to be
(program code).
Bits will play an important role in your programs.
Nibbles
A group of four bits.
BCD (binary coded decimal) numbers, hexadecimal numbers.
It takes four bits to represent a single BCD or hexadecimal
digit.
Can represent up to 16 distinct values.
Hexadecimal numbers, the values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
A, B, C, D, E, and F are represented with four bits.
BCD uses ten different digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
Bytes
The most important data structure used by the 80x86
microprocessor.
Eight bits and is the smallest addressable data item on the
80x86 microprocessor.
Main memory and I/O addresses are all byte addresses.
The smallest data length that can be individually accessed by
an 80x86 program.
Bit 0 is the low order bit or least significant bit, bit 7 is the high
order bit or most significant bit of the byte.
Bytes
Bits 0..3 comprise the low order nibble, bits 4..7 form the high
order nibble. A byte contains exactly two nibbles, byte values
require two hexadecimal digits.
Bytes
A byte contains eight bits, it can represent 2^8, or 256,
different values.
Generally, a byte is used to represent numeric values in the
range 0..255, signed numbers in the range -128..+127.
ASCII/IBM character codes (i.e. 128 defined codes), and
other special data types requiring no more than 256 different
values.
Many data types have fewer than 256 items so eight bits is
usually sufficient.
The Boolean values true and false by 00000001B and
00000000B
Words
A word is a group of 16 bits.
Bit 0 is the low order bit and bit 15 is the high order bit.
Words
Double Words
A double word is a pair of words.
Quantity is 32 bits long
Signed Numbers
How to represent Negative values and positive numbers in
binary?
Negative values -128..-1 and the positive values 0..127
with a single eight bit byte.
16-bit word we can represent values in the range
-32,768..+32,767.
32-bit double word we can represent values in the range
-2,147,483,648..+2,147,483,647.
Signed Numbers
80x86 microprocessor uses the two’s complement notation
to present negative numbers.
In the two’s complement system, the H.O. bit of a number is
a sign bit.
If the MSB is zero, the number is positive;
If the MSB bit is one, the number is negative
For the following 16-bit numbers, determine the sign bit.
8000h is negative because the MSB is one.
100h
7FFFh
0FFFh
Signed Numbers
Storing signed values:
If the MSB is zero, then the number is positive and is stored
as a standard binary value.
If the MSB is one, then the number is negative and is stored
in the two’s complement form.
For example, to compute the eight bit equivalent of -5:
1. 0000 0101 Five (in binary).
2. 1111 1010 Invert all the bits.
3. 1111 1011 Add one to obtain result.
4. Therefore -5 = 1111 1011
Thank You