MattairTech MT--D21E User manual

MT-D21E User uide
Table of Contents
Table of Contents
Overview........................................................................................................................4
Introduction.......................................................................................................................................4
Board Features.................................................................................................................................5
ATSAMD21ExxA Features................................................................................................................6
MT-D21E Hardware.......................................................................................................7
Top View / Pinout..............................................................................................................................7
Main Header Pins (Power)................................................................................................................8
Main Header Pins (Signal)................................................................................................................9
Solder Jumpers...............................................................................................................................11
MattairTech Arduino SAMD Core..............................................................................13
What's New (1.6.6-mt1, November 24, 2015)..................................................................................13
Summary.........................................................................................................................................14
Special Notes..................................................................................................................................15
Pin Configurations...........................................................................................................................16
Pin Capabilities...............................................................................................................................17
MT-D21E and MT-D11 Board Configuration...................................................................................18
Serial Monitor..................................................................................................................................19
Code Size and RAM Usage (1.6.5-mt2)..........................................................................................19
Detailed Memory Usage Output After Compilation..............................................................................20
Installation.......................................................................................................................................21
Driver Installation..................................................................................................................................21
SAMD Core Installation........................................................................................................................22
New PinDescription Table...............................................................................................................22
Possible Future Additions................................................................................................................24
ChangeLog.....................................................................................................................................24
SAM-BA USB CDC Bootloader (Arduino Compatible)............................................26
Bootloader Firmware Installation.....................................................................................................27
Bootloader Installation Using the Arduino IDE................................................................................27
Bootloader Installation Using Another Tool (ie: Atmel Studio, openocd)........................................27
Using Bossac Standalone...............................................................................................................28
USB Mass Storage Bootloader..................................................................................29
Schematic....................................................................................................................31
Fuse and Lock Settings.............................................................................................32
Blink Demo..................................................................................................................32
Troubleshooting / FAQ...............................................................................................33
Support Information..................................................................................................33
Legal.............................................................................................................................34
Appendix A: Precautions...........................................................................................38
Appendix B: Other MattairTech Products................................................................39
July 11, 2016 2 http://www.mattairtech.com/

MT-D21E User uide
Overview
Overview
Introduction
The MT-D21E is a development board for the 32-pin Atmel SAM D21E ARM Cortex M0+ USB
microcontroller. It can be powered from USB or from the Vin pin. Two schottky diodes facilitate simple
switching (and reverse-polarity protection) between the two power sources. This voltage is regulated
to 3.3V by the onboard 250mA, extremely low quiescent current (2uA) LDO regulator that supports up
to 16V DC input voltage. Overcurrent protection is provided by a 180mA hold (400mA trip) PTC
resettable fuse. Also mounted is a mini USB connector, blue LED, 16MHz crystal, 32.768KHz crystal,
and two buttons. A USB CDC bootloader (Atmel SAM-BA) can be pre-installed for device
programming without an external programmer. It is compatible with Arduino, and core files are
provided to support Arduino 1.6.5+. A USB Mass Storage Class bootloader can optionally be installed
for device programming (see caveats). The Cortex debug header (10-pin, 50-mil) can be used with an
external debugger/programmer. The board has 40 main dual inline header pins with 100 mil pin
spacing and 700 mil row spacing which allows for mounting on a breadboard or perfboard. There are 2
3mm mounting holes. The PCB measures approx. 2.1” x 0.9” x 0.062” (52mm x 23mm x 1.6mm).
July 11, 2016 4 http://www.mattairtech.com/

