8/19/2019 Lecture One Digital 1st
1/23
PROGRAMMABLE
1
MICROCONTROLLERSThese are lecture notes to accompany the books:
•Mohammad Ali Mazidi, The 8051 Microcontroller and embeddedsystems.2006
•Milan Verle, PIC Microcontrollers - Programming in C, 2009
8/19/2019 Lecture One Digital 1st
2/23
Course Outline Introduction to Digital systems.
PIC Microcontrollers architecture.
Programming Microcontrollers C-Language
2
8051 Assembly Language programming
Overview on Arduino development
environment and programming language.
8/19/2019 Lecture One Digital 1st
3/23
What is a Microcontroller?3
8/19/2019 Lecture One Digital 1st
4/23
Microcontroller Applications4
8/19/2019 Lecture One Digital 1st
5/23
Microcontroller Applications5
8/19/2019 Lecture One Digital 1st
6/23
Introduction to Digital To understand the software and hardware of a
microcontroller based systems, one first musthave knowledge is some basic concepts under
computer design.
6
Fundamentals of numbering and coding systems.
Introduction to logic gates.
8/19/2019 Lecture One Digital 1st
7/23
Numbering and coding systems The numbering system we use (human)
everyday is decimal. Computers use BINARYsystem.
Decimal Base 10. 0 1 2 3 4 5 6 7 8 9
7
Binary Base two. (0, 1)
8/19/2019 Lecture One Digital 1st
8/23
Converting form Binary to Decimal
To convert form binary to decimal, it is important
to understand the weight concept of each digit. Weight of number (740683)10
3 x 100 =3
8
8 x 101 =80
6 x 102 =600
0 x 103 =0
4 x 104 =40000
7 x 105 =700000
8/19/2019 Lecture One Digital 1st
9/23
Converting form Binary to Decimal
Ex 1:
Convert (11001)2 to Decimal:
Weight: 16 8 4 2 1
9
Sum: 16+ 8+ 0+ 0+ 1=2510
8/19/2019 Lecture One Digital 1st
10/23
Converting form Binary to Decimal Ex2:
Convert (110110.01)2 to Decimal 1 x 2-2 =0.25
0 x 2-1 =0
10
x =
1 x 21 =2
1 x 22 =4
0 x 23 =0
1 x 24 =16
1 x 25 =32
Sum= (54.25)10
8/19/2019 Lecture One Digital 1st
11/23
Converting form Decimal to Binary Ex 3:
Convert (25)10 to Binary. Quotient Reminder
25/2 = 12 1 LSB
11
12/2= 6 0
6/2= 3 0
3/2= 1 1
½= 0 1 (MSB)
Therefore (25)10 is (11001)2
8/19/2019 Lecture One Digital 1st
12/23
Hexadecimal System Base 16, the hexadecimal system is used in a
convenient representation of binary numbers. It is much easier for us to represent a binary
number 111100110101 as its hexadecimal
12
number F25H.
The Hexadecimal (Base 16) : 0-9, A, B, C, D,
E and F.
8/19/2019 Lecture One Digital 1st
13/23
Decimal – Binary - Hexadecimal1313
8/19/2019 Lecture One Digital 1st
14/23
Converting between Binary and Hex
Ex4: Represent (100111110101)2
Solution:
1- Group each 4 bits: 1001 1111 0101
14
-
1001 9, 1111F, 01015
Therefore (100111110101)2 =9F5H
8/19/2019 Lecture One Digital 1st
15/23
Convert Hex to Binary15 Ex5: Convert 3A9H to Binary
3 0011, A 1010, 91001
So (3A)16 = (001110101001)2
8/19/2019 Lecture One Digital 1st
16/23
Converting from decimal to hex16 Two ways:
1- Convert to binary then to hex
Convert directly to hex, by repeated division by
.
8/19/2019 Lecture One Digital 1st
17/23
Converting from decimal to hex17 Ex 6: Convert 4510 To Hex
First convert to binary (sum of weight method):
32 16 8 4 2 1
32+8+4+1= 4510 = 1011012
4510 = (0010 1101)2 = 2D16
8/19/2019 Lecture One Digital 1st
18/23
Convert from hex to decimal18 Convert by summing all weights or convert to
binary then decimal.
8/19/2019 Lecture One Digital 1st
19/23
Counting in bases 10,2 and 1619
8/19/2019 Lecture One Digital 1st
20/23
Counting in bases 10,2 and 1620
8/19/2019 Lecture One Digital 1st
21/23
Addition of binary21 Add the following numbers:
Binary Decimal 1101 13
10110 22
8/19/2019 Lecture One Digital 1st
22/23
Addition of hex numbers22 Ex:7 Perform Hex addition : 23D9+94BE
23D9 LSD: 9+14=231017H 94BE + 1+13+11=251019H
= MSD: 2+9=1110BH
8/19/2019 Lecture One Digital 1st
23/23
ASCII Code23 American Standard Code for Information
Interchange.