Atmel - START - To - MPLAB - Harmony3 - Migration - Guide - DS70005413A
Atmel - START - To - MPLAB - Harmony3 - Migration - Guide - DS70005413A
Introduction
®
This document describes the different steps to consider when porting an embedded application from Atmel START
®
to the MPLAB Harmony 3 framework. It covers the following migration aspects:
• How to create a MPLAB Harmony 3 project under MPLAB X IDE and navigate through the MPLAB Harmony
Configurator (MHC).
• How to identify different elements that compose a project under Atmel START.
• How to port the system/driver/middleware configuration using MPLAB Harmony Configurator.
• Important aspects to consider when porting the project application layer.
To illustrate these aspects, this document references the SAM D21 IO1 Xplained demo example available on Atmel
START. Prior starting the migration process, ensure that the following prerequisites are met:
• Internet connection with access to https://start.atmel.com
• Latest version of MPLAB X IDE https://www.microchip.com/mplab/mplab-x-ide
• Latest version of MPLAB Harmony 3 https://github.com/Microchip-MPLAB-Harmony
• SAM D21 Xplained Pro board (optional)
• I/O1 Xplained Pro board (optional)
Table of Contents
Introduction.....................................................................................................................................................1
Customer Support........................................................................................................................................ 41
Legal Notice................................................................................................................................................. 41
Trademarks.................................................................................................................................................. 42
To create a project for the SAM D21J18A device, follow these steps:
1. Launch MPLAB X IDE.
2. In MPLAB X IDE, select File > New Project (or click the New Project icon).
3. In the New Project window, under Steps, select Choose Project, and then under Choose Project section,
select these options: for Categories select Microchip Embedded, and for Projects select 32-bit MPLAB
Harmony 3 Project.
Note: If the option 32-Bit MPLAB Harmony 3 Project is not available, users need to install the MPLAB
Harmony 3 Configurator plug-in by selecting Tools > Plugins > Available Plugins before continuing with this
demonstration. MPLAB Harmony 3 Configurator overview is available for download at https://
microchipdeveloper.com/harmony3:mhc-overview.
4. Click Next.
5. Select Framework Selection, and under Manage Framework section, enter Framework Path (Path to the folder
in which the MPLAB Harmony 3 packages are downloaded). For this demonstration, the MPLAB Harmony 3
packages are already downloaded at D:\microchip\github\h3.
Figure 1-3. New Project - Framework Selection
6. Click Next.
7. Select Project Settings, and under Name and Location section enter MPLAB Harmony 3 new project details:
– Location: Indicates the path to the root folder of the new project. All project files will be placed inside this
folder.
– Folder: Indicates the name of the MPLAB X IDE folder.
– Name: Enter name of the project. This name will be shown in the MPLAB X IDE.
– Path: It is read-only box. It will update as and when users make changes to other entries.
8. Click Next.
9. Select Configuration Settings, and then enter details as given below:
– Name: Enter the configuration name.
– Target Device: Choose a device name.
10. Click Finish.
Figure 1-5. New Project Wizard Step 4
The software modules associated with the project configuration are seen by selecting Tools > Embedded > MPLAB
Harmony 3 Configurator.
Figure 1-7. Accessing MPLAB Harmony 3 Configurator
The associated MPLAB Harmony 3 Configurator list will be displayed as shown in the figure below.
• Atmel START
{}
ATSAM021JISA
I
MY SOF1WARE COMPONENTS
■ N,ol.'ttlOt'
□ Jrl'odJ-.we () Add 50ftw.Jre aimponent
□ o,-
□ S:,stemdrrw'l!I'
B
IOI_UuHT_SE'6 E08G_COM
I
l2C
GCL<
11 11 11
101 XPLAINED DEMO 0
lh,� �� rea<ls the �pt11:U.-I!: wmor 1tld th!: light Sl!:l'ISOf on the 101 Xpla,ned proe,::�,on bolfd and s,i,ncts th,: valut:5 toa ti:fm1naJ conf'leCtl!!d to the EDSG CDC ,mt11ac11:.
The 101 Xplained pro must be connected ro l!Xtl!nsion he;ioe, 1 (001) on !tie devetopnent kr-� �udrace should be set to 9600 ,n the termiNI applicattOn. Main DrM!l"s and
middlewatt used ,n the l!:)l;bmple-are ADC,. USART, 12C Maste, Dela-/ and GP10
Note: Some applications include additional software functions or middleware that are not part of Atmel START.
Therefore, it is important to review the full application flowchart or project architecture to identify them.
Follow these steps while using the SAM D21 I/O1 example from Atmel START as a reference.
1. In Atmel Studio 7, open the Atmel START project to be ported by selecting Project > Re-Configure Atmel Start
Project.
Note: The project can also be opened by loading its .atstart/.atzip file at https://start.atmel.com/.
Atmel START main window showing Load Project tab is displayed.
Figure 2-4. Load Project From a File Under Atmel START
2. When project is loaded, click on the Dashboard tab and identify the Atmel START drivers and its configuration.
3. Check the application code and application flowchart to identify whether any additional services and
middleware are required. The figure below illustrates the SAM D21 I/O1 flowchart.
Figure 2-6. Additional Service Middleware Identification Using a Flowchart
Main
Temperature Sensor
init
UART init
ADC Enable
4. If MPLAB Harmony Configurator is not opened, from MPLAB X IDE open the MPLAB Harmony 3 Configurator
by selecting Tools > Embedded > MPLAB Harmony 3 Configurator.
5. Search for software module availability in Harmony 3 Configurator, and then drag and drop it into the Project
Graph window.
Figure 2-8. Identifying Software Module in MHC
The table below provides the drivers and middleware used for this demonstration.
Note: Specific development is required for AT30SE75X. Other drivers, system services, and middleware are
available under MPLAB Harmony 3.
Follow these steps for the SAM D21 I/O1 Xplained demonstration:
1. Add peripheral library (drivers) to the MPLAB Harmony 3 project by dragging them from the Available
Component list to the Project Graph section.
Figure 3-2. Add Peripheral Driver from the Available Component List
2. Configure all the MPLAB Harmony 3 peripheral libraries according to their equivalent driver in Atmel START.
Note: Specific Atmel START driver configurations can be seen by clicking individually on each of the driver
component in the application dashboard interface.
After generating the project source code from the MHC interface by clicking or selecting MHC >
Generate Code, the peripheral libraries (PLIBs) configuration can be found in the following project directories:
PLIBs
headers
PLIBs
sources
The API function definition used by the application can be found in the peripheral library header files.
Figure 3-9. Peripheral Libraries API Location
Follow these steps for the SAM D21 IO1 Xplained demonstration:
1. In Atmel START, click on the PINMUX tab and identify which I/O pins are configured and used in the
application.
Note: The configuration of each pin is available by clicking on it in the PINMUX configurator table.
Figure 4-3. Identify I/O Pins Configuration Under Atmel START (Continued)
2. In MPLAB X IDE, select MHC > Tools > Pin Configuration to open the project pin configurator interface.
Note: The following tab in the MHC interface enables the customization of the application pin configuration.
Figure 4-5. Accessing Pin Configuration Windows Under the MHC
3. Port the I/O pin configuration from Atmel Studio to the MHC Pin Setting tab.
– SERCOM 2 I/O settings
4. Verify that the MHC pin diagram is aligned with the initial Atmel START project pin diagram.
Figure 4-9. Pin Configuration Verification
After regenerating the project source from the MHC interface by clicking , the port initialization routine
executed during program initialization can be found in the following project files. This initialization routine is
automatically generated by the MHC according to the user configuration entered in the graphical interface.
Note: During application run-time, the PORT configuration can be changed by calling APIs from the MPLAB
Harmony 3 PORT PLIB.
1. In Atmel START, click the PINMUX tab and identify different clock elements used in the application and their
settings.
Note: Additional information on the settings for a specific clock element can be retrieved by clicking on the
associated blue gear wheel button.
Figure 5-3. Access Clock Element Settings Under Atmel START
2. To open the project pin configurator interface, in MPLAB X IDE, select MHC > Tools > Clock Configuration.
3. Port each clock component configuration from Atmel START to the MHC Clock view.
– 8 MHz Internal Oscillator (OSC8M)
– GCLK Generator 0
– GCLK Generator 1
2. If the middleware is not available under Harmony 3, the user must include the source of the middleware in the
new project, then locate and modify the Hardware Abstraction Layer to call the APIs provided in the Peripheral
Library.
The following steps illustrate the process to be followed for the SAM D21 I/O1 demonstration.
By analyzing the structure of the application (Step 1), using both the Atmel START Dashboard and the application
source code, the following middlewares are used in the Atmel START source application:
• AT30TSE75X : temperature sensor
• STDIO redirection (implicitly added)
The AT30TSE is currently not available under MPLAB X IDE, therefore a manual source port must be created. This
step will be covered in step seven when porting the application source code.
1. In MPLAB X IDE, add the STDIO middleware to the project using the MHC Project Graph window then link the
STDIO middleware to the SERCOM3 driver.
Figure 6-3. Add STDIO Middleware Under MHC
After regenerating the project source from the MHC interface by clicking , the STDIO redirection HAL will
be generated according to the graphical configuration. The getc and putc functions will be redirected to the
SERCOM3 APIs.
c5l Projects x I Active Components r;J StartP� xl�1maii.c xi Proj&tGraph l�plb_port.c •l�xc32_monitor.c xl 8=}]E)@)c:5l
1j 8-· SAt-021_IOl_exarnpe_port Sou-co Hsto,y • I©
I
Ci 1'8 • ■ · I '<l. 'i;, ¢' � '• I 'i? -!,, \h I � � I
8 El 11\1 el � 83
'¥--� Headern1es I I ii'.
34 WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIE" ■ �
·l
� $-·., imp0ftant Fies •
35 • BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO TJ-
I
�
�-- Sou"cefies 36 • FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLl
® @fll:lLm<Fie,
RE T OF FEES, �
(ci
�� F�: !!�s :��= �
(ci
Elf.cidefaut �: : ��/:�u � �A:� ���:����I���H
:
E T c
39
U~f� . s ,�,. exceptions.c
!- - -�
!_!.nclude "d�liniti.9,.n:,. h"
j.... ti-.:--··�1::�::·'
40
�
lbc_syscans.c 42
nt _mon_qetc(int �I
"1I
c5] !
i--··-�starU4)xc32.c
lj}fi:l-•
1 811() stdio
L._� xc32_monitor.c I
45
�
volatile int c '"' 0;
while(SERCOM3_USART_Read((void•)&c, 1) ! = �);
, i 47 return c;
Lbraries
49
i .............. .
f··-·'-
SO void _mon_pntc(char c)
@(i'iLoadabie,
';,_,]
w � :,ize .. O;
53 do
54
55 :,ize .. SERCOM3_USART_Write((voidit)&c, 1);
56 )while (:,ize != l);
57 { -------------------
I
>
c5] Q_ Search ReSUt:s � OJtput Console 12:1 IINs
Porting the application layer requires the review of the Atmel START main application routine and associated
application layer related functions, and modifying them to make use of the MPLAB Harmony 3 APIs instead of the
Atmel START ones.
The following figure illustrates the effort to port the application layer of the SAM D21 IO1 Xplained demo example to
MPLAB Harmony 3.
Figure 7-2. SAM D21 I/O1 Xplained Demo Application Layer Porting Effort
Main Main
Aligned
(no port needed) SYS_Initialize
Atmel Start Init
The result of the SAM D21 I/O1 Xplained demo application layer porting is shown below :
uint16_t adc_read_channel(void);
bool temperature_sensor_init(void);
float temperature_sensor_read(void);
uint16_t adc_read_channel(void)
{
/*- Start ADC channel */
ADC_ConversionStart();
/*- Wait until result is ready */
while(ADC_ConversionStatusGet() != true);
return ADC_ConversionResultGet();
}
bool temperature_sensor_init(void)
{
bool res;
uint8_t buffer[3];
return res;
}
float temperature_sensor_read(void)
{
uint8_t txbuffer[2];
uint8_t rxbuffer[2];
uint16_t data;
int8_t sign = 1;
Customer Support
Users of Microchip products can receive assistance through several channels:
• Distributor or Representative
• Local Sales Office
• Embedded Solutions Engineer (ESE)
• Technical Support
Customers should contact their distributor, representative or ESE for support. Local sales offices are also available to
help customers. A listing of sales offices and locations is included in this document.
Technical support is available through the website at: http://www.microchip.com/support
Legal Notice
Information contained in this publication regarding device applications and the like is provided only for your
convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with
Trademarks
The Microchip name and logo, the Microchip logo, Adaptec, AnyRate, AVR, AVR logo, AVR Freaks, BesTime,
BitCloud, chipKIT, chipKIT logo, CryptoMemory, CryptoRF, dsPIC, FlashFlex, flexPWR, HELDO, IGLOO, JukeBlox,
KeeLoq, Kleer, LANCheck, LinkMD, maXStylus, maXTouch, MediaLB, megaAVR, Microsemi, Microsemi logo, MOST,
MOST logo, MPLAB, OptoLyzer, PackeTime, PIC, picoPower, PICSTART, PIC32 logo, PolarFire, Prochip Designer,
QTouch, SAM-BA, SenGenuity, SpyNIC, SST, SST Logo, SuperFlash, Symmetricom, SyncServer, Tachyon,
TempTrackr, TimeSource, tinyAVR, UNI/O, Vectron, and XMEGA are registered trademarks of Microchip Technology
Incorporated in the U.S.A. and other countries.
APT, ClockWorks, The Embedded Control Solutions Company, EtherSynch, FlashTec, Hyper Speed Control,
HyperLight Load, IntelliMOS, Libero, motorBench, mTouch, Powermite 3, Precision Edge, ProASIC, ProASIC Plus,
ProASIC Plus logo, Quiet-Wire, SmartFusion, SyncWorld, Temux, TimeCesium, TimeHub, TimePictra, TimeProvider,
Vite, WinPath, and ZL are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BlueSky, BodyCom,
CodeGuard, CryptoAuthentication, CryptoAutomotive, CryptoCompanion, CryptoController, dsPICDEM,
dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit Serial Programming, ICSP,
INICnet, Inter-Chip Connectivity, JitterBlocker, KleerNet, KleerNet logo, memBrain, Mindi, MiWi, MPASM, MPF,
MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM,
PICDEM.net, PICkit, PICtail, PowerSmart, PureSilicon, QMatrix, REAL ICE, Ripple Blocker, SAM-ICE, Serial Quad
I/O, SMART-I.S., SQI, SuperSwitcher, SuperSwitcher II, Total Endurance, TSHARC, USBCheck, VariSense,
ViewSpan, WiperLock, Wireless DNA, and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A.
and other countries.
SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.
The Adaptec logo, Frequency on Demand, Silicon Storage Technology, and Symmcom are registered trademarks of
Microchip Technology Inc. in other countries.
GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip
Technology Inc., in other countries.
All other trademarks mentioned herein are property of their respective companies.
© 2019, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.
ISBN: 978-1-5224-5403-8