MPLAB® Extensions for VS Code®: Creating a New MPLAB Harmony Project/Migrating a QSPI Application From SAME70 to SAM9X75

Last modified by Microchip on 2026/02/10 14:03

Introduction

This training module will teach you how to migrate a Quad Serial Peripheral Interface (QSPI) application (QSPI Write, read and verify) from a SAME70 MCU to a SAM9X75 MPU using MPLAB® Extensions for VS Code®. You will also learn to set up a new project on the SAM9X75 Curiosity Development Board using MPLAB Extensions for VS Code.

Once the application has been fully created, the application is built for production. The resulting binary image (harmony.bin) is written to a microSD™ memory card. The harmony.bin binary image is read from NVM by the second-stage bootloader, at91bootstrap, which is also written to a microSD card. However, at91boostrap must be configured and built for a microSD card.

Prerequisites

Download VS Code.


Start VS Code and search for "MPLAB Extension Pack" in the Extension Marketplace (Ctrl + Shift + X).


Install the MPLAB Extension Pack.

Information

​This training was developed with MPLAB XC32 v4.60. For more information, see the 
"Get Started for MPLAB® X IDE Users New to Visual Studio Code (VS Code®)" page.

Back to Top

Hardware

SAM9X75 Curiosity Development Board

See the "SAM9X75 Curiosity Development Board - Features" page.

Set up the SAM9X75 Curiosity Development Board as listed below to the host computer running VS Code.

Jumpers

  • Open jumper J9 to disable NAND Flash boot.
  • Open jumper J10 to disable QSPI boot.
  • Refer to Section 2.5 of the "SAM9X75-Curiosity User Guide" for more details about jumper settings.

SD Memory Cards

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

Power

Debug Communications

  • The SAM9X75 Curiosity Development Board contains a 20-pin JTAG debug port. Connect an MPLAB PICkit™ 5 debugger to the 20-pin JTAG debug port (J34) and the host computer running MPLAB X IDE.

Console Serial Communications

Hardware Setup

  • Power up the board by connecting the Micro-USB cable to the USB-A port J2 on the SAM9X75 Curiosity Development Board.
  • Connect the MPLAB PICkit 5 debugger to the 20-pin JTAG debug port (J34).
  • Connect the FTDI cable to the serial debug port (J35) on the SAM9X75 Curiosity Development Board.      

Set Up a New MPLAB Harmony Project

In this tutorial, you will learn how to create a new project on the SAM9X75 Curiosity Development Board using the MPLAB Extensions for VS Code.

The first step is to launch VS Code.

Information

Note: Ensure that all software tools required are installed as mentioned in the "Prerequisites" section.

To create a new MPLAB Harmony project, go to View > Command Palette > MPLAB: Welcome > Create New Project.

Create a new MPLAB project

Back to Top


The next step in creating an MPLAB Harmony project is to define the following:

  1. Specify the project name.
  2. Select a custom project location.
  3. Choose SAM9X75D2G MPU.
  4. Choose the latest MPLAB XC32 Compiler as shown in the accompanying image.

Configure the project

Back to Top


Once the project creation is complete, a VS Code message will pop up asking if it can trust the author. Confirm by clicking Yes, I trust the authors and proceed to the next step.

Trust The Author

Back to Top


Observe that the MPLAB Harmony project for the SAM9X75 Curiosity Development board has been created and the initial setup is complete.

Completed Creating the project

Back to Top


Now create the MCC configuration to add the necessary peripheral libraries essential for application creation. Go to View > Command Palette > MPLAB MCC: Launch.

Now, click Create New MCC Config and proceed with the default values. A pop-up will prompt you to download the latest SAM9X75 DFP pack. Click YES.

Launch MCC

Back to Top


In addition to the required packages (csp), download the optional packages bsp, and core.

To do this, click on Device Resource, then Content Manager, choose bsp & core and then click Select Latest Version. The content download will take some time, so be patient and wait until all contents are downloaded. Then click Finish.

Information

You can clone all the necessary peripherals required using the Content Manager.

Clone Libraries

 

Back to Top


The Project Graph window will be displayed. From the Device Resources window, click the add button next to SAM9X75 Curiosity BSP, which will add Board Support Packages, reflected in the Project Graph.

Add BSP

Back to Top


Generate the code by clicking the Generate button. Wait until the code generation is complete.

Generate Code

Back to Top


Now you can observe that the bsp.c and bsp.h codes are being generated.​
Verify Code Generation

Back to Top


From the SAM9X75 curiosity user guide, note down the pin mappings of the QSPI peripheral.

Pin Mapping

Back to Top

Configure the QSPI pins using the Pin Configuration plug-in from the project graph as shown below:

Pin Mapping

Back to Top

From SAME70-based QSPI application  we can observe that a timer and QSPI APIs are used. So, in the SAM9X75 application, you must also add the Timer and QSPI peripherals.

Even though the SAME70 Xplained Ultra kit uses the SST26VF032BA (32 Mbit) and the SAM9X75 Curiosity kit uses the SST26VF064BEUIT (64 Mbit), the required drivers for both devices are already available in the peripheral libraries. Therefore, you only need to add the QSPI and PIT (for timing functions) peripherals to the project graph.

