DEPARTMENT OF ELECTRONICS AND COMMUNICATIONS ENGINEERING
LAB MANUAL
EMBEDDED SYSTEMS LAB – I M.Tech I Year II Sem
Prepared By B.Srii!a" A""#cia$e Pr#%e""#r
Th#$a Ra!i The&a A""i"$a$ Pr#%e""#r MALLA REDDY ENGINEERING COLLEGE 'A($##m#(") Mai"amma*(da+ Dh(,apa,,y+ 'p#"$ !ia -aimpe$) Sec(dera/ad0122322 '4235031) 1
LIST OF E6PERIMENTS N#$e7 •
The following programs are to be implemented on ARM based Processors/Equivalent.
•
Minimum of 1 programs from Part !" and # programs from Part $"" are to be conducted.
Par$ 0I7 The following Programs are to be implemented on ARM Processor 1. %imple Assembl& Program for a. Addition ' %ubtraction ' Multiplication ' (ivision b. )perating Modes* %&stem +alls and "nterrupts c. ,oops* -ranches . rite an Assembl& Assembl& programs to configure and control 0eneral Purpose "nput/output " nput/output 0P")2 Port pins. 3. rite an Assembl& programs to read digital values from e4ternal peripherals and e4ecute them with the Target Target board. 5. Program for reading and writing of a file 6. Program to demonstrate Time Time dela& program using built in Timer Timer / +ounter feature on "(E Environment #. Program to demonstrate a simple interrupt handler and setting up a timer. 7. Program demonstrates setting up interrupt handlers. Press button to generate an interrupt and trace the program flow flow with debug terminal. 8. Program to "nterface 8 -it ,E( and %witch "nterface 9. Program to implement -u::er "nterface on "(E environment 1. Program to (ispla&ing a message in a line 4 1# +haracters ,+( displa& and verif& the result in debug terminal. 11. Program to demonstrate "+ "nterface on "(E environment 1. Program to demonstrate "+ "nterface ! %erial EEPR)M 13. (emonstration of %erial communication. Transmission Transmission from ;it and reception from P+ using %erial Port on "(E environment use debug terminal to trace the program. 15. 0eneration of PM %ignal 2
16. Program to demonstrate %($MM+ +ard "nterface.
Par$ 0II7 rite the following programs to understand the use of RT)% with ARM ARM Processor on "(E Environment using ARM Tool Tool chain and ,ibrar&< 1. +reate an application that creates two tas=s that wait on a timer whilst the main tas= loops. . rite an application that creates a tas= which is scheduled when a button is pressed* which illustrates the use of an event set between an "%R and a tas= 3. rite an application that (emonstrates the interruptible "%RsRequires timer to have higher priorit& than e4ternal interrupt button2 5. a2.rite an application to Test message queues and memor& bloc=s. b2.rite an application to Test Test b&te queues 6. rite an application that creates two tas=s of the same priorit& and sets the time slice period to illustrate time slicing.
I$er%aci* Pr#*ram"7 #. rite an application that creates a two tas= to -lin=ing two different ,E(s at different timings 7. rite an application that creates a two tas= displa&ing two different messages in ,+( displa& in two lines. 8. %ending messages to mailbo4 b& one tas= and reading the message from mailbo4 b& another tas=. 9. %ending message to P+ through serial port b& three different tas=s on priorit& -asis. 1. -asic Audio Processing on "(E environment.
3
CYCLE03
LPC4358 'ARM) 4
MICROCONTROLLER
I$r#d(c$i# $# ARM B#ard 'LPC4358)7 This section of the document introduces ,P+158 microcontroller board based on a 1#$ bit/3$bit ARM7T(M"$% +P> with real$time emulation and embedded trace support* that combine microcontrollers with embedded high$speed flash memor& ranging from 3 =- to 61 =-. A 18$bit wide memor& interface and unique accelerator architecture enable 3$bit code e4ecution at the ma4imum cloc= rate. ?or critical code si:e applications* the alternative 1#$bit Thumb mode reduces code b& more than 3@ with minimal performance penalt&. The meaning of ,P+ is ,ow Power ,ow +ost microcontroller. This is 3 bit microcontroller manufactured b& Philips semiconductors BP2. (ue to their tin& si:e and low power consumption* ,P+158 is ideal for applications where miniaturi:ation is a =e& requirement* such as access control and point$of$sale. Fea$(re" #% ARM Micr#c#$r#,,er7 5
1#$bit/3$bit ARM7T(M"$% microcontroller in a tin& ,C?P#5 pac=age. 8 =- to 5 =- of on$chip static RAM and 3 =- to 61 =- of on$chip flash memor&D 18$ bit wide interface/accelerator enables high$speed # M: operation. "n$%&stem Programming/"n$Application Programming "%P/"AP2 via on$chip boot loader software* single flash sector or full chip erase in 5 ms and programming of 6# -&tes in 1 ms Embedded "+E RT and Embedded Trace interfaces offer real$time debugging with the on$chip Real Monitor software and high$speed tracing of instruction e4ecution. >%- . ?ull$speed compliant device controller with =- of endpoint RAM. "n addition* the ,P+158 provides 8 =- of on$chip RAM accessible to >%- b& (MA. )ne or two ,P+151/5 vs* ,P+155/5#/582 1$bit A(+s provide a total of #/15 analog inputs* with conversion times as low as .55 ms per channel. %ingle 1$bit (A+ provides variable analog output ,P+158 onl&2 Two 3$bit timers/e4ternal event counters with four captures and four compare +hannels each2* PM unit si4 outputs2 and watchdog. ,ow power Real$Time +loc= RT+2 with independent power and 3 =: cloc= input.
LPC4358 'ARM9)
6
M#d(,e" ad :(mper" Re,a$i#"hip
7
I$r#d(c$i# $# ;EIL "#%$
1. ;eil was found in 198 b& 0unler and Reinhard =eil. . ;eil implemented the first c compiler design. 3. ;eil provides a board range of development tools* A%;* macro assembler* debugger and lin=ers. 5. ;eil micro vision debuggers accuratel& simulate on$chip peripherals input/output* A/( converters* (/A converters2.
Fea$(re"7 1. ine basic data t&pes including 3$bit "EEE floating point. . ?le4ible* variable allocation with bit* data* bdata* idata* 4data and pdata of the memor& t&pes. 3. "nterrupt functions ma& be written in +. 5. ?all use of the 861 register ban=s. 6. +omplete s&mbol and t&pe information for source level debugger. #. >se of A"MP and A+A"" instructions. 7. -it addressable data obFects. 8. -uilt in interface for the RTB61 real time =ernel. 9. %upport for dual data pointers at the ATME,* AE(* EMPRE%%* and (E,, as semiconductor in line on Philips and transcend microcontroller.
;EIL =>i"i# 5 T##, -#< $# <#r
S$ep 37 0ive a double clic= on Gvision 5 icon on the des= top* it will generate a window as shown below.
S$ep 47 To create new proFect go to proFect select new micro vision proFect.
S$ep @7 select a drive where &ou would li=e to create &our proFect.
10
S$ep 57 +reate a new folder and name it with &our proFect name.
S$ep 17 ) pen that proFect folder and give a name of &our proFect e4ecutable file and save it.
11
S$ep 7 After saving it will show some window there &ou select &our microcontroller compan& i.e BP from Phillips.
S$ep 97 %elect &our chip as ,P+158.
12
S$ep 87 After selecting chip clic= on ); then it will displa& some window as=ing to add %TART>P file. %elect HE%.
S$ep 7 A target is created and startup file is added to &our proFect target and is shown below.
13
S$ep 327 To write &our proFect code select a new file from ?",E menu bar or clic= on
icon.
S$ep 33< "t will displa& some te4t editor* to save that file select %AIE option from ?",E menu bar.
14
S$ep 347 -& giving a file name with e4tension .+ for c files and save it.
S$ep 3@7 rite the code of &our proFect and save it.
15
S$ep 357 To add our c file to target give a right clic= on %ource 0roup* choose JA(( files to 0roup Joption.
S$ep 317 "t displa&s some window there select the file &ou have to add and clic= on A(( option.
16
S$ep 37 The file will be added to our target and it shows in the proFect window .
S$ep 397 ow give a right clic= on target in the proFect window and select J)ptions for TargetK.
17
S$ep 387 "t will show some window* in that go to output option and choose +reate e4 file option b& selecting that bo4.
S$ep 37 "n the same window go to ,in=er option and choose >se Memor& ,a&out from Target (ialog b& selecting the bo4* and clic= );. 18
S$ep 427 ow to +ompile &our proFect go to ProFect select -uild Target option or press ?7 or clic= on -uild2 icon or -uild All2 icon.
S$ep 437 "n the build )>T P>T window &ou can see the errors and warnings if there e4its. And here Hour proFect e4 file will be created.
19
DEBUGGER7 e can debug and also simulate the program using debugger option* Fust clic= on icon or can also select fron menu bar go to (ebug option and in that the first one J%tart/%top debugK. hen &ou clic= on that it will show &ou one window as shown below* clic= o=.
20
After clic=ing ); it will enter simulation screen as show below*
21
The above figure consists of 6 windows as shown in figure indow 1< This window is called as RE0"%TER window. indow < This is A%%EM-,H window* where we can see assembl& code for our corresponding + code. indow 3< This is Editor indow where we can write our + code or Edit it. indow 5< This is serial communication output window where we can see an& output from ARM on serial terminal. indow 6< This window is +all %tac= where we can see the local variables updating which is store in stac= memor&. These are the default windows we can see other windows which is present in debugger are 22
shown in figure below
indow 1 is +ommand window which will displa& an& errors or warning when we build the file. indow is %&mbol window where we can see each and ever& variables of .c files li=e lcd.c* main.c etc indow 3 is a memor& window where we can see values stored in a particular memor&. indow 5 is atch window where we can see run time changes in the variables similar to s&mbol window but in s&mbol window we cannot see 0lobal variables* in this window we can all variables. indow 6 is a local window in this we can see functionLs local variables which are 23
having local scope.
Eec($i# #% pr#*ram7 ?or e4ecuting the program we need to press
this "con or we can directl&
press ?6 function =e& from =e&board. This e4ecution will be done all at a time we can also e4ecute the program step wise b& pressing ?11 or clic=ing on lineK* for step over the current line clic= on
this icon is for Jstep one
icon or press ?1 function =e&* to
step out of the current function press ctrl?11 or clic= on icon.
D#<,#adi* -e %i,e #$# ARM micr#c#$r#,,er7 F,a"h Ma*ic T##, To program the Microcontroller* ?lash Magic tool is used. 0enerall&* the microcontroller is in one of the two modes. )ne is R> mode and the other is PR)0RAMM"0 mode. "n R> mode microcontroller e4ecutes the application present in the microcontroller flash memor&. "n PR)0RAMM"0 mode* microcontroller programs its flash memor& in s&nchroni:ation with ?lash Magic. To enter in to the programming mode* old down %isp2 and %3reset2* then release %3 first and finall& % . To enter in to Run Mode* press the %3reset2 after programming is over.
24
D#<,#adi* -e %i,e #$# micr#c#$r#,,er7 To program the flash memor&* first =eep the microcontroller in PR)0RAMM"0 mode. ,aunch the ?lash Magic Tool. %elect the +)M1* -aud rate as 19* device as ,P+158D )scillator ?req M:2 as 1* in +ommunication bloc=. %elect the bo4 erase all ?lash +ode Rd Prot in Erase bloc=. %elect the bo4 Ierif& after programming in )ptions -loc=. %elect the he4 file in e4 ?ile bloc=. old down % isp2 and %3 reset2* then release %3 first and finall& % .Then clic= %tart -utton in %tart -loc=.
25
Pr#*ram 3
Ari$hme$ic ad Brachi* Opera$i#" Aim7 To verif& verif& arithmetic and branching operations b& writing an assembl& language program.
T##,"7 12P+ 2;eil Microvision5
Pr#*ram7 AREA Arithmeti Arithmetic* c* +)(E* REA(),H ETRH start M)I
r* N
M)I
r1* N6
A((
r* r* r1
M>,
r3* r* r1
%>-0T
r5* r* r1
%>-,T
r6* r1* r
+MP
r1* N
M)I
r8* r
-E
here
M)I
divd
r8* r7
stop - stop 26
divd %>-
r8* r8* r1
A((
r7* N1
+MP
r8* N
-EC
here
-E
divd
E(
O($p($7
Re"(,$7 ence performed assembl& level programming to verif& arithmetic and branching operations in =eil.
27
Pr#*ram04 C#%i*(ra$i# ad C#$r#,,i* O% GPIO P#r$" Aim7 To write write an assembl& asse mbl& level program for +onfiguring and +ontrolling of 0P") ports
T##," U"ed7 12 P+ 2;eil microvision5
Pr#*ram7 AREA m&program* +)(E* REA(),H ETRH P"%E, EC> 4E+ P"%E,1 EC> 4E+5 P"%E, EC> 4E+15 ")("R EC> 4E88 ")%ET ")%ET EC> 4E 4E8 85 5 ")+,R ")+,R EC> 4E 4E8 8+ + ")("R1 EC> 4E818 ")%ET1 ")%ET 1 EC> 4E 4E8 815 15 ")+,R1 ")+,R 1 EC> 4E 4E8 81c 1c
M)I r* N ,(R r1* OP"%E, %TR r* r1Q
M)I r* N ,(R r1* OP"%E,1 %TR r* r1Q
28
M)I r* N ,(R r1* OP"%E, %TR r* r1Q
M)I r* N4???????? ,(R r1* O")("R %TR r* r1Q
M)I r* N4???????? ,(R r1* O")("R1 %TR r* r1Q stop
M)I r* N4???????? ,(R r1* O")%ET %TR r* r1Q
M)I r* NB???????? ,(R r1* O")%ET1 %TR r* r1Q
M)I r3* N -, (E,AH M)I r3* N M)I r* N4???????? ,(R r1* O")+,R %TR r* r1Q
M)I r* NB???????? ,(R r1* O")+,R1 %TR r* r1Q
M)I r3* N 29
-, (E,AH
M)I r3* N - stop
(E,AH ,(R r6* O4?????? DM)I r5* N66 ERE +MP R3* R6 DERE1 D+MP r5* r# DA(( r#* N1 D-E ERE1 A(( R3* N1 -E ERE -B ,R E(
O($p($7 Se$7
C,ear7
30
Re"(,$"7 ence performed assembl& level programming to configure and control 0P") ports.
31
Program$3 Timer %ubroutine in ARM7 Microprocessor Aim< To write program to demonstrate time dela& using built in timer/counter features on "(E environment.
Tools< 12P+ 2=eil microvision5
Program< Ninclude S,P+15B. void timerdela&void2D int main2 U P"%E, O 4D ")("R O 4????????D while12 U ")%ET O 466D timerdela&2D ")+,R O 466D timerdela&2D ")%ET O 4AAD 32
timerdela&2D ")+,R O 4AAD timerdela&2D V V
void timerdela&2 U TT+R O 4D TT+ O D TP+ O D TPR O 16D TMR O 1D TM+R O 4D TT+R O 1D whileTT+ WO TMR2D V
O($p($7 Se$7
C,ear7
33
Timer27
34
Re"(,$7 Timer dela& program using built in timer/counter feature on "(E environment is demonstrated.
Pr#*ram05 Simp,e I$err(p$ -ad,er
T##,"7 12P+ 2;eil microvision 5
Pr#*ram7 Ninclude S,P+15B.
void Timer"nitvoid2D void Timer"%Rvoid2 irqD
unsigned char gflag O D
int main2 U 35
P"%E, O 4D P"%E,1 O 4D P"%E, O 4D ")("R O 4?D Timer"nit2D TT+R O 41D while12D V
void Timer"nitvoid2 U TT+R O 4D TT+ O 4D TPR O 16D TP+ O D TMR O 1D TM+R O 43D I"+"nt%elect 'O 4D I"+Iect+ntl 'O 4'5D I"+IectAddr O unsigned2Timer"%RD I"+"ntEnable 'O 1SS52D V
void Timer"%Rvoid2 irq U ifI"+"RC%tatus X 412 U ifT"R OO 412 U T"R O 41D ifgflag OO 2 U ")%ET O 43?D 36
gflag O 1D V
else U ")+,R O 43?D gflag O D V V V
I"+IectAddr O 4D V
O($p($7 Re"e$7
Ea/,e7
>IC re"e$
37
>IC ea/,e
Re"(,$7 %imple interrupt handler X setting up a timer is demonstrated on "(E environment
38
Pr#*ram 1 B(er Aim7 To write a program to implement -u::er "nterface on "(E environment
T##,"7 12 P+ 2 ;eil Microvision 5
Pr#*ram7 'a)/(er.c
Ninclude S,P+15B. Ninclude YE4p7.hY int main2 39
U P"%E, O 4D P"%E, O 4D ")("R O 48D ")("R1 O 4?D while12 U if%1OO2 while%1 OO 2 -uZZer)D else -uZZer)??D V V '/)Ep9.h
Ndefine -uZZer)?? ")%ETO1SS112 Ndefine -uZZer) ")+,RO1SS112 Ndefine %1 ")P"X1SS1622
O($p($7 B(er0#%%7 GPIO2
40
GPIO3
B(er0# GPIO2
GPIO3
41
Re"(,$7 ence ritten a program to "mplement -u::er "nterface on "(E environment.
Pr#*ram LCD Di"p,ay Aim7 To write a program for (ispla&ing message in a line [ 1# characters ,+( displa& and verif& the result in debug terminal.
T##,"7 12P+ 2;eil Microvision 5
Pr#*ram7
'a)LCD.c7
Ninclude S,P+15B. Ninclude YE4p#.hY int mainvoid2 42
U P"%E, O 4D P"%E,1 O 4D P"%E, O 4D ")1("R O 41+D ")("R O 43+D ,+(init2D ,+(+ommand482D ,+(%end%tringY >"%TR"0 TE+ Y2D ,+((ela&12D ,+(+ommand4+2D ,+(%end%tringY%),>T") PIT ,T(Y2D while12D V
'/)Ep.h
Ndefine ,+(R%(ATA ")1%ETO1SS52 Ndefine ,+(R%+M( ")1+,RO1SS52 Ndefine
,+(R ")1+,RO1SS32
Ndefine
,+(R( ")1%ETO1SS32
Ndefine ,+(E" ")1%ETO1SS2 Ndefine
,+(E,) " )1+,RO1SS2
43
void ,+((ela&unsigned int s2 U unsigned int i O D whiles$$2 U i O D whileiS#2D V V void ,+((ataunsigned int data2 U unsigned char tempD ,+(R%(ATAD ,+(RD temp O dataD ")%ET O temp X 4?2SS#D ,+(E"D ,+(E,)D ")+,R O temp X 4?2SS#D ")%ET O data X 4?2SS1D ,+(E"D ,+(E,)D ")+,R O data X 4?2SS1D 44
,+((ela&12D V void ,+(%end%tringunsigned char [data2 U while[data2 ,+((ata[data2D V void ,+(+ommandunsigned int data2 U unsigned char tempD ,+(R%+M(D ,+(RD temp O dataD
")%ET O temp X 4?2SS#D
,+(E"D ,+(E,)D ")+,R O temp X 4?2SS#D
")%ET O data X 4?2SS1D ,+(E"D ,+(E,)D 45
")+,R O data X 4?2SS1D ,+((ela&12D V void ,+(initvoid2 U ,+(+ommand482D ,+(+ommand42D ,+(+ommand4+2D ,+(+ommand4#2D V
O($p($7
46
Re"(,$7 ence written a program for (ispla&ing message in a line [ 1# characters ,+( displa& and verif& the result in debug terminal.
Program 7 E4ternal "nterrupt andler
Aim< To r rite ite a Program to demonstrate %etting up interrupt handlers and generate an interrupt when button is pressed.
47
Tools< 12 P+ 2 ;eil microvison 5
Program< a2e4tinterrupthandler.c Ninclude S,P+15B. Ninclude YE4p 7.hY void E4t"nt"nitvoid2D void E4t"nt%ervicevoid2irq U >ART%end%tringYE4ternal "nterrupt has arrived \r\nY2D EBT"T 'O 5D I"+IectAddr O D V void E4t"nt"nitvoid2 U EBTM)(E 'O 5D EBTP),AR O 5D I"+Iect+ntl O 4 ' 1#D I"+IectAddr O unsigned long2 E4t"nt%erviceD I"+"ntEnable 'O 1SS1#D V int main2
48
U P"%E, 'O 486D P"%E,1 O 4D E4t"nt"nit2D >ART"nit2D >ART%end%tringY[ E4ternal "nterrupt (emo [\n\n\rY2D (ela&Ms12D >ART%end%tringY Press "nterrupt ;e& %1"T12 for )utput... \n\n\n\rY2D (ela&Ms12D while12D V b2E4p7.h Ndefine >ART-P% 116 Ndefine ?pcl= 16
void >ART"nitvoid2 U unsigned int -aud1#D >,+R O 483D -aud1# O ?pcl= / 1#2/ >ART-P%2D >(,, O -aud1# @ 6#D >(,M O -aud1# / 6#D >,+R O 43D 49
V void >ART%end+harunsigned char value2 U >TR O valueD while>,%R X 45 2 OO 2D V void >ART%end%tringunsigned char [data2 U while[data WO ]\]2 >ART%end+har[data2D V void (ela&Msunsigned int count2 U unsigned int i*FD foriODiScountDi2 U
forFODFS1DF2D V
V
O($p($7
50
Re"(,$7 ence ritten a Program to demonstrate %etting up interrupt handlers and generate an interrupt when button is pressed
51
Pr#*ram 8 I$er%ace 80Bi$ LED ad S
T##,"7
12P+ 2;eil Microvision 5
Pr#*ram7 'a)LED.c
Ninclude S,P+15B. Ninclude YE4p8.hY unsigned int count OD int main2 U P"%E, O 4D P"%E,1 O 4D ")("R O 43?D ")("R1 O 4+D while12 U if%12 U count O count1D while%12D 53
//pattern1onD patternoffD V ifcount OO 12 U ")%ETO43?D ")1%ETO4+D V else ifcount OO 2 U ")%ETO41D ")1%ETO4+D V else ifcount OO 32 U ")%ETO4(D countOD V V V '/)Ep8.h
Ndefine pattern1on ")%ETO43?D")1%ETO4+D Ndefine pattern1off ")+,RO43?D")1+,RO4+D 54
Ndefine patternon ")%ETO41D")1%ETO4+D Ndefine patternoff ")+,RO41D")1+,RO4+D Ndefine pattern3on ")%ETO4(D Ndefine pattern3off ")+,RO4(D Ndefine patternoff ")1+,R O 4+D")+,RO43?D Ndefine %1 ")P"X1SS1622
O($p($7 Pa$$er7 3
Pa$$er7 4
55
Pa$$er7 @
Re"(,$7 ence ritten a program to "nterface 8$-it ,E( and %witch "nterface.
Pr#*ram Seria, dri!er Aim7 To write a program to demonstrate serial driverLs Transmission from =it and Reception ?rom P+ using %erial Port on "(E environment.
T##,"7 56
12P+ 2 ;eil Microvision5
Pr#*ram7 'a)"eria,dri!er.c
Ninclude S,P+15B. void T4stringunsigned char [2D void "nit>artvoid2D void main2 U P"%E,O46D "nit>art2D T4stringYello world\nY2D while12D V '/)"eria,dri!er.c
//Ninclude Y,P+158.hY Ninclude S,P+15B. Ndefine (E%"RE(-A>(RATE 19 Ndefine +RH%TA,?REC>E+H"Z 1 Ndefine MABP+,; +RH%TA,?REC>E+H"Z[62 Ndefine P+,; MABP+,;/52 Ndefine ("I"%)R P+,;/1#[(E%"RE(-A>(RATE22 57
void "nit>artvoid2 U >,+RO483D IP-("IO4D >(,,O("I"%)RX4??D >(,MO("I"%)R8D >,+RO43 D >?+RO46 D V void T4charchar ch2 U if chOO]\n]2 U while W>,%RX422 UV >TRO]\r]D V while W>,%RX422 UV >TROchD V unsigned char R4charvoid2 U char chD 58
while W>,%RX4122 UV chO>R-RD return chD V int T4stringchar [s2 U int iOD whilesiQWO]\]2 U T4charsiQ2D iD V returni2D V void T4numunsigned int num2 U char str9QD int iO*tempD foriODiS8Di2 U
tempOnum@1#D iftemp92
str7$iQO4372tempD 59
else
str7$iQO432tempD
numOnum/1#D V
str8QO]\]D T4stringstr2D V void T4numdecint num2 U char str1QD int iO*temp*lengthD ifnumS2 U
numO$numD
strQO]$]D
iO1D
lengthO11D V
else U
iOD
lengthO1D V 60
forDiSlengthDi2 U
tempOnum@1D
iftemp92
strlength$1$iQO4372tempD
else
strlength$1$iQO432tempD
numOnum/1D V
strlengthQO]\]D T4stringstr2D V
O($p($7 F,a"h ma*ic $##,
61
Termia,
Re"(,$7 ence written a program to demonstrate serial driverLs Transmission from =it and Reception ?rom P+ using %erial Port on "(E environment.
62
Pr#*ram 32 Seria, Ech# Dri!er C#mm(ica$i# Aim7
63
To write a program to demonstrate serial driverLs Echo Transmission from =it and Reception ?rom P+ using %erial Port on "(E environment.
T##,"7 12 P+ 2 ;eil Micro Iision 5
Pr#*ram7 'a)ech#.c
Ninclude S,P+15B. void main2 U P"%E,O46D "nit>art2D
T4stringYThis program will the echo the characters received\nY2D while12 T4charR4char22D V '/)Ech#.c
Ninclude S,P+15B. Ndefine (E%"RE(-A>(RATE 19 Ndefine +RH%TA,?REC>E+H"Z 1 64
Ndefine MABP+,; +RH%TA,?REC>E+H"Z[62 Ndefine P+,; MABP+,;/52 Ndefine ("I"%)R P+,;/1#[(E%"RE(-A>(RATE22 void "nit>artvoid2 U >,+RO483D IP-("IO4D >(,,O("I"%)RX4??D >(,MO("I"%)R8D >,+RO43 D >?+RO46 D V
void T4charchar ch2 U if chOO]\n]2 U while W>,%RX422 UV >TRO]\r]D V while W>,%RX422 UV >TROchD V 65
unsigned char R4charvoid2 U char chD while W>,%RX4122 UV chO>R-RD return chD V int T4stringchar [s2 U int iOD whilesiQWO]\]2 U T4charsiQ2D iD V returni2D V
O($p($7
66
Re"(,$7ence written a program to demonstrate serial driverLs Echo Transmission from =it and Reception from P+ using %erial Port on "(E environment.
67
CYCLE04
Crea$i* a e< pr#&ec$ %#r UCOS II i ;ei, 1. +op& 3 folders APP* ARM and >+os ii from an& e4isting RT)% proFect into a new folder. 68
APP ! Application (ata ARM ! ARM 7 specific files UC#" ii ! RT)% specific files
. )pen ;eil uIision 5 and create a new proFect.
3. %elect (evice ,P+158 from BP
69
5. ow add 3 folders under Target naming APP*ARM and >cos ii
6. >nder the folders add the respective files APP ! startup.s * "RC.s * target.c U"er %i,e"< main.c and >ART.c ARM ! )scpuc.c * )scpua.s Uc#"ii
)%+)RE.c*)%?,A0.c*)%M-)B.c*)%MEM.c*)%M>TEB.c*) 70
%C.c*)%%EM.c*)%TA%;.c*)%T"ME.c
#. "n )ptions for ^Target 1L change the %tart address and %i:e in "R)M 1 and "RAM 1under target tab
IROM37 %tart ! 4* %i:e ! 48 IRAM37 %tart ! 45* %i:e ! 48
7. >nder the )utput tab chec= the option +reate EB file 71
8. -uild the proFect to generate EB file.
Pr#*ram03 72
App,ica$i# $ha$ crea$e" $<# $a"" Aim7 To create an application that creates two tas=s that wait on a timer while the main tas= loops.
T##," Re(ired7 1. pc . ;eil micro vision5 3. Arm board
Pr#*ram7 Mai.c 7 Ninclude Yconfig.hY Ninclude Ystdlib.hY Ndefine
Tas=%t=,engh #5
)%%T;
Tas=%t=1 Tas=%t=,enghQD
)%%T;
Tas=%t= Tas=%t=,enghQD
void
Tas=1void [pdata2D
void
Tas=void [pdata2D
void "nitpllvoid2D int main void2 U P"%E, O 46D "nitpll2D 73
"nit>art2D Target"nit2D )%"nit 2D )%Tas=+reate Tas=1*void [2* XTas=%t=1Tas=%t=,engh $ 1Q* 12D )%Tas=+reate Tas=*void [2* XTas=%t=Tas=%t=,engh $ 1Q* 2D )%%tart 2D return D
V void Tas=1
void [pdata2
U while 12 U T4stringY\nTas= 1Y2D )%Time(l&62D V V void Tas=
void [pdata2
U while 12 U T4stringY\nTas= Y2D )%Time(l&2D 74
V V void "nitpll2 U P,,+?0O45D
P,,+)O41D
P,,?EE(O4AAD
P,,?EE(O466D whileWP,,%TAT X 4522D P,,+) O 43D P,,?EE( O4AAD
P,,?EE(O466D
V
Uar$2.C7 //Ninclude Y,P+158.hY 75
Ninclude S,P+15B. Ndefine (E%"RE(-A>(RATE 9# Ndefine +RH%TA,?REC>E+H"Z # Ndefine P+,; +RH%TA,?REC>E+H"Z/5 Ndefine ("I"%)R P+,;/1#[(E%"RE(-A>(RATE22 void "nit>artvoid2 U >,+RO483D IP-("IO4D >(,,O4#1D >(,MO4D >,+RO43 D >?+RO46 D V char putcharchar ch2 U if chOO]\n]2 U while W>,%RX422 UV >TRO]\r]D V while W>,%RX422 UV
>TROchD 76
return chD V char getcharvoid2 U char chD while W>,%RX4122 UV
chO>R-RD return chD
V int T4stringchar [s2 U int iOD whilesiQWO]\]2 U putcharsiQ2D iD V returni2D V
O($p($7
77
Re"(,$7 A program that create two tas=s that wait on a timer while the main tas= loops is obtained.
Pr#*ram7 4 78
Ta"
T##," Re(ired7 1. pc . ;eil micro vision5 3. Arm board
Pr#*ram7 Mai.c7 Ninclude Yconfig.hY Ninclude Ystdlib.hY Ndefine
Tas=%t=,engh #5
)%%T;
Tas=%t=1 Tas=%t=,enghQD
void
Tas=1void [pdata2D
void "nitpllvoid2D int main void2 U P"%E, O 486D ")("R1 'O 1SS62D ")%ET1 'O 1SS62D "nitpll2D
79
"nit>art2D Target"nit2D inite4tint2D )%"nit 2D )%Tas=+reate Tas=1*void [2* XTas=%t=1Tas=%t=,engh $ 1Q* 12D )%%tart 2D return D
V void Tas=1
void [pdata2
U while 12 U T4stringY\nTas= 1Y2D )%Time(l&62D V V void "nitpll2 U P,,+?0O45D
P,,+)O41D
P,,?EE(O4AAD 80
P,,?EE(O466D
whileWP,,%TAT X 4522D P,,+) O 43D P,,?EE( O4AAD
P,,?EE(O466D
V
Ei$.c7 Ninclude S,P+15B. void eintvoid2 irqD unsigned int iOD void dela&int count2 U int FO*iOD forFODFScountDF2 U foriODiS36Di2D V V void inite4tint2 U EBTM)(E O 45D EBTP),AR O 4D I"+"nt%electO4D 81
I"+Iect+ntl1O4'1#D I"+IectAddr1Ounsigned long 2eintD EBT"T O 4D I"+"ntEnableO41D V void eintvoid2 irq U
ifI"+"RC%tatusOO412 U T4stringY\n"nterruptY2D ")+,R1 'O 1SS62D dela&12D ")%ET1 'O 1SS62D V EBT"T O 45D I"+IectAddr O D
V
O($p($7
82
Re"(,$7 An application that creates a tas= which is scheduled when button is pressed* illustrates the use of an event set between "%R X a tas= is obtained.
Pr#*ram7 @ 83
App,ica$i# $# $e"$ me""a*e (e(e mem#ry /,#c" Aim7 To create an application to test message queue X memor& bloc=s.
T##," Re(ired7 1. pc . ;eil micro vision5 3. Arm board
Pr#*ram7 Mai7 Ninclude Yconfig.hY Ninclude Ystdlib.hY Ndefine
Tas=%t=,engh #5
)%%T;
Tas=%t= Tas=%t=,enghQD
)%%T;
Tas=%t=1 Tas=%t=,enghQD
)%%T;
Tas=%t= Tas=%t=,enghQD
void
Tas=char [pdata2D
void
Tas=1void [pdata2D
void
Tas=void [pdata2D
void "nitpllvoid2D )%EIET [msgqueueD unsigned char [msgsQOUYelloY*YorldYVD unsigned char [msg1*[msgD 84
int main void2 U P"%E, O 46D Target"nit2D "nitpll2D "nit>art2D )%"nit 2D )%Tas=+reate Tas=*void [2* XTas=%t=Tas=%t=,engh $ 1Q* 2D )%Tas=+reate Tas=1*void [2* XTas=%t=1Tas=%t=,engh $ 1Q* 32D )%Tas=+reate Tas=*void [2* XTas=%t=Tas=%t=,engh $ 1Q* 52D )%%tart 2D return D
V void Tas=
char [pdata2
U
msgqueue O )%C+reateXmsgsQ*2D while 12 U )%CPostmsgqueue*char [2msgsQ2D )%CPostmsgqueue*char [2msgs1Q2D 85
T4stringY\nPosted Message 1 and Y2D )%Time(l&M%M***72D V V void Tas=1
void [pdata2
U while 12 U msg1 O )%CAcceptmsgqueue2D ifmsg12 U T4stringY\nMessage 1 < Y2D T4stringmsg12D V )%Time(l&M%M***62D
V V void Tas=
void [pdata2
U while 12 U msg O )%CAcceptmsgqueue2D 86
ifmsg2 U T4stringY\nMessage < Y2D T4stringmsg2D V )%Time(l&M%M***62D V V void "nitpll2 U P,,+?0O45D
P,,+)O41D
P,,?EE(O4AAD
P,,?EE(O466D whileWP,,%TAT X 4522D P,,+) O 43D P,,?EE( O4AAD P,,?EE(O466D V
O($p($7
87
Re"(,$7 A program to test message queues and memor& bloc=s is obtained.
Pr#*ram7 5 App,ica$i# $ha$ dem#"$ra$e $he i$err(p$i/,e ISR Aim7 88
To create an application that demonstrates the interruptible "%R.
T##," Re(ired7 1. pc . ;eil micro vision5 3. Arm board
Pr#*ram7 Mai.c7 Ninclude Yconfig.hY Ninclude Ystdlib.hY Ndefine
Tas=%t=,engh #5
)%%T;
Tas=%t=1 Tas=%t=,enghQD
void
Tas=1void [pdata2D
void "nitpllvoid2D int main void2 U P"%E, O 486D ")("R1 O 1SS62D ")%ET1 O 1SS62D "nitpll2D "nit>art2D Target"nit2D inittimer2D
89
inite4tint2D )%"nit 2D )%Tas=+reate Tas=1*void [2* XTas=%t=1Tas=%t=,engh $ 1Q* 12D )%%tart 2D return D
V void Tas=1
void [pdata2
U T1T+R O 41D while 12 U T4stringY\nTas= 1Y2D )%Time(l&12D V V void "nitpll2 U P,,+?0O45D
P,,+)O41D
P,,?EE(O4AAD
P,,?EE(O466D
whileWP,,%TAT X 4522D 90
P,,+) O 43D P,,?EE( O4AAD
P,,?EE(O466D
V
O($p($7
Re"(,$7 An application that demonstrates the interruptible "%R is obtained.
Pr#*ram7 1 Sedi* me""a*e $# PC $hr#(*h "eria, p#r$ Aim7 To send message to P+ through serial port b& three different tas= on priorit& bases. 91
T##," Re(ired7 1. pc . ;eil micro vision5 3. Arm board
Pr#*ram7 Mai.c 7 Ninclude Yconfig.hY Ninclude Ystdlib.hY Ndefine
Tas=%t=,engh #5
)%%T;
Tas=%t= Tas=%t=,enghQD
)%%T;
Tas=%t=1 Tas=%t=,enghQD
)%%T;
Tas=%t= Tas=%t=,enghQD
void
Tas=char [pdata2D
void
Tas=1void [pdata2D
void
Tas=void [pdata2D
void "nitpllvoid2D int main void2 U P"%E, O 46D "nitpll2D "nit>art2D
92
)%"nit 2D )%Tas=+reate Tas=*void [2* XTas=%t=Tas=%t=,engh $ 1Q* 2D )%Tas=+reate Tas=1*void [2* XTas=%t=1Tas=%t=,engh $ 1Q* 32D )%Tas=+reate Tas=*void [2* XTas=%t=Tas=%t=,engh $ 1Q* 52D )%%tart 2D return D
V void Tas=
char [pdata2
U Target"nit 2D while 12 U T4stringY\nTas= 1Y2D
)%Time(l&M%M***92D V V void Tas=1
void [pdata2
U while 12 U T4stringY\nTas= Y2D 93
)%Time(l&M%M***62D V V void Tas=
void [pdata2
U while 12 U T4stringY\nTas= 3Y2D )%Time(l&M%M***32D V V void "nitpll2 U P,,+?0O45D
P,,+)O41D
P,,?EE(O4AAD
P,,?EE(O466D
whileWP,,%TAT X 4522D P,,+) O 43D P,,?EE( O4AAD P,,?EE(O466D V
O($p($7 94