0% found this document useful (0 votes)
42 views23 pages

Micro Unit - 4

The 8051 microcontroller has the following key components: 1) A CPU that performs arithmetic and logic operations. It contains registers for data storage and program status. 2) ROM for storing the programmed instructions. It contains 128 bytes of memory. 3) RAM for data storage, with 32 bytes divided into four banks. 4) Timers, serial port, and I/O ports to interface with external devices using a bidirectional bus structure.

Uploaded by

utkarshtk1403
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views23 pages

Micro Unit - 4

The 8051 microcontroller has the following key components: 1) A CPU that performs arithmetic and logic operations. It contains registers for data storage and program status. 2) ROM for storing the programmed instructions. It contains 128 bytes of memory. 3) RAM for data storage, with 32 bytes divided into four banks. 4) Timers, serial port, and I/O ports to interface with external devices using a bidirectional bus structure.

Uploaded by

utkarshtk1403
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

(P-LOC UNIT-4i

LP-CPU n eku a Clu


eCCom putu (P,mum@y, haxdant etc)
on

uhuu have to meuty u (onkol Lui


wt u e
do not
mouuu, i n l t o o cte) L
0CVict(uDuslung mcunu, Lu
6n
howe fo ute stogHcLms 0gcun Ogcun
U hQwe to l u t e poAam n
and agoln

bo 54 Uc by. INTEL in 981


uBLS intuoluuu
Masn uatwn Avuiaubla On hl
8 u t CPU
)k8 ROM on cip
128 byte on
chup RAM ax data
wo timuu (16 u )
v) I l o parts Ca 3 wt)
n Cn du'b clotk Osc
Vu 3uu dupux duuoul paN
vu) Jaiwwmut sOur oL

WORkING
CPU:8 t RHOLA RAM: a data
&tag
Logscou oRLation Ra ceived tom ext
J t (oun not sta devic
dato R8 byts
>RoM; undwt mong0My Cdivid in 82
L Uwite phogtamn bnk

on it (eoch bank înduk


8 ugistuus
b/u 2

dwuy
de
1: wud to RpMOVI
Timu 04Tim
euns In i u n a l opo

Inunal
op
16 ut au
s0 at
L
ons Uu nhonized

aoullatoxn thwi's uwil gr


is ostal
0sC: dt in yn
do ckuqunuy) vius to Rn
wex R
uwo
all
wud as lockwr

chtoniz aton devitLs


exiuv I
with
J M Communuication ohLtatidn
Bus Contnol: vuad w u t e
Mum@hy ja u)
Datau buus [8
Ywo tyhi: bidiuciornoul

Aids bus 16 lut)


wuiuthonul

I / o Pots (eat howe 8 wts)


Total pius 4x8s 32 pins
Bidiuhiorwl
commuicote with
u d to
PPoan
exuona unatu
wotR as addius buus
P
P wak mulhi þuxud al"/ doto tuus

waR only ax Ilo otafian


P, Behiu u dedituted Ilo pouk
Inwwiup Contol:6intuouyt Aowlus
Handuaru intuUupt
Aalt wau intuust
SERIAL PGRT: wA LA AUulCemmuulatian
Tx D
Dlasmut dato
RD R CLive at
h p e s au 4uu tubuud (which miuns yohu pou
t tHaniMULsion e u u u thion ek Aofh ho a k t a
hOu
43 u u l temmwuauion modl
mo de 0-> shut mo de
ma de 1 3tundaut UARTCwuwUal aduntho
nous HLLUW tHonU m-

ttu)
mo du 2 mubiphocsOl mo de
BLOCk OIAQRAM OF 8081 C:
EXTCRNAL
NTEROPTS ETC
ROM O on cw (TtMER
Intuulupt RogAam RAM
TIMER 1
ContH cade 4kg
CountunA
LIPS

CPU

OSC BuS
4Ilo ERIAL
CONT R0L
pats PORT

TD
4 THE PSw REG ISTER
BIIS
8061 FLAG
wwnd Haus u s u
PxogHamStatus
PS W eaAy
,01
a
indicoutu 1hu aithemetic owation
Psw
and ofhu Cond hon L

PsW is 8 ut w Rug
6ut wu w by 3054
bit u wAU de u d Ca
Ac(Auwliany),
oVow
Conditionaul
lagCYaxy) ,
PCaty fag)
acantrol Hay RS, 4 R$%)
Do
P Ds DD Da
Ds
P
CY AtFo RS,R 6
PSw + C LARAY FLAA
PSW6 A AuviliyCany
PSw S Fo
selut ut1
PSw:4 RS1 Rugistu baunk
n
PSW 3 ASO-
V Owulow