To add a QSPI peripheral to the project graph, from Device Resources window, expand Peripherals. Then, expand QSPI and click the add button next to QSPI to add it to the Project Graph.

Similarly, add PIT timer to the project graph.
Add QSPI, PIT

Back to Top


Now, check for the QSI configuration to set the QSPI clock to 133 MHz. Refer to the QSPI data sheet for more details.
Configure QSPI Clock

If the QSPI clock is not enabled, then set the QSPI clock as shown in the accompanying image.
​​Configure QSPI Clock

Back to Top


Now verify that the PIT timer is configured with a periodicity of 1 ms. Then generate the code.
Configure PIT

Back to Top


Up to this point in the project creation process, you used MPLAB Code Configurator (MCC) to configure and generate code to initialize the device (SAM9X75) and QSPI and PIT peripherals.

To find all the device resources that have been added to the project graph and initialized, refer to initialization.c. The only remaining task is to write the application code in the app.c file. You can access documentation for each of the peripheral libraries or driver libraries as follows:

Back to Top


In this QSPI migration application, the following APIs are being used:

  • QSPI_CommandWrite(..)
  • QSPI_RegisterRead(...)
  • QSPI_MemoryRead(...)
  • QSPI_MemoryWrite(...)
  • PIT_DelayMs(...)
  • LED_GREEN_On();
  • LED_RED_On();

See the sample code and its header file.

Copy paste app.c and app.h or write your own code. This completes the application development.

Back to Top

Debugging the QSPI Application on the Target

To debug the project on MPLAB X IDE, make sure the board is powered and the external debugger is connected. Refer to the "Hardware Setup" section in this document for more details.

Before debugging, confirm the compiler details.

To do this, go to Command Palette and launch MPLAB: Edit project properties (UI).
Launch Project properties
Go to Toolchain and confirm that XC32 compiler is chosen.
Compiler Configuration

Back to Top


Configure the debug interface of PICkit 5 as shown in the acompanying image:
Tool Configuration

Back to Top


By default, MPLAB X IDE only generates ELF and HEX format output files. To generate application output in binary format, a post-build step needs to be added to the project properties. To do this, go to Overview > Post-build Steps > Add Item. Then add the following command:

${MP_CC_DIR}/xc32-objcopy -O binary %{TargetDirRelative}/%{ConfigurationName}.elf %{TargetDirRelative}/harmony.bin

Build Command

 

Back to Top


Update the user variables as follows to give the at91bootstrap (second-stage bootloader) path to the project.

Information

The at91bootstrap.elf file should be kept in the ./binaries folder (see the example).

The uservariables properties should be updated with the bootloader information in the <project_name>.mplab.json file. To edit this JSON file, go to View > Command Palette > MPLAB Edit Project Properties JSON file and add the properties under uservariables.

Information

"propertyGroups": [

        {

            "name": "default-uservariables",

            "type": "uservariables",

            "properties": {

                "boot.load_adr": "",

                "boot.use": "true",

                "boot.entry_adr": "",

                "boot.path": "./binaries/at91bootstrap.elf ",

                "boot.prj": ""

            }

        },

Added User Variable

 

Back to Top


Once the JSON file is updated, it will be automatically reflected in the project properties, as shown in the accompanying image:
Boot Configuration

Back to Top


Clean and build the project. You will see a message on the output console that the project was successfully built. This completes the building of the MPLAB Harmony application.
Build the project


Back to Top

Now start debugging. Go to View > Command Palette > Debug: Start Debugging and choose MPLAB debugger in the pop up.Debug Configuration

Back to Top


Close the jumper J10 to enable read/write/verify functionality with QSPI.

Now start debugging the project by step in, step out, halt, or run.​​​​​​
Debug

Debug

Back to Top


Now observe the debug console messages. A green LED will turn on once QSPI read, write and verify are completed.
Console Output

Back to Top

Running the Pre-built MPLAB® Harmony Application From the SD Card

The pre-built application BIN files (boot.bin and harmony.bin) can be programmed by following these steps:

Steps to Program the BIN File on SD Card

Take a microSD card formatted with the FAT32 file system (see the "How to Format and Partition an SD Card Larger Than 32GB Using DiskPart in Windows® for MPU" page). 


Copy the boot.bin files from the repository to the microSD card using your PC.


Copy harmony.bin files (available in ./project_directory/out/<project_name>/) to the microSD card using your PC.

The pre-built harmony.bin file is available in the repository.


Insert the SD card to J14 on the SAM9X75 Curiosity Development Board. 

Back to Top

Steps to Run the BIN File From the SD Card

Close the jumper J10 to enable read/write/verify functionality with QSPI and press the reset button.

Back to Top


You can observe the debug logs to see the output. A green LED turns ON once the QSPI write, read, and verify are completed.

Back to Top

Summary

In this training, a QSPI write, read, and verify application is migrated from the SAME70 Xplained Ultra Kit to the SAM9X75 Curiosity Development Board.

Back to Top

Collaterals

Back to Top

Learn More

Back to Top