Demonstrating Secure Digital Flash Memory Card Functionality Using MPLAB® Code Configurator (MCC) - 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-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
a. 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.
Add File System and SD/MMC Card MCC Libraries
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.
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.
The libraries will now be listed in the Project Resources window.
Configure System Module
Now you can start configuring the settings.
a. Click System Module in the upper left window.
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.
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.
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.]
b. In the UART1 configuration window, click the checkbox next to Redirect Printf to UART. This is used to display information to Data Visualizer.
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
In the Pin Module window, select the Easy Setup tab and configure the selected GPIO as follows.
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 accompanying image.
Learn More
- Demonstrating Secure Digital Flash Memory Card Functionality Using MPLAB® Code Configurator (MCC)
- Adding Secure Digital (SD/MMC) Flash Memory Card Functionality Using MPLAB® Code Configurator (MCC) - Step 2: Download Example Code and Setup MCC
- Demonstrating Secure Digital Flash Memory Card Functionality Using MPLAB® Code Configurator (MCC) - Step 4: Configure File System and SD/MMC Card Libraries