PSW O Pput
PSw Cy
CY whn tuu ig a Cauy 0ut om 0

e9-05 C6
b r o t ign

05- 04 CYs1
wstwuion
PSw6 AC wALdd BCo addi tion BC0 3ulustraction
caoytsh o m ouu rubbh to p h ubb
om 3to Du atut add a Sub" then hc1
othuweAL0 D
65 AC 1
aC
0o0 00
ut to Dy bit
AC1
PsW 0V owlow m ons that u got maxl but
hei th A13e wai lablu to s alu
v d inrud 0uaion to detect u -
S In un
a y out lom De t D is hwu
hin 0 1
taucg,65 o 1o_di0
tu bah ( 1 olo
49t ut 19
O haut uans thL uslt's wut ut
Thuy uu te is 1 that in diadcs
-e
umU OV
>Psw.0P J* u ut t num w 1 n
otLumulatax ugis tuA
no 1's 0dd than Pr1
1'S evn
no
thiuPs0
s c u c t v u y i st u r

wed to
P w 4 RS4 TusL au ban k
ban
1n
in

PSw:3 RsO baun R


4Jugis
t 32
3 2 yt
yta
Thuu au
a
B051 eoch comausIr

Add
Lg bank
o0H -01H
RS 1 RSO
ug banko 08H-0FH

y baunk 1
1 H
2 1oH
ug beun R 13H -IF H
3
1 ug ban

BE1Oi

#8FH A O o10 1 0 O
A1
e Mo v A,
B ADO A,#8AH o 10O1
C12

D 13
E14 Conditional laga:
F5 se Dt R cay)r
Ov CDE
CY 0
D cu0y ny n
G 16
P1 AC 1(Da se

Bus STRbETURE Of 808

BANk OF 8061:
REGISTER 8cRATH PAD
TFH RAM
30 H
EH
Bit RAM
atsabu R/W
oH

IEH
REG BANK 3
6 H
H REG BANk 2

oF REGISTER BAN
bn CSTACK)
03H
tak OtH
REG BANh 0
RAM ize 128 by tua
RAM add angi 00H te 1FH
28byts divcd in 3 goups
32 by tus O Rg beun k 4 stack
16 by tus ka R/w adiAs CLblu
8o by tus hu R/w 2toragt muma

Resis tu bankswith huiil adduu:

6
R
R6
FR R t IF R+
E
R5
R6 16 R6
IER6
D
RS 15 RS DR5
R4 R4 4 R4 Ry
R3 B R3 13 R3
R2 BRa
RI
A
R2 12 R2
AR2
oRO
9RI
8 RO
R
BANkO BANK
Ro 18 Ro
BANk2 BANK3
Each benk has8 ugis tus
Ban k RAM LotOuion 94D
PSW 4 Psw8
OOH 0tH
08H 0FH
0loH I7H
3 14H FH> 1 1

ws Aumu RAM &puL CUD TACK


STALk IN 8081 sta
wuh
Apa a mmy
Tempaxuy douto thstuck
doLt Rrown C3
adda
In Caun u
Rug wald t
stick þointun CsP)
8 bit Rg00 FF) 01
on
thun sPs 01H4
whun poiu stocks
al
sP1
oLation sO8H
18
in STACki
Vo stuu dout
RAM
STALkCPD to
To8we dautou on
&tack
&fad
POS H deuro tom
deufctom
uUueve STACk to CPU
PoP To

Ldlocotion
holts Tu lost
S P wsualy
0 STACK

PUSH SPs SP+1