MT-D21E User uide
Board Features
●Atmel SAM D21E 32-pin ARM Cortex M0+ microcontroller
●ATSAMD21E17A (128KB) or ATSAMD21E18A (256KB)
●Up to 48MHz
●128KB or 256KB in-system self-programmable Flash
●16KB or 32KB SRAM Memory
●Onboard 3.3V, 250mA LDO regulator
●up to 16V DC input
●extremely low quiescent current (2.0uA typical)
●low dropout (525mV typical @ 250mA, 725mV max. @ 250mA)
●0.4% output tolerance typical
●Over-current and over-temperature protection
●Simple power source switching
●2 schottky barrier diodes (Vbus and Vin)
●Low voltage drop
●Reverse-polarity protection
●PTC resettable fuse (180mA hold / 400mA trip)
●Cortex Debug Header (10-pin, 50-mil)
●Can be used for device programming and debugging
●16MHz crystal (can use PLL for up to 48MHz cpu clock)
●32.768KHz crystal
●Blue Status LED (can be disconnected)
●Button A for general use (pin A27) with debouncing
●Button B configurable for reset or general use (pin A31) with debouncing
●Two 4.7Kohm resistors can be connected to pins A16 and A17 for use with I2C
●USB SAM-BA (CDC) bootloader (optional)
●Arduino compatible (use the Arduino IDE to upload)
●Bossa command line utility (Windows, Linux, limited OS X)
●Arduino 1.6.5+ compatible core (1.6.6 support now available)
●USB Mass Storage Device (MSD) bootloader (optional, see caveats)
●Mini USB connector
●ESD protection on USB D+ and D- lines
●USB pins routed to header pins (for panel-mount USB connector)
●Powered by USB or external power source (up to 16V) on Vin
●Ferrite bead and 2 capacitors on analog supply
●Two capacitors each can be enabled for pins A3 and/or A4 for use with external references
●19 solder jumpers on PCB bottom for configuration flexibility
●All PORT pins routed to headers
●2 main headers are on 0.1” spacing (breadboard/perfboard mounting)
●Two 3mm mounting holes (~5mm pad)
●High-quality PCB with gold-plated finish
●Measures approx. 2.1” x 0.9” (52mm x 23mm) and 0.062” (1.6mm) thick.
July 11, 2016 5 http://www.mattairtech.com/

MT-D21E User uide
ATSAMD21ExxA Features
●Processor
●ARM Cortex-M0+ CPU running at up to 48MHz
●Single-cycle hard are multiplier
●Micro Trace Bu$er
●Memories
●32/64/128/256KB in-system self-programmable Flash
●4/8/16/32KB SRAM Memory
●System
●Po er-on reset (POR) and bro n-out detection (BOD)
●Internal and external clock options ith 48MHz Digital Frequency Locked Loop (DFLL48M) and 48MHz to
96MHz Fractional Digital Phase Locked Loop (FDPLL96M)
●External Interrupt Controller (EIC) / One non-maskable interrupt
●16 external interrupts
●T o-pin Serial Wire Debug (SWD) programming, test and debugging interface
●Low Power
●Idle and standby sleep modes
●SleepWalking peripherals
●Peripherals
●12-channel Direct Memory Access Controller (DMAC)
●12-channel Event System
●Up to ve 16-bit Timer/Counters TC), congurable as either:
●One 16-bit TC ith compare/capture channels
●One 8-bit TC ith compare/capture channels
●One 32-bit TC ith compare/capture channels, by using t o TCs
●Three 24-bit Timer/Counters for Control TCC), with extended functions:
●Up to four compare channels ith optional complementary output
●Generation of synchronized pulse idth modulation (PWM) pattern across port pins
●Deterministic fault protection, fast decay and con>gurable dead-time (complementary outputs)
●Dithering that increase resolution ith up to 5 bit and reduce quantization error
●32-bit Real Time Counter RTC) with clock/calendar function
●Watchdog Timer (WDT)
●CRC-32 generator
●One full-speed 12Mbps) Universal Serial Bus USB) 2.0 interface
●Embedded host and device function
●Eight endpoints
●Up to six Serial Communication Interfaces SERCOM), each congurable to operate as either:
●USART ith full-duplex and single- ire half-duplex con>guration
●I2C up to 3.4MHz
●SPI
●LIN slave
●One t o-channel Inter-IC Sound (I2S) interface
●One 12-bit, 350ksps Analog-to-Digital Converter ADC) with up to 20 channels
●Di$erential and single-ended input
●1/2x to 16x programmable gain stage
●Automatic o$set and gain error compensation
●Oversampling and decimation in hard are to support 13-, 14-, 15- or 16-bit resolution
●10-bit, 350ksps Digital-to-Analog Converter DAC)
●T o Analog Comparators (AC) ith indo compare function
●Peripheral Touch Controller (PTC)
●I/O
●Up to 52 programmable I/O pins
July 11, 2016 6 http://www.mattairtech.com/

