SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
CENTRE OF DIPLOMA STUDIES



COMPUTER ADDED DESIGN LABORATORY



   LABORATORY INSTRUCTION SHEET



                        DEK 3133
Subject Code and Name
                        MICROCONTROLLER

  Experiment Code       02

                        Introduction to PIC Development Board &
   Experiment Title     Program Delay

    Course Code         DET/DEE/DEX
                         Document
                                              RPP-05
                              Reference No.                                   Page Number                01
                                                                              Edition                     1
                              Document        LABORATORY                      Revision No.                4
                              Title           PRACTICUM                       Effective Date          21/7/2010
                                                                              Amendment               21/7/2010
                                                                              Date
a)




                                              SUBJECT INFORMATION


     SUBJECT                               : DEK 3133 Microcontroller

     TOPIC                                 : Lab 2 – Introduction to PIC Development Board & Program Delay

     AIM                                   : Familiarizing with PIC Development Board and programming
                                           using software delay.


     1      OBJECTIVES 

            1.1   To understand the development concept and testing the program by using PIC Development
                  Board - PICDEV
            1.2   To learn how to download the program into the PIC chip

     2      EQUIPMENT 

            2.1   PIC Development Board – PICDEV
            2.2   MPLAB IDE Program
            2.3   MikroC.
            2.4   The PIC Development Board User manual
            2.5   Power supply 9V



     3      PART 1: Understand the development concept and testing the program by using 
            PIC Development Board ­ PICDEV 

            THEORY AND EQUATIONS
            3.1   The program development
            PIC instructions set is very simple and it has only 35 instructions. To develop a system by using PIC,
            a user must have the suitable equipment.
     Prepared by:                                                Approved by:

     Signature            :                                      Signature           :

     Name                 : Mohamad Bin Hj. Md. Som              Name                : Shamsul Bin Mohamad

     Date                 : 21-July-2010                         Date                : 21-July-2010
                   Document
                                        RPP-05
                        Reference No.                               Page Number           02
                                                                    Edition                1
                        Document        LABORATORY                  Revision No.           4
                        Title           PRACTICUM                   Effective Date     21/7/2010
                                                                    Amendment          21/7/2010
                                                                    Date
a)




     4     ATTENTION 

     4.1.1  
           4.1 Do not move any IC or device inside the board without the order from your instructor.
           4.2 When you want to download and test a PIC 16F877A, make sure the PIC is removed,
               otherwise it will damage the board.

     5     EXPERIMENT PROCEDURE 

     5.1    Communicating with the PIC Development Board – PICDEV 

     5.1.1 Connect the serial cable from the PICDEV PIC programmer serial port to PC’s COM1 
           port. 

     5.1.2 Then connect the 9V 1A power adaptor to the programmer, switch on the 
           programmer and run the MPLAB‐IDE software. 

     5.1.3 At the MPLAB‐IDE software, select Programmer > Select Programmer > PICSTART 
           Plus. Figure 1 shows the steps. 




                                                 Figure 1

     5.1.4 Enable the programmer as shown in Figure 2. It will detect the PIC programmer. If 
           MPLAB does not detect your programmer, check the cable and the COM port and try 
           again. After completing this step, you can write your own program and blow into PIC 
           chip. Figure 3 shows the box that indicates the MPLAB has detected the programmer.
    Document
                         RPP-05
         Reference No.                       Page Number         03
                                             Edition              1
         Document        LABORATORY          Revision No.         4
         Title           PRACTICUM           Effective Date   21/7/2010
                                             Amendment        21/7/2010
                                             Date
a)




                                  Figure 2




                                  Figure 3
                  Document
                                       RPP-05
                       Reference No.                               Page Number            04
                                                                   Edition                 1
                       Document        LABORATORY                  Revision No.            4
                       Title           PRACTICUM                   Effective Date      21/7/2010
                                                                   Amendment           21/7/2010
                                                                   Date
a)




     5.2   Start the program and download the program into the PIC chip 

     5.2.1 Select Project > New to make a new directory to your program. New Project box will 
           appear and you need to give a name to your project and also the directory that you 
           want to use as shown in Figure 4. 




                                                Figure 4

     5.2.2 Select View > Project  and a box that contain the file needed in your directory will 
           appear (see figure 5): 
                             -Source Files
                             -Header Files
                             -Object Files
                             -Library Files
                             -Linker Scripts
                    Document
                                           RPP-05
                         Reference No.                                          Page Number         05
                                                                                Edition              1
                         Document          LABORATORY                           Revision No.         4
                         Title             PRACTICUM                            Effective Date   21/7/2010
                                                                                Amendment        21/7/2010
                                                                                Date
a)




                                                      Figure 5

     5.2.3 Create a new file and start writing the program as shown below and save your 
           program as lab2asm.as. (The circuit related to this code is at attachment: Circuit 
           1) 
     ;**************************************************************************
     PORTA     EQU 05h    ;This tells the assembler where the address of PORTA,
     PORTB     EQU 06h    ;PORTB, STATUS and ADCON1
     TRISA     EQU 85h    ;This Tell the assembler where the address of ports Direction of,
     TRISB     EQU 86h    ;TRISA and TRISB.
     STATUS    EQU 03h
     ADCON1    EQU 9Fh    ;Address of Type of data whether Digital/Analog at PORTA
     RP1       EQU 6      ;Bit 6 and 5 for bank selection in STATUS register.
     RP0       EQU 5      ;To select bank 0, RP1 = 0 and RP0 = 0 {PORTA and PORTB}
                          ;To select bank 1, RP1 = 0 and RP0 = 1 {TRISA,TRISB & ADCON1}
                          ;To select bank 2, RP1 = 1 and RP0 = 0
                          ;To select bank 3, RP1 = 1 and RP0 = 1
                  Document
                                         RPP-05
                       Reference No.                                            Page Number         06
                                                                                Edition              1
                       Document          LABORATORY                             Revision No.         4
                       Title             PRACTICUM                              Effective Date   21/7/2010
                                                                                Amendment        21/7/2010
                                                                                Date
