Program for PIC18 Microcontroller FLASHING OF LEDS USING PIC DRIVING A BUZZER USING PIC

FLASHING OF LEDS USING PIC

AIM OF THE EXPERIMENT: To interface the LEDS to the PIC and blink LEDS continuously.

SOFTWARE REQUIRED: MPLABX IDE 2.0

HARDWARE REQUIRED: Computer System, PIC kit

COURSE OUTCOME/S:ETC/ECE 5.4.5: Design and implement microcontroller based applications

OBJECTIVES (SKILL SET / KNOWLEDGE TESTED / IMPARTED):1.      The main objective is to get familiar with the LED interfacing with PIC2.      To study the PIC kit

PROCEDURE:§  Open MPLABX IDE 2.0§  Go to File and Create a new Project§  Select Microchip Embedded and then standalone Project and Click Next§  Select the family as PIC18 Advanced 8-bit MCU§  Select the Device PIC18F4550 àClick Next§  Again click Next without selecting anything§  Select mpasm and click Next§  Give a project name and give location a folder in the E drive§  Untick set as main project and click finish§  Right click on source file, click New and select Assembler File.asm§  Give the same file name as the project and click finish§  Write the program and then click  clean and build§  If there is no errors it will show “Build Successful”§  Go to Device manager to see which port is connected to the PIC kit§  Go to PIC loader§  In that select Programà  Settingsà select COM port§  Tick only Flash Program Memory§  Press Reset on the PIC Loader Window§  Press Rest on the kit§  Then click Boot Loader mode à File àOpen§  Select Project Folderàdistàdefaultà Productionà Select Hex file à open§  Click on the “Write Device” Button§  It will show “Write Complete” if the hex file is written§  Press Reset

  •  

PROGRAM:

; Switch Positions SW21:[1 2], SW22:[2 3]

PROCESSOR PIC18F4550

#include <p18f4550.inc>

Temp1 equ 0x26                     ; equate location 26H to temp1

Temp2 equ 0x27                     ; equate location 27H to temp2

Temp3 equ 0x28                     ; equate location 28H to temp3

ORG 0x800

GOTO START

START            MOVLW 0x00

                        MOVWF  TRISB       ; TRISB is the configuration register for PortB, where the LEDs are interfaced to on the kit.

Loop1 MOVLW  0xAA

                        MOVWF  LATB        ; LATB is the Output register for PortB

                        CALL Delay1sec        ; Call delay subroutine

                        MOVLW  0x55

                        MOVWF  LATB

                        CALL Delay1sec        ; Call delay subroutine

                        GOTO Loop1

Delay1sec        MOVLW .60               ; approx. 1sec delay

                        MOVWF Temp3

dela     DECFSZ Temp1,1      ; temp1 and temp2 are loaded with maximum count of       00h and decremented then to FFH to back to 00H

                        goto dela

                        DECFSZ Temp2,1

                        goto dela

                        DECFSZ Temp3,1

                        goto dela

                        RETURN

END

RESULT: LED blinking was observed on the PIC kit.

CONCLUSION: LED Program was successfully loaded and run on PIC kit and LED blinking observed.

DRIVING A BUZZER USING PIC

AIM OF THE EXPERIMENT: To interface the Buzzer to the PIC and put it ON and OFF continuously.

SOFTWARE REQUIRED: MPLABX IDE 2.0

HARDWARE REQUIRED: Computer System, PIC kit

COURSE OUTCOME/S:ETC/ECE 5.4.5: Design and implement microcontroller based applications

OBJECTIVES (SKILL SET / KNOWLEDGE TESTED / IMPARTED):1.      The main objective is to get familiar with the buzzer interfacing with PIC2.      To study working of a buzzer

PROCEDURE:§  Open MPLABX IDE 2.0§  Go to File and Create a new Project§  Select Microchip Embedded and then standalone Project and Click Next§  Select the family as PIC18 Advanced 8-bit MCU§  Select the Device PIC18F4550 àClick Next§  Again click Next without selecting anything§  Select mpasm and click Next§  Give a project name and give location a folder in the E drive§  Untick set as main project and click finish§  Right click on source file, click New and select Assembler File.asm§  Give the same file name as the project and click finish§  Write the program and then click  clean and build§  If there is no errors it will show “Build Successful”§  Go to Device manager to see which port is connected to the PIC kit§  Go to PIC loader§  In that select Programà  Settingsà select COM port§  Tick only Flash Program Memory§  Press Reset on the PIC Loader Window§  Press Rest on the kit§  Then click Boot Loader mode à File àOpen§  Select Project Folderàdistàdefaultà Productionà Select Hex file à open§  Click on the “Write Device” Button§  It will show “Write Complete” if the hex file is written§  Press Reset

PROGRAM:

; Switch Positions SW21:[1 2], SW22:[2 3]

PROCESSOR PIC18F4550

#include <p18f4550.inc>

Temp1 equ 0x26                     ; equate location 26H to temp1

Temp2 equ 0x27                     ; equate location 27H to temp2

Temp3 equ 0x28                     ; equate location 28H to temp3

ORG 0x800

GOTO START

START            MOVLW 0x00

MOVWF  TRISA       ; TRISA is the configuration register for PortA, where the relay is interfaced to on the kit.

Loop1 MOVLW  0x20

MOVWF  LATA        ; LATA is the Output register for PortA

CALL Delay1sec        ; Call delay subroutine

MOVLW  0x00

MOVWF  LATA

CALL Delay1sec        ; Call delay subroutine

GOTO Loop1

Delay1sec        MOVLW .60               ; approx. 1sec delay

MOVWF Temp3

dela                 DECFSZ Temp1,1

goto dela

DECFSZ Temp2,1

goto dela

DECFSZ Temp3,1

goto dela

RETURN

END

RESULT: Buzzer Operation was observed on the PIC kit.

CONCLUSION: Buzzer Program was successfully loaded and run on PIC kit and Buzzer operation observed.

Also check – Programs for 8051 microcontroller on keil uvision 3 / BLINKING OF LEDS USING 8051 kit /DISPLAY OF DIGITS ON THE SEVEN SEGMENT DISPLAY USING 8051

Scroll to Top