Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Microchip MPLAB IDE User Guide

Fairuz Abdullah
1. What is MPLAB IDE

It is a software develop by Microchip to help programmer develop software for application using their product. It consist of a text editor, a simulator, a cross assembler that support all microcontrollers and digital signal processor and a device driver made by Microchip.
2. Getting Started

To start, select Start Menu > Programs > Microchip > MPLAB IDE v8.10 > MPLAB IDE. Or you can simply click on the icon (icon g) on your desktop. A splash screen appears for a while then followed by this MPLAB IDE desktop (Figure 1).

Figure 1: MPLAB IDE Desktop

3.

Using MPLAB

To start using MPLAB you have to create a new project. Here are the steps to do such that. 1. Create a new project 2. Enter source les 3. Add source les into the project 4. complile and build the executable code 5. debug the project using the simulator, or ICD2, or ICE
3.A. Creating simple project

Before creating new project, you must congure the project and select the target device. To do so, go to Congure > settings menu and choose the Project tab. Make sure the setting follows what is shown in Figure 2. Then click OK.

Figure 2: Congure the project

Next is to select the right device. As an example, you will use PIC18F452. To select device go to Congure > Select Devices... and the selection as shown in Figure 3. For this course, we will use PIC18F452 throughout as the device. Make sure also the MPLAB SIM bubble is green. Click OK when you have make the necessary change. However, by default, all this setting is already at what you want. Meaning you dont have to make any change. You can just open MPLAB IDE and straight away use it.

Figure 3: Select device dialog

Now it is time to create new project. Selece Project > New and the dialog box (Figure 4) opens. Type a le name, whatever you like and select a place to save the le. Once nished, click OK.

Figure 4: New project dialog

Once you have created new project, you need to set language tools location so that MPLAB can assemble you le correctly. To do so, select Project > Set Language Tools Locations... menu. Once a window shown in Figure 5 opens, select MPASM Assembler as depicted in the gure. Next is to select the language tool. Click Project > Select Language Tools... and windows depicted in Figure 6 opens. Make sure you select MPASM Toolsuite. Then click OK.

Figure 5: Setting language tool location dialog

Figure 6: Dialog for selecting language tool suite

Now you can create new le. Select File > New. Type you program and save it with extension .asm. Once you nished typing your program and save, you have to include the assembly le in the project. To do that, click Project > Add les to project... and select the assembly le you created previously as depicted in Figure 7.

Figure 7: Select input le dialog

Select View > Project to open windows like in Figure 8. Make sure under Source Files folder, the assembly le name is listed. This mean that the le is already included in the project.

Figure 8: Project pane

Next is to build the assembly le. Select Project > Build All or press Ctrl+F10. The assembly will do its work now and if there is any error, it will appear in output window. Double click on the error list and MPLAB will show the error location in your assembly le. Troubleshoot the program and rectify the error before you save and build again. Once you nished building the assembly le, it is time to simulate. Select Debugger > Select Tool > MPLAB SIM. Once you do that, MPLAB SIM text will appear in status bar as shown in Figure 9 (circled in red).

Figure 9: MPLAB IDE window status change after selecting SIM

On top right corner of the tool bar, you can see a set of new icons appear. Click reset, yellow colored icon and this will make the simulator reset and go to the start on the program. In the assembly le window, you will see a green arrow appear at the start of you program as shown in Figure 10.

Figure 10: Source code window after Reset

This indicates that the simulator (processor) is ready to run the program. To go one step or run one step at a time, you can press F7 and you will notice that the green arrow jump to next instruction, which may be next line or few lines after. When you move your cursor over a variable in the source code, MPLAB will display the current value the variable hold as depicted in Figure 11.

10

Figure 11: Mouse over variable count

If you want to watch multiple variables and registers at the same time, you can select View > Watch and it will open the window shown in Figure 12a where you can type the symbol name or variable name or the address you want to watch. For example, you want to watch WREG, just type WREG in symbol name and press enter. When you run the program, any changes in the variable and register will be marked by red-coloured numbers.

11

(a) Watch window for tutor1

(b) Watch window after step through the program

Figure 12: Watch window

12

You might also like