Demonstrating Secure Digital Flash Memory Card Functionality Using MPLAB® Code Configurator (MCC) - Step 3: Configure MCU resources with MCC

Last modified by Microchip on 2023/11/09 08:54

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-bit, 16-bit, and 32-bit devices, which include our PIC®, AVR®, and 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 be using MCC to configure the needed MCU peripherals and General Purpose Inputs and Outputs (GPIO) to complete the exercise. 

Download Project and Launch Plugin

Open MPLAB X IDE.  Then, open the downloaded project microSD-app-pic24fjxxxga7-lab.X
Open Project Selection

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

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.

Back to Top


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 the "How to get MCC Data EEPROM and Emulation library to show up in MPLAB X IDE" article if you have trouble adding MCC libraries to an existing MPLAB X IDE project. 

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

b. Select FatFs FAT System and SD/MMC Card libraries and then click Finish.
MCC Content Manager Wizard

c. 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.
Device Resource window

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

Back to Top


Configure System Module

Now you can start configuring the settings.

a. Click System Module in the upper left window.
System Module selection

b. For the 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.
FRC Oscillator as the Clock Source

c. Scroll down the System Module and go to the ICD section. Verify Communicate on PGEC2 and PGED2 for the Emulator Pin Placement is selected. These are the ICSP pins used for the PICKit-On-Board (PKOB) on-board debugger/programmer.

Emulator Pin Placement field

Back to Top


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.

a. 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.]

Device Resource Window

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

Back to Top


Configure GPIO

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

a. 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 accompanying 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

Pin selection

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

Note: The Custom Name must match the table below 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 NameFunctionCustom NameStart HighDirectionInterrupt-on-change
RB7U1TX YesOutputNone
RB8U1RX NoInputNone
RB13SDI1SDI1NoInputNone
RB14SDO1SDO1NoOutputNone
RB15SCK1OUTSCK1OUTNoOutputNone
RC1CDSDCard_CDNoInputNone
RC9CSSDCard_CSNoOutputNone

The Pin Module settings should look like the accompanying image.

Pin Module Settings

Back to Top

Learn More

Back to Top