a)




     ;**************************************************************************
           ORG 00h       ;Assembler is now set to address 0 where the main
                         ;program is placed


     ;********************PIC SETUP********************************************
           BSF           STATUS,RP0 ;Select bank 1(To use TRISA,B and ADCON1)
           MOVLW         B'00000110'    ;Load literal value=6 into W register


           MOVWF         ADCON1         ;Move the literal value into ADCON1 register.
                                        ;Now PORTA is configured as digital input
           MOVLW         B'00000000'    ;0 is loaded into W register
           MOVWF         TRISB          ;Now all PORTB bits are set as OUTPUT


           MOVLW         B'11111111'    ;move binary value 11111111 to register W
           MOVWF         TRISA          ;Now All PORTA bits are set as INPUT
     ;*******************START OF MAIN PROGRAM*************************
           BCF           STATUS,RP0           ;Back to bank 0;(To use PORTA and PORTB)
           CLRF          PORTB                ;Set PORTB output is 0
     LOOP BTFSS          PORTA,4              ;Bit test PORTA bit 4, if SET skip next line
           GOTO          ON                   ;Goto ON if button is pressed
     OFF   BCF           PORTB,0              ;LED is OFF when button at PORTA is not pressed.
           GOTO          LOOP                 ;Go back and test the button again
     ON    BSF           PORTB,0              ;As PORTA input is 0, mean button is pressed so
                                              ;LED at PORTB bit 0 goes ON
           GOTO          LOOP                 ;Go back to LOOP and test the button again
           END                                ;End of code.




     5.2.4 Right click at Source Files and click Add Files. The Insert Files into Project box 
           will appear and choose the lab2asm.asm as shown in Figure 6. 
                  Document
                                       RPP-05
                       Reference No.                              Page Number           07
                                                                  Edition                1
                       Document        LABORATORY                 Revision No.           4
                       Title           PRACTICUM                  Effective Date     21/7/2010
                                                                  Amendment          21/7/2010
                                                                  Date
a)




                                                Figure 6

     5.2.5 Double click at lab2asm.asm and go through the program and check the types of PIC 
           chip that have been using in the program. Click Configure > Select Device then select 
           the device you want to program a shown in Figure 7. 
                  Document
                                       RPP-05
                       Reference No.                              Page Number          08
                                                                  Edition               1
                       Document        LABORATORY                 Revision No.          4
                       Title           PRACTICUM                  Effective Date    21/7/2010
                                                                  Amendment         21/7/2010
                                                                  Date
a)




                                                    Figure 7

     5.2.6 Then set the Configuration Bits according to the Microchip IC that you choose as 
           shown in Figure 8. To set, go Configure > Configuration Bits 
                   Document
                                        RPP-05
                        Reference No.                               Page Number            09
                                                                    Edition                 1
                        Document        LABORATORY                  Revision No.            4
                        Title           PRACTICUM                   Effective Date      21/7/2010
                                                                    Amendment           21/7/2010
                                                                    Date
a)




                                                Figure 8



     5.2.7 Look at the Link Setting section in the program. Then configure the PIC Development 
           with the correct jumpers setting and jumper leads. Make sure the power is off at this 
           state. 

     5.2.8 After finish setting the jumper, assemble it. Click Project > Built All. This step will 
           convert the assembly language to hex file. In no error, you can place your blank PIC 
           chip at the programmer. 

     5.2.9   Before program the chip, please do a blank check. Click on 
             programmer>Blank Check. This is to make sure that the 
             program memory inside the PIC is empty. 

     5.2.10 If the device is not blank, select Programmer>Erase. The 
            programmer will erase all the contents of program 
            memory. 

     5.2.11 When the device is blank. Click Programmer > Program 
            to blow your PIC chip. Wait until this message appears 
            “Programming/Verification completed successfully!” 

     5.2.12 After that, you can place your PIC chip at the development 
            board and test the programming running correctly. 

     5.2.13 Write your result in the report. 
                    Document
                                           RPP-05
                         Reference No.                                      Page Number              010
                                                                            Edition                   1
                         Document          LABORATORY                       Revision No.              4
                         Title             PRACTICUM                        Effective Date        21/7/2010
                                                                            Amendment             21/7/2010
                                                                            Date
a)




     5.3   Programming the PIC using MikroC and burn into PIC using PICDEV 

     5.3.1 Open Mikro C compiler as shown in figure below. 




     5.3.2 Create a new project 
            
                                                   ‐       Project wizard dialog will appear – fill the dialog
                                           with appropriate settings for your project

                                                    ‐       Enter a name for your new project

                                                    ‐       Choose project path,

                                                    ‐       Enter short text which describes your project (this
                                           is optional)

                                                    ‐       Choose the microcontroller from drop-down menu

                                                   ‐      Set the device clock by entering the value in edit
                                           box (set to 4Mhz)

            ‐   Set configuration bits (device flags) by clicking default

            ‐   After you have set up your project, click OK to continue.
                      Document
                                             RPP-05
                           Reference No.                        Page Number         011
                                                                Edition              1
                           Document          LABORATORY         Revision No.         4
                           Title             PRACTICUM          Effective Date   21/7/2010
                                                                Amendment        21/7/2010
                                                                Date
a)




     5.3.3 Write the code: 
         ‐   Compiler will create the project file and an
             accompanying source file, named same as your                            project.
             This source file will be automatically opened in                        the
             code editor, so you can write the source code.                          Picture
             below is the window of code editor.
                  Document
                                        RPP-05
                       Reference No.                                  Page Number            012
                                                                      Edition                 1
                       Document         LABORATORY                    Revision No.            4
                       Title            PRACTICUM                     Effective Date      21/7/2010
                                                                      Amendment           21/7/2010
                                                                      Date
a)




     5.3.4 Type the source code below into the code editor: 




     5.3.5 Save the file by clicking on the save icon. To compile the source code select Project­
            >Build from the drop‐down menu, or click the Build Icon  . When compiling the 
            “lab2.c” is success, the “lab2.hex” file is created. This file will be use by the MPLAB to 
            burn it into PIC device. 
                   Document
                                         RPP-05
                        Reference No.                                 Page Number         013
                                                                      Edition              1
                        Document         LABORATORY                   Revision No.         4
                        Title            PRACTICUM                    Effective Date   21/7/2010
                                                                      Amendment        21/7/2010
                                                                      Date