Ri to t
PUSH 1 Pushus _dato on

stak

# 25H R 6 ] rå5H
MOV R6, 12H
Mo V R 12H CRCR4J
LPosH)
MOV R3,
*32H [R3] s 32H

PuSH6
PuSH 1
PUSH 3

1H 2H
25H
I5H
SP 503
SPsoh
Pop To al u stack will move in Agollowiny
u &eulied inatuuchion

Nbw in PoP, SP il buu


SP 9P 1

CPo P
OC
54
oB F9
OA 2
F
12 12
o 6
6C L6C 6
SPs0C SP soc SP0B sP OA
0B A

POP 3 Pef Geo Cet ou Hom stouh to Rg3


POP 6
Po P 2
Rq5
A2
I N ERNAL MEMORY ORG ANIEAT ION OF 8051:

8061 heus se patate addas spo Le Hogtam munay


and data memaHY

MEMORY

PROGRAM MEMORY (RO M) C64 kB) DATA MEMORY


CRAM)
INTER NAL EXTERNAL
CoN Chup) INTERNAL XTERNAL
Con chib)
C4k8) C60 k8) C1R8 by te)
Ca chup)
Ce4kE)
PRo AM MEMORY
t is d to sta phoguam ode
ouncuunt momary (RoM)
Raad only mam@y mians
4kB RoM on ohp fhat 60 l RoM is al chup
DATA MEMORY
t ud data usult
i o stolot a
unpa y staags (RAM) ounsappHor
18 bte RAM On chuib thut ma
matu 64kB RAM ohu
F JE 1s eaun thut, intutnou munay s 0A
with 8 ut ald Unu
th16 uf
an exiinal mmay 1s LLAed wi

add u
whon w huwe to we both ertutnal 2 ntun

FFEF
FFFFH
Co kB
xtuna 64 k8
ROM Extuuruu
1006 Ro M
OR

OFFFH| YkB
INTERNAL o00H

805 4 rogham MmayH


, t h wil ws
AND 3

FFH INTERNAL
Diut
ad &in
only G4
AND
extul minUy
h F data

Diudinduud
adduuAsrna
OoH
MOVX wu tob
Bo51 Data meny nl duu mami

In 8051 iotunal RAM in dmded into A0wl


FH apak
Botth pad
30 H
OFH
Bit
Bit
I6 bytus adduAAi
addussing we ca pov
ie addwis
CUy bit huu
IFH.
RLban R 3
32 btus Rg bon R
Rg beun R 2
R4 ban k1
R ban RO

SPECIAL FUNCTION REGIST ER OF 8051:


T(SFR)
rat a RAM Contkols Vauou
in 8051 lbls ths
FFH
12.2 byte
80 H
1FH

Oo H
Accwnuulata Bugistuve
Hon oLm stutu wwn PSW) BP3
P2,
I/opat Jugistu Po, PI,
Dat ou Pointu BTPR 16 ut uj

DPHDPL
Dta pointu
Pata pointu lou by tC

huigh by
&uua data bulleur L4SBU F)
inLEH
THO, TH1,TLO,TL1
Tm ContHo g
TcN, TMOD
douu contol
PCo, ScON
IntwLpt coni0 u
IP IE

intuuu intutukt
engub

SP stouk pintur)
tam countw

16 ut
Accumulata (A) Acc
8 uit vugist
>athumeic 4
Loqi ta okutat on.
Actt Ac 6 Acc 5 Acc ACC 3 AcC-2Ac
Aee A

E4 E3 E2. E) EO
E t EG ES
fListu B is LUL abng ocumuwate in multibliotian
4division onltion

whu ul L it
wing lor muliplication Thon,
B hold muihpliit multiblicond
MUL ABis wwd thun hghut bu te aRadut
will usaved in Rg B

whin u UL using it a division then


Bhold divisa
DIV AB
iswd tLun um unu uu
will u4awed in uugistu B
INPUT JoUT PUT PoRTPo, P1, P2, Pa)
dnpu outputo PO2 Po: 0
8t 86 85 84 83 82 81 2oH