MT-D21E User uide
============================= MattairTech MT-D21E (ATsamd21eXXa) ========================
Other INT PWM Digital Anal g Digital PWM INT Other
=========================================================================================
-------------------
Xin32 | A0 RST | Reset
X ut32 | A1 NC |
DAC 2 2(ADC0) | A2 NC |
REF 3 3(ADC1) | A3 A31 | 31 31(TCC11) 31(INT11) SWDIO*
4(INT4) 4 4(ADC4) | A4 A30 | 30 30(TCC10) 30(INT10) SWDCLK
5(INT5) 5 5(ADC5) | A5 NC |
6 6(ADC6) | A6 A28 | 28 28(INT8) LED
VDIV 7 7(ADC7) | A7 A27 | 27 27(INT15) BTNA
8(INTNMI) 8(TCC00) 8 8(ADC16) | A8 A23 | 23 23(TC41) 23(INT7) SS
9(INT9) 9(TCC01) 9 9(ADC17) | A9 A22 | 22 22(TC40) 22(INT6) MISO
TX1 10(TCC02) 10 10(ADC18)| A10 A19 | 19 19(INT3) SCK
RX1 11(TCC03) 11 11(ADC19)| A11 A18 | 18 18(INT2) MOSI
TX2 14(INT14) 14(TC30) 14 | A14 A17 | 17 17(TCC21) 17(INT1) SCL
RX2 15(TC31) 15 | A15 A16 | 16 16(TCC20) 16(INT0) SDA
| NC NC |
| NC NC |
| Vbus 3.3V| * Butt n B available n 31
USB D- | A24- _____ Vcc |
USB D+ | A25+ | | Vin |
| Gnd | USB | Gnd |
-------------------
Main Header Pins (Power)
Pin Description
Gnd (2) Ground
Vbus Vbus is connected directly to the Vbus pin (5V) of the USB connector. It is routed
through a schottky diode and through J6 to the regulator input circuitry, which includes
a 4.7uF capacitor. Vbus voltage can be measured on pin A1 by connecting J12 and
setting J3 toward the Vbus side of the board. J12 will complete the circuit for a resistor
divider consisting of a 200Kohm (top) and a 20Kohm resistor (bottom), and J3
connects to Vbus. The resistor divider will pull pin A7 to near ground level when Vbus
is disconnected. Because of a small leakage current from the schottky diode, a small
voltage should be interpreted as USB disconnected.
Vin Vin is the external power input pin. Up to 16V can be connected. It is routed through a
schottky diode to the regulator input circuitry, which includes a 4.7uF, 25V capacitor.
The schottky diode can be shorted with J1, eliminating the voltage drop across the
diode, which can be useful for battery applications. Note that when the diode is
shorted, reverse-polarity protection is disabled, and J6 should be disconnected to
prevent Vbus current from flowing into Vin. Vin voltage can be measured on pin A1 by
connecting J12 and setting J3 toward the Vin side of the board. J12 will complete the
circuit for a resistor divider consisting of a 200Kohm (top) and a 20Kohm resistor
(bottom), and J3 connects to Vbus. The resistor divider will pull pin A7 to near ground
level when Vbus is disconnected. Because of a small leakage current from the
schottky diode, a small voltage should be interpreted as Vin disconnected.
July 11, 2016 8 http://www.mattairtech.com/

MT-D21E User uide
Vcc This pin is connected to the Vcc and VccAna (through a ferrite bead) pins on the
microcontroller, the Cortex debug header Vcc pin, the reset pullup, and the TWI pullup
resistors. Vcc is connected to 3.3V through J5, which in turn is connected to the
output of the onboard regulator. The Vcc pin can also be used as an input. Disconnect
J5 to supply power from an external source to the Vcc pin.
3.3V 3.3V is connected to the output of the onboard 3.3V regulator. There is a 10uF
capacitor on the output. 3.3V is normally connected to Vcc through J5.
CAUTION
Higher regulator input voltages mean larger voltage drops and thus higher
thermal dissipation for a given amount of current. Be sure to limit current
consumption to prevent excessive heat when using higher voltages and/or
currents. The regulator will enter thermal shutdown if it gets too hot. All
capacitors are X7R, X7 , or NP0, so they can deal with the higher
temperatures of the regulator. Note that the PTC fuse is located near the
regulator, so high temperatures will lower the PTC trip and hold currents.
Main Header Pins (Signal)
Pin Description
A0, A1 (Xin32, Xout32) These can be used for analog or digital functions. Alternatively, jumpers
J16 and J17 can be set to route A0 and A1 to the 32.768KHz crystal.
A2, A5, A6 These can be used for analog or digital functions. Pin A2 can be used as a
DAC output.
A3, A4 These can be used for analog or digital functions. Alternatively, jumpers
J19 and/or J18 can be set to enable both a 100nF capacitor and a 1uF
capacitor so that the pin can be used with an external voltage reference.
A7 / Voltage Divider This can be used for analog or digital functions. Additionally, this pin can
be connected to the voltage divider for measurement of Vin or Vbus by
setting J3 and J12 appropriately.
A8 - A11 These can be used for analog or digital functions.
A14, A15 (Xin, Xout) These can be used for digital functions. Pin A14 can be used with an
external clock. Alternatively, jumpers J10 and J11 can be set to route A15
and A14 to the 16MHz crystal.
A24-, A25+
(USB D- and D+)
These can be used for digital functions. By default, these pins are also
connected to pins D- and D+ of the USB connector through jumpers J7
and J4. These header pins, along with the adjacent Vbus and Ground pins
can be used for a panel-mount USB connector.
July 11, 2016 9 http://www.mattairtech.com/

