SAMD21: Arduino Zero / Feather M0

Shop / Projects

Minifigure SAM
Sam DEV
HACK-HackAday Cortex Kit
Developed on Hackaday : HaDge update – it’s a HACK
LEMSv2
MakerNet

Aliexpress

SAMD21 M0. 32-bit ARM Cortex M0 core. kompatibel mit Arduino Null, Arduino M0. Form R3.
SAMD21 M0-Mini. 32-bit ARM Cortex M0 core. Pins Abgelötet. kompatibel mit Arduino Null, Arduino M0. Form Mini.
Arduino Zero for dummies

Library

github.com/adafruit/Adafruit_ASFcore: ASF core files for Zero

Debugging

Proper Debugging of ATSAMD21 Processors

I2C

Adding more Serial Interfaces to SAMD microcontrollers (SERCOM) (VERX USEFUL!)
Wire lib hangs when scanning i2c in Wire.endTransmission()

Timer

AMD21 Timer library for the SAM15x15 and Arduino Zero
Arduino ZERO timer interrupts
happy wrappers for TC modules 3,4,5 on SAMD21
github.com/nebs/arduino-zero-timer-demo: A simple demo of the Arduino Zero timer frequency being smoothly changed in real time.
github.com/maxbader/arduino_tools: Arduino libraries and samples

Code

/c/Users/bachman0/AppData/Local/Arduino15
/c/Users/bachman0/Documents/Arduino/libraries/
C:\Users\bachman0\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12\cores\arduino\main.cpp
/c/Users/bachman0/AppData/Local/Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/main.cpp

/*
 * \brief Main entry point of Arduino application
 */
int main( void )
{
  init();

  __libc_init_array();

  initVariant();

  delay(1);
#if defined(USBCON)
  USBDevice.init();
  USBDevice.attach();
#endif

  setup();

  for (;;)
  {
    loop();
    if (serialEventRun) serialEventRun();
  }

  return 0;
}
C:\Users\bachman0\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12
cores\arduino\cortex_handlers.c

/* Exception Table */
__attribute__ ((section(".isr_vector"))) const DeviceVectors exception_table =
{
  /* Configure Initial Stack Pointer, using linker-generated symbols */
  (void*) (&__StackTop),

  (void*) Reset_Handler,
  (void*) NMI_Handler,
  (void*) HardFault_Handler,
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) SVC_Handler,
  (void*) (0UL), /* Reserved */
  (void*) (0UL), /* Reserved */
  (void*) PendSV_Handler,
  (void*) SysTick_Handler,

  /* Configurable interrupts */
  (void*) PM_Handler,             /*  0 Power Manager */
  (void*) SYSCTRL_Handler,        /*  1 System Control */
  (void*) WDT_Handler,            /*  2 Watchdog Timer */
  (void*) RTC_Handler,            /*  3 Real-Time Counter */
  (void*) EIC_Handler,            /*  4 External Interrupt Controller */
  (void*) NVMCTRL_Handler,        /*  5 Non-Volatile Memory Controller */
  (void*) DMAC_Handler,           /*  6 Direct Memory Access Controller */
  (void*) USB_Handler,            /*  7 Universal Serial Bus */
  (void*) EVSYS_Handler,          /*  8 Event System Interface */
  (void*) SERCOM0_Handler,        /*  9 Serial Communication Interface 0 */
  (void*) SERCOM1_Handler,        /* 10 Serial Communication Interface 1 */
  (void*) SERCOM2_Handler,        /* 11 Serial Communication Interface 2 */
  (void*) SERCOM3_Handler,        /* 12 Serial Communication Interface 3 */
  (void*) SERCOM4_Handler,        /* 13 Serial Communication Interface 4 */
  (void*) SERCOM5_Handler,        /* 14 Serial Communication Interface 5 */
  (void*) TCC0_Handler,           /* 15 Timer Counter Control 0 */
  (void*) TCC1_Handler,           /* 16 Timer Counter Control 1 */
  (void*) TCC2_Handler,           /* 17 Timer Counter Control 2 */
  (void*) TC3_Handler,            /* 18 Basic Timer Counter 0 */
  (void*) TC4_Handler,            /* 19 Basic Timer Counter 1 */
  (void*) TC5_Handler,            /* 20 Basic Timer Counter 2 */
  (void*) TC6_Handler,            /* 21 Basic Timer Counter 3 */
  (void*) TC7_Handler,            /* 22 Basic Timer Counter 4 */
  (void*) ADC_Handler,            /* 23 Analog Digital Converter */
  (void*) AC_Handler,             /* 24 Analog Comparators */
  (void*) DAC_Handler,            /* 25 Digital Analog Converter */
  (void*) PTC_Handler,            /* 26 Peripheral Touch Controller */
  (void*) I2S_Handler,            /* 27 Inter-IC Sound Interface */
  (void*) (0UL),                  /* Reserved */
};
digitalRead()
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/wiring_digital.c:int digitalRead( uint32_t ulPin )
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/wiring_digital.h:extern int digitalRead( uint32_t ulPin ) ;

