Migrating a Graphics Application from a PIC32MZDA MCU to a SAM9X60 Hybrid MCU Curiosity Development Board

Last modified by Microchip on 2026/01/19 10:46

Introduction

This training module will teach how to migrate an MPLAB® Harmony-based graphics application developed for a high-performance WVGA LCD Display Module with maXTouch® technology display board using the Microchip Graphics Suite (MGS)  for a 200MHz MIPS® core-based PIC32MZDA Curiosity Development Kit to a 600MHz ARM926-EJS-based SAM9X60 Arm®-based MPU Curiosity Development Board.

Once the application has been fully migrated, it 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, 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 provided in the "Learn More" section.

Prerequisites

​This training was developed with MPLAB X IDE v6.25 and MPLAB XC32 v4.60.

Hardware

Hardware Setup

  • Connect the ribbon cable from the display to the J13 connector of the SAM9X60 Curiosity Development Board.
  • Power up the board by connecting the USB cable to the USB port J1 on the SAM9X60 Curiosity Development Board.
  • Connect the MPLAB PICkit 5 debugger  to  the 20-pin JTAG Debug port (J12) .
  • Connect the FTDI cable to the Serial Debug Port (J11) on the SAM9X60 Curiosity Development Board.

Hardware Setup

Back to Top

Porting an Application From One PIC32MZDA to SAM9X60

In this tutorial, an automotive dashboard application of the PIC32MZDA Curiosity development kit is being migrated to the SAM9X60 Curiosity Development Board. This dashboard application presents a vehicle dashboard User Interface (UI). It has a gauge to show the engine RPM (tachometer), dynamic text to show speed and distance travelled, and images for indicators like turn signals and other alerts. Follow the steps below to migrate the application successfully.

The first step is to clone the PIC32MZDA Curiosity development Kit’s graphics application from GitHub®.


Before generating the project graph for the SAM9X60 Curiosity Development Board, let us take a look at the project graph of the dashboard app for the PIC32MZ DA. To open the project graph of PIC32MZDA , open the dashboard project in MPLAB X IDE, set it as the main project, and launch MCC.

Note: It is assumed that the user is familiar with MPLAB Code Configurator (MCC) and the required libraries like bsp, core, csp, dev_packs, and gfx are already cloned in the user’s MPLAB Harmony v3 content path. If this is not the case, please go through the steps here and clone the libraries mentioned above before proceeding.

Open PIC32MZDA Graphics Application

PIC32MZDA Project Graph


Now start observing the project graph for the components used in the project graph. The following components are used:

The BSP for PIC32MZ DA.

Legato Graphics w/ PDA TM5000 Display template – This automatically activates the rest of the components and connects them.

Graphics Canvas is used between the GLCD driver and Legato.
LE GLCDC settings

In the GLCD driver configuration, the canvas mode option is checked. Observe that in graphics canvas configuration, the number of canvas objects is set to 6, and for Canvas[0] and Canvas[1], the width and height of the object is changed from a default value.Canvas Settings


Given this information, let us now set the project graph for the SAM9X60 Curiosity Development Board project. To do this, first launch MPLAB X IDE from the main menu.


Create a New Project by clicking the New Project icon or by selecting File > New Project. In the New Project window, under Projects, choose Application Project(s). Then, click Next.

Open New Project


In the Select Device dialog, fill in or select the information below:  

  • Family: 32-bit MCUs and MPUs (PIC32C/SAM)
  • Device: SAM9X60

Create new project

 


In the Select Compiler pane, for Compiler Toolchains, select XC32 Compiler and click Next.

Select Compiler

 


Enter Project LocationProject Folder, and Project Name. Click Finish.

Project Information


This creates an empty project and sets this project as the main project. If there are other projects open in the Project Explorer window, set this project as main project by right-clicking on the project and choosing Set as Main Project.