a)




     5.3.6 By using MPLAB, check the PIC whether it empty or not. If not empty, select 
           Programmer>erase and select Programmer>blank check to make sure the PIC is 
           blank. 

                                        5.3.7 Import the lab2.hex file into MPLAB by selecting 
                                        File>Import. 




     5.3.8 When the device is blank. Click Programmer > Program to blow your PIC chip. Wait 
           until this message appears “Programming/Verification completed successfully!” 

     5.3.9 After that, you can place your PIC chip on the development board and test the 
           programming running correctly. 

     6     Assignment 1 (See Attachment : Circuit 2) 

     6.1    By using MikroC, modify the lab2.c to SWITCH ON all the LED at PORTB when the 
            button at PORTA.F4 is pressed. When the button is not pressed all the LED at PORTB is 
            SWITCH OFF. 

     6.2    Draw a flowchart for the modified code in your report. 

     6.3 Before MPLAB burn the file into the PIC, You need to erase your PIC chip by clicking 
         Programmer > Erase Flash Device > Black Check All. 

     6.4    Then you need to blow your PIC chip by doing the same step showing before. (Pls refer 
            to item 5.2.9) 
                    Document
                                            RPP-05
                         Reference No.                                          Page Number          014
                                                                                Edition               1
                         Document           LABORATORY                          Revision No.          4
                         Title              PRACTICUM                           Effective Date    21/7/2010
                                                                                Amendment         21/7/2010
                                                                                Date
a)




     7     Program the PIC using Delay 
            Theory and Equations

     7.1      Introduction 


            CALL
            1.   A CALL command instruct the PIC to store the current location of the program
                 counter, then goes off to the address where the desired call routine exists, and
                 executes instructions until it encounters a RETURN command.
            2.   The RETURN tells the PIC to go back to where it came from and execute the next
                 instruction.
            3.   The CALL routine is placed at the front of the program as 16F84 devices require
                 CALL to be within the first area of memory.


            Timing Delay (Software Delay)
            1.   The crystal fitted to the PIC DEVELOPMENT BOARD run at 4 MHz and each
                 instruction takes 4 cycles to complete.
            2.   Therefore
                              ¼ MHz * 4 = 1μs per instruction
            3.   The CALL routine delay has the number of cycles for each section commented in and
                 the total delay stated as:
                 DELAY
                             movlw       TIMELOW             ;1 cycle
                             movwf       countlow            ;1 cycle      4 cycles
                             movlw       TIMEHIGH            ;1 cycle
                             movwf       counthigh           ;1 cycle

                 delayloop
                             decfsz      countlow            ;1 cycle       3 cycles x countlow
                             goto        delayloop           ;2 cycles
                                                                            number of times
                             movlw       TIMELOW             ;1 cycle
                             movwf       countlow            ;1 cycle
                             decfsz      counthigh           ;1 cycle
                             goto        delayloop           ;2 cycles
                             return                          ;1 cycle
                    ;total delay = 4 + ((3 cycles * countlow) + 5 Cycles)) * counthigh + 1
                       Document
                                            RPP-05
                            Reference No.                                Page Number            015
                                                                         Edition                 1
                            Document        LABORATORY                   Revision No.            4
                            Title           PRACTICUM                    Effective Date      21/7/2010
                                                                         Amendment           21/7/2010
                                                                         Date
a)




             4.    There are two routine, one is the inner routine where a register countlow is
                   decremented to zero and the outer routine where counthigh is decremented.
             5.    Two register; countlow and counthigh are loaded with the starting value (TIMELOW
                   and TIMEHIGH). Countlow is decremented by 1 tested to see if it has reached 0 and
                   if not, decrement.
             6.    When it has reaches 0, it will break the cycle and go to movlw TIMELOW and again
                   countlow will load with TIMELOW.
             7.    And then counthigh is decremented by 1, tested to see if it has reached 0 and if not go
                   to delayloop and do the step as above until counthigh reaches 0.


     8     ASSIGNMENT 2  (See Attachment : Circuit 3) 

     8.1    Using MPLAB, write the program as shown below and use the same step before. Burn the 
            program into the device and see what the result is. Then write the report about it. 
     ;****************************************************************************
     ;*   Assignment 2 Program to flash a LED using delays                       *
     ;*                                                                          *
     ;*   Operation:- This program flashes a LED with 50/50 duty cycle           *
     ;*          at intervals set by TIMEHIGH and TIMELOW                        *

     ;*************** Hardware Definitions - Specific to the PIC *****************

     PORTB        EQU 06h       ;This tells the assembler where the address of port B

     ;********************** Constants (Preset Values) ***************************
     TIMELOW   EQU     H'FF'
     TIMEHIGH EQU      H'FF'

     ;************************* Variables (Registers) ****************************
     countlow EQU      20h   ;Address of General Purpose Register
     counthigh EQU     21h
     ;*************************** Start of the Program ***************************
           ORG 0h
           goto start
     ;############################## Call Routines ##############################
     ;This call routine generates a delay
     ;*********Delay for 200ms******************
     DELAY
           movlw TIMELOW     ;1 cycle 
           movwf countlow    ;1 cycle | 4 cycles
           movlw TIMEHIGH    ;1 cycle |
           movwf counthigh   ;1 cycle /



     delayloop
          decfsz countlow              ;1 cycle 3 cycles x countlow number of times
          goto delayloop               ;2 cycles /

             movlw    TIMELOW          ;1 cycle
                   Document
                                        RPP-05
                        Reference No.                                 Page Number          016
                                                                      Edition               1
                        Document        LABORATORY                    Revision No.          4
                        Title           PRACTICUM                     Effective Date    21/7/2010
                                                                      Amendment         21/7/2010
                                                                      Date
