Step 3: Configure MCU Resources With MCC

MPLAB® Code Configurator (MCC) is a free graphical programming environment that generates seamless, easy-to-understand C code to insert into your project. Using an intuitive interface, it enables and configures a rich set of peripherals and functions specific to your application. It supports our 8-, 16- and 32-bit devices, which include our PIC®, AVR®, SAM microcontrollers (MCUs), and dsPIC® Digital Signal Controllers (DSCs). Both the downloadable MPLAB X Integrated Development Environment (IDE) and the cloud-based MPLAB Xpress IDE include MCC.

We’ll use MCC to configure the needed MCU peripherals and general-purpose inputs and outputs (GPIO) to complete the exercise.

Step 3.1 - Launch MCC


Open MPLAB X IDE and open the downloaded project microSD-app-pic24fjxxxga7-lab.X.



Launch the MCC plugin by clicking Tools > Embedded > MPLAB Code Configurator v5: Open/Close.


Or, you may click the MCC logo in the toolbar.


Use the same method to close MCC.

Note: MCC may take a while to load the first time it is launched.

Step 3.2 – Add File System and SD/MMC Card MCC Libraries

Note: The File System MCC and SD/MMC Card libraries provide an easy-to-use graphical interface to configure the various options of the microSD Click board™.

Note: This process shows how to add the required MCC libraries to a new MPLAB X IDE project. At the time of this publication, MCC requires additional steps to add some libraries. Please refer to this article if you have trouble adding MCC libraries to an existing MPLAB X IDE project.


If prompted, select MCC Classic from MCC Content Manager Wizard.



Select FatFs FAT System and SD/MMC Card libraries and click Finish.



After MCC loads, the FatFs and SD Card (SPI) libraries may be available in the Device Resources window. If so, add the FatFs and SD Card (SPI) libraries by clicking on their + symbols.


The libraries will now be listed in the Project Resources window.


Step 3.3 – Configure System Module

Now you can start configuring the settings.


Click System Module in the upper left window.



For System Module, we will use the FRC Oscillator as the Clock Source, which is the default configuration. In this exercise, we will use an 8 MHz Fosc clock source.



Scroll down the System Module and go to the ICD section. Verify that Communicate on PGEC2 and PGED2 is selected for the Emulator Pin Placement. These are the ICSP pins for the PICKit™ on-board debugger/programmer.


Step 3.4 – Configure UART

Now we will add the peripherals needed for the project and configure the File System Library. The UART will be configured to send information to the MCP2221A Breakout Module and display data on MPLAB X IDE’s Data Visualizer.


Add UART1 by opening the UART folder in the Device Resources window and clicking the + icon for UART1 [Foundation Services Library by Microchip Technology, Inc.].



In the UART1 configuration window, click the checkbox next to Redirect Printf to UART. This is used to display information to Data Visualizer.


Step 3.5 – Configure GPIO

GPIO needs to be configured to control the microSD Click board.


Select Pin Module in Project Resources. Find the Pin Manager: Grid View window. Click each pin with a green lock as either an input or output as shown in the following figure.

  • SD Card (SPI) CD – Port C1
  • SD Card (SPI) CS – Port C9
  • SPI1 SCK1OUT – Port B15
  • SPI1 SDI1 – Port B13
  • SPI1 SDO1 – Port B14
  • UART1 U1RX – Port B8
  • UART1 U1TX – Port B7

In the Pin Module window, select the Easy Setup tab and configure the selected GPIO as follows:

Note: The Custom Name must match the following table for the libraries to build successfully. You may copy the Custom Name from the table below and paste it into the Pin Module Custom Name fields.

Pin Name Function Custom Name Start High Direction Interrupt-on-change
RB7 U1TX Yes Output None
RB8 U1RX No Input None
RB13 SDI1 SDI1 No Input None
RB14 SDO1 SDO1 No Output None
RB15 SCK1OUT SCK1OUT No Output None
RC1 CD SDCard_CD No Input None
RC9 CS SDCard_CS No Output None

The Pin Module settings should look like the following image:

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site 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.