Once the project is created, MCC will be automatically launched. (To launch the MCC manually, from main menu, click on Tools > Embedded > MPLAB Code Configurator or click the MCC button in the MPLAB X IDE toolbar). If MPLAB Harmony contents are not available in the Harmony framework path, then it will launch Content Manger Wizard.

Launch MCC

 


In addition to the required packages (csp), download the optional packages bspcore, gfx, and then click Apply. Content download will take some time. Wait until all the contents are downloaded. Then click Finish.

Clone BSP, Core, Gfx

 


A project graph will be displayed. From the Device Resources pane, click the add button to add Board Support Packages for SAM9X60 Curiosity BSP to the Project Graph.

Add BSP

 


From the Device Resources pane, add Graphics > Templates > Legato Graphics w/PDA TM5000 Display to Project Graph. You will be prompted to allow auto-connection and auto-activation of several components. Click on Yes for all EXCEPT FreeRTOS.

Add Graphics template


Choosing the Legato Graphics w/PDA TM5000 Display template automatically populates the rest of the project components. This can be seen in the way the project graph is set up and connected.

Project Graph

 


Since the PIC32MZDA application uses the Graphics Canvas component between the XLCDC and Legato drivers, first disconnect the direct link between XLCDC and Legato.

Click on the green diamond for LE Display Driver for LE XLCDC Driver and click on Disconnect. The diamond will turn yellow after the disconnection.

Right click on the yellow diamond on the LE LCDC driver, and for Consumers, select Graphics Canvas. Now observe that the Graphics Canvas component appears on the project graph.

Right click on the yellow diamond on the Graphics Canvas driver, and for Consumers, select Legato. The Legato and Graphics Canvas components are automatically connected.

Add Canvas

 


Now the Project Graph looks like the acompanying image:

New project graph window


In the Project Graph, click on FLEXCOM6. In the Configuration Options pane, select Clock Speed (Hz) as 100,000 (100KHz).

Change flexcomm speed


In the Project Graph, click on LE LCDC Driver. In the Configuration Options pane, select Output Color Mode as 18BPP.

Set Output Color Mode


Select the canvas driver from the project graph, and on the configuration window. Use the image below for the following adjustments:

  • Canvas Objects: 6
  • Canvas[0]
    • Width: 1,600
    • Height: 480
    • Frame Buffer Allocation: Auto
  • Canvas[1]
    • Width: 300
    •  Height: 350
    • Frame Buffer Allocation: Auto
  • Canvas[2]
    • Frame Buffer Allocation: Auto
  • Canvas[3]
    • Frame Buffer Allocation: Auto
  • Canvas[4]
    • Frame Buffer Allocation: Auto
  • Check the boxes for Canvas Mode and Use GPU for Blits?

Update Canvas configuration


In the Project Graph window, from the Plugins menu, select Pin Configuration.

Launch Pin Configuration


You can see that PA30 and PA31 are set to FLEXCOM6. Enable Pull Up for those pins. Ensure all the pins are configured as below:

Pin Configuration


Now click the Generate button to generate the code for the added peripherals.

Generate Code


The next step is to migrate graphics using Microchip Graphics Composer. Before we start, launch the Microchip Graphics Composer.

Launch MGS


Then click Load an existing project.

Load Existing Project


Open the zipped graphics design file of PIC32MZDA Curiosity from the downloaded MGS dashboard graphics project of PIC32MZDA as shown in the accompanying image.

Open PIC32MZDA graphics file in SAM9X60 MGS

Graphics Design


Now save the design files by clicking on File from the main menu and selecting Save As. Provide a Filename with <configuration_name>_design (e.g., default_design.zip) and save it in the default folder so that the next time MGC is launched, the design file is automatically opened. Then, click Save.

Save graphics design


Click Project > Memory Locations > DDR_PreProcess and modify the Address to 27000000. (External DDR address location to save assets in SAM9X60 Curiosity).

Add DDR address


Then click Generate Code.

Generate Graphics design C code


Click the Generate button to generate the code for the migrated MGS graphics.

Generate Code

 


Modifications required in the source code and linker files include:

Copy and add app.c, app.h,app_preprocess.c and app_scene1.c from the PIC32MZ DA project to the SAM9X60 Curiosity Development Board project as shown in the accompanying image.Add Source Files

In app.c, change the include path for gfx_canvas_api.h ​​​​​​ from:
#include "config/glcd_rgba8888_mxt_mzda_intddr_cu_wvga/gfx/canvas/gfx_canvas_api.h"  
 to:
#include "config/default/gfx/canvas/gfx_canvas_api.h"   

In app.c, change the following line of code in Backlight_TimerCallback() from:
OCMP1_CompareSecondaryValueSet( (TMR_PERIOD * brightness)/100);  
to:
LCDC_BrightnessSet ( brightness * 0xff / 100 );  

In app_scene1.c, remove the following #include for GLCD driver (the GLCD driver is for PIC32MZDA):

#include "gfx/driver/controller/glcd/plib_glcd.h"  
#include "gfx/driver/controller/glcd/drv_gfx_glcd.h" 

Copy and add app.c, app.h, app_preprocess.c and app_scene1.c from the PIC32MZ DA project to the SAM9X60 Curiosity development board project.

In the plib_flexcom6_twi_master.c file, add the following line of code to enable filter in flexcom6_TWI_Initialize():

Add Flexcomm code

In the linker file, add a dedicated section for assets_preprocess (DDR address should be the same as that of the address used in step 29) as shown in the accompanying image:

Modified Linker

 

This completes the migration of the PIC32MZDA graphics project to the SAM9X60 Curiosity Development Board.

Back to Top

Debugging the Dashboard Graphics Application on the Target:

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

Right-click on the project and click Properties.

  • For Compiler Toolchain select XC32.
  • For Packs expand SAM9X6_DFP > 1.11.127 or latest ​​​​​​

Then, click Apply

Choose DFP

 


Configure the debug interface of PICkit 5 as shown in the accompanying image:

PICkit5 Config


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, right-click on the project and select Properties > Building, and then check the Execute this line after build box. Then, enter the following command:

  ${MP_CC_DIR}/xc32-objcopy -O binary ${DISTDIR}/${PROJECTNAME}.${IMAGE_TYPE}.elf ${DISTDIR}/harmony.bin  

Properties > Building > Execute this line after build

 


In the Categories pane, select Bootstrap.

Observe that Use bootstrap is selected and the pre-compiled version 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 SAM9X60 Curiosity, MPLAB X IDE can be used to run and debug the application. See the "​SAM9X60 Curiosity Development Board - Configuring and Building at91bootstrap for an MPLAB® Harmony 3 Project Using MPLAB® X IDE" page.

Load Bootstrap


Clean and Build the project. The user should see a message on the output console that the project was successfully built. This completes the building of the MPLAB Harmony application.

Build Graphics Project


The harmony.bin binaries will be available at ./project_directory/Graphics_Application_Getting_Started.X/dist/default/production.


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

Debug


Now observe the MGS dashboard graphics application using Microchip Graphics Composer on the display.

Application Executed

 

Back to Top

Running the Pre-Built MPLAB Harmony Application From the SD Card:

The pre-built application bin file can be programmed by following the steps below.

Steps to Program the BIN File on the 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 harmony.bin files (available in the ./project_directory/Graphics_Application_Getting_Started.X/dist/default/production folder) to the microSD card using your PC.


Insert the SD card into J3 on the SAM9X60 Curiosity Development Board.

Steps to Run the BIN File From the SD Card

Press the reset button.


It will display the automotive dashboard graphics application connected with the SAM9X60 Curiosity Development Board.

Graphics Application Executed

Back to Top

Summary

In this training, an automotive dashboard application of the PIC32MZDA Curiosity development kit is being migrated to the SAM9X60 Curiosity Development Board using MGS under MPLAB X IDE.

Back to Top

Learn More

Back to Top

Collaterals

SAM9X60 Series Microprocessor Collaterals and Solutions

Back to Top