MT-D21E User uide
A16, A17 (I2C) These can be used for digital functions. Additionally, jumpers J8 and J9
can be enabled, which will connect two 4.7Kohm pullup resistors for use
with I2C.
A18, A19, A22, A23 These can be used for digital functions.
A27 / Button A This can be used for digital functions. By default, this pin is connected to
Button A through jumper J13. This button is debounced using a 249ohm
resistor and a 100nF capacitor. The pin is brought to ground when the
button is pressed. The button is used for bootloader entry (optional) or can
be for general purpose use.
A28 / LED This can be used for digital functions. By default, this pin is connected to a
blue LED through jumper J14 and a 499ohm resistor. The LED circuit
should consume around 1mA. Drive the pin high to turn on the LED.
A30 / SWD CLK This can be used for digital functions. Additionally, this pin is connected to
the Cortex debug header where it is used as SWD CLK.
A31 / Button B / SWD
IO
This can be used for digital functions. Additionally, the pin is routed to the
Cortex debug header where it is used as SWD IO. Alternatively, this pin
can be connected to Button B through jumper J15 (note that this button
can also be used for RST). This button is debounced using a 249ohm
resistor and a 100nF capacitor. The pin is brought to ground when the
button is pressed. The button can be can be for general purpose use.
RST RST connects to the reset pin of the microcontroller, to Button B through
jumper J15 ( note that this button can also be for general purpose use; see
A31 above), and to the Cortex debug header. A 10K pullup resistor is
connected as well.
NC These pins are not connected to anything. There are 7 pins marked NC.
Cortex Debug Header This 10-pin, 50-mil header can be connected to an external
programmer/debugger.
July 11, 2016 10 http://www.mattairtech.com/

MT-D21E User uide
Solder Jumpers
Jumper Description
J1: Vin diode disable Vin is the external power input pin. Up to 16V can be connected. It is routed through
a schottky diode to the regulator input circuitry. The schottky diode can be shorted
by closing J1, eliminating the voltage drop across the diode, which can be useful for
battery applications. Note that when the diode is shorted, reverse-polarity protection
is disabled, and J6 should be opened to prevent Vbus current from flowing into Vin.
J2: USB Shield Ground Jumper J2 can be closed to connect the USB shield to ground. The USB
specification calls for the USB shield to be connected to ground on the host side
only. However, some prefer to have it grounded. Bear in mind that the USB shield
will then act as an antenna. To avoid this, an 0603 component and an 0402 (ie:
1Mohm resistor and 4.5nF capacitor) may be soldered on the pads.
J3: Voltage divider
input
Vin or Vbus voltage can be measured on pin A7 by closing J12 and setting J3
toward either the Vin (for Vin measurement) or the Vbus (for Vbus measurement)
side of the board (refer to printing on top side of pcb). J12 will complete the circuit
for a resistor divider consisting of a 200Kohm (top) and a 20Kohm resistor (bottom),
and J3 connects to Vin or Vbus. The resistor divider will pull pin A7 to near ground
level when Vbus is disconnected. Because of a small leakage current from the
schottky diode, a small voltage should be interpreted as Vin/Vbus disconnected.
J4: USB D+ / Pin A25 Microcontroller pins A24 and A25 are connected to header pins A24- and A25+. By
default, these pins are also connected to pins D- and D+ of the USB connector
through jumpers J7 and J4. The header pins, along with the adjacent Vbus and
Ground pins can be used for a panel-mount USB connector.
J5: Vcc – 3.3V This connects the 3.3V regulator output rail to Vcc. Open J5 if supplying a regulated
voltage (3.6V or less) externally on the Vcc pin.
J6: Vbus Power This routes Vbus to the regulator input circuitry. There are two schottky diodes, one
for Vin and one for Vbus. They facilitate automatic power switching between these
two sources. If only external power will be used (Vin), open J6. This will prevent
Vbus power from being used when a USB cable is plugged in for communications.
J7: USB D- / Pin A24 See J4.
J8: I2C pullup resistor Close J8 to connect pin A16 through a 4.7Kohm resistor to Vcc for use with I2C.
J9: I2C pullup resistor Close J9 to connect pin A17 through a 4.7Kohm resistor to Vcc for use with I2C.
J10: 16MHz crystal
selection
J10 and J11 determine whether microcontroller pins A15 and A14 connect to
header pins A15 and A14 or to the 16MHz crystal. When the SAM-BA bootloader is
installed, the header pins are connected. If the MSD bootloader or no bootloader
are installed, the alternate position is used by default(16MHz crystal connected).
Note that the MSD bootloader does not use an external crystal, as it uses USB
clock recovery (DFLL tuned using the USB SOF signal).
J11: 16MHz crystal
selection
See J10. The image below shows connection to the header pins.
J12: Voltage divider See J3.
July 11, 2016 11 http://www.mattairtech.com/