a)




            movwf countlow         ;1 cycle | 5 cycles
            decfsz counthigh       ;1 cycle |
            goto delayloop         ;2 cycles /

            return                 ;1 cycle

     ;total delay = 4 + ((3 cycles * countlow) + 5 Cycles)) * counthigh + 1
     ;total delay = 4 + ((3 * 255 + 5)) * 255 + 1 = 196355 * 1us = 196ms ~ 200ms
     ;############################ End of Call Routines #########################

     start
     ;********************************** Setup **********************************
           clrf  PORTB       ;Clear the file PORTB (All outputs set to 0)
           movlw B'00000000' ;The value 0 is loaded into w register bits 0-7
           tris  PORTB       ;This loads w into PORTB, PORTB is now configured
                             ; as all outputs, each output is low as set above
     ;************************ Start of the Main Program ************************

     loop
            bsf      PORTB,0
            call     DELAY
            bcf      PORTB,0
            call     DELAY
            goto     loop
            END
     8.2    By using Mikro C, create a new project and type the program as shown in figure below.




     8.2    Draw a flowchart in your report for the above C code.  

     8.3    Compile the program and burn the hex file into the PIC.  
                       Document
                                              RPP-05
                            Reference No.                                    Page Number            017
                                                                             Edition                 1
                            Document          LABORATORY                     Revision No.            4
                            Title             PRACTICUM                      Effective Date      21/7/2010
                                                                             Amendment           21/7/2010
                                                                             Date
a)




     9     ASSIGNMENT 3 (See Attachment: Circuit 4) 

     9.1     By using Mikro C, modify the program to ON the LED with the sequence from LED1 
             until LED8 and then from LED8 until LED1 continuously. The delay for each LED to ON 
             and OFF is 1 second. 

     9.2     Draw a flowchart in your report. 

     9.3     Compile the program and burn the hex file to the PIC and write your observation. 



     10 REPORT PREPARATION AND SCHEMA. 

     (1)     2 persons for 1 report.


     (2)     Due date to send report is 1 weeks after lab date.


     (3)     Report schema following below requirements:
           • Lab report cover sheet for 1st page.
           • Objective, theory, equipments for the 2nd page. (5)                                   (5M)
           • Observations. (20)
              1. Observations on writing the code using assembly language and burn it into PIC     (10M)
              2. Observations on writing the code using C and burn it into PIC.                     (10M )
           • Discussions. (50)
                    1. Flow chart of assignment 1 (C code)                                          (10M )
                    2. The C code of assignment 1                                                   (10M )
                    3. Flow chart of Assignment 2 (C code)                                          (10M )
                    4. Flow chart of Assignment 3 (C code)                                          (10M )
                    5. The C code of assignment 3                                                   (10M )
           • Questions. (10)
             1. What is the maximum size (Kbyte) of program memory for PIC16F877A (5M)
             2. Draw a diagram of program memory for PIC16F877A                           (5M)
           • Conclusions. (15M)
                  Document
                                       RPP-05
                       Reference No.                               Page Number         018
                                                                   Edition              1
                       Document        LABORATORY                  Revision No.         4
                       Title           PRACTICUM                   Effective Date   21/7/2010
                                                                   Amendment        21/7/2010
                                                                   Date
a)




     Attachments:
     Circuit 1: 1 Button (PORTA bit 4 : Input) and 1 LED (PORTB bit 0 : Output)




     Circuit 2: 1 Button (PORTA bit 4 : Input) and 8 LEDs (PORTB : Output)
                  Document
                                       RPP-05
                       Reference No.                    Page Number         019
                                                        Edition              1
                       Document        LABORATORY       Revision No.         4
                       Title           PRACTICUM        Effective Date   21/7/2010
                                                        Amendment        21/7/2010
                                                        Date
a)




     Circuit 3: PIC with 1 LED (PORTB bit 0 : Output)




     Circuit 4: PIC with 8 LEDs (PORTB : Output)

Weitere ähnliche Inhalte

Andere mochten auch

Tutorial chapter 3 robotic
Tutorial chapter 3 roboticTutorial chapter 3 robotic
Tutorial chapter 3 roboticmkazree
 
Tutorial chapter 2 robotic
Tutorial chapter 2 roboticTutorial chapter 2 robotic
Tutorial chapter 2 roboticmkazree
 
Foster-seely and Ratio Detector (Discriminator )
Foster-seely and Ratio Detector (Discriminator )Foster-seely and Ratio Detector (Discriminator )
Foster-seely and Ratio Detector (Discriminator )mkazree
 
Embedded system (Chapter 2) part A
Embedded system (Chapter 2) part AEmbedded system (Chapter 2) part A
Embedded system (Chapter 2) part AIkhwan_Fakrudin
 
Coal Fired Power Plant
Coal Fired Power PlantCoal Fired Power Plant
Coal Fired Power Plantmkazree
 
Embedded system (Chapter )
Embedded system (Chapter )Embedded system (Chapter )
Embedded system (Chapter )Ikhwan_Fakrudin
 
Contoh kertas kerja program
Contoh kertas kerja programContoh kertas kerja program
Contoh kertas kerja programmkazree
 
174085193 pic-prgm-manual
174085193 pic-prgm-manual174085193 pic-prgm-manual
174085193 pic-prgm-manualArun Shan
 
Do Your Own Project in an easy way. Arduino can help you
Do Your Own Project in an easy way. Arduino can help youDo Your Own Project in an easy way. Arduino can help you
Do Your Own Project in an easy way. Arduino can help youMelanie Torres Bisbal
 
Ii20102011
Ii20102011Ii20102011
Ii20102011mkazree
 
Chapter 1 dc machines new
Chapter 1 dc machines newChapter 1 dc machines new
Chapter 1 dc machines newmkazree
 
Chapter5 dek 3143 dae 32303 9 (nota tambahan)
Chapter5 dek 3143 dae 32303 9 (nota tambahan)Chapter5 dek 3143 dae 32303 9 (nota tambahan)
Chapter5 dek 3143 dae 32303 9 (nota tambahan)mkazree
 
Chapter 3 induction machine
Chapter 3 induction machineChapter 3 induction machine
Chapter 3 induction machinemkazree
 
Performance of dc motors experiment 2
Performance of dc motors experiment 2Performance of dc motors experiment 2
Performance of dc motors experiment 2Karimi LordRamza
 
Chapter 2 transformer new
Chapter 2 transformer newChapter 2 transformer new
Chapter 2 transformer newmkazree
 
Projek rekabentuk
Projek rekabentukProjek rekabentuk
Projek rekabentukmkazree
 
Projek rekabentuk1
Projek rekabentuk1Projek rekabentuk1
Projek rekabentuk1mkazree
 
Report On Arduino
Report On  ArduinoReport On  Arduino
Report On ArduinoTongXu520
 
