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

Last modified by Microchip on 2025/03/27 14:01

Introduction

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

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, at 91boostrap 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

This application demonstrates the control of RTC peripherals using Peripheral Libraries (PLIBs) with minimal external dependencies. This application prints the current date and time periodically and allows the user to set and print the date and time from a serial port. 

Back to top

Prerequisites

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

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 (J10) connector.

Power

Debug Communications

  • The SAMA7D65-Curiosity contains a 20-pin JTAG Debug Port. Connect an MPLAB 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

Developing a RTC Demo Application

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.

Back to Top


In the New Project window, under Projects choose Application Project(s) and click Next.

New Project

Back to Top


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

  • Family: Fill the configuration name as 32-bit MCUs and MPUs (PIC32C/SAM).
  • Device: From the drop-down list, select SAMA7D65.

Select Device

Back to Top


In the Select Compiler window, for Compiler Toolchains select XC32 (v4.60), and click Next.

Select Compiler

Back to Top


Enter the Project NameProject Location, and Project Folder. Click Finish.

Project Name

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 selecting Set as Main Project.

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 toolbar). If MPLAB Harmony contents are not available in the framework path, it will launch the Content Manager Wizard.

Content manager

Back to Top


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

BSP core

Back to Top


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

Add BSP

Back to Top


From the Device Resources window, expand Peripherals, and expand RTC to view the RTC list.

Back to Top


Click the add button to add RTC to the Project Graph.

Add RTC

RTC is added to the Project Graph window.

RTC added

Back to Top


From the Device Resources window, expand FLEXCOM to view the list.

Back to Top


Click the add button to add FLEXCOM6 to the Project Graph.

add flexcom

FLEXCOM6 is added to the Project Graph window.

flexcom6 added

Back to Top


Add UART dependency by right-clicking on the UART button on FLEXCOM6 box and selecting Consumers > STDIO.

add UART dependency

Back to Top


Save and then click Generate Code. This will generate code for all the Device Resources that have been added in the Project Graph.

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 (SAMA7D65). Refer to the initialization.c file in project_directory/src/config to find that all the device resources added in the project graph were initialized. All that is left is for you to write the application code in the main.c and app.c file. 

Information

Documentation for each of the peripheral libraries or driver libraries can be accessed as follows:

Back to Top


APIs used for this application are as follows:

  • RTC_TimeSet
  • RTC_TimeGet
  • FLEXCOM6_USART_ReceiverIsReady
  • FLEXCOM6_USART_ReadByte

Back to Top


Sample code can be found in main.c in project_directory/src folder of the downloaded project.

Back to Top


Right click on the project and select Properties. For Packs, select SAMA7D65_DFP > 1.4.54. For Compiler Toolchain, select XC32 and then click Apply.

Config

Back to Top


By default, MPLAB X IDE only produces 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, select Building, and enable Execute this line after build. Then, enter the following command:

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

building

Back to Top


Click on Apply and OK.

Back to Top


Clean and Build the project. You should see a message on the output console that the project was successfully built.

Build Success

This completes the development of the RTC getting started application.

The harmony.bin binaries will be available in: ./project_directory/RTC_Application_Getting_Started.X/dist/default/production

Back to Top

Running the Pre-built Harmony Application from the SD Card

The pre-built application BIN file can be programmed by following these steps.

Steps to Program the BIN File to the SD Card

Take an SD card formatted with the FAT32 file system.

Back to Top


Copy the boot.bin and harmony.bin files from the project_directory/hex folder from the downloaded project to the SD card.

Back to Top


Insert the SD card to J10 on the SAMA7D65-Curiosity Kit.

Back to Top

Steps to Run the BIN File from SD Card

Press the START button and then press RESET button.

Back to Top


The following debug messages will be displayed on the console:

RTC Getting Started Output

Back to Top


To set time, press any key and enter the command as $SETTIME HH:MM:SS (Ex: $SETTIME 11:25:35) and press Enter.

Back to Top


To set date, press any key and enter the command as $SETDATE WD:DD:MM:YYYY (Ex: $SETTDATE 00:01:01:2025) and press Enter. (MM: 00 - Jan, WD: 00 - Sunday)

Back to Top


To get time, press any key and enter the command as $GETTIME and press Enter.

Back to Top

Debugging Application Project on MPLAB® X IDE

Open project_directory/RTC_Application_Getting_Started.X in MPLAB X IDE.

Back to Top


Open the Project Properties using one of the following methods:

In the Projects pane, highlight RTC_Application_Getting_Started and click on the wrench icon in the RTC_Application_Getting_Started - Dashboard.

In the Projects pane, right-click on RTC_Application_Getting_Started and select Properties from the menu.

The Projects Properties – RTC_Application_Getting_Started dialog box opens.

Config 2

Back to Top


Ensure SAMA7D65 is selected as hardware tool to program/debug the application.

Back to Top


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 MPLAB PICkit 5 to see the debugger available in the drop-down menu.

MPLAB PICkit 5

Back to Top


In the Categories pane, select PICkit 5.

Back to Top


In the Option categories drop down box, select Communications.

Back to Top


Change JTAG Speed to 1.00 MHz.  

Jtag setting

Back to Top


In the Categories pane, select Bootstrap.

Observe that Use bootstrap is selected and the pre-compiled version of the at91bootstrap.elf is selected. (The pre-complied at91bootstrap.elf can be found in the project_directory/hex folder in the downloaded project).

​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.

bootstrap elf

Back to Top


Click the Apply and OK buttons.

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

Back to Top


Build the project.

 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.

Debug halt Main

Back to Top


You can view the second-stage bootloader (at91bootstrap) activity on the console.

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

Back to Top


Click the Continue button. The application binary runs within the target.

Back to Top


Now the following debug messages will be displayed on the console:

debug message

Back to Top


To set time, press any key and enter the command as $SETTIME HH:MM:SS (Ex: $SETTIME 11:25:35) and press Enter.

Back to Top


To set date, press any key and enter the command as $SETDATE WD:DD:MM:YYYY (Ex: $SETTDATE 00:01:00:2025) and press Enter. (MM: 00 - Jan, WD: 00 - Sunday)

Back to Top


To get time, press any key and enter the command as $GETTIME and press Enter.

Back to Top


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

Summary

In this training, you developed, configured, and built an MPLAB Harmony v3 application example using MPLAB X IDE to run on the SAMA7D65-Curiosity Kit. 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.

 For training topics on configuring and building at91bootstrap to load from Non-Volatile Memories (NVM), see:

Back to Top