How to Work With Pic

download How to Work With Pic

of 35

Transcript of How to Work With Pic

  • 7/29/2019 How to Work With Pic

    1/35

    How to Work

    In this chapter we will discuss that how

    work with PIC self learning kit . The

    chapter contain a simple led blinking

    program with starting to software

    initialization to hardware Running.

  • 7/29/2019 How to Work With Pic

    2/35

    Open Pic CCompiler

  • 7/29/2019 How to Work With Pic

    3/35

    In Menu Bar Click on

    Folder Icon, situted at

    near to project and then

    Select new

  • 7/29/2019 How to Work With Pic

    4/35

    Choose Source File

  • 7/29/2019 How to Work With Pic

    5/35

    Select the location where you want to saveyour source file, you can make a simple

    folder and in this folder you can save the

    file as shown in example.

  • 7/29/2019 How to Work With Pic

    6/35

    At this time I have created afolder name as led blink.

    In this folder I save this file

  • 7/29/2019 How to Work With Pic

    7/35

    Note Save this file name with .c extension.

    For example if you save file with name of led then

    you have to type the name as led .c.

    More simply shown in figure

  • 7/29/2019 How to Work With Pic

    8/35

    This window opens

  • 7/29/2019 How to Work With Pic

    9/35

    Write your code

    Full code will be shown in

    next Slide.

  • 7/29/2019 How to Work With Pic

    10/35

    #include

    #device adc=8

    #FUSES NOWDT //No Watch Dog Timer

    #FUSES HS //Highspeed Osc > 4mhz

    //#FUSES INTRC_IO

    #FUSES PUT //Power Up Timer#FUSES NOPROTECT //Code not protected from reading

    #FUSES NODEBUG //No Debug mode for ICD

    #FUSES NOBROWNOUT //No brownout reset

    #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

    #FUSES NOCPD //No EE protection

    #use delay(clock=16000000) // Sets crystal oscillator at 16 megahertz

    #use rs232(baud=9600, xmit=PIN_C6, invert) //Sets up serial port output pin & baud

    rate

    #define m1 PIN_D2 //2A

    #define m2 PIN_D3 //2A

    #define m3 PIN_C4 //2A

    #define m4 PIN_C5 //2A

    #define m5 PIN_C6 //2A

    #define m6 PIN_C7 //2A#define m7 PIN_D4 //2A

    #define m8 PIN_D5 //2A

  • 7/29/2019 How to Work With Pic

    11/35

    void blink()

    {

    output_high(m1);

    output_low(m2);

    output_high(m3);

    output_low(m4);output_high(m5);

    output_low(m6);

    output_high(m7);

    output_low(m8);

    delay_ms(1000);

    output_high(m8);

    output_low(m7);

    output_high(m6);

    output_low(m5);

    output_high(m4);

    output_low(m3);

    output_high(m2);

    output_low(m1);

    delay_ms(1000);

    }

    void main() //main program starts here

    {

    while(true)

    {

    blink();

    }

    }

  • 7/29/2019 How to Work With Pic

    12/35

    After completion of the code you have

    to create its hex file.

    For creating hex file

    You have to perform

    Some operation shown in nextslide.

  • 7/29/2019 How to Work With Pic

    13/35

    Compile the code

  • 7/29/2019 How to Work With Pic

    14/35

    This window appear and after that output window

    shows 0 Error 0 warnin0.g

  • 7/29/2019 How to Work With Pic

    15/35

    Click on Build all

    This option will

    create hex file of

    the code.

  • 7/29/2019 How to Work With Pic

    16/35

    This window appears

    after click on Build all

  • 7/29/2019 How to Work With Pic

    17/35

    After the proceess ouput

    window show that 0 Error 0

    Warnings

  • 7/29/2019 How to Work With Pic

    18/35

    Go to the folder where you saved

    the file you will seen a hex file.

    Burn this hex file in to microcontroller. For

    burning this hex file follow some instruction

    shown in next slide

  • 7/29/2019 How to Work With Pic

    19/35

    C t R i d

  • 7/29/2019 How to Work With Pic

    20/35

    Component Required

    PIC KickStart board

    PIC

    Programmer

    Fly Leads (connectingwires)

    Application Board

    Serial Cable

    Adaptor

  • 7/29/2019 How to Work With Pic

    21/35

    PIC KickStart board

    PIC Programmer

  • 7/29/2019 How to Work With Pic

    22/35

    Connect Serial Cable to PIC Programmer

    and PC

  • 7/29/2019 How to Work With Pic

    23/35

    Connect PIC Programmer with PIC Kick Start Board as shown in Picture

  • 7/29/2019 How to Work With Pic

    24/35

    Open PICPgm Programmer in your PC

    You can Choose Log Tab to view all acions which are performed show in next slide

  • 7/29/2019 How to Work With Pic

    25/35

    Click on Autodetect Programmer

    Log window shows the details

    Choose: File >Load HEX file

  • 7/29/2019 How to Work With Pic

    26/35

    Choose: File >Load HEX file

    Locate Your HEX File and Click to Open for loading HEX File

  • 7/29/2019 How to Work With Pic

    27/35

    Locate Your HEX File and Click to Open for loading HEX File

    After Loading Hex File Click on Program PIC

  • 7/29/2019 How to Work With Pic

    28/35

    After Loading Hex File Click on Program PIC

    No. of Operation will be Performed Automatically

    1. Erasing device

    2. Programming code memory

    These Operation Shown in next slides

  • 7/29/2019 How to Work With Pic

    29/35

    All the details also shown in Log Window

    1. Erasing device

    2. Programming code memory

    When Programmig Complete

  • 7/29/2019 How to Work With Pic

    30/35

    When Programmig Complete

    This Green Color dialouge box appear havig a massge

    Programming finishe succissfully

  • 7/29/2019 How to Work With Pic

    31/35

    Connection with Application Board

    Remove Pic Programmer from KickStart and Connect Adaptor

  • 7/29/2019 How to Work With Pic

    32/35

    Remove Pic Programmer from KickStart and Connect Adaptor

  • 7/29/2019 How to Work With Pic

    33/35

    Connect +5v and Ground

    Pin of Application Board

    with Kick Start Board as

    shown in Picture

    Red Wire shows +5v

    Black Wire Shows Ground

    Note: Power OFF the KickStart

    When you make the connection

    with any type of device

    LED should beOFF when Power

    OFF

    Power ON/OFFButton

    M k th C ti di t i t

  • 7/29/2019 How to Work With Pic

    34/35

    Make the Connection according to picture

    and Power Up the Kick Start Board

  • 7/29/2019 How to Work With Pic

    35/35

    END

    This is a basic practical contains all thing which you need regarding in PIC Programming and

    Interfacing

    Now you can interface all devices in that similar way.

    For any doubt

    Please mail. [email protected]