Chp1 68000 microprocessor copy
Chp1 68000 microprocessor   copyChp1 68000 microprocessor   copy
Chp1 68000 microprocessor copymkazree
 

Andere mochten auch (19)

Tutorial chapter 3 robotic
Tutorial chapter 3 roboticTutorial chapter 3 robotic
Tutorial chapter 3 robotic
 
Tutorial chapter 2 robotic
Tutorial chapter 2 roboticTutorial chapter 2 robotic
Tutorial chapter 2 robotic
 
Foster-seely and Ratio Detector (Discriminator )
Foster-seely and Ratio Detector (Discriminator )Foster-seely and Ratio Detector (Discriminator )
Foster-seely and Ratio Detector (Discriminator )
 
Embedded system (Chapter 2) part A
Embedded system (Chapter 2) part AEmbedded system (Chapter 2) part A
Embedded system (Chapter 2) part A
 
Coal Fired Power Plant
Coal Fired Power PlantCoal Fired Power Plant
Coal Fired Power Plant
 
Embedded system (Chapter )
Embedded system (Chapter )Embedded system (Chapter )
Embedded system (Chapter )
 
Contoh kertas kerja program
Contoh kertas kerja programContoh kertas kerja program
Contoh kertas kerja program
 
174085193 pic-prgm-manual
174085193 pic-prgm-manual174085193 pic-prgm-manual
174085193 pic-prgm-manual
 
Do Your Own Project in an easy way. Arduino can help you
Do Your Own Project in an easy way. Arduino can help youDo Your Own Project in an easy way. Arduino can help you
Do Your Own Project in an easy way. Arduino can help you
 
Ii20102011
Ii20102011Ii20102011
Ii20102011
 
Chapter 1 dc machines new
Chapter 1 dc machines newChapter 1 dc machines new
Chapter 1 dc machines new
 
Chapter5 dek 3143 dae 32303 9 (nota tambahan)
Chapter5 dek 3143 dae 32303 9 (nota tambahan)Chapter5 dek 3143 dae 32303 9 (nota tambahan)
Chapter5 dek 3143 dae 32303 9 (nota tambahan)
 
Chapter 3 induction machine
Chapter 3 induction machineChapter 3 induction machine
Chapter 3 induction machine
 
Performance of dc motors experiment 2
Performance of dc motors experiment 2Performance of dc motors experiment 2
Performance of dc motors experiment 2
 
Chapter 2 transformer new
Chapter 2 transformer newChapter 2 transformer new
Chapter 2 transformer new
 
Projek rekabentuk
Projek rekabentukProjek rekabentuk
Projek rekabentuk
 
Projek rekabentuk1
Projek rekabentuk1Projek rekabentuk1
Projek rekabentuk1
 
Report On Arduino
Report On  ArduinoReport On  Arduino
Report On Arduino
 
Chp1 68000 microprocessor copy
Chp1 68000 microprocessor   copyChp1 68000 microprocessor   copy
Chp1 68000 microprocessor copy
 

Ähnlich wie Lab 2 microcontroller

Ähnlich wie Lab 2 microcontroller (8)

Plano gerenciamento da qualidade - exemplo real (em inglês)
Plano gerenciamento da qualidade - exemplo real (em inglês)Plano gerenciamento da qualidade - exemplo real (em inglês)
Plano gerenciamento da qualidade - exemplo real (em inglês)
 
PRACE ETHZ
PRACE ETHZ PRACE ETHZ
PRACE ETHZ
 
Rfp catalogue version 1.0
Rfp catalogue version 1.0Rfp catalogue version 1.0
Rfp catalogue version 1.0
 
18CSL48.pdf
18CSL48.pdf18CSL48.pdf
18CSL48.pdf
 
Sdlc
SdlcSdlc
Sdlc
 
Soa and togaf practical guide
Soa and togaf practical guideSoa and togaf practical guide
Soa and togaf practical guide
 
[Ms cssp]
[Ms cssp][Ms cssp]
[Ms cssp]
 
Sdlc
SdlcSdlc
Sdlc
 

Mehr von mkazree

Communication Engineering - Chapter 6 - Noise
Communication Engineering - Chapter 6 - NoiseCommunication Engineering - Chapter 6 - Noise
Communication Engineering - Chapter 6 - Noisemkazree
 
Chapter 5 fm receivers
Chapter 5  fm receiversChapter 5  fm receivers
Chapter 5 fm receiversmkazree
 
The Electronic Hobby Kit
The Electronic Hobby KitThe Electronic Hobby Kit
The Electronic Hobby Kitmkazree
 
Dek3223 chapter 2 robotic
Dek3223 chapter 2 roboticDek3223 chapter 2 robotic
Dek3223 chapter 2 roboticmkazree
 
Chapter 3 am receivers
Chapter 3 am receiversChapter 3 am receivers
Chapter 3 am receiversmkazree
 
Dek3223 chapter 3 industrial robotic
Dek3223 chapter 3 industrial roboticDek3223 chapter 3 industrial robotic
Dek3223 chapter 3 industrial roboticmkazree
 
Chapter 3 am receivers
Chapter 3 am receiversChapter 3 am receivers
Chapter 3 am receiversmkazree
 
Comm introduction
Comm introductionComm introduction
Comm introductionmkazree
 
Chapter2 cont
Chapter2 contChapter2 cont
Chapter2 contmkazree
 
Chapter 2 amplitude_modulation
Chapter 2 amplitude_modulationChapter 2 amplitude_modulation
Chapter 2 amplitude_modulationmkazree
 
Chp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copyChp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copymkazree
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copymkazree
 
Chp5 pic microcontroller instruction set copy
Chp5 pic microcontroller instruction set   copyChp5 pic microcontroller instruction set   copy
Chp5 pic microcontroller instruction set copymkazree
 
Chp4 introduction to the pic microcontroller copy
Chp4 introduction to the pic microcontroller   copyChp4 introduction to the pic microcontroller   copy
Chp4 introduction to the pic microcontroller copymkazree
 
Chp3 designing bus system, memory & io copy
Chp3 designing bus system, memory & io   copyChp3 designing bus system, memory & io   copy
Chp3 designing bus system, memory & io copymkazree
 
