SAM9X60-Curiosity – Getting Started with MPLAB® Harmony v3 Development: CSP Application: rtt_periodic_timeout

Last modified by Microchip on 2024/06/20 12:43

Introduction

In this training topic, you will download, configure, and build an MPLAB® Harmony v3 example application using the MPLAB X Integrated Development Environment (IDE) to run on the SAM9X60-Curiosity Development Board (P/N: EV40E67A) 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 SAM9X60D1G, 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. Training topics on how to write binary files to NVM are given in the "What’s Next?" section below. 

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

  • MPLAB X IDE Installed 
  • XC32 compiler installed 

This training topic was developed with MPLAB X IDE v6.20 and XC32 v4.35 

Back to Top

Hardware

For this training, you will use the SAM9X60-Curiosity Development Board (P/N: EV40E67A)

SAM9X60-Curiosity Development Board

For more information, see the “SAM9X60-Curiosity – Features” page. 

Setup the SAM9X60-Curiosity as listed below to the host computer running MPLAB X IDE. 

Jumpers 

SD Memory Cards 

  • Ensure no SD memory cards are plugged into the SD card connector (J5). 

Power 

  • Apply power by connecting a USB micro-B connector to the USB-A Connector (J1) and the host computer, or a suitable USB power source. 

For more information see the “Power Options” section of the “SAM9X60-Curiosity - Features” page. 

Debug Communications 

In the examples below we will be using the MPLAB PICkit 5 with Debugger Adapter Board. 

Console Serial Communications 

Back to Top

Configure and Build a Project for Debugging

In this section, you will download, configure, and build a CSP application example using the MPLAB X IDE to run on the SAM9X60-Curiosity in Debug mode. This scenario is typical of the initial project development steps of coding, building, and debugging. 

As of MPLAB X IDE v6.05, the plugins, MPLAB Harmony 3 Content Manager (MHCM) and MPLAB Harmony Configurator (MHC), have been migrated to MPLAB Code Configurator (MCC) 

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_9x60

Download or clone csp_apps_sam_9x60 library from the Microchip MPLAB Harmony 3 GitHub repository to the Harmony3 directory. 

Back to Top


Open Project: rtt_periodic_timeout_sam_9x60_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>\Harmony3\csp_apps_sam_9x60\apps\rtt\rtt_periodic_timeout\firmware\sam_9x60_curiosity.X 

Click on the Open Project button.  

The rtt_periodic_timeout_sam_9x60_curiosity project loads into MPLAB X IDE. 

Open Project

You may receive a Configuration Loading Error. This is due to an older version of the Device Family Pack (DFP) at the time of creating the project. You will update the DFP to the latest version in the next steps. 

Back to Top


Configure Project Properties for Debugging in MPLAB X IDE 

Open Project Properties 

Open the rtt_periodic_timeout_sam_9x60_curiosity Project Properties using one of the following methods: 

  1. In the Projects pane, highlight rtt_periodic_timeout_sam_9x60_curiosity and click on the wrench icon in the rtt_periodic_timeout_sam_9x60_curiosity - Dashboard
  2. In the Projects pane, right-click on rtt_periodic_timeout_sam_9x60_curiosity and select Properties from the menu. 

The Projects Properties – rtt_periodic_timeout_sam_9x60_curiosity dialog box opens. 

Projects Properties – rtt_periodic_timeout_sam_9x60_curiosity

In the Categories pane, select Config: [sam_9x60_curiosity]

Select the version of DFP and XC32 Compiler you require for the application.  

For the MPLAB PICkit 5 In-Circuit Debugger (ICD) to operate correctly, SAM9X6_DFP version 1.8.210 or higher is required. 

You may see a [Resolve] link next to a version of the Device Family Pack (DFP). This is due to an older version of the Device Family Pack (DFP) at the time of creating the project. Highlight the latest DFP and click on the Apply button. This will update the configuration to the latest DFP.  

The Device Family Pack (DFP) contains device-specific support software. The 32-bit MCU and MPU DFPs are maintained by Microchip Technology and are available on GitHub. 

In the Connected Hardware Tool drop down menu, select the connected debug probe. 

The debug probe must be connected to the host computer to see it available in the drop-down menu. 

For the MPLAB PICkit 5 In-Circuit Debugger (ICD) to operate correctly, SAM9X6_DFP version 1.8.210 or higher is required. 

Click on the Apply button. Observe under the Categories: Conf: [sam_9x60_curiosity) that PICkit 5 and Bootstrap are now listed. 

Project Config: Tool

Project Config: Tool (Apply)

In the Categories pane, select PICkit 5.
In the Option categories drop down box, select Communications.

Change JTAG Speed to 1.00 MHz.  

Project Config: Tool (JTAG)

In the Categories pane, select Bootstrap

