MPLAB® Code Configurator (MCC) Classic

Last modified by Microchip on 2024/05/16 06:32

MCC banner

When starting a new project using PIC16, PIC24, or PIC32 microcontrollers, the setup of the configuration and all the peripherals can be time-consuming, especially for new projects. The MPLAB® Code Configurator (MCC) is an automatically installed plugin for 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 you to configure and generate code for software libraries and off-chip peripherals. The generated drivers or libraries can be used in any 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 screen

Getting Started with MCC

The first step of any project is to use the MPLAB X IDE wizard tool to create a project. The wizard will walk through selecting the microcontroller, the development programmer/debugger and the compiler to use. This should be done before launching the MCC.

The MCC tool, once installed, can be launched from the the MPLAB X IDE Tools menu under the 'Embedded' selection.

MCC launch

The sections of the MCC tool are shown in the accompanying image. We will refer to these sections by name throughout this training page. This highlight can be enabled over the MCC at any time by clicking on the information icon Info icon.

MCC layout

Getting Started with MCC Overview

Back to Top

Using MCC to Select and Setup Peripherals

MCC makes it easy to select the peripherals for a device. The Device Resources shows the peripherals available on the device.

MCC peripherals

By clicking on the name of the peripheral, a list of associated options including multiple versions of the peripheral will appear. There may be multiple comparators on the device so the submenu will show the list of all that are available.

Clicking on the specific peripheral will add that peripheral to the Project Resources.

MCC selected

Setup the Peripherals

The central composer area is where the peripherals are set up. When the peripheral is selected in the Project Resources, the corresponding configuration GUI is displayed in the central composer area. There are three tabs: Easy Setup, Registers, and Notifications. Easy Setup is where you select the settings for the peripheral through a variety of drop-down selections and checkboxes. The example shown is for the System Peripheral setup.

MCC configuration

Register View

The Registers tab shows the various registers for the particular peripheral. The configuration settings can also be viewed and modified under this tab.

Notifications

Any conflicts or recommendations that a setup would require will show up under the Notifications tab. This may be as simple as an I/O pin being set to analog and is recommended to be set to digital for the peripheral setting selected.

Back to Top

Using MCC to Select I/O Pin Configuration

MCC allows you to set up the I/O pin configurations using a graphical interface in the Pin Manager. The first step is to select the device package type to use then a representation of the device will appear. Then click on the accompanying chart to select the arrangement.

MCC I/O setup

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 with 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:

  1. 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.
  2. Blue-colored pin: indicates pins that are available to be allocated to a module.
  3. Green-colored pin (with a lock): this combination indicates that the pin has been allocated and selected for a module. The name that appears on the pin is either the name of the pin in the module’s context or a custom name entered.
  4. Green-colored pin (with chain link): this combination indicates that the pin is shared between multiple functions.
  5. Yellow-colored pin: indicates a possible alternate pin for an already allocated pin function.
  6. Grayed-out locks on a white background: indicate pins that are locked out by selected system functions.

Back to Top

Generating Code

MCC has a separate setup screen for each peripheral selected. After each peripheral is set up along with the configuration and I/O, then just click on the Generate Code button Generate button to have the MCC create all the peripheral driver code for the project.

The code will be placed into the project automatically. If it is 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 IDE.

Generated MCC files

The code produced is fully open-sourced and editable. It can be used as a base and modified for the project's 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 is automatically developed.

Back to Top