MT-D21E User uide
enable
J13: Button A enable This jumper connects to Button A to pin A27. This button is debounced using a
249ohm resistor and a 100nF capacitor. The pin is brought to ground when the
button is pressed. The button is used for bootloader entry (optional) or can be for
general purpose use.
J14: LED enable This jumper connects pin A28 to a blue LED through a 499ohm resistor. The LED
circuit should consume around 1mA. Drive the pin high to turn on the LED.
J15: Button B function
selection
This jumper connects button B to either the RST pin, which is the default as shown
in the image below, or to pin A31 for general purpose use. This button is debounced
using a 249ohm resistor and a 100nF capacitor. The pin is brought to ground when
the button is pressed. Note that pin A31 is also used by the Cortex debug header
(SWD IO). The button can be completely disconnected by removing solder from all
three pads.
J16: 32.768KHz crystal
selection
J16 and J17 determine whether microcontroller pins A0 and A1 connect to header
pins A0 and A1 or to the 32.768KHz crystal. When the SAM-BA bootloader is
installed, they are routed to the crystal. If the MSD bootloader or no bootloader is
installed, they are routed to the header pins by default. Note that the MSD
bootloader does not use an external crystal, as it uses USB clock recovery (DFLL
tuned using the USB SOF signal).
J17: 32.768KHz crystal
selection
See J16.
J18: VREF capacitors When using pin A4 as VREF, close J18 to enable both a 100nF capacitor and a 1uF
capacitor from A4 to ground.
J19: VREF capacitors When using pin A3 as VREF, close J19 to enable both a 100nF capacitor and a 1uF
capacitor from A3 to ground.
Image note: The solder jumper configuration shows BOTH crystals disconnected.
July 11, 2016 12 http://www.mattairtech.com/

