Skip to content

Commit

Permalink
SAMD51
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Jul 24, 2020
1 parent 81eea8c commit a32c0ad
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
17 changes: 9 additions & 8 deletions MCU.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@ The Unique Identifier is located in the first 128 bits of the Flash memory mappi

# Atmel SAMD ARM Microcontroller

Atmel SAMD21 is used in Arduino Zero / Arduino M0.

Each device has a unique 128-bit serial number which is a concatenation of four 32-bit words contained at the following addresses:

* Word 0: 0x0080A00C
* Word 1: 0x0080A040
* Word 2: 0x0080A044
* Word 3: 0x0080A048
| - | SAMD21 | SAMD51 |
| :-------: | :------: | :------:|
| Word 0| 0x0080A00C | 0x008061FC |
| Word 1| 0x0080A040 | 0x00806010 |
| Word 2| 0x0080A044 | 0x00806014 |
| Word 3| 0x0080A048 | 0x00806018 |

The uniqueness of the serial number is guaranteed only when using all 128 bits. [Datasheet Section 9.3.3](https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Atmel-42181-SAM-D21_Datasheet.pdf)
The uniqueness of the serial number is guaranteed only when using all 128 bits.

## Tested Microcontroller

* Atmel SAMD21 ARM Cortex-M0 - 16 bytes
* Atmel SAMD21 ARM Cortex-M0 (Arduino Zero / Arduino M0) - 16 bytes - [Datasheet Section 9.3.3](https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/Atmel-42181-SAM-D21_Datasheet.pdf)
* Atmel SAMD51 ARM Cortex-M4 (Adafruit Metro M4)- 16 bytes - [Datasheet Section 9.6](http://ww1.microchip.com/downloads/en/DeviceDoc/60001507E.pdf)

# STM32 Microcontroller

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ArduinoUniqueID
version=1.0.9
version=1.1.0
author=Luiz Henrique Cassettari
maintainer=Luiz Henrique Cassettari <ricaun@gmail.com>
sentence=Arduino Library to gets the Manufacture Serial Number from the Atmel AVR, SAM, SAMD, STM32, and ESP Microcontroller.
Expand Down
11 changes: 10 additions & 1 deletion src/ArduinoUniqueID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,20 @@ ArduinoUniqueID::ArduinoUniqueID()

#elif defined(ARDUINO_ARCH_SAMD)

// from section 9.3.3 of the datasheet
#if defined (__SAMD51__)
// SAMD51 from section 9.6 of the datasheet
#define SERIAL_NUMBER_WORD_0 *(volatile uint32_t*)(0x008061FC)
#define SERIAL_NUMBER_WORD_1 *(volatile uint32_t*)(0x00806010)
#define SERIAL_NUMBER_WORD_2 *(volatile uint32_t*)(0x00806014)
#define SERIAL_NUMBER_WORD_3 *(volatile uint32_t*)(0x00806018)
#else
//#elif defined (__SAMD21E17A__) || defined(__SAMD21G18A__) || defined(__SAMD21E18A__) || defined(__SAMD21J18A__)
// SAMD21 from section 9.3.3 of the datasheet
#define SERIAL_NUMBER_WORD_0 *(volatile uint32_t*)(0x0080A00C)
#define SERIAL_NUMBER_WORD_1 *(volatile uint32_t*)(0x0080A040)
#define SERIAL_NUMBER_WORD_2 *(volatile uint32_t*)(0x0080A044)
#define SERIAL_NUMBER_WORD_3 *(volatile uint32_t*)(0x0080A048)
#endif

uint32_t pdwUniqueID[4];
pdwUniqueID[0] = SERIAL_NUMBER_WORD_0;
Expand Down

0 comments on commit a32c0ad

Please sign in to comment.