0 ratings0% found this document useful (0 votes) 77 views34 pages8051 Notes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
3051
Alexo eanteoltecr, LL 4
]Fesh C28] | par C256 byte)
Pat
f
Ciseren Ton ,
ramen Pl [rtereres
| +
Poet Oy oS
Myy |
free? tenis) L—| Gurexcuphs
Port |
Taimexs | \ +
foxt 3 <=: i iw ) * ithe
fark _mpdich noe. Spins = (pam!) Centecned)
Ps B(Tx'0 a) | —=
, Timex 0 Then 1 oS SAF
(16 -wi'ts) Css) bs)
THO vyLo TN TU
fokts|| 42-bit poxts oO. ORT 2
Sea Pao — PAT
seg ter Resistors
BY, WoSd2rrta - crystol Aveg wen cy—— From 8251 fami wee ont_uting ATBTS 52. a
Pro 1m te f Ne
on 39-4 Poo CADo)
Prats A. ot pon. Capi -
i a2) Por (pp) i
fh for3_ Caps) 7
rst 8 yu CADe) 7
ELS fo. S Cans)
tf iat) ts 4 wf foe Cope)
4 RST por (AD?
fe oS NT fe
Gres) pay t go} _ALE [PROG 7
| cipro) Pan |, or _| en
Gerdes 1 pepo P27 (ALAS
4 (Te) fag $2 6 Eat (a0)
tn) pas fo fe cap) ;
(ee) e546 | fo4 (tw
Hed) P3-7 faa Aci)
t XTALD e fx 2 Ate)
XTAL 1 res fir (pay =o
Grd “ feo (ad
et— Se
Fela
Peogsammaing \onpage used er
Veit” Soff uderce.
Sow odd the cede to _oux project night click on
tt
Steps of egexedting Keil SoMowve.
fll Open the eoldwore.
DX click on ocoiect —> mew. peoject wizard (vision)
3.|| Pronitle the path: ofthe prdjecl and Save. the project
dbithewt — apace in between!
4. | Sd lect” ah micyd tone Wey Fro th cla dabease provide
firoen ATMEL select _ATEqs52 TC.
5. ; ol He popup. hick _9sK_ to copy sdactup
Ne.
6.|| Now, Prwolect have nce. crated, Mow we nee ck
on editor yoindaw to weite the ¢eche .
7 || Cro do Site elect Mew file Save the Fle
‘nthe Sasne adh of dhe orxa}ect solthout space tn
None _celso _roitth extension Vc", fwv_examel
swengiase,. miaina lst
|| row, you can woxitie the _tacle in the editor
q. lL Once we hae clone uncitlng code now save th
des Yen zt :
ser [thin sttt compile. Shemete. _
; ="
Source _gcoup in _pxolect totndoew. Select ‘acld Mes
jo Source gxoup_|' »
Select dhe Gile _ele pn add _buddan then
Close.Now “au tan bapile he. Pe}
12,
‘eoslag | vould [ve- Youild bus
1s. u_uafl\
Ge peeing ee ly
the Now Heed do create dheriuhen File of ae groo}ect
aol. In she schtalog \onre gee ct
Ciel pn flash tn _nolbec eelect ‘eonfiginadina fash
Oodpust dei
aick on create hee £ile. thon cite bod tay,
Now again build the project amd Abe! hee Mile
wil yo g. Curated:mE zo eect
iS - ee
ATEVSS® | oy Z 7 . —
+ £ * _
£
|! = 6 cowed Souecieg
|
Conxent wscthag at ech to gn Lege_t cro ben
led anc login cho” turin adh Veds
| Cunsvent Javvins eds to gite Logie O cho duxn ork
\ed and __lngie Le ducn oft ject.
| Code to dun of leo! ( sinwing)
o& include <-cegs\-
bit Led = Piri: \ed connect in Sinking
| stoi main ¢>
i
1 Joe); Ned off ynidre tt
white CO aLeal Eliniting Sq i Curvcerd ginting,
AW haeludle 4 v09.5 1th
bit Led = PI*L-
Noid ole bay Cint) 5 walt for same: Hm.
svotd main’ > L a Z
ded = 1, \ tec pdt
while C1) \\_tefinite orp.
f
deol = 0; led on
celoy C1000) Avocet
Sea ved off
dehy C1000): Nt asetdeh
4 g
° a
Nord delag Cint +): \ func} cledinad™
f
int 3 re
fur( tno. Vets jer) N\count jan
Fur(yeo 42 tooo, jee) \ count All leew ine
j - \ ;Blin ving ~ Alaeconte led.
$time luale ¢ veo-Fl-b
sbit ledt = Piro. \\_ tect |
bit Jeol = PIX]: + lech 2
Vord clelos C int) +
raid) edn CD
5
Lec | = \5 \\ led 0 Hf
led 2 = Vy led2 of F
| hile CI) \\_ infinite loop
: Ned t= Oy A tedt_ort
bed2 = 4 \\_tecl2 oft
cletey (rvee), Neva +
Aed t= 15 NA_ Veal] off
ded 2 > 0} \ teal 2 on
olebay Creve); A wot
Jo
3
as
Void delay Cint +)
{
int
Pose 18 i
| 9 : . = ——
foc (j= 0; 4 \eo0; fet )j eei re
WA.P cto opeinte a led to ducn on ache Shao oes
2 \aclude e965 ta
Lehi vel = RIA 2. Z\ \ed ot 9
shit sw = PINts! NX seit act elt
a
vold mal C)
| L
hed = 15. \\ tect odd init lite
hile C1) 7
| # Csw == 0) \\ cheek: statur ot seaitch_
MW leet owSaput ae
TA Icyo Coven | Lee
a
* |i ‘
AR ao _ogecete \edl using Keypad. —
Aeloclude 4veg ols tor oy
ebit vo 2 PI*O » WLS WO. 3s
pit core PIN ch (uy ==0)
abit scr > P12) i
git x3= PI"3; Lect = 0,
gbit_ Co = PIN L
Epa ae Smee y€Ccrs=0)
_llgpit_ co = PI%G; f
ath fae ht veh ete
IN. soon ©) %
t }
\ed = 1) 3
while)x |
|
16 x2 LCD \weelace ehh soc mUlewwceers He
NGS EL CD: [ _
VSS => GAD @Dr > dete Nine
N.C CBS yas t5N, (OD3 > clade Vine a
NEE Brighiness conta (DDa > date line
IRS— t= cha 0 = Commnd O)Os —> oblate line
Rul > Read =| vies 0 (De > data line
Ev\ > H aot pulse to getdida (4)D7—> clads Loe
Do > dade ts @O+ 4 light tect
D> =n @-
lag= C Register Select)
12 dara Vines (to-D7) sill ave Dade to olssple
O= clade Lines (De-TD2) walll Wave Command to Lop
LRwl = Reacl Mwtaite pin re seleck Rend Ley am wise ied
+ led) fee “backtiyle :
led fr back Wight| Keto
| Cormroand s fa fe aye ae -
cate | Disexiphton._ a _ ;
_——+
_ op OF LCD ON Cuxsoy ON — et
_oxol || Crear Leo display — :
ox or. Return Home é
oxo Decrement cursor ( shift “eurgow te 1 4)
Rrote aie ose reer ee ee ene ie a ascnevaet eed a
oxos | suf iselos Right
ono? | shift iG lay Leg
Oxog Dr UN Sav
oxoh | Display oft cuxsor ort
| od
oxo | “Disola: uxsor off
Ono E Dis plas on Cussey on
oxot Display on _carssox blink
Ox10 Shit} Cursor position +e le Fb
1 Sesor
ox14 swift deine chisplay 20 Right
oxig ehidt endixe cli to Led t
ox\e | Shitd _evtive olisploy re_ Right
0x50 | Foxte cursor to shat at I** line \" positon
oxo Foute _cumsov to sing at 9 Wee VY" _pasit lon
Ox 33 Ning: 9 bide oeDi play ‘Hello! on LCh.
ae Include Leegsl hr
sbit +5 Pro;
vy
sbi} «uw = PIAL
bit ens P1%2;
eis te Aedine detel — P2.
| Nlaioh Leo. ernd uuns}ga ed char)»
Nol
wo int);
T
_vold Led "stele Cun
oid ynain C)
{
Led. cmd C ox 38) +
Aral ecrmd (0% 20);
ded uerod Cox oc);
Aceh — dada (*H');
did date (E');
Led dete (OL'Y;
[ud dibe (OL")3
dea oleda (' 0’),
while Oy
[decd stig” mete),
[ded ewd Coxcoy;int i,j
feito; ie dy ist)
foe(jzoj j1 500, ist)
a=}
+
Noid Led data Cun signed ehay A
4
of =d;
ene ly
delay (100,
enzo,
4
i
Noid Neal string ( unsigard chav te)
ywt 10
Foc (ito; Li 12 So!
rt)
t
“ded dads Cp tty);
1HT12D HTIZE upto 100 meter “cange
Appoxts Frequency A534 Hx upto too em Cundes perfect
munication bb, enco, —_
derodey.
dobre ne
HTI2E, WTI2D TC) Jeol troliratoe for veld Avancetcsion:TWmexs iw BOS Mievocerto Hey ¢
A_dhoey Is a spec, ck volich :
ae te measive Alae inhewl A dime shuts cued
— wards Fire us elas Ae
ae o sdopumtdh. Ta § caleulate oe spec iran
eho ox Hime inbecval.
A Couky ig a device Mak stoves cthe nuerbew of
asimes o pesticular erveet} ov proces eccucech, pohth =
sespeck te 4 clock signal. D4 ts usec do count the
exerts happenin e_the otontyre\ econ
counters con he easily Ymeliimented using req} them type
a J
Oecuits such as £\ip> flop:
Dihecence behween a timex ancl _Countere
{
Times . Countess
MI he ~segiahew in “neve istey Ss inescemente
mented fee eve mai Min conghdening 400 x OL
eye. deans} ton, a
ate || PNaximum Court sabe is KE Marimun count ts Y2u od the
o_o) the eseittabng Grepatny| osesMlator frequency i
D Mex uses the inresnal | A county uses on external
cle k Sates amd gicssal signal te count pulses
eee“, ATLAS 52 ( f001 ee
B0S5\_ consist of +wo dimers eat 16-bit
Tisnesd Tine Si i acbit
tMicrocondreller each Heme arcessed with dwo separate
—_____"Seaish Noa byt Ine loyh =
|Timer O ( 1¢- wit Register) =
16-bit svegistex ol amet 1s attested o§ Loam and highs lee
Nmwo~Vesel “segs 1ST TLo fur Hi 2x
's THO. -
—
a Dis [bis DIS [oon Joe] os Joe [57 | D7 | d6 | Dr | d4 | O3 [oe ov Del
KR FAO. A$ —— Fee St
Lead dlata foc dimer O which Is OXEDYB! willbe
| TLo= of#4n, —
| THOS ox €>;
Timer 4 C16 bit Qeatster)
16= bit vegies oh dimer 4 ts cittessed os lower Level &
i Heel ax level _ceatstere “SATU kth.
poypor{ors |or|on |Pte[Da [os] o> [de] oe [vy [os ]o2)o: Joel
[ '
¥ AA = aus =e —St[=] ]
| if ee
I Regisredk Soc _Combiguriong Tne
ime TMoD (tener ede. Select Regster) oe
—_——t —__ ; —
| Bethy Trae O and Spanew 1 use e seeps to.
__ set the voxtous dime opexcdion amecles. 14 is an Sbit
we giste wor TAs one w_timer =
Loma capper on ts once used’ foe Thwew 1+ Sn each rose
(luk ae unto ed the mades Fev Tirnero Ke Tieoexd
lean lor | Mt [ro [ Gey oe [s' [Mo :
7 6 Ss 4 3 zu \ =
Fee 9 Fires 0
Crate —» When Set the timex only runs while tetas
high: ve
[ef — Counter [Timer select ‘hit.
TAL > Mode select vit |
Mo —7 ‘Ande selech bit O a
MA Ho a
0 oO 13- lid dimer : _ _ -
D1] \e- bid dines an
yO | wk Ate Retonct
fT] Spi ties C8 wit)___ ——
“ton ( Timer Cones! Regites) :
Treen 1s an Bdit sogisher Dds bids ore at usecl Yo
a ing _intewcupts Iotecnal ond fox extevral. The
Weck ipowtaat loits al dhe bh TR and TE ave
Jodo Init. TR (timev Rin) and TE (Simey Oxev Flo)
hits eolith coe ure hn almost) oll aver bmey apphiatis
aye jo ite
7 6 5 4 ) °
[rev [om [oro [tro [ae [on [a60 [tro]
TEO ITE) = Tener O | Timev | arew Flow hit
J = Timev Ovex Etna
O- Tmev rot avrerfloew +
TRO TRY F TimexO [timex Rum leit (sheet tina
Va) Tyner Sduvt
O- MNmeys ster
Ato J4t1 ~ Select dhe Tener interrupt Avggee
[= Tntevsugh on foltin 7
On Cmterupt on Low level -
| PEOPLE! = Used Fire dssiggeslnay Exh minions| |
MAP to generate o_deloy od SomSec. DVinw lel.
Catoeledting Coumt fer SomSec.
= t
| $n gos! Ime = 12T so 7
Hy mje = 12
Jojo = 2 ts f= Woo 42 MH,
0.542 x 108
[mje = V0O8s Ut sec.
To execute | instsuchion se need 108s USEC -
\ instecuctiog = ORE Se ¢
as ie 5o_mSec
= “3 3
x = Somgee = _S0* 10 = 4610824 K 10
08S MN See lo as X10 §
HE 46082
rie need 46082 \nsixuchons ox clock Pulses +e
gunesade 50_mSec clelag
Timex ___Shaxts Count fom the _Nectue _11\_mox count.
So it wilt tout uph 65630 Clee bit aimev)
So.
gerar — Ghose = eter (11453), (oxanen de
OF4B eee
OxXED oa
nin
i THo
eesyn?
_ We inelade, Gregor rf
word delay Cvercl 5
ross xc
— Mit Ved “= PINLG al
wath male) ess3s- 42) =(64613>,,
if Crees ye s
| beds 1;
wile C1)
z
| teks on
clebay CD;
J vet Sy,
slelog C3 Mop = oxo}
at Tro = ox6
a THo = oxnfe
Sold ~eaiat) TRO = 15
e art while ( TRQ == 0);
Trop = oxat; TRO = 0;
Tio = oxen; a =
| Tyo ox4p; x = -
Roi = iz + =
il while (Teo == oS; ace
TRO = 0, :
eae Pare oe : .
= 3 aebits ose -beonsaatdiock ore
Sepataial ances sacs the cal leur
al Cowmurisod
feogeal
“tovmunteh dies olocols
pL in _1
Lon posal’
Thee exe alfleeut deer oh ladle tenn fice asvodllable
tol elechonts such 0% serial Corr uoiemdiin
ek Communica
1Erameles of Porvallel eommuni cat an
TSA Atp
SCS3. PCT ond 7 EEE-4 ay
Exam ele
of serial communicate
1 CAn ETHE@NET D2¢, SPE R52 30) USR I-wiie
Lond SATA ete
Dexial | Covamunicablais
ed ol __Cowomunicabiay
at —
Tx
L@—()—G) O| gx0WANT (Uniectal Aganchennas "Receiver & Tramai)
te
“Dote | 1 ° ° \ \ °
1% ] | |
pub
i Z L L
l
lato \ ° 1 o
Received
Ayre can Ste the _transmittecl olatn +
oo \1o and dhe xeceived lota is lolo
whith t wwely ant the some. This heppins because
od sucressive 1" vy O's os a ves lt ot
meocewry po will receive | a singl bit insteack
od _rnuldiple successive tots. ; _
To axestome This _@vvev we can uke o
Cun _Avansmit fe Recerie oleba catth_ahe same speed
which Coun be 1 wit] sec sped. eeReceived
dad
Tin this we hate aah ah
peed to 1 bite
Sethe trunsonittey elit send the lab ills Ibit/
Ord Ake xeceiver soll also -veceive the date sith
Same Speed .
~The ate at ih ake iatuemalts a
ttransfevd oo Communication channel.
. Voit{see
G0 h 8)
ty
Bond sale
Codculadtons
TO meek the
tenndarch laud cates 4 enevally
o €
steel
rol th
M05 42
AHe 15 usedh
The Internal
VART bl
lock at os olivides thts |
machine
cycle.
o
&
ot 29300 Hz which
3a, oh'ch aves She fnetqutny
Sez by uART
Ta acheive o al cote “ak W6on, 28800 frequeny
Iowth Woo abiwiclech toy 3
Ae
This is avheivecl ba wilng Timevl in Mode 2.
Cg- ia
Auto coloach rhode “in dimer) toy putting.
253 in
cH
S gro
aegis rere,
uaiil_Yoe divided by os the timene
ol \\_ovevflon
after.
as eycl
Each
Baud Rote
wil have different value ob
TH) seeqi ster.
o
Vrach
ne Cyl Vaer
lee Foe [Tey =
wy | Te= Fee ees eee
Hr.
6KHe | 2384p
[Baud Rates
THA (Nex Value)
A6oo
FD
4800
FA dd
A400
F4
2.00
Es |_-SBut 2. SCoN _&
|tMop TH, Teom will he itedl to set Baud
| Rote
|
\.) SBue —
|_____‘Th's is a sexial cormunitation lato.
pepsin used to tsconsreit oe receive doo Voseugh
Te is on R-bid register.
+} sCon (Serial Conical Register)
wied 40 Cantyal the owtol
i 2 o
reegistey 18
Il Co a i
Covbyp| transmit cod cecrive operations.
otodtow i
7 é = 4 3 2 ) °
[sno Tat [ons [een [15s [ese [tz [ ma_]
Bits - 716 mo - SM]
tro mM A ecle in cul
| 0 ° bit clade wlth shift equa
oO 1] 3 aid dete saith stax) & stop bid
| °
|| \
Gb lata with shit
\ 1 Sit dada ith what @ au bpb 5 = - Srv2
“Unis loi te uted! ev could prnressow casmeruentead”
Feaduve in Mode 2&3.
Bi4 = REN
Receive enable
\ = enalole R iving oO
O- disable Receiving laa
Bus - TRe Cath wi ae be dvanseni teal)
pie = eae Cary so be Received)
Bik |= Ty = Transroif intexvupt Frag
sets chen complete dlata ' been dranssaitted
BLO = AL - Receivedl imlewupl Clog.
sels when comelete clot Is receivecl tn SBUF.
Crew f predvamming. te dransmit @ charece tew
Cc Ligex Times | im Auto ~ce load
ol Leod TH mith volue 0s per baud rate
[esa dr SCoM isher cotta sevial mode anc contre! bi
ranch times | to Count.
Load “Transmitting data in Rul ~easst,
ytd $P\\ chats ¥5 d-ansenitted completly
Ly [> Joy Le foo po Le
When dhe Tt flag te sod, cleav i4, vepeate from
{step gdp ansmit Same data yoith Some dcloy
fMerite a Pregran so transmit o Charetey
oO
include 4¥eq 5). h
Iroick + uw
vor deley (int) 5
oid wooln €)
i
TMpp = 0x20; int
TH) = oxen: Ene (ito 4 pli is /o's i
SCOM = ax so; i
TRI 2) tvons( pliT)s
while C1) | 1
4 [ust
trans CA'D; {
woes C1 ose);
3
Void beans (unsigned chase a)
{
SRuf 2 by
while (Tr ==0);
TLz0;
3
Vota olelny Cint +)
& ¢
int 1 fy
fuc( ito, j2tj P+)
furl {eos jezody jad
3\lnrbe _o. po geam ore Cein
0
rae Inc lucle ¢ wregs \\ Wy
unsigned Chay seceive C void),
sbit- Jeol. PI*1:
ord smainC >
un sign ol choy Ws
T MoD = 0x20;
TH! = OxKFD;
SCon = OxFO)
STiRAwe Sey
while Cr)
We receive CV;
yf (Cw es
t
\ed= 0}
%
ie Caw e= *2")
t
Jed = VG
%
5
4 a
unsignect chav receive Cveict) —
3
vo igned char dj 1 as; —
while CR 22 0); Jt ew ee
d= squey oe a
RTs 0; "= nf
weturn dy / ani
3
Vffata)
=
TNTEQRRUPT
An Torecuo) 1s an event AYeel | oce ures ceandomly Ini
flow of contin ly. Dt is jugt- lake a! Call & boy
udhen you axe busy tn same isavKcind de oe ding og
cal) pritwity you decide whether #0 attend ox
Same thing happens coith Milero contveolleys. BOS) rae
handel © Sitewrupts sourtes out of “ehy
Internal CTimex Inbecup own 2 aw Ex ternal
C Hoxaluonve) intexruct® and one Secial tntercupt.
Dniercrrupts ov Classi Fied ex (9 paxts.
Bn pt
Horeca oarce (Cxd_e reve!) Source (A hea
eS ae eet a
Neck,
ak ten-Vectored _ Verdavedt Hon
Nester _Adderess of inbexyupts tm 205).
Thi's adldvess is where th Gombrolley umos afky
The Intewruph to serve ISR ( Crhecruph Seevire Kes!
Lotercupt Flag Sptexvup> vechr adh
Reset f 5 Oooo -
aro CExd™. jnd.O I£o 0 0034 __
Timer 0 EEO dboRN
| Tut) Ce int DY) ey Pri
Tim ev | TRY Soon .
Serctol T3| Rie ene ae{E= Tnbeup) Enable Cee. yh
Tit LowetPrlovity—7 Pero
6 oc TL 3 2 t ov
jos pean} fi | es “Vet, [ext | eto | Eo],
bit 2 EA — Enable A\\
[bit 4 £5 — Enable Serial Tntersupt
L= Enable O- dsoble.
bit = ET) - Enable timer 1 Toterrupt
l= Enable O- Usable
cillbita - Ext - Extev EAT}
= Enable O- Disable
bit \- ETO - Enable _Timey 0 Tobewiel
L= Enable © = Dsshle.
bit O- EXO - Erable Evdemnal Tatevrupt (onto)
lo Enable 0- ob/soblIte (tute xe Bu Peincity vapisiec
| a ¢ Se 4 3 2 a
= = — ]Ps [rr] Px [Po Troy
oits ZS - Reserved
bit 47) 9s - Prioxity bit of Sevial Cownmums' cad fan
| Ie Assi High Peclox! by O= Assign Lous feiss
bik 27f PT) — Priosisy it al Ter 1 interrupt
yi -A tg High, Fectoss by O- Assisn LOw Prigt
[bit or] Px = Petectis pi ob Exdemal Trtlewupt (twits)
i. A igo Hish, Prrlostty O- Assig Low frig i
bit 1 3 | PTOr. Podestty lob! ob Tichecd Leee-ce up
LeAssign High Printidy O- Assign Low prissi¥
bik 0 | Pun - felocity bit of Erteraal Tetemupt (Into)
W=.Ai ge High psiecity O- As iy 1 aw.| S05) thas 9 Eyheynal ne" intrvrnphs fro g ri
2.|| 8051 _Contwaller can tae intexvupted by _erternal
| \ntercupt , You roving pulse uaith Level Clow teve).
Hove eas C eats y-2dge). eae
3. Once the _mievucorivallee fs heen tneiggerced | UF ol ll
pause the _angaing peng ca 3 allt jump te
S82 ( tateruph Seesice Routine)
TTCOM Ctimey Comsat) Regtstere ;
71 6 5 4 Ss Lz 4 D
TF | Te | tro [tro | ae! [ati [reo [ito \
| K== Trteccupt twiggee —>
bia ti TE1 - External Pntevewp) | edge flag Set when —
TNTI drciggexed bos Ag nd Clearecl with Tse
JT Havd ease Srlewapt “using — tol
ott || DT) = Tntercup) dxiqeving fox I rtT
|= tye Falling edge Q= Lore bevel
= Erdese excugt © 5 et whe
INTO Aciggevedd Db AalWing edge be Cleaved\ wo
lo
Es
>
bit 0+ TT O = Totewupt twiggestne, Foy INTO
Ealing edge O- Low Level
-EsAling eh ¢ -_ -
Low \evel.i
“Ae Hegedesace | Evtecnal Intevenpt:
IL
t
= AE include dveq5Vhy
bit tel = PIAO-
oid Toto. 7¢@ (void) intrcupt 0
i ded = — pod:
| 3
iL void _iait. anito (void)
= i
7 EA=)-
aa Exo ;
SPo = 1
BR
+ |
4 Void main «)
t 2
+ ih auto 0);
4 while Os
4 4