Using Atmel START with the SAM D21 MCU UART


This project shows you how to:

  • Use Atmel START to add and configure a USART driver for your project.
  • Export your project for the Atmel Studio 7 IDE.
  • Use USART example code to write a message to a serial terminal application.
    • Example code provided by the Advanced Software Framework 4 (ASF4).
  • Program the SAM D21 Xplained Pro Evaluation Kit to verify that your code is working.


Hardware Tools

Tool About Purchase
SAM D21 Xplained Pro
Evaluation Kit

Software Tools

Tool About Installers
Windows Linux Mac OSX
Atmel® Studio
Integrated Development Environment
Atmel® START (ASF4)
Integrated Software Framework
Web Based

Optional Lab Manual

A hardcopy of this tutorial is available here:
Using Atmel START with the SAM D21 MCU >


Step 1: Create a new Atmel START project
Step 2: Add and configure a USART driver
Step 3: Save and export the application for the Studio 7 IDE
Step 4: Import the Atmel START project into the Studio 7 IDE
Step 5: Add USART example code to write a message to a serial terminal application
Step 6: Program the board
Step 7: Verify USART communication

Step 1: Create a new Atmel START project


Open a web browser, go to, and select CREATE NEW PROJECT.



Select a specific board for the project.

  • Click on ‘Show only boards’ from the "RESULTS" section then select the ‘SAM D21 Xplained Pro’ board.
  • Click CREATE NEW PROJECT to complete the project creation.

The project is created in Atmel START and you now have access to the DASHBOARD view. Scroll to the bottom of this window to verify the ATSAMD21J18A is the selected device and explore its capabilities.


Step 2: Add and configure a USART driver

You will use the Virtual COM Port of the SAM D21 Xplained Pro Embedded Debugger (EDBG) as a USART communication channel.


The Embedded Debugger interface is a composite USB device with three interfaces:

  • Programmer/Debugger
  • Virtual COM Port
  • Data Gateway Interface (DGI) which handles events and data

The Virtual COM Port is connected to a UART on the ATSAMD21J18A and provides an easy way to communicate with the target application through terminal software. It offers variable baud rate, parity, and stop bit settings. Note that the settings on the ATSAMD21J18A must match the settings given in the terminal software.


Determine which SAM D21 pins are used for the Embedded Debugger’s virtual COM port. The SAM D21 Xplained Pro Users Guide specifies which SAM D21 pins are used for this port.

  • Note Pins PA22 and PA23 are connected to one of the Serial Communications Peripherals (SERCOM3). Next, you will configure this peripheral as a UART.


Add the USART driver

  • Atmel START displays the 'DASHBOARD' tab (left side) by default. Click the Add software component button.
  • Type 'USART' in the 'Filter' field, look for the USART driver and add it. You can also directly look for it in the Drivers list.


Configure the USART driver

  • Click on the 'USART_0' component block to start its configuration.
  • Configure USART Component Settings:
    • Driver: HAL:Driver:USART_Sync
    • Mode: UART
    • Instance: SERCOM3
  • Configure USART Signals:
    • RX: PA23
    • TX: PA22
  • Basic Configuration:
    • 9600 Bd
    • 8 bits
    • No parity
    • 1 Stop Bit

Step 3: Save and export the project for the Studio 7 IDE

You have now created and configured your Atmel START based project. It’s a good idea to save this configuration so you can make changes to it sometime in the future. Atmel START allows the restoring of any project using its configuration file (*.atstart file format).


Save your Atmel START project.

  • Provide a filename and location, then click Save.


Export the project for the Studio 7 IDE.

  • Provide a filename and location, then click Save.

Your Atmel START project has been exported for the Studio 7 IDE in a *.atzip file format (standard zip format automatically recognized by Studio 7).

Step 4: Import the Atmel START project into the Studio 7 IDE


Open Studio 7 and select:

  • File > Import > Atmel Start Project


Browse to the project you exported from START (*.atzip) and click OK. Your project is now created.


