Blinky SAMD21G micro-controller

samd21g arduino blinky

Pre-requisites

Crystalless option

Create a blinky LED firmware with SAMD21G micro-controller on a custom PCB without crystal.

To ensure the blinky works with the crytalless option, you have to:

  1. Ensure the bootloader code has the crystalless option
  2. Ensure compiled code has the cyrstalless option in build.extra_flags in ~/Library/Arduino15/packages/arduino/hardware/samd/1.8.6/boards.txt on macOS or as part of options in the arduino-cli command
arduino-cli compile --fqbn arduino:samd:arduino_zero_native --build-properties build.extra_flags="-DCRYSTALLESS -D__SAMD21G18A__ {build.usb_flags}" ./

Serial

For serial printing, SerialUSB.println() should be used instead of Serial.println() because SerialUSB uses the Native Port, which is an emulated serial port (USB-CDC).

Upload firmware

  Steps to upload the blinky firmware:

  1. Press the reset button twice to go into the bootloader mode
  2. Run make to upload the blinky firmware with crystalless option

Code

Download code
#define LED 13

void setup() {
  pinMode(LED, OUTPUT);

  // SerialUSB.begin(9600);
  // while (!SerialUSB) {}
  // delay(1000);

  // SerialUSB.println("Start!");
}

void loop() {
  // SerialUSB.println("HIGH");
  digitalWrite(LED, HIGH);
  delay(200);

  // SerialUSB.println("LOW");
  digitalWrite(LED, LOW);
  delay(200);
}

Prototype

A photo of the actual setup.

Blinky SAMD21G micro-controller prototype

Schematic

Wire up the hardware accordingly

Blinky SAMD21G micro-controller schematic

References