Lecture 1
Lecture 1
Lecture 1
Introduction to Microcontrollers
1
Why do we need to learn
Microprocessors/controllers?
• A smaller computer
• On-chip RAM, ROM, I/O ports...
• Example:Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC
16X
8
Block Diagram
External interrupts
On-chip Timer/Counter
CPU
Bus Serial
4 I/O Ports
OSC Control Port
P0 P1 P2 P3 TxD RxD
Address/Data
10
11
8051 features
12
Pin
Description
of the 8051
Figure (b). Power-On RESET Circuit
Vcc
+
10 uF
31
EA/VPP
30 pF X1
19
11.0592 MHz
8.2 K
X2
18
30 pF
9 RST
15
Port 0 with Pull-Up Resistors
Vc
c 10
K
P0.
Port
DS5 P0.
0
P0.
1
000 P0.
2
8751 P0.
3 0
P0.
4
8951 P0.
5
P0.
6
7
The main function of pull-up and pull-down resistors is that the pull up resistor
pulls the signal to high state unless it is driven low; and, a pull-down resistor
pulls the signal to low state unless it is driven high.
Registers
A
B
R0
DPTR DPH DPL
R1
R2 PC PC
R3
R4 Some 8051 16-bit Register
R5
R6
R7
2FH
• The stack pointer in the Bit-Addressable RAM
Hexadecimal
Binary
BCD
Hexadecimal Basis
Hexadecimal Digits:
1 2 3 4 5 6 7 8 9 A B C D E F
A=10
B=11
C=12
D=13
E=14
F=15
Decimal, Binary, BCD, & Hexadecimal
Numbers
(43)10=
(0100 0011)BCD=
( 0010 1011 )2 =
( 2 B )16
Register Addressing Mode
MOV DPTR, A
MOV Rm, Rn
Direct Addressing Mode
MOV A,#65H
MOV R6,#65H
MOV DPTR,#2343H
MOV P1,#65H
SETB bit ; bit=1
CLR bit ; bit=0
SETB C ; CY=1
SETB P0.0 ;bit 0 from port 0 =1
SETB P3.7 ;bit 7 from port 3 =1
SETB ACC.2 ;bit 2 from ACCUMULATOR =1
SETB 05 ;set high D5 of RAM loc. 20h
Note:
INC R7
DEC A
DEC 40H ; [40]=[40]-1
LOOP and JUMP Instructions
Conditional Jumps :
JZ Jump if A=0
JB Jump if bit=1
SETB P0.0
.
.
CALL UP
.
.
.
UP:CLR P0.0
.
.
RET
Review questions
• What are the main differences between a
microprocessor and a microcontroller in
terms of
– Architecture
– Applications
– Instruction set
31