README.md 2.9 KB
Newer Older
Jake Read's avatar
Jake Read committed
1
# Yonder D51
Jake Read's avatar
scratch  
Jake Read committed
2

Jake Read's avatar
Jake Read committed
3
The ATSAMD51 is an ARM Cortex-M4F microcontroller manufactured by Microchip (Atmel).  
Jake Read's avatar
scratch  
Jake Read committed
4

Jake Read's avatar
Jake Read committed
5
As of Oct 13 2019, -> CBA :heart: D51 <-
Jake Read's avatar
Jake Read committed
6

Jake Read's avatar
Jake Read committed
7
## Circuits using the D51
Jake Read's avatar
Jake Read committed
8

Jake Read's avatar
Jake Read committed
9 10
![feather m4 pic](https://cdn-shop.adafruit.com/970x728/3857-00.jpg)
[Adafruit Feather M4](https://www.adafruit.com/product/3857)
Jake Read's avatar
Jake Read committed
11

Jake Read's avatar
Jake Read committed
12 13
![module pic](https://gitlab.cba.mit.edu/squidworks/moduleboard-atsamd51/raw/master/moduleboard-atsamd51/2019-10-13_module-fab.jpg)
[squidworks module](https://gitlab.cba.mit.edu/squidworks/moduleboard-atsamd51/)
Jake Read's avatar
Jake Read committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

## Toolchains

### Adafruit Bootloader / Platformio (or Arduino Compatible)

Since [Adafruit](ada-feather-m4doc) has adopted the SAMD51, it is well supported by the open source community, and we can borrow their development tools.

**fair warning**
>Use of the arduino bootloader *does* assume that your circuit has a USB port available, as well as a 32.678kHz clock on the RTC Xout / Xin pins. During cycles, the bootloader (assuming it is on a Feather M4) will toggle 'D13' (PA23) as well as send Neopixel Data to (?).

To get started, find the latest build of the [adafruit bootloader] and download that (probably a `.bin` or `.elf` or `.hex` file).

We need to write this file into the micro's memory. I have been using the `Serial Wire Debug` interface, which is enabled by default on the D51 hardware (but JTAG is also available, but requires an enable pin pulled low somewhere *I think*). `SWCLK is on PA30` and `SWDIO is on PA31`.

To speak SWD, I just use the Atmel-Ice programmer, and Atmel Studio 7 (a windows application, sorry). Any programmer that speaks SWD should be capable of doing this. In Atmel Studio, go to `Tools -> Device Programming`, and select the Atmel-Ice Tool, the ATSAMD51xxxx device you'd like to program (the bootloader is written for the ATSAMD51J19A), and the SWD interface. You should be able to read the device signature. If this works, your SWD connection is all super-gucci (as they say). You can navigate to `Memories` - and write that bootloader in. OK. The device should now enumerate over USB as an Adafruit Feather M4 / FeatherBoot (or something similar).

### Platformio

To write code and load it, I use PlatformIO, which is an open source 'IOT' (embedded) programming tool written as a package for either `atom` code-editor, or [something else](link both). See their doc for setting up a new project for the D51 / Feather M4.

### Real Registers in an Arduino World

One of the troubles with Arduino is that people forget that it is just a big C++ library. This means that everything under the sun (that compiles) is legal here. *That* means that we can use Arduino as a crutch, but write really nice Special Function Register code inside of the same executable. Great!

Indeed, in the PlatformIO environment, we even have wonderful autocomplete handles on the D51's core register map. For some examples of this kind of manipulation, check out the [hunks](gitlab ponyo) in the [ponyo](gitlab ponyo) project.