SAM9X75 Curiosity – Getting Started with MPLAB® Harmony v3 Development: CSP Application: rtt_periodic_timeout
Introduction
In this training topic, you will download, configure, and build an MPLAB® Harmony v3 example application using MPLAB X Integrated Development Environment (IDE) to run on the SAM9X75-Curiosity Development Board (P/N: EV31H43A) in Debug mode. This scenario is typical of project development steps of coding, building, and debugging.
While in debug mode, the second-stage bootloader, at91bootstrap, is used by MPLAB X IDE to initialize DRAM so that it can continue loading the MPLAB Harmony v3 project binary (harmony.bin). Once the project has been loaded onto the SAM9X75D2G, MPLAB X IDE can be used to run and debug the application.
Once a project has been fully developed, the application is cleaned and built for production. The application binary (harmony.bin) is loaded by at91bootstrap from Non-Volatile Memory (NVM), such as an SD memory card, e.MMC, NAND and NOR Flash memories.
MPLAB Harmony v3 Application
The CSP Application example demonstrates the control of peripherals using Peripheral Libraries (PLIBs) with minimal external dependencies. The rtt_periodic_timeout application blinks the RGB LED once per second when an RTT timer interrupt occurs.
Prerequisites
Hardware
For this training, you will use the SAM9X75-Curiosity Development Board (P/N: EV31H43A)
SAM9X75-Curiosity Development Board
Setup the SAM9X75-Curiosity as listed below to the host computer running MPLAB X IDE.
Jumpers
- Set the jumpers to their default positions as shown in the “Jumper Summary” section of the “SAM9X75-Curiosity User Guide.
SD Memory Cards
- Ensure no SD memory cards are plugged into the SD card connector (J14).
Power
- Apply power by connecting a USB micro-B connector to the USB-A Connector (J2) and the host computer, or a suitable USB power source.
Debug Communications
- Connect a debug probe, such as the Microchip J-32 Debug Probe, or MPLAB PICkit™ 5 In-Circuit Debugger (ICD) with a Debugger Adapter Board to the JTAG Connector (J34) and the host computer running MPLAB X IDE.
Console Serial Communications
- To view the target console, connect the host computer running a terminal emulation program per “SAM9X75-Curiosity – Console Serial Communications.”
Configure and Build a Project for Debugging
In this section, you will download, configure, and build a CSP application example using MPLAB X IDE to run on the SAM9X75-Curiosity in Debug mode. This scenario is typical of the initial project development steps of coding, building and debugging.
Normally, the MPLAB Harmony v3 Software Framework libraries are downloaded when a new MCC project is created in MPLAB X IDE. However, when working with an example application, such as this one, the MPLAB Harmony v3 Software Framework libraries are assumed preinstalled on the host computer. Therefore, if you do not have the MPLAB Harmony v3 Software Framework libraries preloaded, you will have to download or clone the CSP Application Library from the Microchip MPLAB Harmony v3 GitHub repository before opening the example application project. We will show you how in the following steps.
Download the CSP Application Library
Create a Harmony3 Directory
Create a directory named Harmony3. For a Windows operating system, it is typically located at C:\Users\<user>\Harmony3\.
Download or clone csp_apps_sam_9x75
Download or clone the csp_apps_sam_9x7 library from the Microchip MPLAB Harmony 3 GitHub repository to the Harmony3 directory.
Open Project: rtt_periodic_timeout_sam_9x75_curiosity
From MPLAB X IDE, select File > Open project.
An Open Project window will open.
Locate the following project in the Harmony3 directory:
C:\Users\<user>\HarmonyContent\csp_apps_sam_9x7\apps\rtt\rtt_periodic_timeout\firmware\sam_9x75_curiosity.X
Click on the Open Project button.
The rtt_periodic_timeout_sam_9x75_curiosity project loads into MPLAB X IDE.
Configure Project Properties for Debugging in MPLAB X IDE
Open Project Properties
Open the rtt_periodic_timeout_sam_9x75_curiosity Project Properties using one of the following methods:
- In the Projects pane, highlight rtt_periodic_timeout_sam_9x75_curiosity and click on the wrench icon in the rtt_periodic_timeout_sam_9x75_curiosity - Dashboard.
- In the Projects pane, right-click on rtt_periodic_timeout_sam_9x75_curiosity and select Properties from the menu.
The Projects Properties – rtt_periodic_timeout_sam_9x75_curiosity dialog box opens.
Select the version of DFP and MPLAB XC32 Compiler you require for the application.
In the Connected Hardware Tool drop-down menu, select the connected debug probe.
Click on the Apply button. Observe under the Categories: Conf: [sam_9x75_curiosity) that PICkit 5 and Bootstrap are now listed.
Change JTAG Speed to 4.000 MHz.
In the Categories pane, select Bootstrap.
Observe that Use bootstrap is selected and the pre-compiled version of the at91bootstrap.elf is selected.
Configure the MPLAB Harmony Content Path
In this step, you will let MPLAB X IDE know the location (directory) of the MPLAB Harmony Software Framework on your host computer.
Click on the Apply and OK buttons.
Set Debug Reset and Startup Options
Configure the settings for:
- Debug Reset @ – Main
- Debug startup – Halt at Main
Power the SAM9X75-Curiosity
Apply power by connecting a USB Micro-B connector to the USB-A Connector (J2) and the host computer, or a suitable USB power source.
Press the RESET push button (SW1)
This step places the first-stage bootloader into the SAM-BA® Monitor mode. You can observe the RomBOOT message on the console.
Build the Project
Click on the Debug Project icon on the toolbar.
The project will build with debugging parameters, load the application binary to the SAM9X75-Curiosity and halt at Main. Once the build is complete and the application binary is loaded into the target, the toolbar expands to show additional debugging icons.
You can view the second-stage bootloader (at91bootstrap) activity on the console.
Click on the Continue button. The application binary runs within the target. Observe the RGB LED (LD1) flashes blue at a 1 Hz rate.
If you stop a debug session you must press the Reset button on the SAM9X75-Curiosity to initiate the boot process before launching another debug session.
Continuing Development with MPLAB Harmony v3 Software Framework
With the project in Debug mode, you can now pause, insert additional breakpoints and continue running the project. If you change the source code, you will need to reset the SAM9X75-Curiosity before (re)building and loading the project to the target. Resetting places the MPU back into the bootloader mode.
For this example application, you only downloaded or cloned one MPLAB Harmony v3 library: CSP Applications for the SAM9X75. There are several libraries required to perform full development. In this section, you will use MPLAB Code Configurator (MCC) to download and manage these libraries.
Open MPLAB Code Configurator (MCC)
Open MCC by clicking on the MCC shield on the tool bar.
The MCC Content Manager Wizard will open. In the top half window is the Content Download Required.
Click on the Finish button at the bottom-right. The required content will download. Be patient, this will take a while.
A Package Versions Used vs Available dialog may appear if the MPLAB Harmony package versions that the project was developed with do not match the versions available locally. In the next steps, you will update the project to the latest package versions.
Click on the Continue button.
MCC is displayed. The Project Graph, Project Resources, and Device Resources windows are active.
If you received a Package Versions Used vs. Available dialog, perform the following steps:
In the Device Resources pane, click on the Content Manager button.
Observe the packages and versions that were called out in the dialog in Step 3.1 above. You can do either:
- Individually select the latest version available for each package and click on the Apply button. In this example, the csp and dev_packs, or
- Click on the Select Latest Version(s) button and click on the Apply button.
This will update the selected libraries and MCC will restart. You will see the Package Versions Used vs Available dialog again. Click on the Continue button.
Download Packages for MPU Development
There are additional libraries required for MPU development. They are the Board Support Package (bsp) and Core (core).
- The BSP contains the defines (names and attributes) of the features (clock configuration, pins, switches, and LEDs) of a selected evaluation kit.
- The Core Package (core) contains device driver, system service, OSAL, and third-party software libraries.
Click on the Apply button.
The package versions will be downloaded and installed. MCC will restart. You will see the Package Versions Used vs Available dialog again. Click on Continue button.
Click on the Generate button.
MCC will generate new source code. Merge all code. You should no longer see the Package Versions Used vs Available dialog.
Configure and Build a Project for Production
Once a project has been fully developed, the application is cleaned and built for production. The application binary (harmony.bin) is loaded from NVM, such as SD memory card, eMMC, NAND and NOR Flash memories, by the second-stage bootloader: at91bootstrap.
Observe the location of the production binary. Take note of this location as it contains the harmony.bin binary that you will write into NVM.
C:\Users\<user>\HarmonyContent\csp_apps_sam_9x7\apps\rtt\rtt_periodic_timeout\firmware\sam_9x75_curiosity.X\dist\sam_9x75_curiosity\production\harmony.bin
Observe the DDRAM Address that harmony.bin is to be loaded to by at91bootstrap. This is found in the Linker Files: ddram.ld. Take note of this value as it is required for configuring at91bootstrap to load harmony.bin from NVM.
Summary
In this training topic, you downloaded, configured, and built an MPLAB Harmony v3 application example using MPLAB X IDE to run on the SAM9X75-Curiosity in Debug mode. And you cleaned and built the production application and now it’s ready for writing into NVM.