Getting Started with MCU Projects Using MPLAB® Code Configurator (MCC) Melody

Building an MCC Melody Project and Programing a Development Board

Last modified by Microchip on 2024/06/24 06:33

   Downloading an MCC Melody Example Project  Editing an Existing MCC Melody Project   

You now have all the components you need to start developing your firmware project. You have MPLAB® X IDE and MPLAB XC8 compiler installed on your computer, you’ve procured a PIC18F56Q71 Curiosity Nano Demo Board, and you’ve downloaded the PIC18F56Q71 Basic Uart Comms demo project from the Microchip Discover website.

PIC18F56Q71 Curiosity Nano board

However, before you begin hacking the code to customize it for your application, you will want to build the demo project and program it into your demo board to verify that you are starting with a known working project. This will also familiarize you with the build process in MPLAB X IDE.

MPLAB X IDE Overview

If it is not already running, launch MPLAB X IDE.  If this is your first time using the IDE, there are some things you will notice. First is the layout of the graphical user interface. Across the top are the menus and the main toolbar for quick access to the tools and tasks you’ll use most.  

view of MPLAB X first opening from a fresh install with the toolbar highlighted

One important button in the toolbar that you will use later is the Make and Program Device program-target-project icon button. You will use this button to build the project and program the device.  

Below the toolbar are the interactive window groups, where the work gets done. There are four main window groups: the Project Group, the Editor Group, the Navigation Group, and the Output Group. 

MPLAB X IDE session with the four window groups labeled

When you open the IDE for the first time, you may only see the Editor group or maybe the Project and Editor Groups. It depends on whether you had a previous version of MPLAB X IDE on your machine and allowed the new install to use the old settings. In any case, the Navigation Group and Output Group windows will open once you have opened a project to work on. If the Project window is visible, like the Navigation and Output windows, it will have nothing to show until you have opened a project.  

The window group that will be there for sure is the Editor window group. This window will greet you with two tabs to help you get started, the appropriately named Start Page and the MPLAB X IDE Store. 
Close up of Editor Page tabs
Click image to enlarge.
The Start Page consists of three sub-pages, Learn & Discover, My MPLAB X IDE, and What’s New.
Close up of Start Page's three subpages
Click image to enlarge.
The My MPLAB X IDE and Learn & Discover pages contain links to many useful resources like datasheets, user guides, and Getting Started tutorials. 
Highlighting important links on the Learn and Discover page
Click image to enlarge.
The Projects section on these two pages contains shortcuts to creating new projects—either from scratch, from sample code, or importing projects from other IDEs. 
Highlighting the Projects section on Learn and Discover page
Click image to enlarge.
And finally, the What’s New page offers links to articles on the latest releases in development tools from Microchip. 
The What's New page
Click image to enlarge.

The other tab in the Editor window is the MPLAB X IDE Store. Here you can browse through the extensive collection of hardware and software development tools that Microchip offers.  

MPLAB X Store page

The page contains standard web browser controls at the top and a collapsible side menu on the left to help you navigate to find your desired tool. 

Clicking a category on the left side menu brings up an illustrated list of tools on the right. Choose a tool and click on the Read More link to read the full description or click on the name of the tool to display the full Microchip webpage for that tool. 

If you wish to purchase a tool, click on the Add To Cart button and it will pop up a window showing it has added the item to your cart. From that pop-up, you can choose Continue Shopping to close the pop-up, or you can click on Go To Cart to go to Microchip Direct and purchase the item.  

Back to Top

Opening the Project in the IDE

Now that you have a feel for the support resources available through the IDE, you are ready to open the demo project and learn more about the working resources of the IDE.   

To open an existing project, go to the File menu and select Open Project. This will bring up the Open Project browsing window.
Opening the Open Project browsing window
Click image to enlarge.
Navigate to where you've saved the demo project, select it, and click the Open Project button. When navigating in this window, it is easy to recognize which file is a valid MPLAB X IDE project because the name will have a .X suffix and will be displayed with an IC chip icon next to it instead of the usual folder icon. 
Selecting the project to open
Click image to enlarge.

You should now see the basicUARTcomms_Q71 project displayed in the Project window. As mentioned, all of the window groups are now open and populated with information. Notice there are three tabs in the Projects Window: Projects, Files, and Classes. 

Screencap of IDE with project opened