Note a default project name and location have been selected for you. Feel free to change these.

Atmel START projects come with some useful examples to help you get started on the different peripherals you’re looking to use. You’ll find these in the driver_examples.c file in the examples folder.


Open the main.c file. You will see the only function called in the current project is the atmel_start_init() function:


The atmel_start_init() function calls the system_init() function.
The system_init() function calls the init_mcu() function (initialize the MCU oscillators, clocks, flash wait states…), and the USART_0_init() function.

Want to see what these functions do?
Right-click on the function name and select 'Goto Implementation' to see the function definition (C file) and description (header file).
For more detail see the ASF4 API Reference Manual.

Open the driver_init.c file to see these and other initialization functions generated in response to the selections you made in Atmel START. You may also want to check out the configuration header files (found in the 'Config' folder).

Step 5: Add USART example code to write a message to a serial terminal application

As mentioned above, the examples in the driver_examples.c file will be used to help you get started.


Add a USART example function to main.c.

  • Open driver_examples.c in the examples folder, and copy the USART_0_example() function
  • Paste it above the main() function in the main.c file

You will use the io_write() function to send debug messages to the serial terminal. The io function parameter is a structure that describes the peripheral you want to write or read (ASF refers to this as an I/O descriptor). In this case, you've configured the USART_0 driver to use the SERCOM3 peripheral. Executing this function will send 12 bytes (number defined by the third parameter) of the buffer defined by the second parameter ("Hello World!") to the SERCOM3 peripheral.


Make the io structure global and rename the USART example function.

  • The io structure defined in the USART_0_example() function can be used with other functions (e.g., io_read()), so move this structure declaration from inside the USART_0_example() function to outside of it (make it a global variable).
  • Give the USART_0_example() function a more descriptive name … rename it UART_EDBG_init().

Your main.c file should look like this:



Refactor the io structure name to uart_edbg_io. Refactoring a variable renames it everywhere it’s found in the project (i.e., across all files of the project).

Right click on io and select:

  • Refactor (VA) > Rename…
  • Deselect ALL the lines which do not correspond to the main.c file.
  • Rename it from io to uart_edbg_io.
  • Click Rename.

Make sure that only the instances in main.c are renamed or you may modify the usart driver (hal_usart_sync.c) itself or other components.



In the main() function, call UART_EDBG_init() after atmel_start_init().

Your main.c file should look like this:


Step 6: Program the board


Connect the SAM D21 Xplained Pro Evaluation Kit to your computer:

  • Power-up your SAM D21 Xplained Pro board using DEBUG USB Connector.
  • Please be patient as the driver installs (it may take a minute or so).


Select the embedded (on-board) debugger found on the SAM D21 XPRO board as the Debugger/Programmer for the project.

  • Click on Project > Properties.
  • Select Tool > EDBG … as debugger/programmer.


Compile the project and program the board.

  • Compile the project by clicking on the 'Build Solution' icon or by typing ‘F7’, and verify it builds successfully.
  • Program the application by clicking on the 'Start Without Debugging' icon.

Note: If the firmware on the evaluation board is out of date, a Firmware Upgrade window will appear asking you if you want to upgrade the firmware. Select Upgrade and allow the process to complete.

Your application is now running on the evaluation board.

Step 7: Verify USART communication


Open and configure a serial terminal in the Studio 7 IDE.

  • Open the Data Visualizer:
    • Tools > Data Visualizer
  • Open the Serial Port Control Panel:
    • Configuration > External Connection > Serial Port
  • Use the drop-down window to select the Virtual COM Port connected to the board (you can find it using Windows® OS Device Manager).
    • EDBG Virtual COM Port (COMx)
  • Configure the serial port:
    • Baud rate: 9600
    • Parity: None
    • Stop bits: 1
  • Click Connect.


Press the RESET button on the SAM D21 Xplained Pro (beside the USB connector)

  • Verify that Hello World! is displayed on the Serial Terminal.

The SAM D21 USART is communicating with your PC as expected.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site 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 your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.