Migrating a Graphics Application From a PIC32MZDA MCU to a SAM9X75 Hybrid MCU Curiosity Development Board

Last modified by Microchip on 2025/06/17 11:46

Introduction

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

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

Back to top

Prerequisites

Information

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

Back to top

Hardware

For this training, you will use the SAM9X75 Curiosity Development Board.

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 MPLAB X IDE.

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 a PICkit™ 5 debugger to the 20-pin JTAG debug port (J34) and the host computer running MPLAB X IDE.

Console Serial Communications

Display

Hardware Setup

  • Connect the ribbon cable from the display to the J28 connector of the SAM9X75 Curiosity Development Board. To learn more about the hardware connection between the LVDs display and the SAM9X75 Curiosity Development Board, refer to the "Hardware Guide for SAM9x75 Curiosity with 5" LVDS WVGA maXTouch Technology Display Module" page.
  • 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.

          hardware setup

Porting an Application From the PIC32MZDA to the SAM9X75

In this tutorial, an automotive dashboard application of the PIC32MZDA Curiosity development kit is being migrated to the SAM9X75 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 traveled, and images for indicators like turn signals and other alerts. Follow the steps below to successfully migrate the application.

The first step is to clone the PIC32MZDA Curiosity development kit’s graphics application from GitHub® (git clone).

Back to Top


Generate the project graph for the SAM9X75 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.

Information

Note: Please ensure that you are familiar with MCC and the required libraries like bsp, core, csp, dev_packs, and gfx are already cloned in the your MPLAB Harmony content path.

To clone the aforementioned libraries, please follow the seps outlined in the "Open an MPLAB Harmony v3 Example Application Project" page before proceeding.

Open PIC32MZDA Graphics Application

             PIC32MZDA Project Graph

Back to Top


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 are changed from a default value.
Canvas Settings

Back to Top


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

Back to Top


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) and click Next.
Open New Project

Back to Top


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

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

Then click Next.

New Project window Select Device dialog

Back to Top


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

Back to Top


Populate the Project Location, Project Folder and Project Name fields. Click Finish.New Project window Select Project Name and Folder dialog

Back to Top


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 the main project by right clicking on the project and choosing Set as Main Project.

Back to Top


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

Back to Top


In addition to the required packages (csp), download the optional packages bsp, core, gfx, and then click Apply. The content download will take some time. Wait until all the contents are downloaded and then click Finish.Optional Packages

Back to Top


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

Back to Top


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

Back to Top


Choosing the Legato Graphics w/ AC69T88A 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

Back to Top


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.

“Legato” and “Graphics Canvas” components

Back to Top


Observe that the Graphics Canvas is embedded between XLCDC and Legato.
LE XLDC driver settings pane

Back to Top


Select the canvas driver from the project graph, and under Graphics Canvas > Canvas Settings, enter "6" for the number of Canvas Objects. Set the following values:

  • Canvas[0]
    • Width: 1,600
    • Height: 480
    • Frame Buffer Allocation: Auto
  • Canvas[1]
    • Width: 300
    • Height: 350
    • Frame Buffer Allocation: Auto

Graphics Canvas pane

Back to Top


Select the LE XLDC driver from the project graph, and on the configuration pane, under Clock Control > Enable Backlight PWM, ensure Canvas Mode was selected.LE XLDC driver settings pane

Back to Top


From the Project Graph tab Plugins drop-down, select Pin Configuration.
Launch Pin Configuration

Back to Top


You can see that PA24 and PA25 are set to FLEXCOM6. Enable Pull Up for those pins. Ensure all the pins are configured as shown in the acompanying image:Pin configuration

Back to Top


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

Back to Top


The next step is to migrate graphics using Microchip Graphics Composer. Launch the Microchip Graphics Composer.

Launch MGS

Back to Top


Then click Load an existing project.
Load Existing Project

Back to Top


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

Graphics Design

Back to Top


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 click Save.

Save graphics design

Back to Top


Now click Project > Memory Locations > DDR_PreProcess and modify the Address to 27000000 (external DDR address location to save assets in SAM9X75 Curiosity).

Add DDR address

Back to Top


And then click the Generate Code button.
Generate Graphics design C code

Back to Top


Now click the Generate button to generate the code for the migrated MGS graphics.Project Resources Generate button

Back to Top


Modifications required in the source code and linker files.

Copy and add app.c, app.h, app_preprocess.c and app_scene1.c from the PIC32MZ DA project to the SAM9X75 Curiosity Development Board project as shown below.
Adding files to the SAM9X75  Curiosity development board project
Select Item window

Change the include path for gfx_canvas_api.h in app.c 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:
XLCDC_SetBacklightBrightness( brightness * 0xff / 100 );

In app.c, remove the PIC32MZDA platform-specific code. Delete the following lines in APP_Tasks():
TMR2_Start();
OCMP1_Enable();

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"

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 acompanying image:
Modified Linker

Back to Top


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

Debugging the Dashboard Graphics 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.

Right click on the project and click Properties. For Compiler Toolchain, select XC32. For Packs, expand SAM9X7_DFP and select 1.9.170 or latest. Click Apply. Project Properties window Cofiguration

Back to Top


Configure the debug interface of PICkit 5 as shown in the acompanying image: Project Properties window Options for PICkit 5

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

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

Project Properties window

Back to Top


In the Categories pane, select Bootstrap.

Observe that Use bootstrap is selected and the pre-complied 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 SAM9X75 Curiosity, MPLAB X IDE can be used to run and debug the application. See the "SAM9X75 Curiosity – Configure and Build at91bootstrap for an MPLAB Harmony v3 Project with MPLAB X IDE" page.

Project Properties window

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.Clean and build output

Back to Top


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

Back to Top


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

Back to Top


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

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 below steps:

Steps to Program the BIN File on SD Card

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

Back to Top


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

Back to Top


Copy harmony.bin files (available in ./project_directory/Graphics_Application_Getting_Started.X/dist/default/production) to the microSD® card using your PC.

Back to Top


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

Press the reset button.

Back to Top


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

automotive dashboard graphics application

Back to Top

Summary

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

Back to Top

Learn More

Back to Top