The Projects tab displays all the open projects, in this case just the demo project, but it could contain more. When there is only one project open, it is by default the Main Project. That means it is the project that all the tools like the Code Configurator, C compiler, or programmer/debugger will operate upon.   

If you have multiple projects open, you need to choose which project the tools will operate on by designating one of them as the Main Project. This is done by right-clicking the mouse on the name of the project and selecting Set as Main Project in the drop-down menu. The name of that project will now be in bold text to indicate it is the Main Project. 
Right click on project name to set as main
Click image to enlarge.

Back to Top

Examining the Project

The files within the project are organized logically into folders, Header Files, Source Files, etc. Browse the folders to find a file and double-click on it to open it in the Editor Window. 
Project folders expanded
Click image to enlarge.
The Files tab looks much like the Projects tab except that its view includes other project files that are usually unseen, i.e. intermediate build files, debug and symbol files, elf and hex files, etc., and the files are organized as they physically appear on the hard drive. 
Files tab showing all files in project as physically organized on disk
Click image to enlarge.
The other tab is the Classes tab. This view provides a list of all the functions, variables, and macros within the project. Find the function or variable you want to view and double-click on it to open the file that contains its definition. Let’s scroll down to the UART2_Read() function and double-click on that. 
Classes Tab showing project's functions and variables
Click image to enlarge.
This will open the uart2.c file in the Editor Window. This is where you will edit the source files for your project. It is also the default window to display the various plugins like the MPLAB Code Configurator (MCC) that you will be using later.  
Classes Tab showing project's functions and variables
Click image to enlarge.

The Navigation Group in the bottom left corner contains two tabs, the Project Dashboard and the Navigation Window.    

The Dashboard shows other useful information about the project like the Target Device, Compiler, Debug Tool and resources, Memory Usage, etc.  
Project Dashboard
Click image to enlarge.
The Navigation Window, like the Classes window, shows a view of the functions. The difference is that this view is focused on the functions contained in the file that is active in the Editor window rather than the whole project. And since we have the uart2.c file open in the editor, we see the functions contained in that file.
Navigation window showing open file's functions
Click image to enlarge.

Finally, the Output Group window can contain many tabs for communicating information about the various actions happening in the IDE. For instance, compiler output messages, debugging windows like watch variables and breakpoints, memory viewing windows, simulator stimulus and output data, and more. In this case, we see a configuration loading error. This message is because we have a newer version of the compiler than what was used when the demo project was saved in the Discover repository. 

Output window showing compiler difference

It is possible that the output window popped up with messages when you opened the demo project. One tab may be titled Configuration Loading Error and contain a message like:   

Configuration “default” load error: PIC18F-Q_DFP 1.1x.xxx is used in the configuration and it is not installed. Resolution: Click on the below link to resolve the same version of DFP

Output window showing DFP difference message

This is also not a problem, it merely indicates that the project was created using a different Device Family Pack (DFP) than you have installed with your compiler version. If you have a newer version of the DFP, you can ignore this message and the project should build and operate fine. If for some reason it will not build correctly, resolve the DFP issue by downloading and installing the version of DFP that was used originally.   

DFPs contain information on each supported device (microcontroller/microprocessor) grouped by family. This information includes data on device power requirements, programming methods, architecture, etc. The IDE uses this information to configure, build, program, and/or debug your project. For more information on DFPs, see the "Device and Tool Packs Used in MPLAB X IDE Projects" page.

Back to Top

Connecting the Evaluation Board to Your PC

Before you can build and program your target device, you must connect the Curiosity Nano board to your PC. The board has a built-in debugger/ programmer, so all you need to do is plug a USB cable (Standard-A to Micro-B or Micro-AB) between the PC and the debug port (Micro-USB connector) on the Curiosity Nano board.   

 Curiosity board connected to PC via USB cable 

If your demo board was connected successfully, you should see the Kit Window open in the Editor Group with the PIC18F56Q71 Curiosity Nano board displayed.  

Kit Window for the curiosity board

The Kit Window has a block at the bottom titled Kit Information, expanding that box gives a full description of the development board that is connected to the PC, including technical information like the target device, its voltage range, the programming interface used, USB enumeration of the on-board programmer/debugger, and even the serial number of the connected board. 
Kit information box in the Kit Window
Click image to enlarge.
The page also has an External Links section that contains links to the datasheet, user guide, code examples, and the Altium project for the board, which includes schematics, BOM, and Gerber files. 
External links section of Kit Window
Click image to enlarge.

Back to Top

