SK Getting Started in MPLAB
SK Getting Started in MPLAB
Getting Started
Opening & Programming Lesson 1 in MPLAB® IDE
Overview
This document provides a guide to opening, assembling, and programming the first of the 12
PICkit 2 Lessons in the MPLAB IDE. The steps will also apply to working with the remaining
lessons. The lessons themselves are an introduction to programming the PIC Microcontroller
Midrange architecture and the lesson text can be found in the Low Pin Count Demo Board
User’s Guide for the Starter Kit.
1. Ensure the appropriate lessons for the Low Pin Count Demo Board have been installed. The
default install directory is C:\Pk2 Lessons\LPC Demo Board for the Starter Kit.
Note: MPLAB IDE has a limitation on path length to the assembly file. If the lessons are
installed with a path longer than the default it may cause problems building in MPLAB IDE.
2. Connect the PICkit 2 Microcontroller Programmer to the PC with the included USB cable.
Plug the 6-pin header on the demo board into the PICkit 2 ICSP™ connector.
From the MPLAB IDE menu bar, select File > Open
Workspace…
5. The project workspace is opened. In the MPLAB IDE workspace, the project files are
displayed in the Project Window. This window is shown below on the left. On the right is
the Output Window, which displays the results from various associated tools, including the
MPASM assembler under the “Build” tab and the PICkit 2 under the “PICkit 2” tab (not yet
shown).
If the PICkit 2 or demo board was not plugged in, connect them and select the MPLAB IDE
menu Programmer > Connect to try connecting again.
1. Open the lesson assembly source code in an Editor by double-clicking on the file name
Hello World.asm in the Project Window. Project files may easily be opened this way
into an editor from the Project Window.
In the lesson code, the PIC MCU configuration is set so the /MCLR
pin is not active. For a MCU where /MCLR is active, it would be
necessary to select Programmer > Release from Reset before the
programmed code would begin executing.
Next Steps
Now that Lesson projects can be opened and programmed, it is recommended to go through
the 12 lessons in the Low Pin Count Demo Board User’s Guide along with the
PIC16F685/687/689/690 Data Sheet (DS41262). Chapter 2 of the Demo Board User’s
Guide gives a brief overview of the Mid-range PIC microcontroller architecture, and the
lessons are covered in Chapter 3.
IMPORTANT: When programming through the MPLAB IDE and using the Low Pin Count
Demo Board, the by default the Lessons will not recognize the demo board switch as it is
connected to the digital input on the /MCLR pin, which MPLAB IDE drives on the PICkit 2
ICSP header. To allow the button to be used, select Programmer > Settings. In the dialog,
select the “Settings” tab and check ‘3-State on “Release from Reset”’ & “Run after a
successful program”.
To find out more about developing code in the MPLAB IDE, see the MPLAB IDE Quick
Start Guide included in the “Reference” section of the PICkit Starter Kit CD-ROM. The
most recent version of this document is also available on the included MPLAB IDE
CD-ROM.