&am wil uu tT al othu þarts


DPTR
16 ut ugis twL
MOV DPTR # 40a1 H

402 1TTIDn
Can w DPTR in 28 ut numbuts
hen DPTR DPH +DPL
MOV DPL # 2IH o 21
MOV DPH # uoH
Fiust e Q1H is lnded in DPL
4H 3 loaded in DPH
Imu Rugistu
Hmu
THO4 TLO wwed Lan
1 6 ut vg3 WL
THO + TLO

8CH 8AH

TH1 4TL1 Timun1

8DH 8BH

SP (Stok pointuu)
atanw
d+ olds Th last wud mamay

>8 ut u i s t
PusH, PoP, cALL RET ho lds
lds
delault is ho
Powtet ON thn by
01H

IN DIAGRAM OF B061 (
EMIRY ADDRESS DFCBDTAHG IN Ae54
NTER FACING WITH EXTER NAL RoM RAM:

6051 Connecton to extuunaul RoM O DRTA:

Ro M iae8 kB
8kBr 8k x B
r 0x ( 8 )

Numwr a _douta unus 3 u


Nun lun a add inLs 13 uud
13 au dUtuct
Connedte to
Numlu a4add Ains a CPU 16 u's

mainng

on
UNI- 5
APDRE8 IN M0DE OF 8064
h CPu can 0cAs data in VoLUOLLS wOys
T u data Caon u om nistur, em meno
m aicute valut
LOLlud
Jh Voubs w s a cAsing dauta Cuu

ad Sing modu

5 ty Rs a addnsing moda
) 4mme diate mode

2.) Rgstu adiuasing ode


3) t adawsing mode
Rgistur indi adiuuns mode
5) dndeud addusig moe
1mmodiate aldwsing madt: The dato ohuand
to u maruuated is given in Yhu initttion

itsel u k
owaund al data will
immediautely atun OPcoDE
ouand Comu

L*to
L # to lu
u wd elau dfo
ata in
L Ca also bad data DTPR
DTPR
This mod in voluuus th u
2) Rugistur addusng mi.
d uis twe tohold dat to u muni ulated

MOVA Ro Copy thu Contont Ro to A

ADD A, R5 at contunt o s Contut oa


to on ut
A and stou u u s Ulk in Ace

MO V OTPR# 1284H
MOV RT,DPL
MOV R6, 0PH
3) d i t addusing mode memaxy al bus hat
contins thu douto to L ouwuted on is l d e d in
Th ins t tion
L huis mo de wUS u RAM 3051muto.contuolle

)RLgistuIndtuct alduns ingmo di n vus aduusing


th i stue thet Con tain Tu muma adiws
fu data is shu ied i n T instuhon
RLgistur must u ko uwed uy

KeGis tuisw as a
pointU adaCL
R o R1 wsd
L
au as bointL
R2-R Cannot bu wed to hol thu ah dunso
douto
A
Ro o4 L MOV A,Ro movc th
RAM Content o RAM locat
R1 01 2A 4 On whew adimns is
30 30 hlt buy Ro.
B 5A
2
5AOO MOv R4, B

5) de ud addHnsing mo de
a bour addws : 8tau in DTPR
an a Aut Atoud in ccumulata

