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 plugin 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.
Step 6.1 - Open and configure Data Visualizer
2
Close the extra display windows, they won’t be used. Only the Terminal Display is needed.
Step 6.2 - Select displayed parameters
1
Select Send to Terminal for the appropriate communication channel.
Note: The correct communication channel number will likely be different than what is shown here.
2
Select the same communication channel for the Input Source.
Step 6.3 - Verify the correct operation
1
Insert the microSD card into the MIKROE microSD Click Board™.
Upon success, the Data Visualizer Terminal window will display the following messages:
If you have a microSD card reader, you can verify the file contents by opening TEST.TXT.
The TEST.TXT file contents will match the data shown previously in the Data Visualizer Terminal window output:
Note: It is recommended to eject the SD card prior to removing it from the computer.
Step 6.4 – 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 Board.
Step 6.5 – Analysis
You have successfully created a microSD application using MPLAB Code Configurator (MCC) 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.
Step 6.6 – 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 Application Programming Interfaces (APIs) available in the FatFs – Generic FAT Filesystem Module 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.