Step 4: Configure File System (FatFs) and SD/MMC Card Libraries

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® 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 this time to configure the File System Library (FatFs) and SD/MMC card library to complete the exercise.

Step 4.1 – Configure File System Library and Add SD/MMC Card Library

1

From the Project Resources window, select the FatFs library.

microSD22.png

2

Locate the FatFs tab and click on the Configuration tab. Uncheck the Generate example/demo files box.

microSD23.png

3

Add the SD/MMC card library by selecting SD Card (SPI) in the Select a physical layer driver: field. Click the + Insert Driver button.

microSD24.png

4

Scroll down to the Features Selection and Optimizations section. For the String function optimization pull-down, select 1: Enable without LF-CRLF conversion.

microSD25.png

5

Scroll further down and find the Select Source of File Timestamps section. Select Use fixed timestamp.

microSD26.png

Step 4.2 – Configure SD/MMC Card Library

1

From the Project Resources window, select the SD Card (SPI) library.

microSD27.png

2

Locate the SD Card (SPI) tab and make the following changes:

  1. Uncheck the Enable Write Protect (WP) box.
  2. Select Active Low for the Enable Chip Select (CS) Polarity pulldown.
  3. Select Active Low for the Enable Card Detect (CD) Polarity pulldown.
microSD28.png

Note: SPI MCC driver is automatically configured by the SPI Card (SPI) library.

3

Generate the code by clicking the Generate button in the Project Resources window.

microSD29.png

The Output window in the lower right window will read “Generation complete” if successful.

microSD30.png
© 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.