SAMA7D65-Curiosity – Getting Started with MPLAB® Harmony v3 Development: CSP Application: pio_led_on_off_interrupt

Last modified by Microchip on 2024/12/12 10:39

Introduction

In this training, you will download, configure, and build an MPLAB® Harmony v3 Software Framework application to run on the SAMA7D65-Curiosity Kit using MPLAB X Integrated Development Environment (IDE) in Debug mode. This scenario is typical of project development, coding, building, and debugging.

Once the application has been fully developed, the application is cleaned and built for production. The resulting binary image (harmony.bin) is written to Non-Volatile Memory (NVM), such as a Secure Digital (SD) memory card, embedded MultiMediaCard (eMMC), NAND, or NOR Flash memories. The harmony.bin binary image is read from NVM by the second-stage bootloader, at91bootstrap, which is also written to NVM. However, at91boostrap must be configured and built for a given NVM. Instructions on how to do this are given in the "What’s Next?" section.

MPLAB Harmony v3 Application

The Chip Support Package (CSP) application demonstrates the control of peripherals using Peripheral Libraries (PLIBs) with minimal external dependencies. The pio_led_on_off_interrupt application turns on the Red, Green, and Blue (RGB) Light-emitting Diode (LED) when a General-Purpose Input/Output (GPIO) interrupt is generated upon switch press and release. 

Back to top

Prerequisites

​This training was developed with MPLAB X IDE v6.20 and MPLAB XC32 v4.45.

Back to top

Hardware

For this training, you will use the SAMA7D65-Curiosity Kit.

SAMA7D65-Curiosity Kit

See the "SAMA7D65-Curiosity Kit - Features" page.

Set up the SAMA7D65-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 (J4) connector.

Power

Debug Communications

  • The SAMA7D65-Curiosity contains a 20-pin JTAG Debug Probe. Connect a PICkit™ 5 debugger to the 20-pin JTAG Debug port (J38) and the host computer running MPLAB X IDE.

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 using MPLAB X IDE to run on the SAMA7D65-Curiosity in Debug mode. This scenario is typical of project development: coding, building, and debugging.

​As of MPLAB X IDE v6.05, the plugins, MPLAB Harmony v3 Content Manager (MHCM) and 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 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_sama7d65

Download or clone the csp_apps_sama7d65 library from the Microchip MPLAB Harmony v3 GitHub repository to the Harmony3 directory.

Back to Top


Open the pio_led_on_off_interrupt project.

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_sama7d65\apps\pio\pio_led_on_off_interrupt\firmware\sam_a7d65_curiosity.X

Open Project

Click on the Open Project button. The pio_led_on_off_interrupt project loads into MPLAB X IDE.

​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 at91bootstrap project. You can 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  pio_led_on_off_interrupt Project Properties using one of the following methods:

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

The Projects Properties – sam_a7d65_curiosity dialog box opens.

​If you received a Configuration Loading Error in the previous step, you will see a [Resolve] link next to the version of the DFP that the project was originally developed with (see the accompanying figure). To update to the latest version, highlight the latest DFP and click the Apply button. This will update the configuration to the latest DFP.

Project Properties window

In the Categories pane, select Conf: [default].

Select the latest version of DFP and MPLAB XC32 Compiler.

​The 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 PICkit 5 debug probe and click the Apply button.

​You must have the host computer running MPLAB X IDE connected to PICkit 5 to see the debugger available in the drop-down menu.

Project Config: JLink

In the Categories pane, select Bootstrap.

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

​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 SAMA7D65-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 (MPUs). For more information, see the "at91bootstrap: A Second Stage Bootloader for Microchip MPUspage.

Project Properties window bootstrap configuration

Information

Note: To build the at91bootstrap to debug from MPLAB X IDE, see the "SAMA7D65-Curiosity – Configure and Build at91bootstrap for an MPLAB® Harmony v3 Project with MPLAB X IDE" page. 

Click the Apply and OK buttons.

Back to Top


Configure the Harmony Content Path.

In this step, you will let MPLAB X IDE know the location (directory) of the Harmony v3 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 the Apply and OK buttons.

Options window Plugins tab

Back to Top


Set the Debug Reset and Debug 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 window Embedded tab

Click on the OK button.

Back to Top


Build the project.

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

Click on the Debug Project icon on the toolbar.

The project will build with debugging parameters, load the application binary to the SAMA7D65-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 SAMA7D65 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 the "SAMA7D6 Boot Process" page.

​For more information on establishing serial communications with the target console see the "SAMA7D65-Curiosity – Console Serial Communications" page.

COM5 - Tera Term Console

MPLAB X IDE window Debug: Halt

Click the Continue button. The application binary runs within the target. Press USER (SW2) button once and observe the RGB LED D11 glows as green once.

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

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

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, don’t forget to (re)build the project. Also, you must reset the SAMA7D65-Curiosity.

For this example application, you only downloaded or cloned one MPLAB Harmony v3 library, CSP application for the SAMA7D65. There are several libraries required to perform full development. In this section, you will use MCC to download and manage these libraries.

Back to top

Open MPLAB Code Configurator (MCC)

Open MCC by clicking on the MCC shield on the toolbar.

The project graph window will open. In the Device Resources pane, click on the Content Manage button.

Content Manager Wizard

Back to Top


Select the latest version available for csp and dev_packs. Click on the Apply button. 

pio project CM apply

Back to Top


Click on the Generate button.

MCC will generate new source code.

Back to Top


Close MCC.

At this point, the required libraries for the pio_led_on_off_interrupt project are loaded.

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 Board Support Package (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 the device driver, system service, OSAL, and third-party software libraries.

Click on the Component: Filter Content drop-down box and un-check Device Supported Content Only to display all available MPLAB Harmony v3 libraries.

Back to Top


Expand Harmony 3 Core.

Back to Top


Select the latest version of the bsp and core libraries.

Back to Top


Click on the Apply button.

The package versions will be downloaded and installed. MCC will restart.

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

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 an SD memory card, eMMC, NAND, and NOR Flash memories, by the second-stage bootloader: at91bootstrap.

Clean and Build the Project

Click on the Clean and Build icon on the toolbar.

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>/Harmony3/csp_apps_sama7d65/apps/pio/pio_led_on_off_interrupt/firmware/sam_a7d65_curiosity.X/dist/default/production/

Output pane Build Successful for a Project

Back to Top


Observe the DDRAM address that harmony.bin is to be loaded by at91bootstrap. This is found in the Linker Files, ddr.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, you downloaded, configured, and built an MPLAB Harmony v3 application example using MPLAB X IDE to run on the SAMA7D65-Curiosity Kit in Debug mode. Finally, you cleaned and built the application for production.

Back to Top

What’s Next?

Once an 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 image from NVM and writing to SDRAM. The following training topics show how this is done for NAND Flash, NOR Flash (QSPI), and an SD memory card.

Back to Top

Learn More

Back to Top