Observe that Use bootstrap is selected and the pre-compiled version of the at91bootstrap.elf is selected. 

If you have compiled a custom version of the at91bootstrap, press on the Load button, locate and highlight, then press the Open button. For more information, see the training topics listed in the "What’s Next?" section below. 

The 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 SAM9X60-Curiosity, MPLAB X IDE can be used to run and debug the application. 

at91bootstrap is a second-stage bootloader for Microchip Technology Arm®-based microprocessors (MPU). For more information see the “at91bootstrap: A Second Stage Bootloader for Microchip MPUs” page. 

Project Config: bootstrap

Click the Apply and OK buttons.

Back to Top


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. 

From the MPLAB X IDE menu, select Tools > Options.
From the Options window, Select Plugins from the ribbon.
Click on the MPLAB Code Configurator 5.x tab.
Under Harmony Content Path, click on the finder and select the location of the Harmony3 directory.

Click on Apply and OK buttons.

Options - Plugins - Harmony Path

Back to Top


Set Debug Reset and Startup Options

In MPLAB X IDE, click on Tools > Options. An Options window opens.
Click on the Embedded icon at the top and the Generic Settings tab.

Configure the settings for:

  • Debug Reset @ – Main
  • Debug startup – Halt at Main

Options - Embedded - Generic Settings

Click on the OK button.

Back to Top


Power the SAM9X60-Curiosity

Apply power by connecting a USB Micro-B connector to the USB-A Connector (J1) and the host computer, or a suitable USB power source.

For more information see the “Power Options” section of the “SAM9X60-Curiosity - Features” page.

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.

For more information see: SAM9X60 Boot Process

At this point you have configured the MPLAB Harmony v3 project within MPLAB X IDE. In the next step, you will build the project for debugging. 

Back to Top


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 SAM9X60-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.

MPLAB X IDE uses at91bootstrap to initialize the SAM9X60D1G and then exits without loading any additional binary files to SDRAM. MPLAB X IDE then loads the application program to SDRAM. For more information see: SAM9X60 Boot Process.

IDE Debug Halt

You can view the second-stage bootloader (at91bootstrap) activity on the console.

For more information on establishing serial communications with the target console see: SAM9X60-Curiosity - Console Serial Communications

Console: Application Booting

Click on the Continue button. The application binary runs within the target. Observe the RGB LED (LD1) flashes blue at a 1 Hz rate.

The rtt_periodic_timeout application blinks the RGB LED once per second when an RTT timer interrupt occurs.

If you stop a debug session you must press the Reset button on the SAM9X60-Curiosity to initiate the boot process before launching another debug session.

Congratulations! You successfully downloaded, configured, and built an MPLAB Harmony v3 CSP Application example to run on the SAM9X60-Curiosity in debug mode.

Back to Top

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 SAM9X60-Curiosity prior to (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 SAM9X60. There are several libraries required to perform full development. In this section you will use MPLAB Code Configurator to download and manage these libraries.

As of MPLAB X IDE v6.05, the plugins, MPLAB Harmony 3 Content Manager (MHCM) and MPLAB Harmony Configurator (MHC), have been migrated to MPLAB Code Configurator (MCC)

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.MCC Content Manager Wizard

Back to Top


Expand the rows in the Component column to view the required libraries.

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.

Project Manifest

Click on the Continue button.

MCC is displayed. The Project Graph, Project Resources, and Device Resources windows are active.

Back to Top


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.

MCC Project Graph

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.

MCC Content Manager Update

Back to Top

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.
Select the Content Libraries tab and scroll down until you see Harmony 3 – Core.

Expand Harmony 3 - Core.

Select the latest version of the bsp and core 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.

The bsp and core libraries give you more resources for MPU development. However, there are number of additional libraries available. Select and download them as needed using the same steps outlined above. 

Back to Top


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.

Back to Top


Close MCC

The required libraries for the project are loaded.

Back to Top

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.

Click on the Clean and Build icon on the toobar.

Back to Top


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>\Harmony3csp_apps_sam_9x60\apps\rtt\rtt_periodic_timeout\firmware\sam_9x60_curiosity.X\dist\sam_9x60_curiosity\production\harmony.bin

IDE Output

Back to Top


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.

Linker for Production: ddram

Back to Top

Summary

In this training topic, you downloaded, configured, and built an MPLAB Harmony v3 application example using the MPLAB X IDE to run on the SAM9X60-Curiosity in debug mode. And you cleaned and built the application for production and now it’s ready for writing into NVM.

Back to Top

What’s Next?

Once a MPLAB Harmony v3 application (harmony.bin) has been developed and built for production, the next step is to configure and build the second-stage bootloader, at91bootstrap, for reading the harmony.bin binary from NVM and writing to SDRAM. For example, from the NAND Flash and SD memory card. 

Back to Top