Mplab X User Guide
Mplab X User Guide
User’s Guide
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
QUALITY MANAGEMENT SYSTEM Microchip received ISO/TS-16949:2009 certification for its worldwide
CERTIFIED BY DNV headquarters, design and wafer fabrication facilities in Chandler and
Tempe, Arizona; Gresham, Oregon and design centers in California
and India. The Company’s quality system processes and procedures
== ISO/TS 16949 == are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping
devices, Serial EEPROMs, microperipherals, nonvolatile memory and
analog products. In addition, Microchip’s quality system for the design
and manufacture of development systems is ISO 9001:2000 certified.
Preface ........................................................................................................................... 7
Chapter 1. What is MPLAB X IDE?
1.1 Introduction ................................................................................................... 11
1.2 An Overview of Embedded Systems ............................................................ 12
1.3 The Development Cycle ............................................................................... 19
1.4 Project Manager ........................................................................................... 20
1.5 Language Tools ............................................................................................ 21
1.6 Target Debugging ......................................................................................... 22
1.7 Device Programming .................................................................................... 23
1.8 Components of MPLAB X IDE ..................................................................... 24
1.9 MPLAB X IDE Online Help ........................................................................... 24
1.10 Other MPLAB X IDE Documentation .......................................................... 25
1.11 Web Site ..................................................................................................... 26
1.12 MPLAB X IDE Updates .............................................................................. 26
Chapter 2. Before You Begin
2.1 Introduction ................................................................................................... 27
2.2 Install JRE and MPLAB X IDE ...................................................................... 27
2.3 Install the USB Device Drivers (For Hardware Tools) .................................. 28
2.4 Connect to a Target (For Hardware Tools) .................................................. 31
2.5 Install the Language Tools ........................................................................... 31
2.6 Launch the IDE ............................................................................................. 32
2.7 Launch Multiple Instances of the IDE ........................................................... 35
Chapter 3. Tutorial
3.1 Introduction ................................................................................................... 37
3.2 Setting Up the Hardware and Software ........................................................ 38
3.3 Creating and Setting Up a Project ................................................................ 39
3.4 Running and Debugging Code ..................................................................... 55
Chapter 4. Basic Tasks
4.1 Introduction ................................................................................................... 63
4.2 Working with MPLAB X IDE Projects ........................................................... 63
4.3 Create a New Project ................................................................................... 64
4.4 View Changes to the Desktop ...................................................................... 72
4.5 View or Make Changes to Project Properties ............................................... 73
4.6 Set Options for Debugger, Programmer or Language Tools ........................ 74
4.7 Set Language Tool Locations ....................................................................... 76
Chapter 7. Editor
7.1 Introduction ................................................................................................. 133
7.2 Editor Usage ............................................................................................... 133
7.3 Editor Options ............................................................................................. 133
7.4 Editor Features of Note .............................................................................. 135
7.5 Code Folding .............................................................................................. 136
7.6 C Code Refactoring .................................................................................... 139
Chapter 8. Troubleshooting
8.1 Introduction ................................................................................................. 141
8.2 USB Driver Installation Issues .................................................................... 141
8.3 Cross-Platform Issues ................................................................................ 141
8.4 MPLAB X IDE Issues ................................................................................. 142
8.5 NetBeans Platform Issues .......................................................................... 143
8.6 Errors .......................................................................................................... 143
8.7 Forums ....................................................................................................... 144
Chapter 9. MPLAB X IDE vs. MPLAB IDE v8
9.1 Introduction ................................................................................................. 145
9.2 Major Differences ....................................................................................... 145
9.3 Menu Differences ....................................................................................... 148
9.4 Tool Support Differences ............................................................................ 154
Chapter 10. Desktop Reference
10.1 Introduction ............................................................................................... 155
10.2 Menus ....................................................................................................... 156
10.3 Toolbars ................................................................................................... 165
10.4 Status Bar ................................................................................................. 167
10.5 Grayed-out or Missing Items and Buttons ................................................ 167
Chapter 11. MPLAB X IDE Windows and Dialogs
11.1 Introduction ............................................................................................... 169
11.2 MPLAB X IDE Windows with Related Menus and Dialogs ....................... 169
11.3 MPLAB X IDE Wizards ............................................................................. 179
Chapter 12. NetBeans Windows and Dialogs
12.1 Introduction ............................................................................................... 181
12.2 NetBeans Specific Windows and Window Menus .................................... 181
12.3 NetBeans Specific Dialogs ....................................................................... 181
Chapter 13. Project Files and Folders
13.1 Introduction ............................................................................................... 183
13.2 Projects Window View .............................................................................. 183
13.3 Files Window View ................................................................................... 184
13.4 Importing an MPLAB IDE v8 Project – Relative Paths ............................. 186
13.5 Moving a Project ....................................................................................... 186
13.6 Building a Project Outside of MPLAB X IDE ............................................ 186
INTRODUCTION
This chapter contains general information that will be useful to know before using
MPLAB® X IDE. Items discussed include:
• Document Layout
• Conventions Used
• Recommended Reading
DOCUMENT LAYOUT
This document describes how to use the MPLAB X IDE. The manual layout is as
follows:
• Chapter 1. “What is MPLAB X IDE?” – An overview of what the MPLAB X IDE is
and where help can be found.
• Chapter 2. “Before You Begin” – Describes how to install USB drivers for
hardware tools and language toolsuites for compiling/assembling code.
• Chapter 3. “Tutorial” – Provides step-by-step descriptions of features for using
MPLAB X IDE.
• Chapter 4. “Basic Tasks” – Describes how to use the basic features of MPLAB
X IDE. It is similar to the Tutorial chapter but with more detail.
• Chapter 5. “Additional Tasks” – Describes how to use additional features of
MPLAB X IDE, i.e., importing MPLAB IDE v8 projects or using the stopwatch.
• Chapter 6. “Advanced Tasks” – Describes how to use the advanced features of
MPLAB X IDE, i.e., working with multiple projects and project configurations.
• Chapter 8. “Troubleshooting” – Discusses troubleshooting techniques.
• Chapter 9. “MPLAB X IDE vs. MPLAB IDE v8” – Explains the major, feature,
menu, and tool support differences between MPLAB X IDE and MPLAB IDE v8.
• Chapter 10. “Desktop Reference” – Provides a reference to MPLAB X IDE
desktop items, including menus, toolbars, and the status bar.
• Chapter 11. “MPLAB X IDE Windows and Dialogs” – References NetBeans™
windows and dialogs and discusses the windows and dialogs that are unique to
MPLAB X IDE.
• Chapter 13. “Project Files and Folders” – Explains the folder structure and
locations of project files.
• Chapter 14. “Configuration Settings Summary” – Shows how to set Configura-
tion bits in code for supported language tools. This is required in MPLAB X IDE as
the Configurations Settings window only temporarily sets the bits for debug.
CONVENTIONS USED
The following conventions may appear in this documentation:
DOCUMENTATION CONVENTIONS
Description Represents Examples
Arial font:
Italic Referenced books MPLAB® IDE User’s Guide
Emphasized text ...is the only compiler...
Initial caps A window the Output window
A dialog the Settings dialog
A menu selection select Enable Programmer
Quotes A field name in a window or “Save project before build”
dialog, or an individual menu
item
Underlined, italic with right A path in text File>Save
angle bracket between text
Right angle bracket between A path in a table cell File>Save
text
Bold characters A dialog button Click OK
A tab Click the Power tab
Text in angle brackets < > A key on the keyboard Press <Enter>, <F1>
Courier New font:
Plain Sample source code #define START
Filenames autoexec.bat
File paths c:\mcc18\h
Keywords _asm, _endasm, static
Command-line options -Opa+, -Opa-
Bit values 0, 1
Constants 0xFF,’A’
Italic A variable argument file.o, where file can be
any valid filename
Square brackets [ ] Optional arguments mpasmwin [options]
file [options]
Curly brackets and pipe Choice of mutually exclusive errorlevel {0|1}
character: { | } arguments; an OR selection
Ellipses... Replaces repeated text var_name [,
var_name...]
Represents code supplied by void main (void)
user { ...
}
RECOMMENDED READING
This user’s guide describes how to use MPLAB X IDE. Other useful documents are
listed below. The following Microchip documents are available and recommended as
supplemental reference resources.
Readme for MPLAB IDE
For the latest information on using MPLAB X IDE, read the release notes under the
“Release Notes and Support Documentation” heading on the Start page. The release
notes contain update information and known issues that may not be included in this
user’s guide.
Readme Files
For the latest information on using other tools, read the tool-specific Readme files in
the Readmes subdirectory of the MPLAB X IDE installation directory. The Readme files
contain update information and known issues that may not be included in this user’s
guide.
Online Help Files
Comprehensive help files are available for MPLAB X IDE, MPLAB Editor and MPLAB
SIM simulator. Tutorials, functional descriptions and reference material are included.
Device Data Sheets and Family Reference Manuals
See the Microchip web site, http://www.microchip.com, for complete and updated ver-
sions of PIC® MCU and dsPIC® DSC data sheets and related device family reference
manuals.
FIGURE 1-1: PIC® MCU DATA SHEET – PROGRAM MEMORY AND STACK
PC<12:0>
CALL, RETURN 13
RETFIE, RETLW
Stack Level 1
Stack Level 2
Stack Level 8
Access 0-FFFh
1FFFh
The microcontroller also has data or “file register” memory. This memory consists of
Special Function Registers (SFRs) and General Purpose Registers (GPRs) as shown
in Figure 1-3. SFRs are registers used by the CPU and peripheral functions for control-
ling the desired operation of the device. GPRs are for storage of variables that the pro-
gram will need for computation or temporary storage. Some microcontrollers have
additional data EEPROM memory. As with program memory, device data sheets
describe the details of data memory use and operation.
General General
General Purpose Purpose
Purpose Register Register
Register
80 Bytes 80 Bytes
96 Bytes EFh 16Fh
accesses F0h accesses 170h accesses 1F0h
7Fh 70h-7Fh FFh 70h-7Fh 17Fh 70h-7Fh 1FFh
Bank 0 Bank 1 Bank 2 Bank 3
In order to design such a system, it must be decided which peripherals are needed for
an application.
Peripherals on the PIC MCU called “timers” accurately measure signal events and gen-
erate and capture communications signals, produce precise waveforms, even auto-
matically reset the microcontroller if it gets “hung” or lost due to a power glitch or
hardware malfunction.
Other peripherals detect if the external power is dipping below dangerous levels so the
microcontroller can store critical information and safely shut down before power is
completely lost.
The peripherals and the amount of memory an application needs to run a program
largely determines which PIC MCU to use. Other factors might include the power con-
sumed by the microcontroller and its “form factor,” i.e., the size and characteristics of
the physical package that must reside on the target design.
D1 D
2
1
B
n
CH x 45
A
c
A2
L
A1
(F)
T1OSI 1 2 3 4 5 6 7 8
TSCS
OSC1
Internal TOSC
System
Clock TDLY
SCS
(OSCCON<0>)
Program PC PC + 2 PC + 4
Counter
2. Compile, assemble and link the software using the assembler and/or compiler
and linker to convert your code into “ones and zeroes” – machine code for the
PIC MCUs. This machine code will eventually become the firmware (the code
programmed into the microcontroller).
3. Test your code. Usually a complex program does not work exactly the way
imagined, and “bugs” need to be removed from the design to get proper results.
The debugger allows you to see the “ones and zeroes” execute, related to the
source code you wrote, with the symbols and function names from your program.
Debugging allows you to experiment with your code to see the value of variables
at various points in the program, and to do “what if” checks, changing variable
values and stepping through routines.
4. “Burn” the code into a microcontroller and verify that it executes correctly in the
finished application.
Of course, each of these steps can be quite complex. The important thing is to concen-
trate on the details of your own design, while relying upon MPLAB X IDE and its com-
ponents to get through each step without continuously encountering new learning
curves.
Compile/Assemble/
Link Code Download Code to
Debugger
Edit/Create/Design Analyze/Debug
Source Code Code
MPLAB X IDE is a “wrapper” that coordinates all the tools from a single graphical user
interface, usually automatically. For instance, once code is written, it can be converted
to executable instructions and downloaded into a microcontroller to see how it works.
In this process multiple tools are needed: an editor to write the code, a project manager
to organize files and settings, a compiler or assembler to convert the source code to
machine code and some sort of hardware or software that either connects to a target
microcontroller or simulates the operation of a microcontroller.
Source
Files
Individual
Build
Options
Object
File
Libraries
Assembler Compiler
Linker
Script
Linker
Debug Executable
File File
The source files are text files that are written conforming to the rules of the assembler
or compiler. The assembler and compiler convert them into intermediate modules of
machine code and placeholders for references to functions and data storage.
The linker resolves these placeholders and combines all the modules into a file of exe-
cutable machine code. The linker also produces a debug file which allows MPLAB X
IDE to relate the executing machine codes back to the source files.
A text editor is used to write the code. It recognizes the constructs in the text and uses
color coding to identify various elements, such as instruction mnemonics, C language
constructs and comments. The editor supports operations commonly used in writing
source code. After the code is written, the editor works with the other tools to display
code execution in the debugger. Breakpoints (which stop or “break” the execution of
code) can be set in the editor, and the values of variables can be inspected by hovering
the mouse pointer over the variable name. Names of variables can be dragged from
source text windows and then dropped into a Watch window where their changing
values can be watched after each breakpoint or during code execution.
The size of programs for computers typically extends into the megabytes for moder-
ately complex programs. The size of simple embedded systems programs may be as
small as a thousand bytes or less. A medium size embedded system might need 32K
or 64K of code for relatively complex functions. Some embedded systems use
megabytes of storage for large tables, user text messages or data logging.
On the Start Page, there are 3 tabs with links. The items on each tab are defined below.
2.7.1 Windows OS
Create a shortcut with the –-userdir option. For example:
1. Right click on the desktop and select New>Shortcut.
2. Browse to the installed MPLAB X IDE executable, by default at:
"C:\Program Files\Microchip\MPLABX\mplab_ide\bin\
mplab_ide.exe"
3. At the end of the line, enter:
--userdir "C:\Documents and Settings\MyFiles\
ApplicationData\.mplab_ide\dev\beta7Instance2"
4. Click OK.
2.7.2 Linux OS
The installed version run without any parameters (clicking on the desktop icon) will run
with a user directory of $(HOME)/.mplab_ide. To change the user directory, run the
$InstallationDir/mplab_ide/bin/mplab_ide shell script passing the argu-
ment --userid anydir. For example, to run MPLAB X IDE in two different instances:
$ /opt/microchip/mplabx/mplab_ide/bin/mplab_ide --userdir ~/.anydir1 &
$ /opt/microchip/mplabx/mplab_ide/bin/mplab_ide --userdir ~/.anydir2 &
You can create desktop icons that have the user ID embedded too.
2.7.3 Mac OS
Open a Shell window and type the following command line to execute your installation
of MPLAB X IDE (example: Beta 7.12) in the alternate user directory:
$/bin/sh /Applications/microchip/mplabx/712/mplab_ide.app/Contents/
Resources/mplab_ide/bin/mplab_ide --userdir "${HOME}/Library/
Application Support/mplab_ide/dev/beta7.12”
STEP 1
Step 1 asks you to choose a project category.
This is a NetBeans dialog. To work with Microchip products, choose “Microchip
Embedded”.
Secondly, choose a project type. For this tutorial choose “Stand-alone Project”.
Click Next> to move to the next dialog.
STEP 3
Step 3 only appears if a header is available for your selected device. Since there is no
header for the PIC32MX360F512L device, MPLAB X IDE knows to skip this step.
For some tools, there are two lights next to the tool name, where the first light is the
left-most light and the second light is to the right of the first.
Light No. Debug Tools Simulator
1 Debugger Support Core (Instruction Set) Support
2 Programmer Support Peripheral Support
For the hardware tools, you will notice that a serial number (SN) is specified below any
tool that is connected to your computer. This allows you to select from several
connected hardware tools.
Select your tool and then click Next>.
Step 5 only appears if MPLAB REAL ICE in-circuit emulator is selected as the tool.
For the MPLAB REAL ICE in-circuit emulator, you may specify a plug-in board to use.
A plug-in board is the circuit board that is inserted into the emulator’s driver board slot.
Since the Explorer 16 board works with either the Standard or High-Speed Communi-
cations driver boards, leave the “Supported Plugin Board” as “None”.
Select your tool and then click Next>.
Step 6 selects the language tool, either a C compiler or assembler. Again, the colored
circle (light) in front of the compiler name signifies the device support level. Mouse over
for text.
The version and installation location of a language tool is displayed beneath that tool.
This allows you to select from several installed language tools.
Select your tool and then click Next>.
If you double click on any file name in the File pane, the related file will open in the
Editor pane under a tab next to the Start Page. To close the tab, click on the “x” next to
the file name.
Right click on the project name in the File pane, Projects window, to view the pop-up
(context) menu. Do the same for the project’s subfolders.
/*
** Message in a bottle
**
** Explorer16 version (long delays)
**
** Thanks to Lucio DiJasio for letting us use this example.
**
** Run this example on Explorer-16 board with PIC32MX PIM.
** Hold the board vertically from the PICtail connector size
** and wave the board back-and-forth to see message "HELLO" on LEDs
*/
#include <p32xxxx.h>
// Config settings
// POSCMOD = HS, FNOSC = PRIPLL, FWDTEN = OFF
// PLLIDIV = DIV_2, PLLMUL = MUL_16
// PBDIV = 8 (default)
// Main clock = 8MHz /2 * 16 = 64MHz
// Peripheral clock = 64MHz /8 = 8MHz
// 3.2 initialization
TRISA = 0; // all PORTA as output
T1CON = 0x8030; // TMR1 on, prescale 1:256 PB
Build Icon
Build progress will be visible in the Output window (lower right hand corner of the desk-
top.) For this tutorial, the code should build successfully.
The lights on the demo board should be flickering. Wave the board back and forth to
see the word, “Hello”.
Run progress will be visible in the Output window as well.
Use the Hold in Reset button to toggle between device Reset and running.
You can add a “Run Project” icon to the toolbar if you wish
(View>Toolbars>Customize).
Run Icon
Debug Run the tutorial program again. The program will halt at the breakpoint. Hover
over the bitmap[] variable to see its values.
Run Icon
Note: Not all programming functions are in the MPLAB X IDE. For additional pro-
gramming support, see the MPLAB IPE included with the MPLAB X IDE
installation.
1. Create a New Project by using the New Project wizard. Then View Changes
to the Desktop.
Create and Build a 2. View or Make Changes to Project Properties in the Project Properties
Project dialog. Also Set Options for Debugger, Programmer or Language Tools in
the same dialog.
3. Set Language Tool Locations and Set Other Tool Options in the Tools
Options dialog.
4. Create a New File to add to your project or Add Existing Files to a Project.
Enter or edit your application code to the File window.
5. Discover other features for Editor Usage.
6. Add and Set Up Library and Object Files.
7. Set File Properties to keep or exclude individual files from the build.
8. Set Build Properties for pre- and post-build steps and loading an alternative
hex file on build.
9. Build a Project.
Program a Device
Note: You can select a header later (if one is available) using the Project Proper-
ties window.
For some tools, there are two lights next to the tool name, where the first light is the
left-most light and the second light is to the right of the first.
Light No. Debug Tools Simulator
1 Debugger Support Core (Instruction Set) Support
2 Programmer Support Peripheral Support
For the hardware tools, you will notice that a serial number (SN) is specified below any
tool that is connected to your computer. This allows you to select from several
connected hardware tools.
Select your tool and then click Next>.
Note: If you do not see your language tool listed, look under Tools>Options
(mplab_ide>Preferences for Mac OSX), Embedded button, Build Tools
tab, to ensure MPLAB X IDE can find the tool. If your tool is listed, then your
project device may not be supported by your tool. Consider selecting or
installing another language tool that supports the device.
For more on each language tool, consult the language tool documentation.
For third party language toolchains (CCS, etc.), see the “Readme for Third Party
Tools.htm” file on the Start Page, “Release Notes and Support Documentation”.
The file will appear in the File pane under the project specified and a tab with the file’s
name will appear in the Editor pane. Enter your file content under this tab. The text in
the file will have syntax color based on its file type.
Hold in Reset
3. For simulators, the application will simply execute with no debugging capability.
Run progress will be visible in the Output window.
MPLAB X IDE operation connects to the hardware tool at runtime (Run or Debug Run).
To always be connected to the hardware tool (like MPLAB IDE v8), see Tools>Options
(mplab_ide>Preferences for Mac OSX), Embedded button, Generic Settings tab,
“Maintain active connection to hardware tool” checkbox.
For more on programming a device, see Section 4.24 “Program a Device”.
Debug Project
3. Once a Memory window is open, you may further modify your view by selecting
the type of memory and memory format in drop-down boxes.
TABLE 4-7:MEMORY WINDOW OPTIONS – 8- AND 16-BIT DEVICES
Option Value Description
Memory File Registers All file register memory on the device
Program All program memory on the device
SFR All Special Function Registers (SFRs)
Configuration Bits All Configuration registers
EEPROM All EEPROM memory
User ID User ID memory
Format Data Data Memory (RAM)
Code Program Memory (ROM)
TABLE 4-8:MEMORY WINDOW OPTIONS – 32-BIT DEVICES
Option Value Description
Memory RAM Memory All RAM memory on the device
Flash Memory All Flash memory on the device
Peripheral All Special Function Registers (SFRs)
Configuration Bits All Configuration registers
CPU Memory All CPU memory
Memory All memory
User ID User ID memory
Format Data Data Memory (RAM)
Code Program Memory (ROM)
Debug Reads
For most devices, you must halt your program (Finish Debugger Session) before you
can read device memory. For some devices, you can read while in debug mode (Debug
Read). You will know that this is available as the “Read Device Memory” icon will not
be grayed-out when you are debugging.
Currently, MPLAB REAL ICE in-circuit emulator and MPLAB ICD 3 support Debug
Reads.
Debug Reads are done at target oscillator speeds so if the target is running very slow,
a read may take a long time. You can force a fast ICSP read by finishing the debug ses-
sion and then doing a read since ICSP reads will always be done when not in a debug
session.
Note: Not all programming functions are in the MPLAB X IDE. For additional programming support,
see the MPLAB IPE included with the MPLAB X IDE installation.
Add Functionality
* To see this feature, refer to the Start Page, My MPLAB X IDE tab, “Extend MPLAB”
section, “Selecting Simple or Full-Featured Menus” topic.
Note: To program a prebuilt image into a device, you will click the “Make and Pro-
gram Device” button even though it will only program the device (no make).
There are two ways to open this wizard – the Start Page option and the New Project
option.
To begin, open the New Project wizard by doing one of the following:
• On the Start Page, click on the Learn & Discover tab, “Dive In” section, “Create
New Project” link.
• File>New Project (or Ctrl+Shift+N)
A wizard will launch to guide you through new project set up. Click Next> to move to
the next step.
• Step 1. Choose Project: Select the “Microchip Embedded” category and choose
from the project type “Library Project”.
• Step 2. Select Device: Select the device you will be using in your application
from the “Device” drop-down list. To narrow your selection list, chose a Family
first.
• Step 3. Select Header: This step will appear if a header is available for your
selected device. To determine if a header is required for debug or if your device
has on-board debug circuitry, consult the Header Specification (DS51292 or
online help). Then choose whether or not to use a header.
• Step 4. Select Tool: Select the development tool you will be using to develop
your application from the list.
The level of tool support for the selected device will be displayed next to the tool
name. That is, green for full support, yellow for beta support and red for no
support yet.
• Step 5. Select Compiler: Select the language tool (compiler) you will be using to
develop your application from the list.
The level of tool support for the selected device will be displayed next to the tool
name. That is, green for full support, yellow for beta support and red for no
support.
• Step 6. Select Project Name and Folder: Select a name and location for your
new project. You may browse to a location.
The new project will open in the Project window.
HW Tool SN#xxxx was selected in the project configuration, but does not appear to
be connected. HW Tool SN#yyyy is currently connected. Would you like to use this
HW Tool instead?
OK Cancel
You may also plug in two or more hardware tools and switch between them in the
Project Properties dialog (File>Project Properties).
To switch between different versions of compiler toolchains (language tools), again use
the Project Properties dialog.
The stopwatch has the following icons on the left side of the window:
Icon Description
Properties Set stopwatch properties. Select one current breakpoint or
trigger to start the stopwatch and one to stop the stopwatch.
Reset Stopwatch on Run Reset the stopwatch time to zero on the start of a run.
Clear History Clear the stopwatch window.
Clear Stopwatch (Simulator Only) Reset the stopwatch after you reset the
device.
For hardware debug tools, the connection is only active during a Debug
Run, Run, or programming. Otherwise it is inactive. To keep the tool con-
nection active at all times, go to Tools>Options (mplab_ide>Preferences for
Mac OSX), Embedded button, Generic Settings tab, and check “Maintain
active connection to hardware tool”.
Click the “Refresh Debug Tool Status” button to see hardware debug tool
firmware versions and current voltage levels.
Refresh debug tool status. Click this to see hardware debug tool details.
Get device data sheet from Microchip web site. Click to either open a saved, local
data sheet or open a browser to go to the Microchip web site to search for a data
sheet.
Note: To see this feature, refer to the Start Page, My MPLAB X IDE tab, “Extend
MPLAB” section, “Selecting Simple or Full-Featured Menus” topic.
Note: To see this feature, refer to the Start Page, My MPLAB X IDE tab, “Extend
MPLAB” section, “Selecting Simple or Full-Featured Menus” topic.
Note: The higher the logging level, the more data is collected, but the slower your
application will run.
Note: To see this feature, refer to the Start Page, My MPLAB IDE tab, “Extend
MPLAB” section, “Selecting Simple or Full-Featured Menus” topic.
Refactoring is the use of small transformations to restructure code without changing
any program behavior. Just as you factor an expression to make it easier to understand
or modify, you refactor code to make it easier to read, simpler to understand, and faster
to update. And just as a refactored expression must produce the same result, the
refactored program must be functionally equivalent with the original source.
Some common motivations for refactoring code include:
• Making the code easier to change or easier to add a new feature
• Reducing complexity for better understanding
• Removing unnecessary repetition
• Enabling use of the code for other needs or more general needs
• Improving the performance of your code
The IDE’s refactoring features simplify code restructuring by evaluating the changes
that you want to make, showing you the parts of your application that are affected, and
making all necessary changes to your code. For example, if you use the Rename oper-
ation to change a class name, the IDE finds every usage of that name in your code and
offers to change each occurrence of that name for you.
• Refactor Menu
• Undoing Refactoring Changes
• Finding Function Usages
• Renaming a Function or Parameter
• Moving, Copying and Safely Deleting C Code
8.6 ERRORS
Errors can take many forms in the IDE, most commonly as icons in windows or mes-
sages in the Output window. Hovering over icons will pop up text that may explain the
issue. For text messages, please refer to online help to search for the error.
Some errors are listed below.
Could not access the URL through the external browser. Check the
browser configuration
In MPLAB X IDE, select Tools>Options, General Tab. In the “Web Browser” drop-down
list, select your browser. Click OK.
For more information see:
http://netbeans.org/bugzilla/show_bug.cgi?id=21236
http://netbeans.org/bugzilla/show_bug.cgi?id=38211
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4646857
8.7 FORUMS
If you do not see your issue here, check out our forums at:
http://www.microchip.com/forums/f238.aspx
Here you will find discussions and recently posted solutions to problems.
Note: When the NetBeans help topic refers to a workspace, it is talking about a
desktop. It is not referring to the MPLAB IDE v8 and earlier workspace.
• Menus
• Toolbars
• Status Bar
• Grayed-out or Missing Items and Buttons
STATUS BAR
10.2 MENUS
Many MPLAB IDE functions are accessible as menu items through the menu bar
located across the top of the desktop. Menu items followed by ellipses (...) will open a
dialog. For more on dialogs, see Chapter 11. “MPLAB X IDE Windows and Dialogs”.
Shortcut keys for menu items are listed next to the menu item. Example: The shortcut
keys for “New File” are Control-N (CTRL+N). More shortcut key information is available
in the NetBeans help topic under “IDE Basics>Keyboard Shortcuts”.
Menu items may be grayed-out for various reasons. See Section 10.5 “Grayed-out or
Missing Items and Buttons”.
Additional context menus are available by right clicking in a window. For more on these
menus, see Section 11.2.7 “Projects Window”.
Available menus are listed below.
• File Menu
• Edit Menu
• View Menu
• Navigate Menu
• Source Menu
• Refactor Menu
• Run Menu
• Debug Menu
• Team Menu
• Tools Menu
• Window Menu
• Help Menu
10.3 TOOLBARS
MPLAB IDE displays different toolbars depending on which features or tools you are
using. The icons in these toolbars provide shortcuts to routine tasks. To add or remove
icons from a toolbar, or create a new toolbar, see Section 6.5 “Customize Toolbars”.
Toolbar buttons may be grayed-out for various reasons. See
“Section 10.5 “Grayed-out or Missing Items and Buttons”.
Toolbars Available
The following basic toolbars are available.
• File Toolbar
• Clipboard Toolbar
• Status Flags Toolbar
• Undo/Redo Toolbar
• Run Toolbar
• Debug Toolbar
• Memory Toolbar
• Quick Search Toolbar
• Editor Toolbar
Toolbar Features
Toolbars have the following features:
• Hover the mouse pointer over an icon to pop up the icon function.
• Click and drag the toolbar to another location in the toolbar area.
• Right click in the toolbar area to show/hide a toolbar or change the contents of
some toolbars.
• Select View>Toolbars to show/hide a toolbar, change the contents of some
toolbars or create a custom toolbar.
Right clicking on the Window tab will display other options, such as Close,
Maximize/Minimize window, and Dock/Undock window.
Right clicking in the Output window will display various options as shown below.
Item Description
Logging Level Set the message logging level.
OFF: No logging
SEVERE: Log severe (error) messages only.
WARNING: Log warning messages only.
INFO: Log informational messages only.
CONFIG: Log configuration information only.
FINE: Log some module to module communication.
FINER: Log more module to module communication.
FINEST: Log all module to module communication.
Log File Path and location of log file.
Projects Folder Path and location of the folder where you will place your MPLAB® X
IDE projects.
Close open source file Close any open source files in the Editor window when you close
on project close your project.
Clear output window Clear out the contents of the Output window when you build your
before build project.
Remove breakpoints When importing a file into your project, remove all existing project
upon importing a file breakpoints.
Halt build on first failure When building, halt the process on the first failure.
The selected project language tool can be set up to determine
which errors are produced. Go to the Project Properties dialog,
select the language tool under “Categories” and “Errors and
Warnings” under “Option Category”.
Maintain active connec- If selected, keep hardware tool connected always, not just at
tion to hardware tool runtime. (MPLAB® IDE v8 behavior)
Clear tool output window Clear out the contents of the Output window when you begin a Run,
on new session (debug, Debug Run or upload.
program, upload)
Silent build Build without generating messages in the Output window.
Enable alternate watch Display three watch view diamonds in the Watches window. Associ-
list views during debug ate a watch view with a watch variable. When you click on a watch
session view diamond, only the variables associated with that view will be
displayed. So this feature works like a filter.
Reset @ Select action on reset.
Main: Stop at main on reset.
Reset Vector: Stop at the Reset vector on Reset.
Debug start-up Select action on debug start.
Run: Start execution immediately.
Main: Stop at main.
Reset Vector: Stop at the Reset vector.
Right click on a row to open the Watches menu. The items available will depend on
whether a symbol is in the row or what debug tool you are using.
TABLE 11-11: WATCHES WINDOW MENU ITEMS
Menu Item Description
New Watch Add a new symbol to watch
New Runtime Watch MPLAB REAL ICE In-Circuit Emulator Only
Add a new runtime watch for the selected symbol.
Run Time Update Interval MPLAB REAL ICE In-Circuit Emulator Only
Specify the rate at which the symbol value will be updated. “No
Delay” will update as quickly as your personal computer is able. If
you are seeing errors in the runtime data, you can add a delay to
decrease the update speed.
Export All Watches to List Export information about the symbols to be watched to a file
File (.xwatch).
Delete All Remove all the watched symbols from the Watches window.
Note: You can also right-click in a symbol in code to add it to a New Watch or New
Runtime Watch.
You can change the columns displayed in the window by right clicking on a heading to
pop up the “Change Visible Columns” dialog.
TABLE 11-12: CHANGE VISIBLE COLUMNS ITEMS
Dialog Item If Checked
Name Show name of column (always checked)
Address Show memory address of variable
Binary Show binary formatted value
Char Show character formatted value
Decimal Show decimal formatted value
Type Show type of watch variable
Value Show value of watch expression (in hexadecimal)
For more on the Watches window, see the NetBeans Help topic C/C++/Fortran
Development>Debugging C/C++/Fortran Applications with gdb>Viewing C/C++/For-
tran Program Information>Creating a C/C++/Fortran Watch.
The names of the images by default are (with respect to the MPLAB X IDE directory):
dist/$CONF_NAME/production/$PROJ_NAME.production.hex
dist/$CONF_NAME/debug/$PROJ_NAME.debug.cof (or elf)
14.2.1 __config
The directive __config is used for PIC10/12/16 MCUs. It may be used for PIC18
MCUs (excluding PIC18FXXJ devices) but the config directive is recommended. The
syntax is as follows:
__config expr ;For a single configuration word
or
__config addr, expr ;For multiple configuration word
where:
addr: Address of the Configuration Word. May be literal but usually represented by a
macro.
Note: Macros must be listed in ascending register order.
expr: Expression representing the value to which the specified Configuration bits will be
set. May be literal but usually represented by a macro or macros ANDed together.
Macros are specified in the device include file (*.inc) that is located in the Windows
OS default directory:
C:\Program Files\Microchip\MPLABX\mpasmx
Directive case does not matter; __CONFIG or __config is acceptable. Macro case
should match what is in the header.
;Watch Dog Timer enable, Watch Dog Timer PostScaler count - 1:128
__CONFIG _CONFIG3, _WDT_ON_3 & _WDTPS_128_3
14.2.2 config
The directive config is used for PIC18 MCUs (including PIC18FXXJ devices). The
syntax is as follows:
config setting=value [, setting=value]
where:
setting: Macro representing a Configuration bit or bits.
value: Macro representing the value to which the specified Configuration bit(s) will be
set. Multiple settings may be defined on a single line, separated by commas.
Settings for a single configuration byte may also be defined on separate lines.
Macros are specified in the device include file (*.inc) that is located in the Windows
OS default directory:
C:\Program Files\Microchip\MPLABX\mpasmx
Directive case does not matter; __CONFIG or __config is acceptable. Macro case
should match what is in the header.
Example – PIC18 MCUs
#include p18f452.inc
;Watch Dog Timer enable, Watch Dog Timer PostScaler count - 1:128
CONFIG WDT=ON, WDTPS=128
PICC Example
#include <htc.h>
PICC-18 Example
#include <htc.h>
//Watch Dog Timer enable, Watch Dog Timer PostScaler count - 1:128
__CONFIG(2, WDTEN & WDTPS128);
/*Watch Dog Timer enable, Watch Dog Timer PostScaler count - 1:128*/
#pragma config WDT = ON, WDTPS = 128
//JTAG off, Code Protect off, Write Protect off, COE mode off, WDT off
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF )
//Oscillator in HS mode
_FOSC(POSCMD_HS);
//JTAG off
_FICD(JTAGEN_OFF);
Example
#include “p32xxxx.h”
14.9 XC TOOLCHAINS
To create code that is as portable as possible, refer to the Common Compiler Interface
(CCI) chapter, config macro, in each of the following documents:
• MPLAB XC8 C Compiler (DS52053) or related help file
• MPLAB XC16 C Compiler (DS52071) or related help file
• MPLAB XC32 C Compiler (DS51686) or related help file
WARRANTY REGISTRATION
Web Site: http://www.microchipdirect.com
Registering your development tool entitles you to receive new product updates. Interim
software releases are available at the Microchip web site.
MICROCHIP FORUMS
Forums: http://www.microchip.com/forums
Microchip provides additional online support via our web forums. Currently available
forums are:
• Development Tools
• 8-bit PIC MCUs
• 16-bit PIC MCUs
• 32-bit PIC MCUs
CUSTOMER SUPPORT
Users of Microchip products can receive assistance through several channels:
• Distributor or Representative
• Local Sales Office
• Field Application Engineer (FAE)
• Technical Support
Customers should contact their distributor, representative or field application engineer
(FAE) for support. Local sales offices are also available to help customers. A listing of
sales offices and locations is included in the back of this document. See our web site
for a complete, up-to-date listing of sales offices.
Technical Support: http://support.microchip.com
Documentation errors or comments may be e-mailed to [email protected].
H
Halt
A stop of program execution. Executing Halt is the same as stopping at a breakpoint.
Heap
An area of memory used for dynamic memory allocation where blocks of memory are
allocated and freed in an arbitrary order determined at runtime.
Hex Code\Hex File
Hex code is executable instructions stored in a hexadecimal format code. Hex code is
contained in a hex file.
Hexadecimal
The base 16 numbering system that uses the digits 0-9 plus the letters A-F (or a-f). The
digits A-F represent hexadecimal digits with values of (decimal) 10 to 15. The rightmost
digit counts ones, the next counts multiples of 16, then 162 = 256, etc.
High Level Language
A language for writing programs that is further removed from the processor than
assembly.
I
ICE/ICD
In-Circuit Emulator/In-Circuit Debugger: A hardware tool that debugs and programs a
target device. An emulator has more features than an debugger, such as trace.
In-Circuit Emulation/In-Circuit Debug: The act of emulating or debugging with an in-cir-
cuit emulator or debugger.
-ICE/-ICD: A device (MCU or DSC) with on-board in-circuit emulation or debug circuitry.
This device is always mounted on a header board and used to debug with an in-circuit
emulator or debugger.
ICSP
In-Circuit Serial Programming. A method of programming Microchip embedded
devices using serial communication and a minimum number of device pins.
IDE
Integrated Development Environment, as in MPLAB IDE.
Identifier
A function or variable name.
IEEE
Institute of Electrical and Electronics Engineers.
Import
Bring data into the MPLAB IDE from an outside source, such as from a hex file.
Initialized Data
Data which is defined with an initial value. In C,
int myVar=5;
defines a variable which will reside in an initialized data section.
Instruction Set
The collection of machine language instructions that a particular processor
understands.