MOVCA A +DPTR
move co de
byte 13 ocahon ke jo
eg A 53H bhi tau he g
DPTR3 1a3H a 34 H
wo ownul afr
53H
Ce& H ] muy hula suyyo
lus
bit nun
2a
roghaum ha aldi tion a
Mema adds dout cu
25H
20H
56H
(3/
aLH

Save
MOV Ro,#2020H) adal 15t ne in Ro (souu
ieshinahon
sum
MOV R1, # 4oH a d * fsave
20H will
movt in aec
Mov A,Ro data a
2nt no. in RozL21H
INC Ro ade
ADD A, Ro 25H +56H 18 H
Mov @ R1, A
HALT: 6TMP HALT 3t

E is wRd to8taud addwn


to 8tau dato kuAnt at that
0is wd
ad dns
IST num lun a5H
2nd 66 H

&ave dat o 4000 H

MOV A, 25H
ApD A #56 H

Mov DPTR, 4ooo H


Mo V8PPTR, A
HALT: STMP HALT
ogHoum a addition 2 8 ut num bruu with
cwtuy
emgy addAS Dat ou 5HI 16
20 H
56H and i6 in
aH B2 H Hexode umal
Sowe 4oH Som 08H
56 H
4HCoUUy 01H B2 H

MOV Ro t 20H
MOV
add*15t no CwOy
Souu
L8um
R1, t 40 H dst ad al usult
MOv Ru, # 00
R ou caXuy u
MOV A, Ro
1st A daua in
INC RO
Sowr u add a 2d no
ADD A, Ro
CAJ s o8
TNC Lo0P 1 Jum no Ceuy
INC RY4
w CUY s RUV: CoUUuy t 1

LooP 1 MovR1, A whun n Couy


then simb ly th
will u ace Staud in
ER INC R1
destadd* o ccuUy CyIHO
MOV R1, RH 3awe CaUy cut 4IH
HALT: STMP HALT

>ASS EMBLER DIRECTIVES;


AssembL ds wAd to tianslate n aasembly angug0
Roghaminto machwin Code

Assemblu Diuo Hive: A


Apeual a 8peucl instxuction
aAsemb progtaum and a atd tode in
sheuicunchions.
* h
diucti aHO nof bat aeLeut ab l
ROgam
ORG 2000H This tulls us u Ou qin
R 1 o h o m a n d s no
MOV A, + 25H

Iyhs aaAsembur diuciu:


ORG0uginat de Linu th stcuting ad duns ja
Tpog in pog memay

END=-uoed to tuuminat u erogtam): Tus is th


Last atate mnt in thu Bouwmu u t tus th
aem blur to to thu asembly Ro Us
Any Thing atu END diu hive ignat
isigna
onsim buh

EQu(Equate): 3 This ws to deina Corn3 t a t


witho ut OCcup ying a momary louhan

N EQU a5H
MON R4 #N a5 will u loqdg d in R1

DB(Deinu Byte) : Mot ui tely wALd dato diuutive


in asembur
J + is Ae to dehinu a
buyt o a 8-bit datu

Decima D Binay B, rtuxa deoma


ASCTI
INSTRUOTLON TYPE OF 8051
)Data tHansu instHuthon
2:) Authe ma tic
3) Logi cal
ins thuction
instution
4)Bran ching ins tuction
5.) Bitmini pulation instnuution
1.) Data ttans Ul
instxuchion AS aduta trans
Daut a Can bu tuns uuud
om to extura RAM
@ within th ntuinal
Ex MOV A Rn memayitse
MOV R 1, #a5
Mov A, R1
PoSH, POP
xCH

2 Au theme tic instx wtion: Add", subinvMnt,


dUwmUnte division
L duto will bu avauiabu inside
Intvinal RAM
ThuCentolw in

Add ADD A, R

SUPB AR

In owrwnt INC ( Ro LRo -23 H LRo


Ro>Ry H

:OEC R 4

Mulii aign MOV Ay +6


MOV B, # F
MUL AB
Dvisio n: DIV AB

8 0

A 2
A B5

3 Loqi tal instt uchicn Boo le cn Logit o dattu

oUat ionns: AND OR, xoR, YLR, RoTAT LON

Ex ANL A t lo H aAsum As A6H

A5 0010 0lo35H
O00 00 00 (0H)
oto

O0oo 000 0 mmodiate


Hutt AvD
Vcul
will u bitwi

4)Bxanching innsttwtion:

uncondi honc 4um ping


LAhsoluwe jum (ATMP ALALL)
Lo Long jum (LJMP6 LCALL)
s h a t Jum STMP)
Cond tiona Jumbing
T2
A 00
L JN2 J un h
L DTNz decmot E junp i n o 3ulo
5) it manibul ahon insttt ion
nctttineludus logita 4 tanchung instrudion

CLR C CY70
SET BC CYs
CPL C CY CY
CPL brt bit bit
ANL C bit AND CY u't with 3heue lut

You might also like