You are on page 1of 8

POLITEKNIK KUALA TERENGGANU

Jabatan Kejuruteraan Elektrik


Lab 1 EC501 Embedded System Applications Objectives : i. To introduce how to build a C18 project ii. To build a project of blinking led using assembly language iii. To introduce the simulation process in Embedded System Preparation : Microchips MPLAB IDE and MPLAB C18 compiler are required for this and all the lessons. It is assumed that these have already been installed as instructed in an earlier lesson. : Computer with MPLAB, Microchip C18 Compiler, Oshon PIC18 Simulator and PIC18F4550 datasheet : In this lab a project will be created that is compiled under C18. The program is essentially an empty program shell, but it illustrates the procedure for creating a new C18 project and compiling it under MPLAB.

Required Resources

Procedure

Note: It is highly recommended that each project be saved under a separate directory. This will ensure that all project related files are accessible from the same folder. 1. Create a new folder (use your name & matrix number for folder name) on computer drive (in MyDocuments) then, create a sub-folder and name it Lab1ec501. 2. Open a MPLAB session. Click on the Project Menu and select Project Wizard.

2. 3.

asalam.saad,pkt.jun2012

4.

From the Welcome dialog, click on Next to proceed.

5.

Having selected the correct device, PIC18F4550, clicks the Next button.

6. Step two of the dialog box opens, displaying the current language tool suite in effect. Make sure to select Microchip C18 Toolsuite from the dropdown menu.

asalam.saad,pkt.jun2012

7. This step requires the user to create new file for the project. Click browse button and select your personal ec501 lab1 folder and use <your name>+ec501 lab1 as a file name. Example Abdul Salam bin Saad ec501 lab1.

8. Click next button for the following step until finish button. The following screenshot is the expected result.

asalam.saad,pkt.jun2012

9.

Click New from the File tab and type the following instruction set ;politeknik kuala terengganu ;ec501 ;lab 1 - pic18f4550 led blinking #include p18f4550.inc CONFIG WDT=OFF; disable watchdog timer CONFIG LVP = OFF ; Low-Voltage programming disabled (necessary for debugging) CONFIG FOSC = INTOSCIO_EC ; Internal oscillator, port function on RA6 reg1 equ 0x28 org 0 movlw b'00001111' movwf TRISD loop bsf PORTD,6 call delay bcf PORTD,6 call delay goto loop ; delay subroutine

movlw 0x1e movwf reg1 d1 decf reg1 bnz d1 return end asalam.saad,pkt.jun2012

delay

10. Then, click Save File and use ec501 lab1.asm as a file name. Please tick the checkbox Add File To Project at the bottom.

asalam.saad,pkt.jun2012

11. Click Make button from the tab menu and select Absolute button when it appear. This will compile the assembly language code.

12.

If there is no error, the following is the expected result.

13. Open the Oshon PIC18 Simulator IDE program. Click Load Program from File menu and select ec501 lab1.HEX from our lab1 folder. Then click at the white box beside the Microcontroller box and choose PIC18F4550. Other option remains the same.

asalam.saad,pkt.jun2012

14.

From the Tools tab menu, select Microcontroller View.

15. From the Rate tab menu, select Normal. This is the simulation speed controller. Then, we can start the simulation by click the Start from the Simulation tab.

16.

Observe the simulation output.

asalam.saad,pkt.jun2012

Discussion

i. Observes the blinking speed of LED, suggest how to increase and decrease the speed of the blinking. Show the instruction in assembly language. ii. The Embedded System application need 5 LED to blink at the same time. As an Embedded System Engineer, show how the modified code to make 5 LED from any pin at PORTD to blink.

Conclusion

: write your lab1 conclusions.

asalam.saad,pkt.jun2012

You might also like