New timer library and fast PWM-DAC library for the SAMD21
I have made easy to use libraries for the SAMD21:
- SAMD21 Timer library for the SAM15x15 and Arduino Zero
- Fast PWM-DAC library for the SAM15x15 and Arduino Zero
Since 2015, there is a new powerful microcontroller available which can be programmed by the Arduino platform: the SAMD21. It is a 48MHz 32-bit ARM Cortex M0+ low power processor. Since it is quite new, there is not so much information about it on the Internet. That is why I will share my experience with the SAMD21 and discuss some particularities.
For sale: Mini Arduino compatible SAMD21 development board 15x15mm
The SAM 15x15 is an Arduino development board of just 15 x 15mm, with the same powerful controller as the Arduino Zero: the SAMD21G18. Despite the small size, it has more I/O pins than the Arduino Zero: 34 instead of 20. See the article and how to buy here.
Why do I use the SAMD21G?
I have developed a sophisticated e-bike computer, called the E-bike cable killer; it requires a small but powerful Arduino microcontroller. The widely used ATmega328, used at the Arduino Uno, doesn't have enough connections and is too slow; the main advantage is that its dual inline package fits into a normal IC socket.
Before 2015, the only faster Arduino alternative was the Arduino Due, but the processor has 144 pins and that is too much of a good thing. The Arduino Zero, which was released in 2015, contains the SAMD21G; this is a fast processor with a TQFP48 package.
Complete microcontroller development system with the Arduino SAMD21G
As you can see, we hardly need extra components to build a complete microcontroller development system with the Arduino SAMD21G:
Download the SAMD21G Eagle library HERE for the Eagle schematic symbol of the image above.
SAMD21G peripheral functions
There are 34 free pins available *. The most important pin peripheral functions are indicated with letters in the schematic symbol:
D = general purpose I/O, digitalWrite(), digitalRead()
A = ADC analog input, analogRead()
P = PWM output, analogWrite()
Pins may have many other peripheral functions, but in order not to lose overview, these are not indicated with a letter in the schematic symbol:
External Voltage Reference
Inter-IC Sound Controller
Peripheral Touch Controller
*If the USB is not used, the 2 USB pins are also available, which increases the number of free pins to 36.
SAMD21G with a preprogrammed bootloader for sale
Note that we need a SAMD21G with a preprogrammed bootloader. You can buy the SAMD21G with bootloader HERE.
The ATSAMD21G18A-AUT is the 48 pin version with 256k byte flash memory:
These are the main characteristics of the J, G and E types:
Built in Serial interface
The ATmega328 always needs an additional controller for programming. The SAMD21 instead, has a built-in serial interface which can directly be connected to an USB cable. This simplicity saves costs and board space. All we need is the SAMD21 with pre-programmed bootloader, a crystal and some capacitors: Note that the Arduino Zero board contains a lot of components; however these are in principle not all necessary.
How to use all SAMD21G pins
In order to make all SAMD21G pins available, we have to install the SAM 15x15 package.
How to solder the SAMD21
With some exercise, this TQFP48 chip it can be soldered by yourself; see here how to do it. You will, however, find out that the soldering is not so easy like in the examples. Maybe they have taken 10 videos and shown the best: