MPLAB - Getting Started
MPLAB - Getting Started
June 2005
P.O. Box 2452 Brookeld, Wisconsin 53186 USA Sales: 262-522-6500 ext. 35 Tech Support: 262-522-6500 ext. 32
Copyright 2005 Custom Computer Services, Inc. All rights reserved worldwide. No part of this work may be reproduced or copied in any form by any means-electronic, graphic or mechanical, including photocopying, recording, taping or information retrieval systems-without written permission.
Custom Computer Services, Inc. proudly supports the Microchip brand with highly optimized C compilers and embedded software development tools.
PIC, PICmicro and MPLAB are registered trademarks of Microchip Technology Inc. in the USA and in other countries.
MPLAB IDE Installation You can download and install MPLAB IDE from Microchips website (www.microchip.com).
MPLAB IDE and additional plug-ins may be installed in any order. Use only MPLAB IDE versions 6.40 and up.
Getting Started
To start a new project, you can use either the Wizard or create it manually. To create a CCS
project using the Wizard, follow these steps:
Select the Project Menu. Choose Project Wizard to make the Project Wizard window appear. Click Next on the Welcome Page. Step One, choose PIC16F877A from the drop-down list and click Next.
PIC, PICmicro and MPLAB are registered trademarks of Microchip Technology Inc. in the USA and in other countries.
CCS, Inc.
Step Two, select CCS C Compiler for PIC12/14/16/18 from the drop-down list. Click Next. Note: If the plug-in is not listed, make sure that Show all installed tool suite is checked. If it still doesnt appear, then the CCS Plug-in may not be installed correctly. You will need to reinstall. Step Three, type the project name EX_SQW and type or select the project directory C:\Program Files\PICC\Examples. Click Next. Step Four, select le Ex_SQW.C. Click Add. Click Next. View Summary, click Finish.
Enter the following program into MPLAB IDE as EX8.c in the Exercises Directory. Go to Project>New. Name the project EX8 and choose the Exercises Directory. Click Add File to the Project in the Project menu and select the ex8.c le. Click Select Language Tool Suite and make sure CCS C Compiler for PIC12/14/16/18 is selected. Go to Congure>Select Device and select PIC16F877A, then click OK. MPLAB IDE will then choose the right CCS C Compiler and options for the device.
Debugging
Follow the steps of the MPLAB ICD 2 USB Device Driver First Time Installation document found in C:\Program Files\Microchip\MPLAB IDE\ICD2\Drivers\ddicd2.htm. This will install the MPLAB ICD 2 device drivers. Be sure to install the drivers for the MPLAB ICD 2 before connecting the device to the PC via a USB cable. Connect the MPLAB ICD 2 the PC to the target board, and power up the target board. Go to Debugger>Select Tool>MPLAB ICD 2.
CCS, Inc.
The MPLAB ICD 2 Setup Wizard will open or can be opened by going to Debugger>MPLAB ICD 2 Setup Wizard. Click Next in the Welcome Page. Step One, select USB. Step Two, check Target Has Own Power Supply. Click Next. Step Three, select MPLAB IDE Automatically Connects to the MPLAB ICD 2. Click Next. Step Four, select MPLAB ICD 2 Automatically Downloads the Required Operating System. Click Next. View Summary, click Finish. Go to Debugger>Connect. This makes sure that the MPLAB ICD 2 is ready. Click Debugger>Program. This will download the program to the target board. Once the program is downloaded you can control the operation of the program with the buttons on the toolbar. You can just run the program or step through the program one line of code at a time. You can also step into function calls. Go to View>Watch.
In the Watch Window use the drop-down box on the right to choose a and click Add Symbol. Do this for both b and c. Now step through the program using the Step Over button on the toolbar and watch the values change for a, b, and c. A breakpoint can be added to a line of code by double clicking on it. The View Menu has several other windows, which can be useful.
CCS, Inc.
Optimization
Set the optimization level for the compiler. A higher optimization level produces more efcient code.
Extra Denes
This category allows dening additional global denes that are going to be used when compiling the code. Adding a Dene: Put the dene name in the ID eld. Put the value in the Value eld. Press the + button to add the dene. Modifying a Dene: Select a denition from the list box. Change the ID eld and/or the Value eld, and click Modify. Removing a Dene: Select a denition from the list box. Press the - button to remove it. Removing all Denitions: Click Remove All to remove all the denitions in the list box.