Download - Embedded Lab 3 Report

Transcript
  • 7/25/2019 Embedded Lab 3 Report

    1/11

    LAB REPORT

    EC501- EMBEDDED SYSTEM APPLICATION

    LAB : 3

    TITTLE : C LANGUAGE PROGRAMMING

    GROUP MEMBER:

    NO. NAME REG. NUMBER

    1 MOHAMAD AMERUDIN BIN RAMLI 16DET12F1047

    2 BADRUL AMIN BIN MOHD RADZI 16DET12F1061

    3 16DET12F10

    4 16DET12F10

    Cover pageObjective

    Equipment

    BackgroundTheory

    Procedures Datacollection

    Discussion Conclusion Total Marks

    / /10 /20 /30 /1 /100

  • 7/25/2019 Embedded Lab 3 Report

    2/11

    EXPERIMENT 3TITLE C LANGUAGE PROGRAMMINGOBJECTIVES At the end o this lab session! the student should be able to"

    #$ Create and manage Project C programming language$%$ E&plain and Construct Basic '(O and )imple delay $

    *$ E&amine the structure o C program or P'C #+$

    MATERIAL ANDAPPARATUS

    E)P'C,-C Trainer board ! Personal Computer .ith /P0AB 'DE! )erialBootloader and! P'C#+1,23%% Datasheet$

    THEORY As the scale o microcomputer based systems has increased over theyears! productivity and maintainability using Assembly language hasbecome an issue$ As a result! C language has become a popularalternative$

    The ollo.ing e&plains the main eatures o the C language anddescribes ho. to .rite a program in 4C4$

    Feat!e" #$ t%e C La&'a'e5#6 An easily traceable program can be .ritten$

    The basics o structured programming! i$e$! 4sequential processing4!4branch processing4! and 4repeat processing4! can all be .ritten in acontrol statement$ 1or this reason! it is possible to .rite a program.hose 7o. o processing can easily be traced$

    5%6 A program can easily be divided into modules$A program .ritten in the C language consists o basic units called4unctions4$ )inceunctions have their parameters highly independent o others! a

    program can easily bemade into parts and can easily be reused$ 1urthermore! modules.ritten in the assembly language can be incorporated into a Clanguage program directly .ithout modi8cation$

    5*6 An easily maintainable program can be .ritten$1or reasons 5#6 and 5%6 above! the program ater being put intooperation can easily bemaintained$ 1urthermore! since the C language is based on standardspeci8cations5A9)' standard59ote66! a program .ritten in the C language can beported into othertypes o microcomputers ater only a minor modi8cation o the sourceprogram$

    R(e" #& C (a&'a'eThe ollo.ing lists the si& items that need to be observed .hen .ritinga C languageprogram"

  • 7/25/2019 Embedded Lab 3 Report

    3/11

    5#6 As a convention! use lo.ercase letters to .rite a program$5%6 )eparate e&ecutable statements in a program .ith a semicolon 4:4$5*6 Enclose e&ecution units o unctions or control statements .ithbrackets 4;4 and 46 ?rite comments bet.een 4(@4 and 4@(4$

    PROCEDURES)

    EXERCISES 1 *CREATE NE+ PROJECT,

    Ater 8nished install the /P0AB 'DE! .e are going to sho. you ho. to create aproject using it$ There is

    just a e. simple step to ollo. on ho. to create it$ Please ollo. the step belo."

    #$ o to to /E9 BA= and click P!#e.t- / P!#e.t +a!2

    %$ Click Ne4t/ $ On the Device menu! choose PIC1F65788 because .e are goingto use thisP'C /C or coming project$

  • 7/25/2019 Embedded Lab 3 Report

    4/11

    *$ Choose HI-TECH U&9e!"a( T##("te in Active Toolsuite$ A HI-TECH ANSI CC#:;(e!.ill sho. up in the Toolsuite Content$

  • 7/25/2019 Embedded Lab 3 Report

    5/11

    ,$ Ater that! choose a destination .here the project you create to be save as$ Andalso the projectname$ Ater that! click NEXT/$

    2$ 'n step ,! there are no e&isting 8le to be added so .e can skip this step by justclick NEXT/ FINISH

    Ater that! a project are created .ith the project name you added earlier$

    >$ Create 9e. 1ile )ave as LAB3.

  • 7/25/2019 Embedded Lab 3 Report

    6/11

    //Mac$( -")%'%()2-")" LED LATBb%'#.LATB0

    //P$($a+ U'a+a(%- +a%)

    )#%)"- ca$ -%9 //,(ca, a$%ab,"#

    OSCCO?@05!9 //PIC18F : I?TOSC 4M; I)%'%a,%;"

  • 7/25/2019 Embedded Lab 3 Report

    7/11

    %$ Press CTRL F10 $#!the 8rst time or F10to compile$ Gou also can clickB(2 t% C#:;(e!icon to compile$ Do the same procedure till********** Buildsuccessful! **********

    *$ ?rite to the project board$ =eset the project board$

    ,$ Change the instructions code to change blinking(delay time and change output toanother 0EDs port$

    2$ ?rite the code belo.$ )ave as LAB3B$

    2%)c,-" &18L456!!.7

    //F)c'%() &$('('&" -"c,a$a'%()9(%- I)%'%a,%;"

  • 7/25/2019 Embedded Lab 3 Report

    8/11

    2-")" S1 PORTEb%'#.RE02-")" S! PORTEb%'#.RE1

    //P$($a+ U'a+a(%- +a%)

    )#%)"- ca$ -%9 //,(ca, a$%ab,"#

    OSCCO?@05!9 //PIC18F : I?TOSC 4M; I)%'%a,%;"

  • 7/25/2019 Embedded Lab 3 Report

    9/11

    )ource code

  • 7/25/2019 Embedded Lab 3 Report

    10/11

    >$ 'nsert the instructions code to activate all the s.itches 5)?#!)?% and )?*6

    LAB3C

  • 7/25/2019 Embedded Lab 3 Report

    11/11