0% found this document useful (0 votes)
65 views48 pages

Practical No:1 Introduction of Epb (Educational Practise Board)

This document provides instructions for using the IDE-51 C compiler to create and debug embedded system programs. It describes how to: 1) Install the IDE-51 software and select the debugger or IDE program. 2) Create a new project by selecting File > New File, typing a sample "Hello World" C program, saving and adding it to a new project. 3) Configure compiler options like selecting the target MCU, memory model and generating debug files for use with the simulator. 4) Compile and debug the program using the simulator, which displays program variables and I/O. Single stepping allows running the program line-by-line.

Uploaded by

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

Practical No:1 Introduction of Epb (Educational Practise Board)

This document provides instructions for using the IDE-51 C compiler to create and debug embedded system programs. It describes how to: 1) Install the IDE-51 software and select the debugger or IDE program. 2) Create a new project by selecting File > New File, typing a sample "Hello World" C program, saving and adding it to a new project. 3) Configure compiler options like selecting the target MCU, memory model and generating debug files for use with the simulator. 4) Compile and debug the program using the simulator, which displays program variables and I/O. Single stepping allows running the program line-by-line.

Uploaded by

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

Parul Institute of Engineering & Technology Electronics & Communication

Practical No:1
INTRODUCTION OF EPB(EDUCATIONAL PRACTISE BOARD):
Embedded System 1
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 2
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 3
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 4
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 5
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System !
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System "
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System #
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 1$
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 11
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 12
Parul Institute of Engineering & Technology Electronics & Communication
Practical No:2
INTRODUCTION OF IDE-51 COMPILER:
%nce the soft&are is installed' clic( on Start)Programs and you should see a ne& menu
o*tion +SP, Systems- I.E51/C01 &hen you select it' you should further see t&o sub/
o*tions2 +.ebugger0 and +I.E03 If you clic( on +.ebugger0' it &ill start the Simulator
*rogram3 If you clic( on +I.E0' it &ill start the I.E *rogram3 To create your first *ro4ect'
clic( on the +I.E03
%nce the I.E *rogram starts' it &ill usually ha5e automatically o*ened one of the
e6am*le *rograms3 To create your first *ro4ect' com*ile it and debug it' follo& these
sim*le ste*s3
17 Select Pro4ect)Close from the menu3 This &ill close the currently o*en *ro4ect of
the e6am*le *rogram3
27 Select 8ile)9e& 8ile from the menu3 This &ill create a blan( *rogram &indo&' in
&hich you can ty*e the *rogram3 :ou may ty*e the follo&ing2
;include <sfr313h=
;include <stdio3h=
;include <standard3h=
5oid main >7 ?
init@ser>7 1
&hile>17 ?
*rintf>+Aello &orldBCn07 1
D
D
37 Efter ty*ing the *rogram' select 8ile)Sa5e Es to sa5e the ne& *rogram file and
gi5e it a suitable name e3g3 first3c
47 Select 8ile)9e& Pro4ect from the menu3 Ty*e a name for your ne& *ro4ect e3g3
first3*r4 in the 8ilename bo6 and then clic( on the %*en button3
57 9o& you should see the Pro4ect Settings &indo& as sho&n in figure 13 9ear the
to* of this &indo&' you see the title +8iles in Pro4ect0 and 4ust belo& it' you &ill
see a &indo& &hich lists the files &hich are *art of this *ro4ect3 In this &indo&'
the I.E automatically inserts a file &ith the same name as your *ro4ect' but &ith
e6tension 3C3 So you &ill see the name +first3c0 already listed in this &indo&3
E5ery *ro4ect must ha5e one C file in it3 E *ro4ect can also o*tionally ha5e one
ESF *atch file and one GIH file3 If you need to add a file' you can clic( on the
+Edd a 8ile0 button3 Similarly' to remo5e a filename from the list' you may select
the filename and then clic( on +Iemo5e 8ile0 button3 8or our first *ro4ect' 4ust
one C file is enough3
7 8urther' there are se5eral other o*tions that you can set as *er your needs3
!7 This com*iler su**orts almost all micro/controllers from the "$51 family3 To set
some of the com*iler o*tions correctly' you may select a manufacturer from the
list and then you may select the desired chi* number from the list of micro/
controllers3 If you are not able to find the manufacturer ) micro/controller name in
the lists' still it is 5ery li(ely that the com*iler su**orts the chi* that you &ant to
Embedded System 13
Parul Institute of Engineering & Technology Electronics & Communication
use3 In this case' select +%ther0 for manufacturer as &ell as for the micro/
controller3 8or our e6am*le' you may select Intel)"$313
"7 Jhen you select the desired manufacturer)micro/controller' the com*iler
automatically +(no&s0 &hether the selected chi* has 12" bytes internal IEF or
25 bytes3 Ao&e5er' if you ha5e selected +%ther0 as manufacturer and C' then
you may need to manually s*ecify &hether your C has 12" bytes or 25 bytes
Internal IEF3
#7 This C Com*iler su**orts t&o memory models K Garge >select this if e6ternal data
memory is a5ailable7 and Small >select this if e6ternal data memory is not
a5ailable73 8or our e6am*le' *lease select small memory model3
1$7 In case you selected Garge memory mode' you need to tell the com*iler ho&
much e6ternal data IEF is a5ailable >s*ecify e6ternal IEF start and end
addresses7 so the com*iler &ill *lace all your 5ariables &ithin this s*ace3
117 Code %ffset is the address from &here code &ill be generated3 Hy default' it is $
as "$51 reset 5ector is $3 Ao&e5er' if reLuired' you can ty*e a non/Mero code
offset3 8or e6am*le' if you &ant to do&nload the code into the IEF address
$62$$$ of target >li(e in our Fa6i51 e5aluation board7' you may need to enter
2$$$ as code offset3
127 The standard "$51 has 5 interru*t sources and their corres*onding 5ectors are at
addresses $6$$$3' $6$$$b' $6$$13' $6$$1b and $6$$233 So the com*iler must
lea5e these locations unused3 Hy default' the com*iler lea5es first $6$$5$
locations in *rogram memory for interru*t 5ectors3 Ao&e5er' some "$51
deri5ati5es *ro5ide many more interru*t sources' so their 5ector locations can be
beyond $6$$5$3 In such case' you can change the 5alue from $6$$5$ to &hate5er
you desire3
137 If you &ant to use the simulator' you must chec( the o*tion +Nenerate debug
info0 so the com*iler generates the files needed by the simulator' so it can
facilitate source le5el debugging3
147 Hy default' the com*iler generates only HI9ary file K that is I%F image file3 If
you &ant Intel AEO format file' chec( the o*tion +Nenerate AEO file03
157 Chec( +Nenerate GST file0 o*tion to generate the listing file3
17 The com*iler can insert C source lines >as comments7 in the generated ESF code'
if you chec( the corres*onding o*tion3
1!7 Chec( +Nenerate %F8 file0 o*tion if you need the %F8 file for debugging &ith
an In Circuit Emulator3
1"7 If you are using the PSH chi*s from Cy*ress)Enchor' the com*iler needs to
generate code little differently3 So &hen you select Cy*ress or Enchor as
manufacturer' the o*tion +Psing EQPSH chi*sR0 is automatically chec(ed3
Similarly' if any other manufacturer is selected' then this o*tion is automatically
9%T chec(ed3 Ao&e5er' if you select +%ther0 as manufacturer' then you must
manually either chec( or not chec( this o*tion3 Jhen you chec( this o*tion' the
com*iler assumes that the ne& S8I +FPENE0 at address $6#2 must be used to
hold the high byte of address &hile using the +mo56 SIi0 instructions3
1#7 Jhen you ha5e set all the o*tions correctly' clic( %(3
Embedded System 14
Parul Institute of Engineering & Technology Electronics & Communication
8igure 1
2$7 Select Com*ile)Com*ile from the menu3 This &ill in5o(e the com*iler &ith
a**ro*riate o*tions3 The com*iling *rocess may ta(e a &hile3 Efter that' the
com*ilerTs out*ut &ill be dis*layed in UCom*iler %ut*ut Jindo&-3 Hro&se
through it' to ma(e sure that there are no errors in your *rograms3 >In case you
detect any error in your *rogram' 4ust double clic( on the error message in the
UCom*iler %ut*ut Jindo&-3 This &ill automatically mo5e the cursor into the
Program file onto the line containing error3 Correct the error and com*ile again37
217 Select Iun).ebugger from the menu3 This &ill start the Simulator >JSIF5173
227 The JSIF51/C &ill dis*lay four &indo&s2 Program Jindo&' C Variable Jatch
Jindo&' S8I Jatch Jindo&' Serial Jindo&3 The *rogram &indo& contains
your *rogram3 %*tionally you can o*en)close other &indo&s i3e3' E6ternal IEF
Jatch &indo&' Internal IEF Jatch &indo&' I% Jatch Jindo&3
237 Select Configuration ) Vie&)Change Configuration ) Femory Fodel ) Small from
the menu3 Je need to do this' because' &e had selected the small memory model
&hile com*iling our *rogram3
247 To single ste* through your *rogram' Select Iun)Single/Ste* from the menu or
*ress 8!3 Jhen you do so' a band a**ears on the first statement in the main>7
function3 In our e6am*le' it is the +init@ser>70 function call3 It means' &hen you
Embedded System 15
Parul Institute of Engineering & Technology Electronics & Communication
*ress 8! again' this statement &ill be e6ecuted >actually simulated73 Press 8!
again and the band mo5es to the ne6t statement i3e3 the *rintf statement inside the
&hile>17 loo*3 The init@ser function initialiMes the serial *ort for 24$$ or 4"$$
baudrate >assuming 12 FAM crystal73 If you loo( inside the serial &indo&' you
can see the effect of the init@ser function call2 you &ill see the baudrate as 24$$ or
4"$$ and you &ill also see that serial in*ut is no& enabled3
257 Press 8! again3 9o& the *rintf statement &ill be e6ecuted3 The *rintf function
sends formatted out*ut to the standard out*ut de5ice3 The default standard out*ut
de5ice is the on/chi* serial *ort' so effecti5ely' this statement out*uts all
characters in the string +Aello &orldBCn0 to the on/chi* serial *ort3 Es an effect'
you can see the same string inside the serial out*ut &indo&3
27 Since the *rintf statement is inside an infinite loo*' it &ill (ee* e6ecuting again
and again' as long as you (ee* *ressing 8!3 To sto* the debugging' you may select
Iun)Terminate *rogram from the menu3
Starting the debuger:
To run the debugger' select Program)SP, Systems- I.E 51/C).ebugger from start menu3
The debugger &ill start and the screen should something li(e figure 23
:ou &ill see 5arious &indo&s as described belo& /
Prora! "i#$o%2 .is*lays the currently o*en file >if any73
C &aria'l( "atc) "i#$o%2 .is*lays the contents of the selected C 5ariables3>This
is &indo& &ill not be acti5ated in case of JSIF517
SFR "atc) "i#$o%2 .is*lays the contents of "$51 internal registers3
S(rial "i#$o%2 The Serial Jindo& dis*lays the out*ut of "$51-s on/chi* serial *ort3
The same can also be used to simulate in*ut to the on/chi* serial *ort3
IO "atc) "i#$o%2 Similarly the I)% Jatch Jindo& can dis*lay the status )
acti5ities of 5arious *eri*herals >if any are connected373
8igure 2
Embedded System 1
Parul Institute of Engineering & Technology Electronics & Communication
E*t(r#al RAM "atc) %i#$o%2 This dis*lays the contents of selected locations of
the e6ternal IEF3
I#t(r#al RAM "atc) %i#$o%2 This dis*lays the contents of selected locations of
the internal IEF3
Running the example:
In order to run >i3e3 simulate7 a *rogram' t&o things are necessary3 The first is that you
must o*en the *rogram file3 The second is you must set the configuration to match &ith
the target hard&are3 To do this' select Configuration ) Vie&)Change Configuration from
the menu3 Change the configuration as *er your reLuirement3 Set the addresses of the
*eri*herals and a**ro*riate internal IEF siMe >12")25 bytes73 Jhen you are done'
select Sa5e Configuration from Configuration menu3 The configuration information is
sa5ed in a file &ith e6tension 3cfg and name same as the o*en *rogram file3 Jhen you do
this' you ha5e done *recisely the same t&o things necessary to run a *rogram' so you are
ready to run >simulate7 the *rogram3
The first step:
9o& select Iun) Single ste* from the menu3 That &ill actually start the o*ened *rogram3
Elternately' you can *ress the 8! (ey3 :ou &ill see a greater than sign >=7 on a *articular
line of the *rogram3 Ectually' this is the first statement to be e6ecuted3 Jhen you *ress
8! again' this U=- statement &ill be e6ecuted3 It-s effect &ill be reflected in the 5arious
Jatch Jindo&s3 This is ho& you +i#l( +t(, through a *rogram3 If you are not interested
in *ausing after each statement' you may *ress Ctrl W 8!3 This &ill *ut you in co#ti#-o-+
(*(c-tio# mode3 9o& your *rogram is being run and you can see the results in Serial
Port ) Iegisters ) Femory Jatch ) I)% Jatch Jindo&s3
Simulating input:
The simulator simulates number of *eri*heral de5ices' and it allo&s you to simulate in*ut
to these *eri*herals3 8or e6am*le' "2!# is su**orted by this simulator3 The "2!# is used
for (eyboard and dis*lay interface3
To simulate (eyboard entry' "2!# must be added to configuration3 To do this select
Configuration)Vie& Change Configurations and add "2!# *eri*heral &ith a**ro*riate
address3 9o& right clic( in I)% Jatch Jindo&' select Edit from *o*/u* menu' select
"2!# from a dialog bo63 :ou &ill be *rom*ted to enter the scan/code e6*ected from
"2!#3 .o ty*e in a 5alue in the edit bo6 and *ress %X
Stop it !:
8inally &hen you are done' 4ust *ress Iun)Terminate3 This &ill bring you bac( to sto*
mode3 9o& you may o*en another *rogram' or change the configuration and so on3 If
you &ant to restart the ne& ) same *rogram' *lease remember to IESET first3 To do this
select Iun o*tion and then CPP Ieset or *ress Ieset button from the tool bar3 This &ill
simulate the action of a hard&are reset signal to the "$51 CPP3
Embedded System 1!
Parul Institute of Engineering & Technology Electronics & Communication
Thus you ha5e learnt a fe& things in this e6am*le3 9o& you can try your o&n *rograms3
If things are not clear' continue reading the ne6t cha*ters3 %ther&ise you may (ee* this
manual on your table' and refer to it as and &hen reLuired3
Configuring the target system
In order to simulate your "$51 based hard&are' the com*uter must (no& %)at i+ .o-r
)ar$%ar( li/(3 Jhen &e say +configuration0 &e mean +telling0 the com*uter about your
hard&are3 Jhen you select Co#0i-ratio# form main menu' you &ill see 4 sub/o*tions 2
+Goad0' +Sa5e0' +Vie&)Change0 and +Tab SiMe03 These are e6*lained in detail in this
cha*ter3
Load Configuration:
Ello&s the user to load a configuration file / a file in &hich all configuration *arameters
are stored3 If you ha5e already created a configuration file for your o&n hard&are' you
may load the file to set all configurable *arameters as *er your reLuirement3
Save Configuration:
Ello&s the user to sa5e the configuration information in a file3 %nce you ha5e set all the
configuration *arameters as *er your hard&are' you may choose this menu o*tion3 The
configuration information is sa5ed in a file &ith e6tension 3cfg and name same as the
o*en *rogram file3
View / Change Configuration:
Jhen you select this o*tion' you &ill further see a list of o*tions3 Aere &e &ill see all
of them one by one3
1223 Co#0i-ratio#:
This Soft&are simulates "2!# &hich is Programmable Xeyboard ) .is*lay Interface3 If
you are using "2!# in your target hard&are' select "2!# o*tion to configure it3 8irst' you
&ill ha5e to chec( connect chec(/bo6 and s*ecify the address of "2!#3 Ty*e the address
of "2!# data register in 4 digit AEO format3 Please note that' the address of "2!#
command register is assumed to be this address *lus one3 e3g3 su**ose you enter "2!#
address as $$$' then $$$ >AEO7 is treated as the "2!# data register address and $$1
>AEO7 is treated as the "2!# command register address3
Then' you may s*ecify the IIY connection for "2!#3 i3e3 in your hard&are' you might
connect the IIY out*ut of "2!# to "$51-s I9T$' or to I9T1 or you may not use the IIY
Embedded System 1"
Parul Institute of Engineering & Technology Electronics & Communication
out*ut at all3 :ou can s*ecify any one of these choices here3 Su**ose' you ha5e connected
"2!#-s IIY out*ut to "$51-s I9T1 interru*t in*ut3 Then s*ecify the same here3 So that'
&hen you simulate a (ey entry' I9T1 &ill be automatically generated3 >Pro5ided it is
enabled by your *rogram7
Psually "2!# is used for handling (eyboard and ! segment dis*lay3 8or such dis*lays' the
! segment code to character relation may be different de*ending on ho& you connect all
of the ! segments3 That means' there is no uni5ersal ! segment code for a character
>unli(e ESCII73 To define your ! segment codes &rite do&n the se5en segment code >in
code edit &indo&7' corres*onding character >in char edit &indo&7 and *ress add3 Ie*ear
the *rocedure for all the se5en segment code that your *rogram needs3 The ad5antage of
the facility is that' &hen you run your *rogram' you may *ut "2!# in I)% &atch' &hich
&ill sho& you the characters corres*onding to the code contained in "2!#-s dis*lay
IEF3
1155 Co#0i-ratio#:
"155 is an I)% Port3 To configure the "155' you ha5e to select the "155 menu o*tion3 If
you are using "155' chec( the connect chec(/bo6 and enter the correct base address3 i3e3
you should ty*e the address of "155 command register3 e3g3 if you enter it as "$$$ >AEO7'
then the simulator ) debugger &ill assume follo&ing addresses for "155 2
"$$$ /= "155 Command register
"$$1 /= Port E
"$$2 /= Port H
"$$3 /= Port C
"$$4 /= Timer Go& byte
"$$5 /= Timer Aigh byte
1255 Co#0i-ratio#:
If you ha5e as many as fi5e "255 chi*s connected to "$51 in your target hard&are' you
can configure it accordingly and simulate your *rogram3 To do this' chec( the connect
chec(/bo6 and enter the correct base address for the chi*3 e3g3 su**ose you enter the
address of "255 as "$$$' then the simulator &ill assume follo&ing address 2
"$$$ /= Port E
"$$1 /= Port H
"$$2 /= Port C
"$$3 /= Control register
1254 Co#0i-ratio#:
"253 is Programmable Inter5al Timer3 Similar to "255' you may enter the base address
for "253' if you &ant3
1251 Co#0i-ratio#:
"251 is Pni5ersal Synchronous)Esynchronous Iecei5er Transmitter3 Similar to "255' you
may enter the base address for "253' if you &ant3
LCD Co#0i-ratio#:
To connect GC. module to "$51 in your target hard&are' select this o*tion and chec( the
connect chec(/bo63
Embedded System 1#
Parul Institute of Engineering & Technology Electronics & Communication
Eddress 2 This is the base address of GC. as usual3 e3g3 if you enter the address as 4$$$'
then the simulator assumes follo&ing address 2
4$$$ /= GC. command register
4$$1 /= GC. data register
Ectual chars ) line 2 This is the logical number of characters *er line for the GC.3 e3g3 in
case of a 1 char O 1 line GC. module' this should be entered as "3 Hecause' e5en
though *hysically it is a single line dis*lay' it has 2 logical lines / each " characters &ide3
.is*lay chars ) line 2 This is the *hysical number of characters *er line3 e3g3 in case of a
1 char O 1 line dis*lay' this should be entered as 13
Ti!(r Co#0i-ratio#:
The timer &ill be selected only if one of the *eri*heral &ith a timer >i3e3 either "155 or
"2537 is included in the configuration' by gi5ing its address3 If any timer is used and this
item is selected' you &ill see a sub/menu from &hich you &ill select either "155 or one of
the "2533 e3g3 su**ose' you selected "155' then further you ha5e 2 o*tions 2
Prescaler 2 The simulator assumes that all these timers are getting cloc( in*ut at the same
freLuency as that of "$513 Hut' in reality' it may not be so3 e3g3 the cloc( freLuency in*ut
to "155 timer may be half that of "$51 crystal freLuency3 To simulate this e6actly' you
may enter the 5alue of *re/scaler as 23 In fact' you can change the *rescaler 5alue from 1
to ffff >Ae673 The default 5alue for *re/scaler is 13
%ut*ut connected to 2 The out*ut of this timer may or may not be connected to one of the
interru*ts of "$51 >i3e3 I9T$ or I9T17 in your target hard&are3 E6actly the same
connection can be s*ecified here3
M(!or. Ma,:
Jhen you select this item' you &ill see 3 o*tions 2
Program memory 2 Select this o*tion to s*ecify the amount of *rogram memory a5ailable
in the target hard&are3 :ou can s*ecify u* to 4 different ban(s of *rogram memory by
entering the starting and ending address3
.ata memory 2 Select this o*tion to s*ecify the amount of data memory a5ailable in the
target hard&are3 :ou can s*ecify u* to 4 different ban(s of data memory by entering the
starting and ending address3
%5erla* memory 2 Select this o*tion to s*ecify the amount of o5erla**ed memory
a5ailable in the target hard&are3 :ou can s*ecify u* to 4 different ban(s of o5erla**ed
memory by entering the starting and ending address3 %5erla**ed memory is that area of
e6ternal memory' &hich can be used as read)&rite memory >using mo56 instruction7 and
also as *rogram memory >using mo5c ) l4m* ) lcall instructions etc7
I#t(r#al RAM :
:ou can select either 12" bytes or 25 bytes Internal IEF3
M(!or. !o$(l :
Please note that' memory model s*ecified &hile com*iling and the memory model
s*ecified here must be same3 %ther&ise' the debugger may not be able to sho& the 5alues
of 5ariables correctly3
Please note that this o*tion is a5ailable' only if you ha5e *urchased the C cross com*iler
also3 %ther&ise this o*tion remains disabled3
Embedded System 2$
Parul Institute of Engineering & Technology Electronics & Communication
Running !rogram
Efter the com*ilation *rocess' user can e6ecute the *rogram and can see the out*ut of
that *rogram3 It is also *ossible to debug through the *rogram and set brea(*oints at
many *laces in the *rogram3 The R-# menu has fi5e o*tions &hich contains the facility
of adding brea(*oints' debugging' e6ecution of *rogram and CPP reset3
dding "rea#points:
E sim*lest &ay to add or remo5e a brea(*oint is to double clic( on a line &here you &ant
to add brea(*oint3 %ne can also select the Br(a/,oi#t sub/o*tion from R-# menu3 Efter
doing this' you &ill see a U5BR6 U brea(*oint characters on the line in the *rogram
&indo&3 Thus you can bro&se through the entire *rogram3 8or setting brea(/*oint at any
statement' mo5e the cursor to that line3 Then *ress F12 or $o-'l( clic/ on that line3 :ou
&ill see UZHI[- on the left hand side3 This indicates that you ha5e set a brea(/*oint at that
line3 To remo5e a brea(/*oint' you may use the same *rocedure 2 i3e3 *ressing F12 or
double clic( actually toggles the brea(/*oint state3
Single Stepping :
Single ste**ing is another mode of e6ecuting your *rogram3 Through single ste**ing'
each instruction is e6ecuted one by one3 The contents of system registers are continuously
dis*layed in Iegister &indo&3 Simultaneously user can see the memory and I)% &atch3
To single ste* through a *rogram' select the sub/o*tion Si#l( St(,3 Elternately' you may
4ust *ress F2 (ey for single ste**ing through the *rogram3 E colored band &ill be
dis*layed on the 5ery first e6ecutable instruction of your *rogram3 The ne6t time you
*ress F2' the statement dis*layed &ith a colored band gets e6ecuted and the band mo5es
ahead >or sometimes e5en bac(7 to the ne6t statement3
Continuous Run :
Jhen this o*tion is selected' the *rogram is run continuously3 %ff/course' you may sto*
the *rogram e6ecution any time by selecting Iun)Terminate Program3 %ther&ise' the
*rogram e6ecution continues till a brea(/*oint is encountered3 Jhen that ha**ens' the
*rogram e6ecution sto*s automatically and you are bac( to single ste* mode3 Jhile the
*rogram is being run' 5arious &atch &indo&s are u*dated at the end of each statement3
C!$ Reset :
This o*tion acts li(e a reset signal to "$513 It sets all the system registers of "$51 to the
5alue &hich is actually set after resetting "$513 Elso all the *eri*herals are set to their
reset condition3
Embedded System 21
Parul Institute of Engineering & Technology Electronics & Communication
%ther &enu options while running a program :
Jhile your *rogram is being run >either in continuous mode or in single ste* mode7' you
may need to add some &atch 5ariables' edit some memory locations' edit some 5ariables3
Aere is the descri*tion of all these to do these2
A$$i# M(!or. "atc) :
Clic( on the 789 button from tool to get the E6ternal Femory Jatch Jindo&3 8or the
Internal Femory Jatch Jindo& clic( on 7IM9 button of tool bar3 Elternati5ely' you can
select Vie&)E6ternal memory &atch or Vie&)Internal memory &atch from the menu3
Jhen you do this' screen loo(s li(e figure 33 To add a &atch in e6ternal ) internal
memory &atch &indo&' right clic( inside the &indo&3 E menu &ill *o*/u*3 Select Edd
from the menu3 :ou &ill be *rom*ted to enter the memory address >Ae67' ty*e it and
*ress enter or clic( %(3 The same address &ill a**ear in the memory &atch &indo&'
follo&ed by 1 5alues in AEO follo&ed by their ESCII eLui5alent characters3 These are
the contents of 1 consecuti5e locations starting from the address you entered3
A$$i# SFR "atc) "i#$o% :
If you &ant to see the contents of a S*ecial 8unction Iegister >S8I7' select this o*tion
from 7&i(%9 menu or 4ust clic( 7R9 button of tool bar3 Jhen you do this' S8I Jatch
Jindo& &ill a**ear3 To modify the contents of a S8I' double clic( on the desired S8I3
The name of the S8I &ill no& a**ear in a ne& edit &indo&3 It &ill dis*lay the current
contents in AEO' follo&ed by the binary re*resentation3 :ou can change the contents and
clic( %( to sa5e the ne& 5alue3
A$$i# C :aria'l(+ :
If you &ant to see the 5alue of a 5ariable declared in your *rogram' select this o*tion
from UVie&- menu or clic( 7C9 button of tool bar3 Then you &ill get the UC Variable
Jatch Jindo&-3 To add the C 5ariable' 4ust do the right mouse clic( on the dis*layed
message3 Then select declared UC- 5ariable from the dro* do&n list of all C 5ariables' and
cloc( UEdd-3 Please note' that the list contains the 5ariables that are global 5ariables and
5ariables that are c-rr(#tl. i# acti:( +co,(3 e3g3 if you are in the middle of a function'
then 5ariable list contains global 5ariables and local 5ariables declared in the c-rr(#t
0-#ctio# or it may be a *arameter to the c-rr(#t 0-#ctio#3 Ao&e5er' if you selected a
local 5ariable' it-s 5alue &ill be dis*layed' only so long as your *rogram is inside the
function3 The moment you return from the function' the debugger &ill be unable to
dis*lay it-s 5alue3 The debugger &ill flash the message +%ut of sco*e0 in front of the
5ariable name in the &atch &indo&3
Embedded System 22
Parul Institute of Engineering & Technology Electronics & Communication
8igure 3
The 5ariable name &ill a**ear in the &atch &indo&' follo&ed by it-s 5alue3 Please note'
that the debugger (no&s the ty*e of the 5ariable' so it &ill dis*lay it-s 5alue a**ro*riately
de*ending on it-s ty*e3 e3g3 int and long int 5ariables are dis*layed as decimal 5alues
follo&ed by it-s AEO eLui5alent in a *air of *arenthesis3 char 5ariables are dis*layed as
ESCII character3 Errays of char are dis*layed as a character string enclosed in double
Luotes3
Please note that you can add C Variable Jatch Jindo& only if you ha5e loaded a 3C file
to debugger3 If you ha5e loaded a binary >3bin7 or Ae6 >3he67 file' you can not add C
Variable Jatch Jindo& and hence can not obser5e 5alues of C 5ariables for an ob5ious
reason that these files do not contain 5ariable information3
Ao&e5er if you ha5e *urchased JSIF51' i3e3 Jindo&s based Simulator' you can not
load C file at all3 Aence C Variable Jatch Jindo& is disabled3
A$$i# I;O "atc) :
Select I)% Jatch sub/o*tion from UVie&- menu3 Egain' do the right clic( to add' delete or
edit an I)% &atch3
Jhen you clic( to add a &atch' a list of connected *eri*herals a**ears on the screen3 i3e3
a list of *eri*herals for &hich you ha5e s*ecified some 5alid address in the configuration
&ill a**ear3 :ou may select the desired *eri*heral from the list and then *ress <Enter=3 It
&ill be dis*layed in the I)% &atch &indo&3 .e*ending on the ty*e of *eri*heral selected'
it-s information &ill be dis*layed in different format3 e3g3 if you select "2!#' the contents
of 1 >or "7 locations of it-s dis*lay IEF &ill be dis*layed in the I)% &atch &indo&3 If
you select GC.' &hate5er message is out*ut to the GC. &ill be dis*layed3 If you select
Embedded System 23
Parul Institute of Engineering & Technology Electronics & Communication
"155' the contents of PE' PH and PC &ill be dis*layed along &ith their *ort directions
>In*ut ) %ut*ut73
E*(c-ti# o#( +tat(!(#t :
Select Iun)Single Ste* >or Press F27 to do this3
S%itc)i# to co#ti#-o-+ r-# !o$( :
Select Iun)Iun >or Press Ctrl F2) to do this3
Si!-lati# (*t(r#al i#t(rr-,t (INT<;INT1) :
Select 7I#t(rr-,t <9 or 7I#t(rr-,t 19 sub/o*tion from 7CPU9 menu to simulate I9T$ or
I9T1 res*ecti5ely3 Elternati5ely' you can clic( on the I$ or I1 buttons on the toolbar3
Please note' that &hen you do this' the *rogram control &ill immediately transfer to the
5ector location of the interru*t >Pro5ided it is enabled by your *rogram73
Si!-lati# +(rial ,ort i#,-t :
Ecti5ate the Serial Jindo& using US- tool on toolbar >or select 7S(rial "atc)9 sub/o*tion
from 5ie& menu37 The Serial Jindo& contains 5arious &indo&s to dis*lay mode' baud/
rate' out*ut and edit &indo&s to gi5e in*uts to serial *ort3 These are described belo&3
Mo$(;Ba-$ Rat( "i#$o%2 This dis*lays a mode and baud/rate at &hich the *ort is
o*erating3
=(* I#,-t S(ctio#2 Fany times you need to gi5e he6 in*ut to serial *ort3 In that case you
may need use this section3 This contains the three controls2
%ne small button >&ith ca*tion $ or 137 This button is used to gi5e #
th
bit in*ut to
*rocessor3 This is reLuired in case of multi*rocessor communication mode3
Edit Jindo&2 Enter the a he6 code to gi5e in*ut to serial *ort3
Ecce*t Ae6 In*ut2 Jhen you ha5e entered the Ae6 code and #
th
bit' *ress this button3
Jhen this button is *ressed the in*ut you ha5e ty*ed in' goes to *rocessor3
9ote that all these controls &ill be disabled if you ha5e not enabled recei5er in your
soft&are3
ASCII I#,-t "i#$o%2 This &indo& is used to gi5e ESCII in*ut to serial *ort3 %f course
you can use Ae6 in*ut &indo& to do this' but in that case you need to ty*e he6 code of
the character you &ant to in*ut3 In ESCII In*ut &indo&' 4ust ty*e the character you &ant
to in*ut' it is automatically sent to serial *ort of the micro/controller3 Please note that
debugger &ill ta(e the last character in this &indo& and send it to serial *ort3 If your
ty*ing s*eed is 5ery fast' you &ill miss some characters3
This &indo& &ill be disabled if you ha5e not enabled a recei5er of "$51 in your *rogram3
Si!-lati# i#,-t to ,(ri,)(ral+ :
To simulate in*ut to *eri*herals i3e3 "2!#)"155)"255)"251)"253' right clic( in I% Jatch
Jindo& and select Edit from *o* u* menu3 Select the *eri*heral to &hich you &ant to
gi5e in*ut3 Jhen you do this' you &ill be *rom*ted to enter the in*ut 5alue for the
corres*onding *eri*heral3 e3g3 if you select "2!#' you &ill be *rom*ted to enter the
e6*ected scan/code of the desired (ey in AEO3 Similarly if you select the "155' you &ill
be *rom*ted to enter the in*ut e6*ected on PE' PH' PC *orts of "155' de*ending on
&hich of them are in*ut *orts3
Embedded System 24
Parul Institute of Engineering & Technology Electronics & Communication
Mo$i0.i# t)( co#t(#t+ o0 E*t(r#al RAM :
Iight clic( in E6ternal IEF Jatch Jindo& and Select edit from *o*/u* menu3 E
+Fodify Femory Contents0 dialog bo6 a**ears as sho&n in figure 43
8igure 4
This dis*lays the current contents of the memory3 No to the location you &ant using
UPage P*-' UPage .o&n-' UChange Eddress- buttons3 Enter the ne& contents in the
corres*onding edit &indo& and clic( %X3
Mo$i0.i# t)( co#t(#t+ o0 I#t(r#al RAM :
Iigth clic( in Internal IEF Jatch Jindo& and Select edit from *o*/u* menu3 E
+Fodify Femory Contents0 dialog bo6 a**ears3
This dis*lays the current contents of the memory3 No to the location you &ant using
UPage P*-' UPage .o&n-' UChange Eddress- buttons3 Enter the ne& contents in the
corres*onding edit &indo& and clic( %X3
Mo$i0.i# t)( :al-( o0 a C la#-a( :aria'l( :
Iight clic( in C Variable Jatch Jindo& and select Edit from *o*u* menu3 Then select
the name of the 5ariable from the dro* do&n list and *ress %X3 Then you &ill get the ne&
&indo& &ith the current 5alue of that 5ariable' and you may change it to &hate5er you
&ant3 8inally' clic( %X' so that the ty*ed 5alue is stored in that 5ariable3
This o*tion is a5ailable' only if you ha5e *urchased the JSIF51/C also3 %ther&ise' this
o*tion remains disabled3
Mo$i0.i# t)( co#t(#t+ o0 a# SFR :
.ouble clic( on the desired S8I from the S8I Jatch Jindo&3 Then the current contents
of that S8I &ill be dis*layed' and you may change it to &hate5er you &ant3 8inally'
cloc( %X' so that the ty*ed 5alue is stored in that S8I3
Embedded System 25
Parul Institute of Engineering & Technology Electronics & Communication
Mo$i0.i# t)( co#t(#t+ o0 a r(i+t(r :
.ouble clic( on any of the register i3e3 I$/I!' ECC' PSJ' .PTI' P$/P3 and SP' in S8I
Jatch Jindo&3 Then the current contents of that register &ill be dis*layed' and you may
change it to &hate5er you &ant3 8inally' *ress <Enter=' so that the ty*ed 5alue is stored
in that register3
'riting Simple ssembly Language Sub(routines :
It may be sometimes 5ery con5enient to &rite small functions in assembly language
and call these functions from C language *rogram3 This section describes e6actly ho&
to do it3 Get us ta(e a sim*le e6am*le / it may not be useful in real life' but it
nonetheless illustrates the method to be follo&ed3 This is ho& our e6am*le function
goes 2
_exmpl_func:
; Example function written in assembly language
mov a,p0 ; read P0 data
rlc a ; rotate left through Carry
mov p0,a ; write bac to P0
ret
In your C *rogram' you might call this function' sim*ly by &riting 2
exmpl_func!" ;
Jriting assembly language functions is as sim*le as that3 :ou only need to remember a
fe& rules 2
En assembly language function must start &ith a label' &hich is same as the name
of the function *receded by an underscore character >T@T73
Jhile calling such a function from C language *rogram' you must omit the
underscore character3
The assembly language function may modify the contents of any of the registers >I$
through I!7 and Ecc3
9e5er s&itch register ban(3
9e5er change the contents of Stac( Pointer >SP73 Fa(e sure that the PPSAs and
P%Ps are e6actly matching3
9e5er &rite into any location in internal or e6ternal data memory3
9e5er access any location in internal ) e6ternal data memory by using hardcoded
addresses3 El&ays define global 5ariable in your C *rogram' so that the reLuired
s*ace gets allotted to them3 Pse only the names of these 5ariables as internal )
e6ternal data memory addresses3 e3g3 if you &ant to use a byte location in e6ternal
data memory' you should declare a unsigned char ty*e global 5ariable in your C
*rogram as 2
Embedded System 2
Parul Institute of Engineering & Technology Electronics & Communication
unsigned char asm_var ;
In your assembly language function' you can use it as 2
mov dptr,#_asm_var ; load the addr$ in %P&'
movx a,(dptr ; read the value
; do some processing
movx (dptr,a ; write bac the value
If you stic( to these rules' chances of \system crash\ &ill be far too less B
ssembly Language )un*tion+s return value :
Su**ose you &ant the assembly language function to return some 5alue' follo& these
guidelines3 In your C *rogram you must *ut the functionTs declaration3 e3g3
unsigned char some_func !" ;
Then you may call this function as and &hen reLuired3 e3g3
value ) some_func!" * +, ;
In assembly language you &rite'
_some_func:
; some code here
; finally compute the return value in -cc,
; and then store
mov myacc,a
; the return value put in proper place
ret
9ote that the return 5alue should be al&ays *ut in the internal IEF location /
myacc3 .e*ending on the ty*e of return 5alue' you may &rite 1 to 4 bytes from location
on&ards3 e3g3 in case of int ty*e return 5alue' you should &rite the GSHyte of the return
5alue at myacc and the FSHyte should be &ritten at >myacc W 173
Please note that if a function-s return 5alue is of ty*e Ubit- then you should use the bit
location Ubit@acc- instead of internal IEF location Umyacc-3 e3g3 if you &ant to return 1
>bit ty*e7' then you must &rite 2
setb bit_acc
ret
at the end of the function3
Embedded System 2!
Parul Institute of Engineering & Technology Electronics & Communication
ssembly Language )un*tions with parameters :
If you &ant the assembly language function to ta(e *arameters' you must start and end
the function in a s*ecific manner3 Egain this is different for large model and small
model *rograms3 Get us consider large model *rograms first3
Acc(++i# ,ara!(t(r+ i# lar( !o$(l ,rora!+ :
Et the beginning' you must &rite these four lines 2
push bpl
push bph
mov bpl,spl
mov bph,sph
Et the end' you must &rite these fi5e lines 2
mov spl,bpl
mov sph,bph
pop bph
pop bpl
ret
Jhen a function is called from C language *rogram' itTs *arameters are *ushed
onto EOTEI9EG STECX &hich resides in e6ternal data memory3 The last *arameter
is *ushed first3 To access these *arameters' you should ma(e use of b*l and b*h3 8or
e6am*le consider this C language statement 2
some_func.!par.,par+" ;
Get us assume that *ar1 is of int ty*e and *ar2 is of unsigned char ty*e3 The first
*arameter can be al&ays found at the address contained in b*h and b*l *lus 13 e3g3 to
load the 5alue of *ar1 in I3/I2 >FSHyte in I37' you may &rite 2
mov a,bpl
add a,#.
mov dpl,a
mov a,bph
addc a,#0
mov dph,a ; %P&' ) !bph"!bpl" * . ) addr of par.
movx a,(dptr ; read lo byte of par.
mov r+,a ; put it in '+
inc dptr
movx a,(dptr ; read hi byte of par.
mov r/,a ; put it in '/
Embedded System 2"
Parul Institute of Engineering & Technology Electronics & Communication
9ote that Tlo&er byte at lo&er addressT *hiloso*hy is follo&ed e5ery&here3 The
remaining *arameters are stored at consecuti5e locations3 e3g3 *ar2 can be found at >b*h7
>b*l7 W 33 Please note that you must ne5er modify the contents of b*l' b*h' s*l or
s*h3
Acc(++i# ,ara!(t(r+ i# +!all !o$(l ,rora!+ :
Et the beginning' you must &rite these t&o lines 2
push bp
mov bp,sp
Et the end' you must &rite these three lines 2
mov sp,bp
pop bp
ret
Jhen a function is called from C language *rogram' itTs *arameters are *ushed
onto stac(3 The first *arameter is *ushed first3 To access these *arameters' you should
ma(e use of b*3 8or e6am*le consider this C language statement 2
some_func.!par.,par+" ;
Get us assume that *ar1 is of int ty*e and *ar2 is of unsigned char ty*e3 The last byte of
the first *arameter can be al&ays found at the address >>b*7 / 373 e3g3 to load the 5alue
of *ar1 in I3/I2' you may &rite 2
mov a,bp
clr c
subb a,#0
mov r0,a ; '0 ) !bp" 1 0 ) addr of par.
mov a,(r0 ; read 234yte of par.
mov r+,a ; put it in '+
inc r0
mov a,(r0 ; read 534yte of par.
mov r/,a ; put it in '/
9ote that Tlo&er byte at lo&er addressT *hiloso*hy is follo&ed e5ery&here3 The
remaining *arameters are stored at consecuti5e locations / bac(&ard3 e3g3 *ar2 can be
found at >b*7 / 53
Please note that you must ne5er modify the contents of b* or s*3
Embedded System 2#
Parul Institute of Engineering & Technology Electronics & Communication
Calling C fun*tions from assembly language :
:ou can sim*ly call C language function from assembly language by name' but by
*receding it by an underscore character3 e3g3 if your C function is defined as 2
void some_func !" ;
:ou can call it from assembly language as 2
lcall _some_func
Pa++i# ,ara!(t(r+ (lar( !o$(l ,rora!+) :
If the C function ta(es any *arameters' you should ma(e use of s*l and s*h to *ass
*arameters3 Get us modify the abo5e e6am*le and redefine the same function &ith
*arameters as 2
void some_func !int par., unsigned char par+" ;
8or sim*licity' let us assume that 5alue of *ar1 is in I3/I2 >FSHyte in I37 and 5alue
of *ar2 is in I43 The last *arameter >*ar2 in this case7 is *ushed first3 i3e3 *arameters
are *ushed in the re5erse seLuence3 >s*h7>s*l7 *oints to the To* of Stac( >ToS7 minus
13 8irst you should *ush the *arameters into the e6ternal stac(' then you call the
function' then you should ad4ust the e6ternal stac(3 8or the abo5e e6am*le' this is
ho& you do it 2
mov a,spl
clr c
subb a,#+
mov dpl,a
mov a,sph
subb a,#0
mov dph,a
; %P&' ) !sph"!spl" 1 total no$ of bytes re6uired
; for -22 parameters * .
mov a,r+ ; lo byte of par.
movx (dptr,a
inc dptr
mov a,r/ ; hi byte of par.
movx (dptr,a
inc dptr
mov a,r0 ; par+
movx (dptr,a
; thus all parameters pushed
; now ad7ust stac pointer !sph,spl"
mov a,spl
Embedded System 3$
Parul Institute of Engineering & Technology Electronics & Communication
clr c
subb a,#/ ; decrement !sph"!spl" by total no$ of
mov spl,a ; byte re6uired for -22 parameters
mov a,sph
subb a,#0
mov sph,a
; now call the function
lcall _some_func
; now read7ust the stac pointer !sph,spl"
mov a,spl
add a,#/ ; increment !sph"!spl" by total no$ of
mov spl,a ; byte re6uired for -22 parameters
mov a,sph
addc a,#0
mov sph,a ; that is all 8
Pa++i# ,ara!(t(r+ (+!all !o$(l ,rora!+) :
If the C function ta(es any *arameters' you should ma(e use of s* to *ass
*arameters3 Get us modify the abo5e e6am*le and redefine the same function &ith
*arameters as 2
void some_func !int par., unsigned char par+" ;
8or sim*licity' let us assume that 5alue of *ar1 is in I3/I2 >FSHyte in I37 and 5alue
of *ar2 is in I43 The last *arameter >*ar2 in this case7 is *ushed first3 i3e3 *arameters
are *ushed in the re5erse seLuence3 8irst you should *ush the *arameters onto stac('
then you call the function' then you should ad4ust the stac(3 8or the abo5e e6am*le'
this is ho& you do it 2
mov a,r0
push acc
mov a,r+
push acc
mov a,r/
push acc
lcall _some_func
mov a,sp
clr c
subb a,#/ ; decrement sp by total no$ of
mov sp,a ; bytes re6uired for -22 parameters
Embedded System 31
Parul Institute of Engineering & Technology Electronics & Communication
Practical No: 1
INTERFACIN> OF LED:
Embedded System 32
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 33
Parul Institute of Engineering & Technology Electronics & Communication
Practical No: 2
INTERFACIN> OF S"ITC= AND LED:
Embedded System 34
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 35
Parul Institute of Engineering & Technology Electronics & Communication
Practical No: 4
INTERFACIN> OF LED AND T"O S"ITC=:
Embedded System 3
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 3!
Parul Institute of Engineering & Technology Electronics & Communication
Practical No:?
INTERFACIN> OF SE&EN SE>MENT DISPLA@:
Embedded System 3"
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 3#
Parul Institute of Engineering & Technology Electronics & Communication
Practical No:5
Embedded System 4$
Parul Institute of Engineering & Technology Electronics & Communication
Practical No: A
INTERFACIN> OF LCD:
Embedded System 41
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 42
Parul Institute of Engineering & Technology Electronics & Communication
Practical No: 2
Embedded System 43
Parul Institute of Engineering & Technology Electronics & Communication
Practical No: 1
INTERFACIN> OF ADC:
Embedded System 44
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 45
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 4
Parul Institute of Engineering & Technology Electronics & Communication
Practical No: 3
SIN>LE BIT COUNTER:
Embedded System 4!
Parul Institute of Engineering & Technology Electronics & Communication
Embedded System 4"

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy