Migrating an MPLAB® Harmony v3 Software Framework Application from the SAM9X60-EK to SAM9X60-Curiosity: rtt_periodic_timeout
In this training, you will learn how to migrate an MPLAB® Harmony v3 application developed for the SAM9X60-EK Evaluation Kit to the SAM9X60-Curiosity Development Board. We will use a Chip Support Package (CSP) application, Real-Time Timer (RTT) Periodic Timeout, as an example. When an RTT timer interrupt occurs, the project blinks the RGB LED once per second.
The functions of MPLAB Harmony v3 Content Manager (MHCM) and MPLAB Harmony Configurator (MHC) are being migrated to MPLAB Code Configurator (MCC). You will use MCC to configure and build the project.
Prerequisites
- MPLAB X IDE installed with the following plug-ins:
- MPLAB Harmony v3 Content Manager (MHCM)
- MPLAB Harmony v3 Configurator (MHC)
- MPLAB Code Configurator (MCC)
- MPLAB XC32 Compiler installed
- MPLAB Harmony v3 Software Framework installed
- csp_apps_sam_9x60
Hardware
For this training, you will use the SAM9X60-Curiosity Development Board.
SAM9X60-Curiosity Development Board
SAM9X60-Curiosity Development Board - Features
SAM9X60-Curiosity Development Board - Comparison
Setup
Set up the SAM9X60-Curiosity Development Board as listed below to the host computer running MPLAB X IDE.
- Jumpers
- Open NAND BOOT jumper J4 to disable booting from NAND Flash
- Close J14-RX and J15-TX in the DBGU position to enable the UART debug port for console serial communications
- SD memory cards
- Ensure no SD memory cards plugged into the J3 SDMMC0 or J5 SDMMC1 connectors
- Power
- Apply power to the SAM9X60-Curiosity Development Board by connecting a Micro-B USB cable to J1 USB-A port and a USB power supply
- Typically, a USB port from the host computer
- Apply power to the SAM9X60-Curiosity Development Board by connecting a Micro-B USB cable to J1 USB-A port and a USB power supply
- Debug communications
- Connect a debug probe, such as the Microchip J-32 Debug Probe, to J12 JTAG connector and the host computer
- Console serial communications
- Connect a USB-to-Serial 3.3 VDC TTL Level adapter with a 6-pin single-in-line 0.1” pitch connector to J11 UART DEBUG connector and establish serial communications with the host computer running a terminal emulation program.
Porting an Application From the SAM9X60-EK to SAM9X60-Curiosity
To demonstrate how to port an application that was developed for the SAM9X60-EK we will use a CSP application, RTT Periodic Timeout (rtt_periodic_timeout_sam_9x60_ek), developed for the SAM9X60-EK as an example. The project blinks the RGB LED once per second when an RTT timer interrupt occurs.
Open Project: rtt_periodic_timeout_sam_9x60_ek
From MPLAB X IDE, select File > Open project. An Open Project window will open.
Locate the following project in the MPLAB Harmony v3 path:
C:\Users\<user>\Harmony3\csp_apps_sam_9x60\apps\rtt\rtt_periodic_timeout\firmware\sam_9x60_ek.X
Click on the Open Project button. The rtt_periodic_timeout_sam_9x60_ek project loads into MPLAB X IDE.
Open Project Properties
Open the rtt_periodic_timeout_sam_9x60_ek Project Properties. The Projects Properties – rtt_periodic_timeout_sam_9x60_ek Project dialog box opens.
Configure Project for Debugging on the SAM9X60-Curiosity
In the Categories pane, select Config: [sam_9x60_ek].
Select the version of DFP, CMSIS, and MPLAB XC32 compiler you need for the application. This may be the versions used when the application was originally developed or you may use the latest versions available at the time of migration.
In the Connected Hardware Tool drop-down menu, select the debug probe. In the accompanying figure, we are select the J-32 Debug Probe.
In the Categories pane, select Bootstrap.
Ensure Use Bootstrap is checked.
Click on the Load button and locate and select the at91bootstrap.elf that was compiled as shown in the "SAM9X60-EK – Configure and Build at91bootstrap for an MPLAB® Harmony v3 Project with MPLAB X IDE" page.
In the Categories pane, select J-32.
Click on the Options categories drop-down box and select Communication.
Click on the JTAG Method drop-down box and select 4-wire JTAG.
Click the Apply and the OK button.
Harmony Content Path
In this step, you will let MCC know the location (directory) of the MPLAB Harmony Software Framework on your host computer.
From the MPLAB X IDE menu, select Tools > Options.
From the Options window, select Plugins from the ribbon.
Click on the MPLAB Code Configurator 5.x tab.
Under Harmony Content Path, click on the finder and select the path of the Harmony Content.
Click on Apply and the OK button.
Start MCC
You will use the MCC to download and configure the MPLAB Harmony v3 software libraries. In this section, you will start MCC and download the software packages required for the project.
Start MCC by clicking on the MCC shield in the toolbar. A Package Versions Used vs Available dialog may appear if the MPLAB Harmony package versions that the project was developed with does not match the versions available locally. You will roll-back the versions in the following steps.
Click on the Continue button. MCC is active and displayed in the IDE.
In the Device Resources pane, click on the Content Manager button. Roll-back the packages that you were alerted to in Step 5.2., which is , csp and dev_packs in this example.
Click on the Apply button. The package versions will be downloaded and installed and MCC will restart.
Update Pin Configurations Using MCC
In this step, you will change pin assignments for the RGB LED from SAM9X60-EK to SAM9X60-Curiosity.
From the Plugins dropdown box, select Pin Configuration. A Pin Settings tab will be displayed.
From the Order dropdown box, select Ports. This will order the pins by Pin ID (Ports). The pin configurations displayed are those for the SAM9X60-EK.
Scroll down to Pins PB11, PB12, and PB13. These are the pin assignments for the RGB LED (LD1) on the SAM9X60-EK. You need to change them to the pins on the SAM9X60-Curiosity.
Refer to the SAM9X60-Curiosity users guide (DS60001783) Section 3.5.4 RGB LED. Note the pin assignments for the Curiosity RGB LED (D1). The table below summarizes the pin assignments for the SAM9X60-EK and Curiosity.
RGB Pin Names | SAM9X60-EK | SAM9X60-Curiosity |
---|---|---|
LED_RED | PB11 | PD17 |
LED_GREEN | PB12 | PD19 |
LED | PB13 | PD21 |
To change pin assignments, first select Function: Available for PB11, PB12, and PB13. This will remove the pin assignments.
Next, scroll down to pin PD17, PD19, and PD21 and select Function: GPIO.
Finally, click on the Direction to toggle In to Out and Latch to Low.
Change the Custom Name field to the RGB Pin Names listed in the table in Step 6.4 and shown in the accompanying figure.
In the Project Resources pane (upper left), click on the Generate button. This will generate new source code with the Curiosity’s RGB LED pin assignments.
If a merge window is displayed, merge all. You will observe in the source code the changes in pin assignments.
Close MCC by clicking on the MCC shield in the toolbar.
Debugging the Application
At this point you have configured the MPLAB X IDE project, MPLAB Harmony v3 project using Project Properties, and configured and generated code using MCC. In this section, you will set up the application project for debugging using MPLAB X IDE.
Set debug reset and startup options:
- In MPLAB X IDE, click on Tools > Options. An Options window opens.
- Click on the Embedded icon at the top and the Generic Settings tab.
- Configure the settings for:
- Debug Reset @: Main
- Debug startup: Halt at Main
- Click on the OK button.
Click on the Debug Project icon on the toolbar. The project will build with debugging parameters, load the application binary to the SAM9X60-Curiosity Development Board using the AT91Bootstrap to initialize DRAM, 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.
Click on the Continue button. The application binary runs within the target. Observe the RGB LED D1 flashes blue at a 1 Hz rate.
Congratulations! You migrated an MPLAB Harmony v3 application developed for the SAM9X60-EK Evaluation Kit to the SAM9X60-Curiosity Development Board. You can now pause, insert breakpoints, and continue running the project.
If you change the source code, don’t forget to (re)build the project.
Summary
In this training, you migrated a MPLAB Harmony v3 application that was developed for the SAM9X60-EK Evaluation Kit to the SAM9X60-Curiosity Development Board. You used a CSP application, RTT Periodic Timeout, as an example to make the RGB LED (D1) once per second when a RTT timer interrupt occurs.