sk getting started in mplab 1

8
© 2007 Microchip Technology Inc. Page 1 of 7 PICkit™ 2 Starter Kit Getting Started Opening & Programming Lesson 1 in MPLAB ®  IDE Overview A subset of PICkit™ 2 supported PIC ®  Microcontroller devices may be programmed from directly within the MPLAB ®  IDE. For a l ist of de vices su pport ed direct ly, see the MPLAB ®  IDE Readme file for PICkit™ 2, found in C:\Program Files\Microchip\MPLAB IDE\Readmes. 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 Mi crocontroller Midrange architecture and the lesson text can be found in the  Low Pin Count Demo Board User’s Guide for the Starter Kit. Openin g Lesson 1 i n MPLA B IDE 1. Ensure the appropriate lessons for the Low Pin Count Demo Board have been install ed. The default install directory is C:\Pk2 Lessons\LPC Demo Board  for the Starter Kit.  Note: MPLAB IDE has a limitation on path length t o the assembly file. If the lessons are installed with a path longer than the default it may cause problems building in MPLAB IDE. 2. Conne ct the PICk it 2 Microcon trol ler Prog rammer to the PC wit h the includ ed USB cable . Plug the 6-pin header on the demo board into the PICkit 2 ICSP™ connector. 3. Start MPLAB IDE.

Upload: luis-navarro

Post on 30-Oct-2015

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SK Getting Started in MPLAB 1

7/15/2019 SK Getting Started in MPLAB 1

http://slidepdf.com/reader/full/sk-getting-started-in-mplab-1 1/7© 2007 Microchip Technology Inc. Page 1 of 7

PICkit™ 2 Starter Kit

Getting StartedOpening & Programming Lesson 1 in MPLAB® IDE

Overview

A subset of PICkit™ 2 supported PIC® Microcontroller devices may be programmed from

directly within the MPLAB®

IDE. For a list of devices supported directly, see the

MPLAB®

IDE Readme file for PICkit™ 2, found in C:\Program Files\Microchip\MPLABIDE\Readmes.

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.

Opening Lesson 1 in MPLAB IDE

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.

3. Start MPLAB IDE.

Page 2: SK Getting Started in MPLAB 1

7/15/2019 SK Getting Started in MPLAB 1

http://slidepdf.com/reader/full/sk-getting-started-in-mplab-1 2/7

PICkit™ 2 Starter Kit Getting Started (MPLAB)

© 2007 Microchip Technology Inc. Page 2 of 7

From the MPLAB IDE menu bar, select  File > Open

Workspace…

A “workspace” contains information on the selected

device (set by Configure > Select Device…), the active

 programmer and/or debugger, open windows and their 

location, and other IDE configuration settings. The lessonworkspace should already be set up for the PIC MCU on

the included demo board.

The workspace is also associated with a “project”, which

contains the files needed to build an application (source

code, include files, linker scripts, etc.) along with

associated language (compiler) tools and build options.

The lesson projects use the MPASM™ assembler to build

the assembly source code, and only have two files: theassembly code file (.asm) and the include file (.INC).

4. Browse into the folder for lesson 1, “Hello World” and

select the workspace file C:\Pk2 Lessons\LPC Demo Board\01 Hello

World\Hello World.mcw then click Open.

Page 3: SK Getting Started in MPLAB 1

7/15/2019 SK Getting Started in MPLAB 1

http://slidepdf.com/reader/full/sk-getting-started-in-mplab-1 3/7

PICkit™ 2 Starter Kit Getting Started (MPLAB)

© 2007 Microchip Technology Inc. Page 3 of 7

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).

(Continued on next page…)

Page 4: SK Getting Started in MPLAB 1

7/15/2019 SK Getting Started in MPLAB 1

http://slidepdf.com/reader/full/sk-getting-started-in-mplab-1 4/7

PICkit™ 2 Starter Kit Getting Started (MPLAB)

© 2007 Microchip Technology Inc. Page 4 of 7

Connecting to the PICkit 2 Microncontroller Programmer 

1. Select the PICkit 2 Microcontroller 

Programmer as the programming tool.

In the MPLAB IDE menu, select Programmer > Select Programmer >

 PICkit 2. (It may already be selected in

the workspace; reselecting it will not cause

a problem.)

The Output Window shows connection to

the PICkit 2 Microcontroller Programmer,

2. and that the target microcontroller (in this case a PIC16F690 on the Low Pin Count Demo

Board) was found.

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.

Page 5: SK Getting Started in MPLAB 1

7/15/2019 SK Getting Started in MPLAB 1

http://slidepdf.com/reader/full/sk-getting-started-in-mplab-1 5/7

PICkit™ 2 Starter Kit Getting Started (MPLAB)

© 2007 Microchip Technology Inc. Page 5 of 7

Build and Program Lesson 1 in MPLAB IDE

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.

Page 6: SK Getting Started in MPLAB 1

7/15/2019 SK Getting Started in MPLAB 1

http://slidepdf.com/reader/full/sk-getting-started-in-mplab-1 6/7

PICkit™ 2 Starter Kit Getting Started (MPLAB)

© 2007 Microchip Technology Inc. Page 6 of 7

2. Build the project assembly code into a hex file by

selecting menu Project > Build All. 

The results of the build will display in the Output

Window under the “Build” tab. If there are no errors

it will display “BUILD SUCCEEDED”

This creates a hex file in the project directory that

contains the machine instructions for the assembled

code, as well as the PIC Microcontroller 

configuration information.

The lessons set the configuration bits in the assembly

code using the assembler “__CONFIG” directive.

The bits may also be examined and changed by

selecting the menu item Configure > Configuration

 Bits… Note that each time the project is built, anychanges to the configuration bits will be wiped out

 by the settings after the “__CONFIG” directive in the

code.

Page 7: SK Getting Started in MPLAB 1

7/15/2019 SK Getting Started in MPLAB 1

http://slidepdf.com/reader/full/sk-getting-started-in-mplab-1 7/7

PICkit™ 2 Starter Kit Getting Started (MPLAB)

© 2007 Microchip Technology Inc. Page 7 of 7

3. The assembled firmware is now ready to program into the PIC

Microcontroller. The PICkit 2 was already selected and connected to

as the programmer in “Connecting to the PICkit 2 Microncontroller 

Programmer ” Step 1. To program the demo board MCU, select

 Programmer > Program.

The results of the programming operation will appear in the Output

Window. Once programming is complete, the first LED on the demo

 board will light up.

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’sGuide 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.

Microchip’s Online Discussion Groups at forum.microchip.com are a good place to ask 

questions and get information on developing with PIC MCUs. The [Development Tools] – 

Programmers sub-forum is the best place for PICkit 2 related topics.