Configuring Project Properties

Since this is your first time building this project, it must be set up for your needs. Right-click on the project name in the Projects window and select Properties
Opening Project Properties Window
Click image to enlarge.
In the Categories pane of the Project Properties window, select Conf: [default]. Then, in the Configuration pane, open the pull-down menu under Connected Hardware Tool and select the PIC18F56Q71 Curiosity Nano Board from the list.   
Selecting Hardware Toll for Project
Click image to enlarge.
Below the tool selection menu, you will find the Packs and Compiler Toolchain windows. Verify that you have the latest version of the device family pack and MPLAB XC8 compiler selected. This is where you can resolve the DFP mismatch if you choose to do so later.  Click Apply to apply the settings to the project and then click OK to close the dialog box.  
Close up of Packs and Compiler setup windows
Click image to enlarge.

Back to Top

Building the Project and Programming the Board

You are now ready to build the project and program the board. There are two main options for building, Production or Debug. Since you just want to see if it works, we’ll go with Production and get into Debug later. You can build the project without programming to verify that it builds successfully. Click on the Build Project build-project icon drop-down to the right of the button in the toolbar. From the list of options, select Build Project. If everything is set up correctly, you should see a "BUILD SUCCESSFUL" message in the Output window.
Build Project options pull-down
Click image to enlarge.

Output window showing successful build

To program the board, click on the Make and Program Device program-target-project iconbutton on the main toolbar. MPLAB X IDE will build your project again and then program the board. If the firmware in the debugger chip on the board is out-of-date, the system will update this firmware first before programming the target device. This may take a minute or two, but eventually, it will program the device and you should see a "PROGRAMMING AND VERIFY SUCCESSFUL" message in the Output window. 

Output showing successful programming of target

Back to Top

Verifying Functionality with the Data Visualizer

Congratulations! Your board is now programmed. To verify it's working correctly, you will need to use the Data Visualizer tool as specified in the instructions provided with the PIC18F56Q71 Basic Uart Comms demo project on Microchip Discover.   

View of project page on Discover showing how the project works

To launch the Data Visualizer, click the DV button data-visualizer icon on the toolbar. The Visualizer will open in a new tab within the Editor window. The PIC18F56Q71 Curiosity Nano board is recognized by the Data Visualizer, as evidenced by the name of the board displayed at the top of the Connections tab on the left side of the display. 

Data Visualizer window opened

Below the name, you should see the two data connections from the project, Debug GPIO and a USB COM port. The COM port is provided by a serial-to-USB converter inside the programmer/debugger, and it streams data from a UART on the microcontroller to the PC. The number of the COM port will vary depending on the number of connections on your PC. 
Data connections in Data Visualizer
Click image to enlarge.
To the right of the connections, you will see two display panels for the data, each with two tabs. The top display panel has a Time Plot and a Dashboard tab. The Time Plot visualizes incoming data over time as plots, bands, and string flags. The Dashboard displays or can input data using widgets.  
Time Plot and Dashboard Tabs in Data Visualizer
Click image to enlarge.

The other display contains the Terminal and XY Plot tabs. The Terminal displays data as text, either as raw values or ASCII-encoded characters. It is also capable of sending text-based data. The XY Plot visualizes incoming x vs y data as a plot.   

The Terminal window will be the only one used for this exercise, so the other windows can be closed or simply ignored.   

Terminal and XY Plot tabs in Data Visualizer
Click image to enlarge.
Begin communication between the COM port and terminal by hovering over the COM port component, which will expose some button icons at the bottom of that box. Hover over the second icon and you should see the "Display as text in the terminal" pop-up message. Click that button.
Beginning communication between DV and board
Click image to enlarge.

You should now see a red square and the word “Capturing” indicating that you are now communicating with the board and capturing the interactions in the terminal screen.  

Verify that the UART2_Read() function is working by clicking inside of the terminal window and entering the character "T". This action will toggle the LED on the Curiosity Nano board ON/OFF. Entering any other character will have no effect.  
Typing T character verifies UART2_Read function works if LED toggles
Click image to enlarge.
Verify the UART2_Write() function is working by pressing the push-button switch on the Curiosity Nano board. The character "S" will be output to the terminal every time you press the button.  
UART2_Write function is verified if pushing button causes S character to appear in DV terminal
Click image to enlarge.

And that’s it! You have verified that the demo project is working. You can now begin customizing the code to meet the requirements of your project.