Demonstrating Secure Digital Flash Memory Card Functionality Using MPLAB® Code Configurator (MCC) - Step 6: Test application

Last modified by Microchip on 2024/06/04 12:30

Test Application

Troubleshooting your code's run-time behavior has never been easier. MPLAB® Data Visualizer is a free debugging tool that graphically displays run-time variables in an embedded application. Available as a plug-in for MPLAB X Integrated Development Environment (IDE) or a stand-alone debugging tool, it can receive data from various sources such as the Embedded Debugger Data Gateway Interface (DGI) and COM ports. You can also track your application's run-time behavior using a terminal or graph.

We’ll use MPLAB Data Visualizer to display messages from the software and verify it is functioning correctly. If you have a microSD card reader, we’ll show you how to verify the file contents as well. 

Open, configure Data Visualizer

Open Data Visualizer by clicking on its icon in MPLAB X IDE. 

data visualizer button

Close the extra display windows; they won’t be used. Only the Terminal Display is needed.

Data Visualizer windows to close


Select displayed parameters

Select Send to Terminal for the appropriate communication channel.

send to terminal option

The correct communication channel number will likely be different that what is shown here

Select the same communication channel for the Input Source.

Source drop-down list


Verify correct operation
Insert the microSD card into the MIKROE microSD Click board.

Press the Run button run button in MPLAB X IDE. The project will build, program, and run.

Upon success, the Data Visualizer Terminal window will display the following messages:

Data Visualizer Terminal window

If you have a microSD card reader, you can verify the file contents by opening TEST.TXT.

test.txt file options

The TEST.TXT file contents will match the data shown previously in the Data Visualizer Terminal window output:

TEST.TXT file contents

It is recommended to eject the SD card prior to removing it from the computer.

microsd card options

Back to top

Results

You observed the application create, write, read and close a text file on a microSD card. This information is displayed on MPLAB Data Visualizer via the MCP2221 Breakout Module using a MIKROE microSD card Click. 

Back to top

Analysis

You have successfully created a microSD application using MPLAB Code Configurator and the Microchip File System Library. Your application used all the fundamental elements that go into building a real-time microSD application to write and read data. This application determines if the card is present, registers the file system object to the FAT File System module, creates and opens a new file (TEST.TXT), writes a data string, reads it back then finally closed the file and unmounts the drive. You configured the FAT and SD card MCC libraries. You set up UART1 to interface with the MCP2221A USB to UART module to display metering data via MPLAB Data Visualizer. Finally, you also configured GPIO for the microSD card interface. 

Back to top

Conclusions

This tutorial provided you with training for configuring the Microchip File System Library using MPLAB X IDE and MCC. As a next step, you can create your own application to suit your needs. You can also investigate the APIs available in the FatFs - Generic FAT Filesystem Module user guide to add functionality to your own application. Ultimately, if you were to use another MCU supported by MCC, you can explore a similar solution. Note that the pin configuration would change since the MCU resources will be different.

Back to top