MT-D21E User uide
MattairTech Arduino SAMD Core
MattairTech Arduino SAMD Core
Please visit https://github.com/mattairtech/ArduinoCore-samd for updated documentation and
information on the new 1.6.7-beta release with support for OS X and many updates.
This is a fork from arduino/ArduinoCore-samd on GitHub. This will be used to maintain Arduino
support for SAMD boards including the MattairTech MT-D21E and the MT-D11 (see
https://www.mattairtech.com/). It primarily adds support for new devices as well as a more flexible pin
configuration / mapping system. It also adds some size optimizations, including the ability to select any
combination of CDC, HID, or UART through the menu (~7.5KB for blink sketch with CDC+HID+UART,
~2.5KB without USB or UART).
This core is intended to be installed using Boards Manager (see below). To update from a previous
version, click on MattairTech SAMD Boards in Boards Manager, then click Update.
What's New (1.6.6-mt1, November 24, 2 15)
●New documentation section 'Special Notes'. Please read!
●Updated ASCII pinouts to be more readable and less ambiguous.
●Updated the Signed driver for Windows (extras directory).
adds CDC/MIDI/HID, CDC/MSD/HID, and CDC/MSD/MIDI/HID composite USB
devices.
Of the above, currently only CDC/MIDI/HID is usable (see MIDIUSB library).
●Merged in changes from upstream past SAMD CORE 1.6.2 release
Added SPI.transfer16(..) method
Bugfix: added missing Serial.begin(baud, config) method. Thanks @tuxedo0801
the pin mode is changed to INPUT mode, arduino/ArduinoCore-samd#28
HardwareSerial BUG Rx pin floating input, arduino/ArduinoCore-samd#48
Send a ZLP if data size is multiple of EPX_SIZE for USB sends, arduino/ArduinoCore-
samd#63
Print not aborting on write failure, changelog update
Tone fix for arduino/ArduinoCore-samd#59 and optimizations
Fix warnings about deprecated recipe.ar.pattern
●Merged in changes from upstream SAMD CORE 1.6.2 2015.11.03
Fixed bug in delay calculations
Fixed deadlock conditions in Wire. Thanks Erin Tomson
Print not aborting on write() failure. Thanks @stickbreaker
SPI can now be configured in variants. Thanks @aethaniel
Implemented Wire.end
Implemented Wire.setClock. Thanks @PaoloP74
July 11, 2016 13 http://www.mattairtech.com/

MT-D21E User uide
Wire: allow scanning bus via beginTransmission-endTransmission
USB Device: big refactoring and bug fix
USB Device: added PluggableUSB interface
Summary
Feature MT-D21E MT-D11
Microcontroller ATSAMD21ExxA, 32-Bit ARM Cortex M0+ ATSAMD11D14AM, 32-Bit ARM
Cortex M0+
Clock Speed 48 MHz 48 MHz
Flash Memory 256 KB (D21E18A) / 128 KB (D21E17A) /
64 KB (D21E16A) / 32 KB (D21E15A)
16 KB (4KB used by USB SAM-
BA bootloader)
SRAM 32 KB (D21E18A) / 16 KB (D21E17A) / 8
KB (D21E16A) / 4 KB (D21E15A) 4 KB
EEPROM None (emulation may be available in the
future)
None (emulation may be available
in the future)
Digital Pins 22 17
Analog Input Pins 10, 12-bit ADC channels 10, 12-bit ADC channels
Analog Output Pins 1, 10-bit DAC 1, 10-bit DAC
PWM Output Pins 12 8
External Interrupts 15 (1 NMI) 9 (1 NMI)
USB Device and Host (CDC and HID) Device and Host (CDC and HID)
UART (Serial) 2 1
SPI 1 1
I2C (TWI) 1 1
Operating Voltage 3.3V (Do not connect voltages higher than
3.3V!) 3.3V (Do not connect voltages
higher than 3.3V!)
DC Current per I/O
Pin 7 mA 7 mA
July 11, 2016 14 http://www.mattairtech.com/

MT-D21E User uide
Special Notes
●Boards Manager must be opened twice to see some updates
●Errors when compiling, uploading, or burning the bootloader
Be sure to install the Arduino samd core before installing the MattairTech samd
core. If you have problems upgrading the IDE to 1.6.6, you may need to uninstall
both the Arduino and MattairTech cores, then re-install in the proper order. Use
Arduino core 1.6.2 or above.
●Tools->Communications menu
Currently, the Tools->Communications menu must be used to select the
communications configuration. This configuration must match the included
libraries. For example, when including the HID and Keyboard libraries, you must
select an option that includes HID (ie: CDC_HID_UART). This menu is currently
needed to select the USB PID that matches the USB device configuration
(needed for Windows). This may become automatic in a future release.
➢Be sure that the Tools->Communications menu matches the sketch and
libraries you are compiling.
➢Different combinations of USB devices will result in different COM port
assingments in Windows.
●Incude platform specific libraries
You may need to manually include platform specific libraries such as SPI.h,
Wire.h, and HID.h.
●Differences from Arduino in versioning
The MattairTech ArduinoCore-samd version currently tracks the IDE version. In
some cases, it may indicate the minimum IDE version. This is the case for both
1.6.5-mtX and 1.6.6-mtX (which corresponds to SAMD CORE 1.6.2). 1.6.6-mt1
corresponds to Arduino SAMD CORE 1.6.2 plus some pull requests.
July 11, 2016 15 http://www.mattairtech.com/

MT-D21E User uide
Pin Configurations
Most pins have multiple configurations available (even analog pins). For example, pin A10 on the MT-
D21E can be an analog input, a PWM output, Digital I/O, or the TX pin of 'Serial1'. These always
reference the pin number printed on the board but without the 'A' (with the usable pins starting at 2).
DO NOT connect voltages higher than 3.3V!
SAMD21 (MT-D21E)
============================= MattairTech MT-D21E (ATsamd21eXXa) ========================
Other INT PWM Digital Anal g Digital PWM INT Other
=========================================================================================
-------------------
Xin32 | A0 RST | Reset
X ut32 | A1 NC |
DAC 2 2(ADC0) | A2 NC |
REF 3 3(ADC1) | A3 A31 | 31 31(TCC11) 31(INT11) SWDIO*
4(INT4) 4 4(ADC4) | A4 A30 | 30 30(TCC10) 30(INT10) SWDCLK
5(INT5) 5 5(ADC5) | A5 NC |
6 6(ADC6) | A6 A28 | 28 28(INT8) LED
VDIV 7 7(ADC7) | A7 A27 | 27 27(INT15) BTNA
8(INTNMI) 8(TCC00) 8 8(ADC16) | A8 A23 | 23 23(TC41) 23(INT7) SS
9(INT9) 9(TCC01) 9 9(ADC17) | A9 A22 | 22 22(TC40) 22(INT6) MISO
TX1 10(TCC02) 10 10(ADC18)| A10 A19 | 19 19(INT3) SCK
RX1 11(TCC03) 11 11(ADC19)| A11 A18 | 18 18(INT2) MOSI
TX2 14(INT14) 14(TC30) 14 | A14 A17 | 17 17(TCC21) 17(INT1) SCL
RX2 15(TC31) 15 | A15 A16 | 16 16(TCC20) 16(INT0) SDA
| NC NC |
| NC NC |
| Vbus 3.3V| * Butt n B available n 31
USB D- | A24- _____ Vcc |
USB D+ | A25+ | | Vin |
| Gnd | USB | Gnd |
-------------------
SAMD11 (MT-D11)
=========================== MattairTech MT-D11 (ATsamd11D14AM) ==========================
Other INT PWM Digital Analog Digital PWM INT Other
=========================================================================================
-------------------
DAC (ADC0) | A | USB | Gnd |
REF 3 3(ADC1) | A3 | | Vcc |
4(INT4) 4(TCC00) 4 4(ADC ) | A4 ----- A31 | 31 31(TC 1) 31(INT3) RX/SWDIO
5(INT5) 5(TCC01) 5 5(ADC3) | A5 A30 | 30 30(TC 0) TX/SWDCLK
6(TCC0 ) 6 6(ADC4) | A6 A 7 | 7 7(INT7)
7(TCC03) 7 7(ADC5) | A7 A 3 | 3 SCL
MOSI 10(INT ) 10 10(ADC8) | A10 A | (INT6) SDA
SCK 11 11(ADC9) | A11 A17 | 17 17(TC11)
MISO 14(INTNMI) 14 14(ADC6) | A14 A16 | 16 16(TC10) 16(INT0) LED
BTN/SS 15(INT1) 15 15(ADC7) | A15 RST | Reset
-------------------
All pins operate at 3.3 volts. DO NOT connect voltages higher than 3.3V!
July 11, 2016 16 http://www.mattairtech.com/

MT-D21E User uide
Pin Capabilities
●Digital: All pins can be used for general purpose I/O
●Supports INPUT, OUTPUT, INPUT_PULLUP, and INPUT_PULLDOWN.
●Each pin can source or sink a maximum of 7 mA (when PER_ATTR_DRIVE_STRONG
is set for the pin).
●Internal pull-up and pull-down resistors of 20-60 Kohms (40Kohm typ., disconnected by
default).
●Use the pinMode(), digitalWrite(), and digitalRead() functions.
●Analog Inputs: 10 pins can be configured as ADC analog inputs.
●These are available using the analogRead() function.
●All pins can be used for GPIO and some pins can be used for other digital functions (ie.
pwm or serial).
●Each pin provides 10 bits of resolution (1024 values) by default.
●12-bit resolution supported by using the analogReadResolution() function.
●Each pin measures from ground to 3.3 volts.
●The upper end of the measurement range can be changed using the AREF pin and the
analogReference() function.
●DAC: One analog output is available on pin 2.
●Provides a 10-bit voltage output with the analogWrite() function.
●PWM: 12 pins (MT-D21E) or 8 pins (MT-D11) can be configured as PWM outputs.
●Available using the analogWrite() function.
●Each pin provides 8 bits of resolution (256 values) by default.
●12-bit resolution supported by using the analogWriteResolution() function.
●External Interrupts: 15 pins (MT-D21E) or 9 pins (MT-D11) can be configured with
external interrupts.
●Available using the attachInterrupt() function.
●Serial: 2 pairs of pins (MT-D21E) or 1 pair (MT-D11) can be configured for TTL serial I/O.
●MT-D21E: Serial1: pin 11 (RX) and pin 10 (TX). Serial2: pin 15 (RX) and pin 14 (TX).
●MT-D11: Serial1: pin 31 (RX) and pin 30 (TX).
●SPI: 3 or 4 pins can be configured for SPI I/O (SPI).
●MT-D21E: Pin 18 (MOSI), pin 19 (SCK), pin 22 (MISO), and optionally pin 23 (SS, not
currently used).
●MT-D11: Pin 10 (MOSI), pin 11 (SCK), pin 14 (MISO), and optionally pin 15 (SS, not
currently used).
●SPI communication using the SPI library.
●Note that the SPI library will set SS as an output.
●On the MT-D11, the button must be configured as reset (default) when using SPI.
●TWI (I2C): 2 pins can be configured for TWI I/O (Wire).
●MT-D21E: Pin 16 (SDA) and pin 17 (SCL).
●MT-D11: Pin 22 (SDA) and pin 23 (SCL).
●TWI communication using the Wire library.
●LED: One pin can be configured to light the onboard LED (LED_BUILTIN).
July 11, 2016 17 http://www.mattairtech.com/

MT-D21E User uide
●Pin 28 (MT-D21E) or pin 16 (MT-D11). Bring the pin HIGH to turn the LED on. The
pullup is disabled on this pin.
●Button: One pin can be configured to read the onboard Button A (BUTTON_BUILTIN).
●Pin 27 (MT-D21E) or pin 15 (MT-D11). Pressing the button will bring the pin LOW. The
pullup must be enabled first.
●If the debouncing capacitor is connected, delay reading the pin at least 6ms after
turning on the pullup.
●AREF: One pin can be configured as an AREF analog input.
●The upper end of the analog measurement range can be changed using the
analogReference() function.
●Reset: Bring this line LOW to reset the microcontroller.
MT-D21E and MT-D11 Board Configuration
●The 32.768KHz crystal is used by the Arduino core, so it MUST be connected via the
solder jumpers.
●Note that the sketch may still run without the crystal attached, but the clock speed will
be very inaccurate.
●The 16MHz crystal is not used. It should be disconnected via the solder jumpers.
●The I2C (TWI) pullup resistors should be enabled via the solder jumpers.
●The LED should be enabled via the solder jumper.
●Button A should be connected via the solder jumper. The debouncing capacitor should
also be connected.
●Button B (MT-D21E only) is connected to the Reset pin by default, but can be
connected to pin 31 via the solder jumper.
●A reference voltage can be connected to AREF. In this case, the capacitors should be
enabled via the solder jumper.
●On the MT-D11, BTN is shared with SPI SS, so the button must be configured as reset
(default) when using SPI.
July 11, 2016 18 http://www.mattairtech.com/

MT-D21E User uide
Serial Monitor
To print to the Serial Monitor over USB, use 'Serial'. Serial points to SerialUSB (Serial1 and
Serial2 are UARTs). Unlike most Arduino boards (ie. Uno), SAMD boards do not
automatically reset when the serial monitor is opened. To see what your sketch outputs to the
serial monitor from the beginning, the sketch must wait for the SerialUSB port to open first.
Add the following to setup():
while (!Serial) ;
Remember that if the sketch needs to run without SerialUSB connected, another approach
must be used. You can also reset the board manually with the Reset button if you wish to
restart your sketch. However, pressing the Reset button will reset the SAMD chip, which in
turn will reset USB communication. This interruption means that if the serial monitor is open, it
will be necessary to close and re-open it to restart communication.
Code Size and RAM Usage (1.6.5-mt2)
Sketch and Configuration MT-D21E (Code + RAM) MT-D11 (Code + RAM)
Blink (CDC + HID + UART) 7564 + 1524 7452 + 1424
Blink (CDC + UART) 6588 + 1496 6484 + 1396
Blink (CDC Only) 5248 + 1304 5192 + 1300
Blink (UART Only) 3828 + 336 3716 + 236
Blink (No USB or UART) 2472 + 144 2416 + 140
Datalogger (No USB or UART) 10340 + 948 10260 + 944
●180 bytes of flash can be saved on the MT-D11 by using PIN_MAP_COMPACT (see 'New
PinDescription Table' below).
●Datalogger compiled without USB or UART support, but with SPI and SD (with FAT filesystem)
support. Serial output was disabled.
●Note that USB CDC is required for auto-reset into the bootloader to work (otherwise, manually
press reset twice in quick succession).
●USB uses primarily 3 buffers totaling 1024 bytes. The UART uses a 96 byte buffer. The
banzai() function (used for auto-reset) resides in RAM and uses 72 bytes.
●Any combination of CDC, HID, or UART can be used (or no combination),
by using the Tools->Communication menu.
July 11, 2016 19 http://www.mattairtech.com/

MT-D21E User uide
Detailed Memory Usage Output After Compilation
The flash used message at the end of compilation is not correct. The number shown
represents the .text segment only. However, Flash usage = .text + .data segments (RAM
usage = .data + .bss segments). In this release, two programs are run at the end of
compilation to provide more detailed memory usage. To enable this output, go to File-
>Preferences and beside "Show verbose output during:", check "compilation".
Just above the normal flash usage message, is the output from the size utility. However, this
output is also incorrect, as it shows .text+.data in the .text field, but 0 in the .data field.
However, the .text field does show the total flash used. The .data field can be determined by
subtracting the value from the normal flash usage message (.text) from the value in the .text
field (.text+.data). The .bss field is correct.
Above the size utility output is the output from the nm utility. The values on the left are in
bytes. The letters stand for: T(t)=.text, D(d)=.data, B(b)=.bss, and everything else (ie: W)
resides in flash (in most cases).
July 11, 2016 20 http://www.mattairtech.com/
Table of contents
Other MattairTech Motherboard manuals