When starting out with a new project using Microchip 8-bit or 16-bit microcontrollers, setup of the configuration and all the peripherals can be time consuming, especially for new projects. The MPLAB® Code Configurator (MCC) is a plugin for the MPLAB® X IDE that simplifies this down to a series of simple selections from the menus within the MCC. The 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.
Additionally, the MCC is used to configure and generate libraries, which allows the user to configure and generate code for software libraries and off-chip peripherals. The generated drivers or libraries can be used in any Microchip PIC device application program.
The MCC requires an 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.
MCC Installation (step by step)
The MCC Plugin can be installed from the Tools/Plugins menu in the MPLAB® X IDE
1) Select the 'Tools' menu, and click on 'Plugins'
2) In the MPLAB® X IDE Plugins window, click the 'Available Plugins' tab
3) Select MPLAB® Code Configurator and click 'Install'
Getting Started with MCC
The first step of any project is to use the MPLAB X wizard tool to create a project. The wizard will step through selecting the microcontroller, development programmer/debugger and compiler to use. This should be done before launching the Microchip Code Configurator.
The MCC tool, once installed, can be launched from the the MPLAB® X Tools menu under the Embedded selection.
Using MCC to Select Peripherals
The Code Configurator makes it easy to select the peripherals for a device. The Devices Resources area of the Code Configurator shows the peripherals available on the device.
By clicking on the name of the peripheral, the list of associated options including multiple versions of the peripheral appears. There may be multiple Comparators on the device so the sub menu will show the list of all that are available.
Clicking on the specific peripheral will add that peripheral to the Project Resources area.
Using MCC to Setup the Peripherals
The central composer area is where the peripherals are setup. When the peripheral is selected in the Project Resources area, the corresponding configuration GUI is displayed in the central composer area. There are three tabs, Easy Setup, Registers and Notifications. The Easy Setup is where the developer selects the settings for the peripheral through a variety of drop down selections and check boxes. The example shown is for the System Peripheral setup.
The Registers Tab shows the various registers for the particular peripheral. The configuration settings can also be viewed and modified under this tab.
Any conflicts or recommendations that a setup would require will show up under the notifications tab. This may be a simple as an I/O pin is set to analog and is recommended to be set to digital for the peripheral setting selected.
Using MCC to Select I/O Pin Configuration
The Code Configurator allows the user to setup the I/O pin configurations using a graphical interface in the Pin Manager Area. The first step is to select the device package type to use and a representation of the device will appear. Then click on the chart below the graphical picture of the device to select the arrangement.
A blue pin is unconnected and a green pin is connected to a peripheral or designated as a digital I/O pin. The menu of peripherals to connect the pin to can be positioned on the top (horizontal) or on the left side (vertical) by clicking on the horizontal or vertical selection.
The pin(s) associated to the peripheral will show up in the row or column of the peripheral name. This way it can be easily determined which pins to select for that particular peripheral. Once the pin is selected, the color will change to green and the lock symbol will close indicating the pin is locked into that arrangement. Clicking on the green lock will reset it back to a blue unused state.
There are several other colors that will appear as described below:
- Gray colored pin: indicates that the pin is not usable in the selected configuration and that there is no enabled module which has any functionality on that pin. There are also grayed out locks on a white background that indicate pins that are locked out by selected system functions.
- Blue colored pin: indicates pins that are available to be allocated to a module.
- Green colored pin (with a lock): this combination indicates that the pin has been allocated and selected for a module. The name displayed against the pin is either the name of the pin in the module’s context or a custom name entered.
- Green color pin (with chain link): this combination indicates that the pin is shared between multiple functions.
- Yellow colored pin: indicates a possible alternate pin for an already allocated pin function.
- Grayed out locks on a white background indicates pins that are locked out by selected system functions.
Generating CodeThe Code Configurator has a separate setup screen for each peripheral selected. After each peripheral is setup along with the configuration and I/O, then just click on the Generate Code button to have the MCC create all the peripheral driver code for the project.
The code will be placed into the project automatically. If its a new project then a main.c file will also be produced. If the project already has a main.c then the MCC will only produce the peripheral driver files. The code will show up in the project area of MPLAB® X.
The code produced is fully open sourced and editable. It can be used as a base and modified for the projects needs. This also makes a great way to start a new project so initially a set of peripheral driver code with functions for each peripheral are automatically developed.
The MCC User Guide can be downloaded for more detailed information on using MCC.