Chp2 introduction to the 68000 microprocessor copy
Chp2 introduction to the 68000 microprocessor   copyChp2 introduction to the 68000 microprocessor   copy
Chp2 introduction to the 68000 microprocessor copymkazree
 

Mehr von mkazree (16)

Communication Engineering - Chapter 6 - Noise
Communication Engineering - Chapter 6 - NoiseCommunication Engineering - Chapter 6 - Noise
Communication Engineering - Chapter 6 - Noise
 
Chapter 5 fm receivers
Chapter 5  fm receiversChapter 5  fm receivers
Chapter 5 fm receivers
 
The Electronic Hobby Kit
The Electronic Hobby KitThe Electronic Hobby Kit
The Electronic Hobby Kit
 
Dek3223 chapter 2 robotic
Dek3223 chapter 2 roboticDek3223 chapter 2 robotic
Dek3223 chapter 2 robotic
 
Chapter 3 am receivers
Chapter 3 am receiversChapter 3 am receivers
Chapter 3 am receivers
 
Dek3223 chapter 3 industrial robotic
Dek3223 chapter 3 industrial roboticDek3223 chapter 3 industrial robotic
Dek3223 chapter 3 industrial robotic
 
Chapter 3 am receivers
Chapter 3 am receiversChapter 3 am receivers
Chapter 3 am receivers
 
Comm introduction
Comm introductionComm introduction
Comm introduction
 
Chapter2 cont
Chapter2 contChapter2 cont
Chapter2 cont
 
Chapter 2 amplitude_modulation
Chapter 2 amplitude_modulationChapter 2 amplitude_modulation
Chapter 2 amplitude_modulation
 
Chp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copyChp7 pic 16 f84 interfacing - copy
Chp7 pic 16 f84 interfacing - copy
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copy
 
Chp5 pic microcontroller instruction set copy
Chp5 pic microcontroller instruction set   copyChp5 pic microcontroller instruction set   copy
Chp5 pic microcontroller instruction set copy
 
Chp4 introduction to the pic microcontroller copy
Chp4 introduction to the pic microcontroller   copyChp4 introduction to the pic microcontroller   copy
Chp4 introduction to the pic microcontroller copy
 
Chp3 designing bus system, memory & io copy
Chp3 designing bus system, memory & io   copyChp3 designing bus system, memory & io   copy
Chp3 designing bus system, memory & io copy
 
Chp2 introduction to the 68000 microprocessor copy
Chp2 introduction to the 68000 microprocessor   copyChp2 introduction to the 68000 microprocessor   copy
Chp2 introduction to the 68000 microprocessor copy
 

Kürzlich hochgeladen

ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 

Kürzlich hochgeladen (20)

ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 

