BUILDING OUR OWN DEVELOPEMENT BOARD COMPATIBLE TO ARDUINO ZERO
WHAT IS ARDUINO ZERO!
Let's first discuss what is Arduino zero before making our own!
The Zero is a simple and powerful 32-bit extension of the platform established by the UNO. The Zero board expands the
family by providing increased performance, enabling a variety of project opportunities for devices, and acts as a great
educational tool for learning about 32-bit application development. The Zero applications span from smart IoT devices,
wearable technology, high-tech automation, to crazy robotics. The board is powered by Atmel's SAMD21 MCU (ATSAMD21G18A),
which features a 32-bit ARM Cortex M0+ core. One of its most important features is Atmel's Embedded Debugger (EDBG), which provides a
full debug interface without the need for additional hardware, significantly increasing the ease-of-use for software debugging.
EDBG also supports a virtual COM port that can be used for device and bootloader programming.
The buil-in EDBG in Arduino Zero is for the ease of consumers so that the users do not need any external debugger like Atmel ICE Burner
for bootloading or debugging but for our developed board we will need need an Atmel ICE Burner or any other debugger.
Warning: Unlike most Arduino boards, the Zero (as well as the chip ATSAMD21G18A) runs at 3.3V. The maximum voltage that the
I/O pins can tolerate is 3.3V. Applying voltages higher than 3.3V to any I/O pin could damage the board.
Figure. 1: Arduino Zero Controller.
ARM CORE BENIFITS
ARM is a a 32-bit RISC processor architecture currently being developed by the ARM corporation. The business model behind ARM is based on licensing the ARM architecture to companies that want to manufacture ARM-based
CPU's or system-on-a-chip products. The two main types of licenses are the Implementation license and the Architecture license.
The Implementation license provides complete information required to design and manufacture integrated circuits containing an ARM processor core. ARM licenses two types of cores: soft cores and hard cores. A hard core is optimised for a specific manufacturing process, while a soft core can be used in any process but is less optimised.
The architecture license enables the licensee to develop their own processors compliant with the ARM ISA. ARM processors possess a unique combination of features that makes ARM the most popular embedded architecture today: First, ARM cores are very simple compared to most other general-purpose processors, which means that
they can be manufactured using a comparatively small number of transistors, leaving plenty of space on the chip for application-specific macrocells. A typical ARM chip can contain several peripheral controllers, a digital signal processor, and some amount of on-chip memory, along with an ARM core.
Second, both ARM ISA and pipeline design are aimed at minimising energy consumption - a critical requirement in mobile embedded systems. Third, the ARM architecture is highly modular: the only mandatory component of an ARM processor is the integer pipeline; all other components, including caches,
MMU, floating point and other co-processors are optional, which gives a lot of flexibility in building application-specific ARM-based processors. Finally, while being small and low-power, ARM processors provide high performance for embedded applications. For example, the PXA255 XScale processor running at 400MHz provides performance comparable to Pentium 2 at 300MHz, while using fifty times less energy.
The Zero has a 32-bit ARM core that can outperform typical 8-bit microcontroller boards. The most significant differences are:
32-bit core that allows operations on 4 byte wide data within a single CPU clock.
32-bit core that allows operations on 4 byte wide data within a single CPU clock.
CPU Clock at 48MHz
12 channels DMA controller that can relieve the CPU from doing memory intensive tasks
32 bit Real Time Counter (RTC) with clock/calendar function
32 bit CRC generator
Two-channel Inter IC Sound (I2S) interface
Peripheral Touch Controller (PTC)
Specifications of Arduino Zero are as under:
Figure. 2: Specifications of Arduino Zero.
FROM ATSAMD21G18A TO CUSTOMIZED ARM-BASED DEVELOPMENT BOARD
ATSAMD21G18A is a chip that needs other peripherals to operate like crystal, regulator, LEDS, proper pins to connect t other devices and many more.
Below is the process to make a developement board - a working controller - comapitable to Ardiono Zero from just a tiny Chip.
ATSAMD21G18A
It is a low-power, high-performance Microchip's ARM Cortex-M0+ based flash microcontroller,
the ATSAMD21G18 is ideal for a wide range of home automation, consumer, metering, and industrial applications.
It features:
256KB of flash and 32KB of SRAM
Up to 48MHz operating frequency
Full Speed USB Device and embedded Host
Support for up to 120 touch channels
1.62V to 3.63V power supply
Easy pin migration to SAMD21G and SAMD21J devices
Six serial communication modules (SERCOM) configurable as UART/USART, SPI or I2C,
three 16-bit timer/counters, 32-bit Real-Time Clock and calendar, 20 PWM channels,
one 14-channel 12-bit ADC, one 10-bit DAC
COMPARISON WITH 8-BIT MICROCONTROLLER
As you can see this is a very powerful microcontroller compared to the older 8-bit/16MHz Arduino microcontrollers.
To just show you how powerful they are, we compared them side by side with the ATmega328P that is on your Arduino UNO.
Table. I: Comparison of SAMD21G18A and Atmega328P
Features
ATSAMD21G18A
ATmega328P
Architecture
ARM Cortex-M0
AVR
Bus Size
32 Bit
8 Bit
CPU Speed
48MHz
20MHz
Flash
256KB
32KB
SRAM
32KB
2KB
EEPROM
32KB
1KB
Voltage Range
1.62V to 3.63V
1.8V to 5.5V
GPIO Count
38
23
ADC Channels
14
8
ADC Resolution
12 Bit
10 Bit
USB Controller
✔
✖
Digital-to-Analog Converter (DAC)
✔
✖
Peripheral Touch Controller
✔
✖
Direct Memory Access (DMA)
12 Channels
✖
MAKING OF DEVELOPMENT BOARD ATSAMD21G18A is a chip having several analog, digital, power, ground and serial pins.
Understanding its pinout is the key to understand the ARM microcontroller.
After understanding pin configuration of ATSAMD21G18A we can easily connect all other
required components to it in oreder to make the developement board.
Then we are all good to go for the design on the Eagle Software, from where we can have our PCB circuit printed
on the PCB board.
Figure. 3: External Pin configuration of ATSAMD21G18A.
Figure. 4: Internal Pin configuration of ATSAMD21G18A on EAGLE.
OUR DESIGNS ON EAGLE SOFTWARE:
We have designed PCB layout on Eagle Software. EAGLE is a scriptable electronic design automation (EDA) application with
schematic capture, printed circuit board (PCB) layout, auto-router and computer-aided manufacturing (CAM) features. EAGLE
stands for Easily Applicable Graphical Layout Editor (German: Einfach Anzuwendender Grafischer Layout-Editor) and is developed
by CadSoft Computer GmbH. The company was acquired by Autodesk Inc. in 2016.
EAGLE contains a schematic editor, for designing circuit diagrams. Schematics are stored in files with
.SCH extension, parts are defined in device libraries with .LBR extension. Parts can be placed on many sheets and connected
together through ports. The PCB layout editor stores board files with the extension .BRD. It allows back-annotation to the
schematic and auto-routing to automatically connect traces based on the connections defined in the schematic. EAGLE saves
Gerber and PostScript layout files as well as Excellon and Sieb & Meyer drill files. These are standard file formats
accepted by PCB fabrication companies, but given EAGLE's typical user base of small design firms and hobbyists, many PCB
fabricators and assembly shops also accept EAGLE board files (with extension .BRD) directly to export optimized production
files and pick-and-place data themselves. EAGLE provides a multi-window graphical user interface and menu system for editing,
project management and to customize the interface and design parameters. The system can be controlled via mouse, keyboard
hotkeys or by entering specific commands at an embedded command line. Keyboard hotkeys can be user defined. Multiple
repeating commands can be combined into script files (with file extension .SCR). It is also possible to explore design
files utilizing an EAGLE-specific object-oriented programming language (with extension .ULP).
We have learnt and used Eagle to develope the designs for the board we are going to make with ATSAMD21G18A.
Figure. 5: Our Schematic Design of the ATSAMD21G18A Controller on EAGLE.
Figure. 6: Our Schematic Design of the ATSAMD21G18A Controller on EAGLE.
Figure. 7: The Printed Circuit Board (PCB).
Figure. 8: The Soldered Printed Circuit Board (Top View).
Figure. 9: The Soldered Printed Circuit Board (Side View).
Finally a fully soldered board is ready for the bootloading.
We have been careful in soldering the chip on the board because the pins were so tiny that soldering those could short the whole circuit.
Figure. 10: Pin Configuration of Our Developed Board.
BOOTLOADING OF DEVELOPEMENT BOARD
REQUIREMENTS HARDWARE AND SOFTWARE
Here is what we will be using to boatload the bare microcntroller:
Atmel Studio (Debugging Software)
Atmel ICE Burner (SAM PORT)
JTAG Cable
SWD Port of the microcontroller
ATMEL STUDIO 7
Atmel Studio 7 is the integrated development platform (IDP) for developing and debugging SMART ARM-based and AVR
microcontroller (MCU) applications. Studio 7 supports all AVR and SMART MCUs. The Atmel Studio 7 IDP gives you a
seamless and easy-to-use environment to write, build and debug your applications written in C/C++ or assembly code.
It also connects seamlessly to Atmel debuggers and development kits.
Additionally, Atmel Studio includes Gallery, an online apps store that allows you to extend your development environment
with native and third-party tools and embedded software vendor developed plug-ins. Atmel Studio 7 can also seamlessly
import your Arduino sketches as C++ projects, providing a simple transition path from Makerspace to Marketplace.
Figure. 10:Atmel Studio IDE.
ATMEL ICE BURNER
Atmel-ICE is a powerful development tool for debugging and programming Arm Cortex-M based Microchip
SAM and AVR microcontrollers with On-Chip Debug capability.
It supports:
Programming and on-chip debugging of all Microchip AVR 32-bit microcontrollers on both JTAG and aWire interfaces
Programming and on-chip debugging of all Microchip AVR XMEGA family devices on both JTAG and PDI two-wire interfaces
Programming (JTAG, SPI, UPDI) and debugging of all Microchip AVR 8-bit microcontrollers with OCD support on either JTAG,
debugWIRE or UPDI interfaces
Programming and debugging of all Microchip SAM Arm Cortex-M based microcontrollers on both SWD and JTAG interfaces
Programming (TPI) of all Microchip tinyAVR 8-bit microcontrollers with support for this interface
Figure. 12: Atmel Ice Burner.
ICE Burner has two ports AVR and SAM (can be seen in above figure). AVR port is used for ISP inteface of AVR Microcontrollers and SAM port
is used for ARM-Based Microcontrollers. SAM Port of ICE Burner impliments SWD (Serial Wire Debug) interface.
JTAG CABLE & SWD PHYSICAL INTERFACE
The Arm SWD interface is a subset of the JTAG interface, making use of TCK and TMS pins.
The Arm JTAG and AVR JTAG connectors are, however, not pin-compatible, so when designing an application PCB,
which uses a SAM device with SWD or JTAG interface, it is recommended to use the Arm pinout shown in the figure below.
The SAM connector port on the Atmel-ICE can connect directly to this pinout.
In our project we will be connecting SWD pins of both ATSAMD21G18A and SAM Port of ICE Burner together via JTAG cable and few wires
Figure. 13: SAM/SWD Pinout of Ice Burner and JTAG Cable's Specifications.
Figure. 14: Description of Pin connections of Atmel-ICE (SWD) and (JTAG) header.
What is SWD Debugging?
SWD, also known as Serial Wire Debug is a 2-pin interface (SWDIO/SWCLK) of which it's also an alternative
JTAG interface that has the same JTAG protocol.
SWD uses an ARM CPU standard bi-directional wire protocol, defined in the ARM Debug programmer.
CONNECTING TO BOATLOAD
Connect the Atmel ICE Debug Programmer to the PC and also power the microcntroller from the power pins.
Then connect the pins carefully understanding the JTAG Cable pin configuration as follows
Table. II: Table. II: Pin connections of SAMD21G18A with Atmel-ICE.
Figure. 15: SWD Connection of ATSAMD21G18A with the SAM SWD Poert Via JTAG Cable Header.
Figure. 16: Physical Pin Connections.
Remember one thing that JTAG Cable turns the Pin configuration of ICE Ports upside down so be careful with connection--------
BOOTLOAD BEGINS
To properly write the bootloader of ATSAMD21G18A, we have used the Atmel Ice Burner
and the tool provided by ATMEL "AtmelStudio version x.y". It is important to learn how to program the
bootloader on the developed board because the debugging process substitutes it. We need to reprogram the
bootloader as explained in this below to bring the board back to its standard behavior.
For bootloading we need the "bootloader program" of Arduino Zero which can be downloaded from the Google by typing "Arduino Zero Core".
You will find a GitHub page, a ZIP file option must be opted.
Once the file is downloaded, extract it, following are the steps for burning the bootloader:
Ensure the connection of ATMEL ICE with the computer,
Ensure that the microcontroller is powered properly,
Ensure the proper connectivity of SWD - from the ICE to the microcontroller as suggested in above figure,
1. Open any version of AtmelStudio;
2. Go to "Tools -> Device Programming" or press the keys "CTRL + SHIFT + P"
3. in Tool, select "Atmel Ice----"
4. in Device, select "ATSAMD21G18A"
5. in Interface, select "SWD"
6. press "Apply"
7. Make sure these values appear before proceeding!
If the board is not detected, or your wiring is not detected,
Atmel Studio will throw an error that it could not connect to the board.
Check your wiring (especially the SWDIO/SWCLK wires), that your USB cables
are connected to the computer, and try to connect again.
8. Go to "Memories", Click "Erase now"
9. Go to Fuses, Un-set Bootloader Protection Fuse, if not already
The SAMD21 has a BOOTPROT fuse protecting the flash area of the bootloader.
You'll want to clear the BOOTPROT fuse before flashing the bootloader.
Go to the Fuses page
Click Read in the bottom right section to read the fuses. Look for the BOOTPROT fuse
For SAMD21, you will need to set it to 0x07 or Zero Bytes
Click Program, wait for a confirmation that the fuses have been set. Then, click Verify.
10. Go to "Memories", Select the bootloader file "Arduino Zero Bootloader" to burn
(Bin File) that we downloaded from github and extracted.
Click "Program" and again, in the log console you will see "OK".
11. After flashing, you'll need to set the BOOTPROT fuse back to a 8kB bootloader size.
From Fuses, set BOOTPROT to 0x2 or 8KB and click Program
If there are only check marks already and no any exclamation mark before BOOTPROT, leave it as it is, it is fine.
12. Check Success!
Go to "Device Manager", there you must find COM PORT with the name of Ardiono Zero Native Port!!!!
PROGRAMMING THE MICROCONTROLLER FROM ARDUINO IDE
For programming the bare microcontroller we need:
Arduino IDE
USB-Micro-B (to create Arduino Zero like Native Port for Serial Communication)
B-Type Cable
ARDUINO INTEGRATED DEVELOPEMENT ENVIRONMENT (IDE)
The Arduino Integrated Development Environment - or Arduino Software (IDE) -
contains a text editor for writing code, a message area, a text console, a toolbar
with buttons for common functions and a series of menus. It connects to the Arduino
hardware to upload programs and communicate with them.
Programs written using Arduino Software (IDE) are called sketches.
These sketches are written in the text editor and are saved with the file extension .ino.
The editor has features for cutting/pasting and for searching/replacing text. The message
area gives feedback while saving and exporting and also displays errors. The console displays
text output by the Arduino Software (IDE), including complete error messages and other information.
The bottom righthand corner of the window displays the configured board and serial port.
The toolbar buttons allow you to verify and upload programs, create, open, and save sketches,
and open the serial monitor.
ARDUINO IDE 2.0
On October 18, 2019, Arduino Pro IDE (alpha preview) was released.
Later, on March 1, 2021, the beta preview was released, renamed IDE 2.0.
The system still uses Arduino CLI (Command Line Interface), but improvements
include a more professional development environment, autocompletion support,
and Git integration. The application frontend is based on the Eclipse Theia Open Source IDE.
The new major release of the Arduino IDE is faster and even more powerful!
In addition to a more modern editor and a more responsive interface it features autocompletion,
code navigation, and even a live debugger.
The debugger is compatible with all SAMD boards.
The main features available in the new release are:
Modern, fully featured development environment
Dual Mode, Classic Mode (identical to the Classic Arduino IDE) and Pro Mode (File System view)
New Board Manager
New Library Manager
Board List
Basic Auto-Completion (Arm targets only)
Git Integration
Serial Monitor
Dark Mode
We will be using Arduino IDE 2.0 for the purpose of programming our board.
Before connecting board containing ATSAMD21G18A chip, "SAMD Boards" mudt be added to "Arduino IDE" from its "Board Manager"
Figure. 17: Arduino IDE.
MICRO-USB-B AND NATIVE PORT
What is the USB Micro B?
The micro B type connector holds 5 pins to support USB OTG,
which permits smartphones and other similar mobile devices to read external drives,
digital cameras, or other peripherals as a computer might.
What is a Native PORT?
The Native USB port (which supports serial communication using the SerialUSB object)
is connected directly to the ATSAMD21G18A. It is used for Programming the chip.
Below picture shows the schematic for the connections of the ATSAMD21G18A with USB-Micro-B Female to
create the native port for programming.
Figure. 18: Pin connections of USB micro-B (Female) connector with ATSAMD21G18A.
Figure. 19: Physical Pin Connections of USB Port.
CONNECT AND INITIATE PROGRAMMING
Connect the USB-Micro-B cable with the developement board:
Connect to the computer,
1. Launch the Arduino Software (IDE), open the blink.ino sketch from the "Basics" in "examples" and
make "ON" delay 2000 and "OFF" delay 3000:
2. And then, select the Arduino Zero (Native Port) from the boards menu, because we have bootloaded Arduino
Zero Bootloaders:
3. Select the COM port where the developed board compatible to Arduino Zero is connected:
4. Then Click Upload:
5. It should be noticed that a "OUTPUT" window must appear below, where the process is under goes:
6. Looking at the console window (the area below the sketch), upload status could be verified, which says "UPLOAD COMPLETE":
After finishing the uploading of code. The demo video is attached.
Reference link for uploading and programming the arm based microcontroller
Delegation of Tasks
CONCLUSION
We have designed and fabricated SAMD21G18A development board at FAB LAB Sukkur IBA University that is compatible to Arduino Zero.
The SAMD21G18A developement board has been equipped with a USB interface for programming and power, surrounded with an RTC crystal of 32.768 GHZ,
and a 600mA 3.3V regulator. All pins of the microcontroller were given connections through headers.
Developement board was miniaturized as much as possible. The I/O and voltage rails are all broken out to a pair of
breadboard-compatible headers. Power can be supplied, and the board can be programmed, through the micro-B USB connector.
One of the most unique features of the SAMD21 is SERCOM - a set of six configurable serial interfaces that can be turned into
either a UART, I2C master, I2C slave, SPI master, or SPI slave. Each SERCOM provides for a lot of flexibility:
the ports can be multiplexed, giving you a choice of which task each pin is assigned. At the M0's heart is an
ATSAMD21G18 ARM Cortex M0 processor, clocked at 48 MHz and at 3.3V logic, the same one used in the new Arduino Zero.
This chip has a whopping 256K of FLASH (8x more than the Atmega328 or 32u4) and 32K of RAM (16x as much)!
This chip comes with built in USB so it has USB-to-Serial program & debug capability built in with no need for an
FTDI-like chip. To make it easy to use for portable projects,
we added a connector for any of our 3.7V Lithium polymer batteries and built in battery charging.
You don't need a battery, it will run just fine straight from the
micro USB connector.
ISSUES FACED
Data cable must be used for programming instead of power cable.
As USB interface is not embedded on board, it cause problems during programming.
The size of circuit is small so traces were too close, we were very carefull during soldering.
We use Rasberry Pi/Arduino to power the breakout because power port is not available in board.
Verfication bits were not detected in bootloading due to wrong wiring and cable issues.
We faced library issues in Arduino IDE and Atmel during programming.
FUTURE WORK
There are many possibilities left for the future with the ATSAMD21G18A. The most important is to intefrate the USB-Micro-B inside the designed circuit to have an efficient
board overall. Through USB port we can also effectively draw power to the IC through the regulator. As we are now familiar with the chip and board we can now have more customized and project based boards.
And many more.
SPECIAL THANKS TO:
TEACHER:
ASSOCIATE PROFESSOR DR. MUHAMMAD ASIM SAMEJO
&
FAB-LAB ASSISTANT:
ENGR. NADIR ALI
(DoEE) DEPARTMENT OF ELECTRICAL ENGINEERING SUKKUR IBA UNIVERSITY