Floating Point Unit support

Zip up Adafruit's SAMD51 code and write a JSON file, to create a new entry in the Arduino IDE boards manager, so that the new board and code could be installed.

You don't HAVE to have a JSON file. You can still copy new directories into the hardware/ tree directly. I've got a 1.8.2 IDE with espressif ESP32 and SAMD11 boards added that way...

You don't HAVE to have a JSON file. You can still copy new directories into the hardware/ tree directly. I've got a 1.8.2 IDE with espressif ESP32 and SAMD11 boards added that way...

Thanks for this information. I didn't know that simply copying the files would work.

I did try to copy the files across at the start, but I guess I must have placed them in the incorrect directory, as they weren't picked up by the IDE and I ended up going down the unnecessary harder route, (not for the first time).

This certainly simplifies this first step.

Speaking of the SAMD51, I've been putting together this spreadsheet describing the available pin functions:
Google Docs SAMD51 Pinout
I find it especially useful to be able to sort on a particular columns; otherwise it's mostly a copy of the table from section 6.1 of the manual.
(Light gray sections are incomplete, and/or copied from a similar SAMD21 spreadsheet (and thus perhaps inaccurate.)

Thank you for your spreadsheet. With the port pins in ascending order, I find it much easier to read than the datasheet table.

So far I've successfully tried out the I2C Wire library and SerialUSB with the SAMD51. I managed to get it reading back raw accelerometer/gyroscope values from a MPU-9250 sensor, using the I2C bus in fast mode (400kHz) and displaying them on the Arduino IDE console.

I also replicated the test that Limor Fried did in her Adafruit video about the SAMD51, using successive calls to the OUTTGL (output toggle) register, to bit bang the GPIO output at 30MHz!

The SAMD51 also offers more in the way of timers and channels, the SAMD51J20A has 6, 16-bit TC timers (TC0...TC5) with two channels each. In addition, it has 5 TCC timer channels for PWM (TCC0..TCC4), with 6, 4, 3, 2 and 2 channels respectively. This is in addition to the standard on-chip Systick and RTC timers.

There is one issue however and it's to do with the SERCOM Tx pin on the SAMD51. On each SERCOM there are are 4 pads (0..3) that in the case of the USART configuration can be assigned to TX, RX, CTS and RTS, and for the SPI configuration to SCLK, MISO, MOSI and SS.

The SERCOM peripherals' pads are located on the same pins on both the SAMD21 and SAMD51 devices. On the SAMD21 it's possible to mix 'n' match practically any SERCOM signal to any pad. On the SAMD51 however, while the RX/MISO signal can be assigned to any pad, the USART's TX output is limited to the pin at pad 0 and the SPI's MOSI can only output on the pin at pads 0 or 3.

The consequence is that if you're designing a custom board using SAMD51, it limits the flexibility of which pins you can use as a USART TX or SPI MOSI. It also reduces the viability of the SAMD51 as a simple plug in replacement for the SAMD21.

Overall though, I guess this slight reduction in pin flexibility is a small price to pay for the SAMD51's increase in performance.

The SERCOM peripherals' pads are located on the same pins on both the SAMD21 and SAMD51 devices. On the SAMD21 it's possible to mix 'n' match practically any SERCOM signal to any pad. On the SAMD51 however, while the RX/MISO signal can be assigned to any pad, the USART's TX output is limited to the pin at pad 0

Huh. I had noticed that UART TX was limited to Pad0, but not that this was different than the SAMD21. (come on. a Sercom should be the same on all devices! Grr...) Even on the D21, you only have a choice between Pad0 and Pad2, so it's still not great...

Looks like Adafruit are in the process of manufacturing their prototype Metro M4 boards: Adafruit Prototyping League tackles the Metro M4 #ManufacturingMonday (video) « Adafruit Industries – Makers, hackers, artists, designers and engineers!.

From their Gibhub SAMD51 repo, it also looks like they're also planning on a Feather M4. I believe that these initial boards will use the SAMD51J19A, 64-pin device with 512K flash and 192K RAM.

Adafruit's code now allows you to seamlessly upload code to the SAMD51 via the native USB port using the Arduino IDE. I've now ported the firmware from my SAMD21, Arduino Zero based flight controller over to the SAMD51 and have successfully flown the new microcontroller in a tricopter frame. I'm using the SAMD51J20A, 64-pin device with 1M flash and 256K RAM.

The SAMD51 is similar to the SAMD21 pinout in terms of power and port pins, except for a three way swap of the VDDCORE, PA27 and VSW pins, used for microcontroller's internal regulated supply. Like the SAMD21 it also uses the same 32.768kHz crystal.

Internally the SAMD51 uses a digital frequency locked loop to generate a 48MHz clock source, this is then divided down and ramped up to 100MHz and 120MHz using two fractional digital phase locked loops. All these clocks are available as sources for the microcontroller's internal peripherals. Having the 48MHz clock source is nice, as it allows peripherals to be clocked at the same rate as the SAMD21. The 100MHz clock is necessary, as this is the maximum clocking frequency of some of the internal peripherals such as the SERCOM modules. The 120MHz clock drives the processor core.

From an Arduino point of view the code runs exactly the same as the SAMD21, just around 2.5 times faster. If your sketch uses a lot of single precision floating point calculations, it'll run faster still, on account of the microcontroller's hardware FPU (Floating Point Unit).

For those using register manipulation, some of the peripherals like the SERCOM remain almost identical to the SAMD21, while others remain strangely familiar, but different. The TC timers for example are now more akin to the TCC timers in terms of operation.

The SAMD51 isn't just a turbo-charged version of the SAMD21 though. It has more memory, dual ADC and DAC, multiple interrupt handlers per peripheral, more timers and timer channels, plus a number of other specialised on-board peripherals not available on the SAMD21. The only main disadvantage that I've found with respect to the SAMD21, is the lack of flexibility with regard to multiplexing of the SERCOM's transmit pin, but this is only really a circuit board layout issue.

The other nice thing about the SAMD51 and SAME51 families is that they're available 48, 64, 100 and 128-pin packages. This makes it possible to produces various sizes of board, while leveraging a single SAMD code base. In this regard, Adafruit have also mentioned about making a Mega sized board with the SAMx51 100-pin variant.

westfw, GREAT JOB ON THE MAPPING.

Using it to review my own. i know it's a few months later but do you still use it.
maybe it's usefull to you : PA12 & PA13 alternate COM show a different PAD#
not done yet but wanted to know if you are actively using it.

I was just about to start a schematic with the SAMD21G and will most likely use the J version now.
Making sure my board would also work with the D51/E5x

E

PA12 & PA13 alternate COM show a different PAD#

Ah. Pad 1/0 instead of Pad 0/1. Thanks for the update!

wanted to know if you are actively using

No. I didn't even get very far on the "which pins would go where, best, for a due-sized board" idea that I was thinking about.
I've decided my short term interest is in some of the 5V ARM chips, like SAMC and MKE02

@westfw, nice job on the spreadsheet. It looks like you corrected PA12/13 COM (O23:24) as per the docs. N23 and N24 should be swapped as well since TX is only available on pad 0.

Has anyone verified that PA12/13 SERCOM4 pads were actually swapped or was this a documentation error? That's a pretty good OOPS if they physically swapped since you would have to make board level changes if using SERCOM4.

@westfw, did you do a similar spreadsheet for the D21? It would be nice to compare the D21 and D51 via spreadsheet.

Robin