Lab 2 microcontroller

  • 1. CENTRE OF DIPLOMA STUDIES COMPUTER ADDED DESIGN LABORATORY LABORATORY INSTRUCTION SHEET DEK 3133 Subject Code and Name MICROCONTROLLER Experiment Code 02 Introduction to PIC Development Board & Experiment Title Program Delay Course Code DET/DEE/DEX
  • 2.   Document RPP-05 Reference No. Page Number 01 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) SUBJECT INFORMATION SUBJECT : DEK 3133 Microcontroller TOPIC : Lab 2 – Introduction to PIC Development Board & Program Delay AIM : Familiarizing with PIC Development Board and programming using software delay. 1 OBJECTIVES  1.1 To understand the development concept and testing the program by using PIC Development Board - PICDEV 1.2 To learn how to download the program into the PIC chip 2 EQUIPMENT  2.1 PIC Development Board – PICDEV 2.2 MPLAB IDE Program 2.3 MikroC. 2.4 The PIC Development Board User manual 2.5 Power supply 9V 3 PART 1: Understand the development concept and testing the program by using  PIC Development Board ­ PICDEV  THEORY AND EQUATIONS 3.1 The program development PIC instructions set is very simple and it has only 35 instructions. To develop a system by using PIC, a user must have the suitable equipment. Prepared by: Approved by: Signature : Signature : Name : Mohamad Bin Hj. Md. Som Name : Shamsul Bin Mohamad Date : 21-July-2010 Date : 21-July-2010
  • 3.   Document RPP-05 Reference No. Page Number 02 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) 4 ATTENTION  4.1.1   4.1 Do not move any IC or device inside the board without the order from your instructor. 4.2 When you want to download and test a PIC 16F877A, make sure the PIC is removed, otherwise it will damage the board. 5 EXPERIMENT PROCEDURE  5.1 Communicating with the PIC Development Board – PICDEV  5.1.1 Connect the serial cable from the PICDEV PIC programmer serial port to PC’s COM1  port.  5.1.2 Then connect the 9V 1A power adaptor to the programmer, switch on the  programmer and run the MPLAB‐IDE software.  5.1.3 At the MPLAB‐IDE software, select Programmer > Select Programmer > PICSTART  Plus. Figure 1 shows the steps.  Figure 1 5.1.4 Enable the programmer as shown in Figure 2. It will detect the PIC programmer. If  MPLAB does not detect your programmer, check the cable and the COM port and try  again. After completing this step, you can write your own program and blow into PIC  chip. Figure 3 shows the box that indicates the MPLAB has detected the programmer.
  • 4.   Document RPP-05 Reference No. Page Number 03 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) Figure 2 Figure 3
  • 5.   Document RPP-05 Reference No. Page Number 04 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) 5.2 Start the program and download the program into the PIC chip  5.2.1 Select Project > New to make a new directory to your program. New Project box will  appear and you need to give a name to your project and also the directory that you  want to use as shown in Figure 4.  Figure 4 5.2.2 Select View > Project  and a box that contain the file needed in your directory will  appear (see figure 5):  -Source Files -Header Files -Object Files -Library Files -Linker Scripts
  • 6.   Document RPP-05 Reference No. Page Number 05 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) Figure 5 5.2.3 Create a new file and start writing the program as shown below and save your  program as lab2asm.as. (The circuit related to this code is at attachment: Circuit  1)  ;************************************************************************** PORTA EQU 05h ;This tells the assembler where the address of PORTA, PORTB EQU 06h ;PORTB, STATUS and ADCON1 TRISA EQU 85h ;This Tell the assembler where the address of ports Direction of, TRISB EQU 86h ;TRISA and TRISB. STATUS EQU 03h ADCON1 EQU 9Fh ;Address of Type of data whether Digital/Analog at PORTA RP1 EQU 6 ;Bit 6 and 5 for bank selection in STATUS register. RP0 EQU 5 ;To select bank 0, RP1 = 0 and RP0 = 0 {PORTA and PORTB} ;To select bank 1, RP1 = 0 and RP0 = 1 {TRISA,TRISB & ADCON1} ;To select bank 2, RP1 = 1 and RP0 = 0 ;To select bank 3, RP1 = 1 and RP0 = 1
  • 7.   Document RPP-05 Reference No. Page Number 06 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) ;************************************************************************** ORG 00h ;Assembler is now set to address 0 where the main ;program is placed ;********************PIC SETUP******************************************** BSF STATUS,RP0 ;Select bank 1(To use TRISA,B and ADCON1) MOVLW B'00000110' ;Load literal value=6 into W register MOVWF ADCON1 ;Move the literal value into ADCON1 register. ;Now PORTA is configured as digital input MOVLW B'00000000' ;0 is loaded into W register MOVWF TRISB ;Now all PORTB bits are set as OUTPUT MOVLW B'11111111' ;move binary value 11111111 to register W MOVWF TRISA ;Now All PORTA bits are set as INPUT ;*******************START OF MAIN PROGRAM************************* BCF STATUS,RP0 ;Back to bank 0;(To use PORTA and PORTB) CLRF PORTB ;Set PORTB output is 0 LOOP BTFSS PORTA,4 ;Bit test PORTA bit 4, if SET skip next line GOTO ON ;Goto ON if button is pressed OFF BCF PORTB,0 ;LED is OFF when button at PORTA is not pressed. GOTO LOOP ;Go back and test the button again ON BSF PORTB,0 ;As PORTA input is 0, mean button is pressed so ;LED at PORTB bit 0 goes ON GOTO LOOP ;Go back to LOOP and test the button again END ;End of code. 5.2.4 Right click at Source Files and click Add Files. The Insert Files into Project box  will appear and choose the lab2asm.asm as shown in Figure 6. 
  • 8.   Document RPP-05 Reference No. Page Number 07 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) Figure 6 5.2.5 Double click at lab2asm.asm and go through the program and check the types of PIC  chip that have been using in the program. Click Configure > Select Device then select  the device you want to program a shown in Figure 7. 
  • 9.   Document RPP-05 Reference No. Page Number 08 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) Figure 7 5.2.6 Then set the Configuration Bits according to the Microchip IC that you choose as  shown in Figure 8. To set, go Configure > Configuration Bits 
  • 10.   Document RPP-05 Reference No. Page Number 09 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) Figure 8 5.2.7 Look at the Link Setting section in the program. Then configure the PIC Development  with the correct jumpers setting and jumper leads. Make sure the power is off at this  state.  5.2.8 After finish setting the jumper, assemble it. Click Project > Built All. This step will  convert the assembly language to hex file. In no error, you can place your blank PIC  chip at the programmer.  5.2.9 Before program the chip, please do a blank check. Click on  programmer>Blank Check. This is to make sure that the  program memory inside the PIC is empty.  5.2.10 If the device is not blank, select Programmer>Erase. The  programmer will erase all the contents of program  memory.  5.2.11 When the device is blank. Click Programmer > Program  to blow your PIC chip. Wait until this message appears  “Programming/Verification completed successfully!”  5.2.12 After that, you can place your PIC chip at the development  board and test the programming running correctly.  5.2.13 Write your result in the report. 
  • 11.   Document RPP-05 Reference No. Page Number 010 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) 5.3 Programming the PIC using MikroC and burn into PIC using PICDEV  5.3.1 Open Mikro C compiler as shown in figure below.  5.3.2 Create a new project    ‐ Project wizard dialog will appear – fill the dialog with appropriate settings for your project ‐ Enter a name for your new project ‐ Choose project path, ‐ Enter short text which describes your project (this is optional) ‐ Choose the microcontroller from drop-down menu ‐ Set the device clock by entering the value in edit box (set to 4Mhz) ‐ Set configuration bits (device flags) by clicking default ‐ After you have set up your project, click OK to continue.
  • 12.   Document RPP-05 Reference No. Page Number 011 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) 5.3.3 Write the code:  ‐ Compiler will create the project file and an accompanying source file, named same as your project. This source file will be automatically opened in the code editor, so you can write the source code. Picture below is the window of code editor.
  • 13.   Document RPP-05 Reference No. Page Number 012 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) 5.3.4 Type the source code below into the code editor:  5.3.5 Save the file by clicking on the save icon. To compile the source code select Project­ >Build from the drop‐down menu, or click the Build Icon  . When compiling the  “lab2.c” is success, the “lab2.hex” file is created. This file will be use by the MPLAB to  burn it into PIC device. 
  • 14.   Document RPP-05 Reference No. Page Number 013 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) 5.3.6 By using MPLAB, check the PIC whether it empty or not. If not empty, select  Programmer>erase and select Programmer>blank check to make sure the PIC is  blank.  5.3.7 Import the lab2.hex file into MPLAB by selecting  File>Import.  5.3.8 When the device is blank. Click Programmer > Program to blow your PIC chip. Wait  until this message appears “Programming/Verification completed successfully!”  5.3.9 After that, you can place your PIC chip on the development board and test the  programming running correctly.  6 Assignment 1 (See Attachment : Circuit 2)  6.1 By using MikroC, modify the lab2.c to SWITCH ON all the LED at PORTB when the  button at PORTA.F4 is pressed. When the button is not pressed all the LED at PORTB is  SWITCH OFF.  6.2 Draw a flowchart for the modified code in your report.  6.3 Before MPLAB burn the file into the PIC, You need to erase your PIC chip by clicking  Programmer > Erase Flash Device > Black Check All.  6.4 Then you need to blow your PIC chip by doing the same step showing before. (Pls refer  to item 5.2.9) 
  • 15.   Document RPP-05 Reference No. Page Number 014 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) 7 Program the PIC using Delay  Theory and Equations 7.1   Introduction  CALL 1. A CALL command instruct the PIC to store the current location of the program counter, then goes off to the address where the desired call routine exists, and executes instructions until it encounters a RETURN command. 2. The RETURN tells the PIC to go back to where it came from and execute the next instruction. 3. The CALL routine is placed at the front of the program as 16F84 devices require CALL to be within the first area of memory. Timing Delay (Software Delay) 1. The crystal fitted to the PIC DEVELOPMENT BOARD run at 4 MHz and each instruction takes 4 cycles to complete. 2. Therefore ¼ MHz * 4 = 1μs per instruction 3. The CALL routine delay has the number of cycles for each section commented in and the total delay stated as: DELAY movlw TIMELOW ;1 cycle movwf countlow ;1 cycle 4 cycles movlw TIMEHIGH ;1 cycle movwf counthigh ;1 cycle delayloop decfsz countlow ;1 cycle 3 cycles x countlow goto delayloop ;2 cycles number of times movlw TIMELOW ;1 cycle movwf countlow ;1 cycle decfsz counthigh ;1 cycle goto delayloop ;2 cycles return ;1 cycle ;total delay = 4 + ((3 cycles * countlow) + 5 Cycles)) * counthigh + 1
  • 16.   Document RPP-05 Reference No. Page Number 015 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) 4. There are two routine, one is the inner routine where a register countlow is decremented to zero and the outer routine where counthigh is decremented. 5. Two register; countlow and counthigh are loaded with the starting value (TIMELOW and TIMEHIGH). Countlow is decremented by 1 tested to see if it has reached 0 and if not, decrement. 6. When it has reaches 0, it will break the cycle and go to movlw TIMELOW and again countlow will load with TIMELOW. 7. And then counthigh is decremented by 1, tested to see if it has reached 0 and if not go to delayloop and do the step as above until counthigh reaches 0. 8 ASSIGNMENT 2  (See Attachment : Circuit 3)  8.1 Using MPLAB, write the program as shown below and use the same step before. Burn the  program into the device and see what the result is. Then write the report about it.  ;**************************************************************************** ;* Assignment 2 Program to flash a LED using delays * ;* * ;* Operation:- This program flashes a LED with 50/50 duty cycle * ;* at intervals set by TIMEHIGH and TIMELOW * ;*************** Hardware Definitions - Specific to the PIC ***************** PORTB EQU 06h ;This tells the assembler where the address of port B ;********************** Constants (Preset Values) *************************** TIMELOW EQU H'FF' TIMEHIGH EQU H'FF' ;************************* Variables (Registers) **************************** countlow EQU 20h ;Address of General Purpose Register counthigh EQU 21h ;*************************** Start of the Program *************************** ORG 0h goto start ;############################## Call Routines ############################## ;This call routine generates a delay ;*********Delay for 200ms****************** DELAY movlw TIMELOW ;1 cycle movwf countlow ;1 cycle | 4 cycles movlw TIMEHIGH ;1 cycle | movwf counthigh ;1 cycle / delayloop decfsz countlow ;1 cycle 3 cycles x countlow number of times goto delayloop ;2 cycles / movlw TIMELOW ;1 cycle
  • 17.   Document RPP-05 Reference No. Page Number 016 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) movwf countlow ;1 cycle | 5 cycles decfsz counthigh ;1 cycle | goto delayloop ;2 cycles / return ;1 cycle ;total delay = 4 + ((3 cycles * countlow) + 5 Cycles)) * counthigh + 1 ;total delay = 4 + ((3 * 255 + 5)) * 255 + 1 = 196355 * 1us = 196ms ~ 200ms ;############################ End of Call Routines ######################### start ;********************************** Setup ********************************** clrf PORTB ;Clear the file PORTB (All outputs set to 0) movlw B'00000000' ;The value 0 is loaded into w register bits 0-7 tris PORTB ;This loads w into PORTB, PORTB is now configured ; as all outputs, each output is low as set above ;************************ Start of the Main Program ************************ loop bsf PORTB,0 call DELAY bcf PORTB,0 call DELAY goto loop END 8.2 By using Mikro C, create a new project and type the program as shown in figure below. 8.2 Draw a flowchart in your report for the above C code.   8.3 Compile the program and burn the hex file into the PIC.  
  • 18.   Document RPP-05 Reference No. Page Number 017 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) 9 ASSIGNMENT 3 (See Attachment: Circuit 4)  9.1 By using Mikro C, modify the program to ON the LED with the sequence from LED1  until LED8 and then from LED8 until LED1 continuously. The delay for each LED to ON  and OFF is 1 second.  9.2 Draw a flowchart in your report.  9.3 Compile the program and burn the hex file to the PIC and write your observation.  10 REPORT PREPARATION AND SCHEMA.  (1) 2 persons for 1 report. (2) Due date to send report is 1 weeks after lab date. (3) Report schema following below requirements: • Lab report cover sheet for 1st page. • Objective, theory, equipments for the 2nd page. (5) (5M) • Observations. (20) 1. Observations on writing the code using assembly language and burn it into PIC (10M) 2. Observations on writing the code using C and burn it into PIC. (10M ) • Discussions. (50) 1. Flow chart of assignment 1 (C code) (10M ) 2. The C code of assignment 1 (10M ) 3. Flow chart of Assignment 2 (C code) (10M ) 4. Flow chart of Assignment 3 (C code) (10M ) 5. The C code of assignment 3 (10M ) • Questions. (10) 1. What is the maximum size (Kbyte) of program memory for PIC16F877A (5M) 2. Draw a diagram of program memory for PIC16F877A (5M) • Conclusions. (15M)
  • 19.   Document RPP-05 Reference No. Page Number 018 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) Attachments: Circuit 1: 1 Button (PORTA bit 4 : Input) and 1 LED (PORTB bit 0 : Output) Circuit 2: 1 Button (PORTA bit 4 : Input) and 8 LEDs (PORTB : Output)
  • 20.   Document RPP-05 Reference No. Page Number 019 Edition 1 Document LABORATORY Revision No. 4 Title PRACTICUM Effective Date 21/7/2010 Amendment 21/7/2010 Date a) Circuit 3: PIC with 1 LED (PORTB bit 0 : Output) Circuit 4: PIC with 8 LEDs (PORTB : Output)