millis()
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/delay.c:uint32_t millis( void )
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/delay.h:extern uint32_t millis( void ) ;

yield()
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/Arduino.h:void yield( void ) ;
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/hooks.c:void yield(void) __attribute__ ((weak, alias("__empty")));

dtostrf()
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/avr/dtostrf.c:char *dtostrf (double val, signed char width, unsigned char prec, char *sout) {
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/avr/dtostrf.h:char *dtostrf(double val, signed char width, unsigned char prec, char *sout);

String / StringObject
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/WString.cpp:String::String(const char *cstr)
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/WString.h:class String

Stream::readStringUntil()
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/Stream.cpp:String Stream::readStringUntil(char terminator)
Arduino15/packages/arduino/hardware/samd/1.6.12/cores/arduino/Stream.h:  String readStringUntil(char terminator);
C:\Users\bachman0\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.6.12
cores\arduino\SERCOM.h

/c/Users/bachman0/AppData/Local/Arduino15/packages/arduino/hardware/samd/1.6.12/libraries/Wire

TwoWire::TwoWire(SERCOM * s, uint8_t pinSDA, uint8_t pinSCL)
{
  this->sercom = s;
  this->_uc_pinSDA=pinSDA;
  this->_uc_pinSCL=pinSCL;
  transmissionBegun = false;
}

void TwoWire::begin(void) {
  //Master Mode
  sercom->initMasterWIRE(TWI_CLOCK);
  sercom->enableWIRE();

  pinPeripheral(_uc_pinSDA, g_APinDescription[_uc_pinSDA].ulPinType);
  pinPeripheral(_uc_pinSCL, g_APinDescription[_uc_pinSCL].ulPinType);
}

void TwoWire::begin(uint8_t address) {
  //Slave mode
  sercom->initSlaveWIRE(address);
  sercom->enableWIRE();

  pinPeripheral(_uc_pinSDA, g_APinDescription[_uc_pinSDA].ulPinType);
  pinPeripheral(_uc_pinSCL, g_APinDescription[_uc_pinSCL].ulPinType);
}


void (*onReceiveCallback)(int);
void TwoWire::onService(void)
void SERCOM3_Handler(void); // Interrupt Handler

#if WIRE_INTERFACES_COUNT > 0
  /* In case new variant doesn't define these macros,
   * we put here the ones for Arduino Zero.
   *
   * These values should be different on some variants!
   */
  #ifndef PERIPH_WIRE
    #define PERIPH_WIRE          sercom3
    #define WIRE_IT_HANDLER      SERCOM3_Handler
  #endif // PERIPH_WIRE
  TwoWire Wire(&PERIPH_WIRE, PIN_WIRE_SDA, PIN_WIRE_SCL);

  void WIRE_IT_HANDLER(void) {
    Wire.onService();
  }
#endif
/c/Program\ Files\ \(x86\)/Arduino/libraries/SD

File
Arduino/libraries/SD/src/File.cpp:File::File(SdFile f, const char *n)
Arduino/libraries/SD/src/SD.h:class File : public Stream

File::openNextFile
Arduino/libraries/SD/src/SD.cpp:File File::openNextFile(uint8_t mode)

SdFile
Arduino/libraries/SD/src/utility/SdFat.h:class SdFile : public Print {
Arduino/libraries/SD/src/utility/SdFat.h:  uint8_t open(SdFile& dirFile, const char* fileName) {  // NOLINT
Arduino/libraries/SD/src/utility/SdFile.cpp:uint8_t SdFile::open(SdFile* dirFile, const char* fileName, uint8_t oflag) {

SdFile::openRoot
Arduino/libraries/SD/src/utility/SdFile.cpp:uint8_t SdFile::openRoot(SdVolume* vol) {
Arduino/libraries/SD/src/utility/SdFile.cpp:uint8_t SdFile::openRoot(SdVolume* vol, Stream* stream) {

/c/Users/bachman0/AppData/Local/Arduino15
packages/SparkFun/hardware/samd/1.3.2/variants/SparkFun_9DoF_M0/variant.cpp

[...]

// Multi-serial objects instantiation
SERCOM sercom0( SERCOM0 ) ;
SERCOM sercom1( SERCOM1 ) ;
SERCOM sercom2( SERCOM2 ) ;
SERCOM sercom3( SERCOM3 ) ;
SERCOM sercom4( SERCOM4 ) ;
SERCOM sercom5( SERCOM5 ) ;

Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ;
Uart Serial( &sercom5, PIN_SERIAL_RX, PIN_SERIAL_TX, PAD_SERIAL_RX, PAD_SERIAL_TX ) ;

/**
 * SERCOM0_Handler is mapped to Serial1
 * How can I remap it to I2C??
 */
void SERCOM0_Handler()
{
  Serial1.IrqHandler();
}

void SERCOM5_Handler()
{
  Serial.IrqHandler();
}

IMU / MARG / MEMS sensors

Affordable 9 DoF Sensor Fusion
Hardware Sensor Fusion Solutions

  • MPU-6050 (Invensense)
  • GY-80
  • MPU-9150 (Invensense)
  • MPU-9250 (Invensense)
  • LSM9DS0 (ST Microelectronic)
  • MPU-6050 + HMC5883L
  • MAX21100 (Maxim)
  • BMX055 (Bosch)
  • BMI055 (Bosch)
  • BMI160 (Bosch)
  • BMP280 (Bosch)

UDOO x86

UDOO X86
GET STARTED X86 – UDOO
UDOO X86 Documentation
nRF51822: Bluetooth low energy and 2.4GHz proprietary SoC
BMI160: 16-bit inertial measurement unit
Intel Curie
Arduino 101 / Genuino 101


[ESC] to go to BIOS

$ inxi -Fxz
System:    Host: udoo-x86 Kernel: 4.15.0-36-generic x86_64 bits: 64 gcc: 7.3.0
           Desktop: Cinnamon 3.8.9 (Gtk 3.22.30-1ubuntu1) Distro: Linux Mint 19 Tara
Machine:   Device: laptop System: SECO product: UDOO x86 v: Version serial: N/A
           Mobo: SECO model: UDOO x86 v: Board Version serial: N/A UEFI: SECO v: 1.01 date: 02/20/2017
Battery    hidpp__0: charge: 50% condition: NA/NA Wh model: Logitech M705 status: Discharging
CPU:       Quad core Intel Celeron N3160 (-MCP-) arch: Airmont rev.4 cache: 1024 KB
           flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 12800
           clock speeds: max: 2240 MHz 1: 493 MHz 2: 1026 MHz 3: 480 MHz 4: 480 MHz
Graphics:  Card: Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Integrated Graphics Controller
           bus-ID: 00:02.0
           Display Server: x11 (X.Org 1.19.6 ) drivers: modesetting (unloaded: fbdev,vesa)
           Resolution: 1280x1024@60.02hz
           OpenGL: renderer: Mesa DRI Intel HD Graphics 400 (Braswell)
           version: 4.5 Mesa 18.0.5 Direct Render: Yes
Audio:     Card Intel Atom/Celeron/Pentium Processor x5-E8000/J3xxx/N3xxx Series High Definition Audio Controller
           driver: snd_hda_intel bus-ID: 00:1b.0
           Sound: Advanced Linux Sound Architecture v: k4.15.0-36-generic
Network:   Card: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
           driver: r8169 v: 2.3LK-NAPI port: 1000 bus-ID: 02:00.0
           IF: enp2s0 state: up speed: 100 Mbps duplex: full mac: <filter>
Drives:    HDD Total Size: NA (-)
           ID-1: /dev/mmcblk0 model: N/A size: 31.3GB
Partition: ID-1: / size: 29G used: 13G (49%) fs: ext4 dev: /dev/mmcblk0p2
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 53.0C mobo: 53.0C
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 192 Uptime: 0 min Memory: 476.1/3852.9MB Init: systemd runlevel: 5 Gcc sys: 7.3.0
           Client: Shell (bash 4.4.191) inxi: 2.3.56 

KiCAD

Getting Started in KiCad
SparkFun Beginner’s Guide to KiCad

KiCAD v5

KiCad FOSDEM 2018: Status & New Features in KiCad 5

CERN

  • Open Hardware Initiative (OHI)
  • CERN Beams department
  • BE-CO-HT section
  • Tomasz Wlostowski
  • Javier Serrano
  • Antonella Del Rosso
  • differential pair routing: support fast signals over a long distance and with less noise
  • length matching: two signals take exactly the same time to cross the PCB
  • Push and Shove router

Open Hardware Repository | Wiki | WorkPackages
KiCad software gets the CERN treatment

Eeschema

Eeschema – Reference manual


[w]   = Change to wire mode


Pcbnew

Pcbnew – Reference manual
Drawing Traces
Can I make KiCAD pcbnew NOT place all components at (0,0), Auto-Place


[ESC]         = Cursor
[X]           = Track
[S]           = Set Origin
[SPACE]       = Set Relative Origin
[S]           = Set Grid Origin (manually set in menu "Dimensions" -> "Grid")

[PG UP]       = Switch to Front-Layer
[PG DOWN]     = Switch to Back-Layer
[V]           = Switch between Front and Back
[N]           = Switch Grid to Next
[SHIFT] + [N] = Switch Grid to Previous


Add tracks and vias (wiring):
[Backspace]   = Delete node

Interactive Router (OpenGL):
============================
in normal cursor mode
[X]           = Change to wiring mode
[Left Click]  = Select segment
[U]           = Select trivial connection
[I]           = copper connection

in wiring mode
[D]           = Drag node / track
[E]           = Interactive Router Settings

Solder Mask / Paste Setup

Wörterbuch

NPTH = Non Plated Through Hole = nicht durchkontaktiertes Loch
PTH  = Plated Through Hole     = durchkontaktiertes Loch

3D

3D Model

C:\Program Files\KiCad\share\kicad\modules\packages3d

Move exactly

Only available in OpenGL canvas!

“Move exactly” for block selection in pcbnew?

Panelize / Append

Start Pcbnew (stand-alone), not via KiCad!

The “File -> Append Board” menu item is disabled

github.com/madworm/Panelization.pretty, LAYOUT FILES: KiCad footprints useful for PCB panelization (mouse-bites…)
github.com/ThisIsNotRocketScience/GerberTools, Tools to load/edit/create/panelizer sets of gerber files

pointer tool
fiducial tool
enable high contrast
(like hiding all other layers!)

This is not rocket science: PCB Panelizer & Gerber Tool Suite
Panelization – using GerberPanelizer on Windows (Linux possible)
Panelizing Boards The Easy Way
Panelizing a PCB in KiCad
PCB Design Perfection Starts in the CAD Library – Part 19: PCB Breakaway Panels
PCB Designers Need to Know These Panelization Guidelines
Multiple board outlines don’t render nicely in 3D

Old stuff?
Automated PCB panelization
Panelize Kicad PCB
kicad panelize

Export to STEP

How to share step 3D model with all the components on the PCB too?
KiCad Script Hack for Better Mechanical CAD Export
kicad StepUp script hacks MCAD world!
In Development: 3D Plugins

github.com/easyw/kicad-3d-models-in-freecad
kicad3dmodels
github.com/cbernardo/kicad3Dmodels
Manufacturer: Sullins Connector Solutions

Pad


Eeschema

Multiple Sheet Schematics

Multiple Sheet Schematics in KiCAD
Kicad/eeschema/Hierarchical Sheets
KiCad Hierarchy Tutorial x01 (PDF)

Libraries

KiCad/kicad-library
Kicad Electronic CAD libraries
Quick KICAD Library Component Builder : Component Setup
Wemos KiCad Libraries and Footprints, Lolin32
Arduino Nano library files for kicad
Kicad: librairie Arduino.pretty (for all Arduino types)

github

github.com/niko20010/kicad_libraries, CNY65, etc.
github.com/kiwichrish/kicad_ArduinoNano, Arduino Nano libraries for Arduino Nano
SH_Capacitors.pretty, JST, Molex, USB
ESP32-kiCAD-Footprints, Footprints for the Espressif ESP32 WiFi/BLE Chip and ESP3212 module
github.com/Tinkerforge/kicad-libraries, Verschiedene Footprints, ex. USB Mini mit 3D Modell


FAQ

Question

Electrical Rules Checker

Pin connected to some other pins but no pin to drive it
@(...): Pin 1 (Power input) of component #PWR001 is not driven (Net 24)

Answer

Power pins and Power flags
KiCad: Pin connected to some others pins but no pin to drive it

Windows 10 and HiDPI

General

Force DPI Scaling on Windows
High DPI (4K) And EAGLE CAD

Java

DPI Scaling in Windows GUIs
JavaFX DPI Scaling: Fixed!

Resource Hacker

How do I run Java apps upscaled on a high-DPI display?
How to get older programs to scale on HiDPI displays in Windows 10
HiDPI with Eclipse and NetBeans
How to fix apps that look small on high DPI and high resolution displays

Icons and fonts too small with HIDPI displays
Not possible to specify a Java application as per-monitor DPI aware in Windows 8