MPLAB® Extensions for VS Code®: Creating a New MPLAB Harmony Project/Migrating a QSPI Application From SAME70 to SAM9X75
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.
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
- Apply power as shown in the "Power Options" section of the "SAM9X75 Curiosity Development Board - Features" page.
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
- To view the target console, connect the host computer running a terminal emulation program in accordance with the “SAM9X75 Curiosity Development Board – Console Serial Communications” page.

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.
To create a new MPLAB Harmony project, go to View > Command Palette > MPLAB: Welcome > Create New Project.

The next step in creating an MPLAB Harmony project is to define the following:
- Specify the project name.
- Select a custom project location.
- Choose SAM9X75D2G MPU.
- Choose the latest MPLAB XC32 Compiler as shown in the accompanying image.

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.

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

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.

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.

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.
Generate the code by clicking the Generate button. Wait until the code generation is complete.

Now you can observe that the bsp.c and bsp.h codes are being generated.
From the SAM9X75 curiosity user guide, note down the pin mappings of the QSPI peripheral.

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

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.
Now, check for the QSI configuration to set the QSPI clock to 133 MHz. Refer to the QSPI data sheet for more details.
If the QSPI clock is not enabled, then set the QSPI clock as shown in the accompanying image.

Now verify that the PIT timer is configured with a periodicity of 1 ms. Then generate the code.
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:
- QSPI peripheral libraries APIs
- BSP libraries APIs can be found in bsp.h
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.
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).
Go to Toolchain and confirm that XC32 compiler is chosen.
Configure the debug interface of PICkit 5 as shown in the acompanying image:
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

Update the user variables as follows to give the at91bootstrap (second-stage bootloader) path to the project.
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.

Once the JSON file is updated, it will be automatically reflected in the project properties, as shown in the accompanying image:
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.
Now start debugging. Go to View > Command Palette > Debug: Start Debugging and choose MPLAB debugger in the pop up.
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.

Now observe the debug console messages. A green LED will turn on once QSPI read, write and verify are completed.
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.
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.
You can observe the debug logs to see the output. A green LED turns ON once the QSPI write, read, and verify are completed.
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.
Collaterals
- SAM9X7 Series Microprocessor Collaterals and Solutions
- Hybrid Microcontrollers (MCUs)
- Key Considerations When Migrating From MCUs to Hybrid MCUs
- 32-bit Microprocessor (MPU) Evaluation Kits and Development Boards