Code Configuration Guide Final1
Code Configuration Guide Final1
Preface
Introduction
®
This document describes how to install, configure and use the MPLAB Code Configurator (MCC)
software tool before starting or during the development process of an embedded software application
®
designed with PIC microcontrollers.
Recommended Reading
This user's guide refers to MCC operation only. Other useful documents are listed below. The following
Microchip documents are available and recommended as supplemental reference resources:
• Release Notes for the MPLAB Code Configurator
• MPLAB X IDE User’s Guide
Table of Contents
Preface............................................................................................................................ 1
1. Introduction ...............................................................................................................3
2. Installation................................................................................................................. 4
2.1. Installing MPLAB Code Configurator from the Microchip Plugins Update Center........................4
2.2. Installing MPLAB Code Configurator from the Microchip Website............................................... 5
2.3. Updating MPLAB Code Configurator........................................................................................... 6
2.4. Older MPLAB Code Configurator Versions.................................................................................. 6
3. Operating Areas........................................................................................................ 7
3.1. Project Resources Area............................................................................................................... 8
3.2. Device Resources Area..............................................................................................................10
3.3. Versions Area............................................................................................................................. 11
3.4. Package View Area.................................................................................................................... 12
3.5. Table View Area......................................................................................................................... 13
3.6. The Composer Area................................................................................................................... 16
3.7. MCC Options..............................................................................................................................19
7. Revision History.......................................................................................................30
Customer Support......................................................................................................... 31
Legal Notice...................................................................................................................32
Trademarks................................................................................................................... 32
1. Introduction
®
The MPLAB Code Configurator (MCC) generates driver code using a Graphical User Interface (GUI).
®
The generated drivers control the peripherals on PIC microcontrollers. The GUI provides an easy means
®
for setting up the configuration of the peripherals. MCC is a plugin for the MPLAB X IDE.
Additionally, the MCC is used to configure and generate libraries, which allows you to configure and
generate code for software libraries and external components.
The generated drivers or libraries can be used in any Microchip PIC device application program. MCC
requires a MPLAB X IDE project to be created, or an existing project opened, before launching the MCC
plugin. This is necessary as the MCC needs to know the device used in the project, to have access to
device-specific information like registers, bits and configurations, and to set up the MCC GUI.
The MCC generates source and header files based on selections made in the GUI. The generated files
are added to the active project of MPLAB X IDE.
2. Installation
The MPLAB Code Configurator can be installed in two ways: via the Microchip Plugins Update Center, or
from the Microchip website. The following chapters describe these procedures and also the MCC update
process.
2.1 Installing MPLAB Code Configurator from the Microchip Plugins Update Center
MCC is not installed together with the MPLAB X IDE by default, so you must download it separately and
install it. One way to do so is via the Microchip Plugins Update Center:
1. In the MPLAB X IDE, go to Tools -> Plugins.
2. Go to the Available Plugins tab.
3. Select MPLAB Code Configurator and click the Install button. See figure below.
4. The Plugin installer opens. Click Next and check the Terms and Agreements. After this step, the
Plugin installer begins downloading the MCC plugin.
5. When the MCC plugin download is complete, MPLAB X IDE will ask to be restarted. Upon restart,
the plugin is installed.
6. You can now open MCC on a new or already existing MPLAB X IDE project. See Section 4.1
“Setting Up MPLAB X IDE and Launching MCC.“
Figure 2-1. Installing MPLAB Code Configurator
Once downloaded, extract the archive which contains the MCC plugin to a location of your preference. To
install the plugin you downloaded, complete the following instructions:
1. Open MPLAB X IDE.
2. Go to Tools -> Plugins.
3. Select the Downloaded tab and click on the Add Plugins... button.
4. Navigate to the folder where you extracted the downloaded .zip file and select the MCC plugin. It
should have a .nbm file extension.
5. Click on the Install button. MPLAB X IDE will ask to be restarted. Upon restart, the plugin is
installed. See figure below.
6. You can now open MCC on a new or already existing MPLAB X IDE project. See Section 4.1
“Setting Up MPLAB X IDE and Launching MCC.”
Figure 2-3. Installing MCC from Downloaded File
3. Operating Areas
The MCC user interface consists of six main operating areas, as shown in Figure 3-1.
1. Project Resources Area: displays the complete list of peripherals, libraries and external
components available for the selected device, based on the loaded libraries in the Versions Area.
2. Device Resources Area: displays the peripherals, libraries or external components selected for
the current project. Selection is done via the Project Resources Area. The System Module, Pin
Module and Interrupt Module are selected by default. Configuration for each of the selected
modules is done through the Composer Area. Selecting a component from this area will move the
component to the Project Resources area.
3. Versions Area: shows the complete list of MCC Cores, Peripheral Libraries and Software Libraries
which can be used with the selected device. Some of these are installed together with MCC, others
are available for download. Depending on the selected device, some core and library versions are
interchangeable.
4. Composer Area: this is the main area in which a peripheral or library driver can be configured. It
displays the possible configurations of the peripheral/library.
5. Pin Manager Grid View Area: contains three inner tabs: Notifications (errors, warnings and
general information regarding the current selections), Pin Manager - Grid View (a table version of
the Pin Module Package View) and Output (MCC Log & MPLAB X IDE Log).
6. Pin Manager Package View Area: graphic interface for pin selection and configuration.
Bidirectional operation with the Pin Manager Grid View.
Figure 3-1. MCC Operating Areas
Note: All operating areas are dockable. Each can be dragged and dropped into another position, even
out of the MPLAB X IDE main window (closing the IDE however will close all MCC windows, including the
ones moved outside the IDE).
Besides the partial configuration export mechanism, the Context menu of the Project Resources Area
(Figure 3-4) includes several other operations on the loaded components or modules such as:
• Force Update: regenerates code for all the selected modules/components, even if there were no
modifications added to their configuration. See Section 4.3 “Generating Code”.
• Refresh [module_name] Windows: reopens the configuration window of the selected module if
that window has been closed previously. If the Context menu is invoked by right-clicking under the
Resources list, with no module/component selected, this option will be available as Refresh Module
Windows and its effect will be global - all previously closed MCC windows will be reopened.
• [module_name] Help: opens the help content for the user interface of the selected module/
component, if available.
The Device Resources tree shown in the previous figure can also be navigated and handled by using the
following keys:
1. Up and down arrow keys: for moving up and down in the tree, respectively
2. Right arrow key: for expanding a node
3. Left arrow key: for collapsing a node
Right-clicking on a module or component in this tree shows the Device Resources Context menu through
which the help content of the selected module can be invoked.
The Device Resources list can be filtered via the top combo box (see the figure below). Available filters
are: all supported and tested modules, all supported modules (including untested ones), all modules
(including unsupported ones).
Figure 3-6. Resource Filtering in Device Resources Area
Besides the Versions Area, a core or a library can be loaded also via the MPLABX IDE menu in Tools →
Options → Plugins → MPLAB Code Configurator (see Section 3.8 “MCC Options”).
Note: All MCC libraries are published via the Microchip website: www.microchip.com/mcc.
By right-clicking on a specific pin all available pin functions are listed for selection. A snapshot of the
package view configuration can be saved in PNG format by right-clicking on the package and selecting
"Export Image."
Figure 3-8. Package View Area
The three leftmost columns in the Table View indicate the module’s name, functionality name and the
direction, respectively.
The Table View allows you to:
• Expand/collapse rows and ports (Figure 3-10)
• Hide and show ports and rows (Figure 3-11 and Figure 3-12)
• Show only the pins that are configured (Isolate) (Figure 3-13)
Figure 3-10. Collapsing Ports and Rows
• SEVERE: either the code generation or the compilation process will be faulty with the current
configuration.
• WARNING: the code will be generated according to settings made and it may compile, but it might
also fail to function as intended.
• HINT: this provides information to assist in the successful configuration of the module. The module
and the MCC can still be used. Action might be required.
• INFO: information only, no action is required.
These can be filtered out using the Type combo box. If there are any WARNING or SEVERE type
messages present in the Notifications tab when you click the Generate button, a message box displays,
giving the option of reconfiguration in order to eliminate the possible errors in the current settings. This
action can be skipped, assuming the notifications have been reviewed and taken into consideration.
Figure 3-15. The Notifications Tab
Note: The notification type may change as you change the configuration of MCC. For example,
WARNING might indicate that a module requires another module to be added to the project to operate
correctly. After the module is added, the notification type would change to INFO.
The EUSART Easy Setup tab in the Composer Area allows configuring various EUSART parameters
related to transmission and reception operations.
→ MPLAB Code Configurator 3.x, click on the Install Core button and select the .mc3core file via the
Open File dialog box. The Versions window will now list your fresh core installation.
To switch to another core version, either double click on it, or right-click on it and select “Switch Core
Version.” The Versions window will now refresh the core selection with your choice. You can always
check the core installations by opening the Core folder, from Tools → Options → Plugins → MPLAB
Code Configurator 3.x path. Refer to Section 3.4. “Versions Area” for more details about core switching.
Removing a core version is done from the Remove Core button. The Folder selection dialogue window
will open your "Core" folder. Select the core version you want to remove and click on the Remove button
on the Folder selection dialogue. You can verify that the core version is no longer present on your
machine anymore by going to the Versions operating area - the core version you removed is not present
on your machine anymore. It may be present as available for download.
If you attempt to remove a core version you are currently using (green tick in the Versions area), MCC will
not allow you to do so. In order to remove that core version, you need to switch to another core version,
go back to the Options window and press the Remove Core button again for the core version you want to
delete.
When opening MCC for the first time on an MPLAB X project, the configuration saving dialog will be
displayed asking for a name and saving path for the MCC configuration file attached to the project. The
MCC configuration is also saved to the disk when the Generate button is pressed, or if the MPLAB X IDE
Save button is clicked. An existing MCC configuration file can be loaded by double-clicking on the
desired .mc3 file in the Important Files section of the MPLAB X IDE project.
A list of all the files that need to be merged is shown at the top of the Merge [MCC] window. You must
select each file in the list, in turn, to ensure that all of the newly generated code is incorporated into the
project.
At the top of the Merge [MCC] window, in the center margin, there is an arrow, as shown in Figure 4-3.
Clicking on the arrow will replace all of your edits in the current file with the MCC updated code that the
MCC has just generated. The numbers above the arrow indicate the current difference and the total
number of differences.
Figure 4-3. Merge [MCC] Window - Replacing All Edits with MCC Generated Code
The individual lines of MCC Updated Code can be selected to replace the edited code. As shown in
Figure 4-4, clicking on the arrows in the right margin of the left window will copy the MCC Updated Code
to the generated driver file. Once the changes are accepted, the Merge mechanism will remove the
highlighted file and highlight the next file on the list. To insure all updates are completed, a warning will be
generated if the Merge mechanism is closed before all the changes are accepted.
Figure 4-4. Merge [MCC] Window - Replacing Single Changes with MCC Generated Code
Note:
1. Remember to merge the code for every file shown in the file list in the Merge [MCC] window.
2. Be sure to save all the changed files from the Merge process.
1. The mcc.h and mcc.c files include the definitions of Configuration bits and the
‘OSCILLATOR_initializer’ function. These definitions are based on the settings which were
made for the System module in the Composer. Also included is the ‘SYSTEM_initializer’
function which can be called in the application program to call all the other default initializers (the
ones marked in the GUI by sprocket symbol).
2. The pin_manager.h and pin_manager.c files include the Pin Manager initializer functions
based on the configurations which were made in the Pin Manager GUI.
3. The interrupt_manager.h and interrupt_manager.c files are optional files which are
generated only when peripheral interrupts are enabled and they include interrupt initializer
functions.
4. The .c and .h are module specific files and include each module’s peripheral\library configuration
functions.
5. The main.c file is generated only when the MCC detects that there is no main.c file present in
the project. If there is any previous main.c in the project regardless of its creator (you or the
MCC), it will not generate or overwrite the existing one. When using a main.c not generated by the
MCC, the lines ‘#include "mcc_generated_files/mcc.h";’ and
‘SYSTEM_Initializer()’ need to be added to the main.c file. The main.c file generated by
the MCC may include commented out code lines to enable interrupts. Remove the comments from
the appropriate lines if the application requires interrupts to be enabled when it starts.
The functions provided in any of these MCC generated files can be called from the user application code,
as required. The MPLAB X IDE provides auto-completion assistance of all of the MCC generated content.
While editing source code in the project, start typing in a MCC API, or MCC variable name, and press
<CTRL+ Space>. The MPLAB X IDE will show a list of options to complete the entry.
7. Revision History
Revision A (January 2016)
Initial release of the document.
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.
Technical support is available through the web site at: http://www.microchip.com/support
• 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.
Legal Notice
Information contained in this publication regarding device applications and the like is provided only for
your convenience and may be superseded by updates. It is your responsibility to ensure that your
application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR
WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY
OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS
CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE.
Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life
support and/or safety applications is entirely at the buyer’s risk, and the buyer agrees to defend,
indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting
from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual
property rights unless otherwise stated.
Trademarks
The Microchip name and logo, the Microchip logo, AnyRate, AVR, AVR logo, AVR Freaks, BeaconThings,
BitCloud, CryptoMemory, CryptoRF, dsPIC, FlashFlex, flexPWR, Heldo, JukeBlox, KeeLoq, KeeLoq logo,
Kleer, LANCheck, LINK MD, maXStylus, maXTouch, MediaLB, megaAVR, MOST, MOST logo, MPLAB,
OptoLyzer, PIC, picoPower, PICSTART, PIC32 logo, Prochip Designer, QTouch, RightTouch, SAM-BA,
SpyNIC, SST, SST Logo, SuperFlash, tinyAVR, UNI/O, and XMEGA are registered trademarks of
Microchip Technology Incorporated in the U.S.A. and other countries.
ClockWorks, The Embedded Control Solutions Company, EtherSynch, Hyper Speed Control, HyperLight
Load, IntelliMOS, mTouch, Precision Edge, and Quiet-Wire are registered trademarks of Microchip
Technology Incorporated in the U.S.A.
Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BodyCom,
chipKIT, chipKIT logo, CodeGuard, CryptoAuthentication, CryptoCompanion, CryptoController,
dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit Serial
Programming, ICSP, Inter-Chip Connectivity, JitterBlocker, KleerNet, KleerNet logo, Mindi, MiWi,
motorBench, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient
Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, PureSilicon, QMatrix, RightTouch logo, REAL
ICE, Ripple Blocker, SAM-ICE, Serial Quad I/O, SMART-I.S., SQI, SuperSwitcher, SuperSwitcher II, Total
Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, and ZENA are
trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.
Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.
GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of
Microchip Technology Inc., in other countries.
All other trademarks mentioned herein are property of their respective companies.
© 2018, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
ISBN:
ISO/TS 16949
Microchip received ISO/TS-16949:2009 certification for its worldwide 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 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.