Using the SAMD51 True Random Number Generator @weasdown @MicrochipMakes

William Easdown investigates using the True Random Number Generator (TRNG) in the Microchip SAMD51 microcontroller:

Lately, I’ve been wanting to learn how to do direct register access on the SAM family of microcontrollers. I have a SAMD51-based Adafruit Feather M4 Express board, so was looking through the SAMD51’s datasheet to work out which registers I could do something useful with while not having to dive too deep into the microcontroller.

Looking down the extensive list of peripherals, I came across the True Random Number Generator (TRNG). This seems to be a relatively rare feature for a microcontroller – I haven’t seen any others with one – and it struck me that it should be fairly simple to get going because it shouldn’t need to interface with too many other peripherals or central parts of the chip.

Indeed, reading its description revealed it just need a clock source from the Main Clock (MCLK) and an interrupt setting up and I’d be ready to go. This involved setting three registers in total: the first to send the MCLK to the TRNG, the second to enable the TRNG and the third to enable interrupts from the TRNG when a new random number is available.

The SAMD51 datasheet states that the TRNG “passes the American NIST Special Publication 800-22 and Diehard Random Tests Suites”. William uses Arduino code to test the TRNG and a Python program to generate the results in the plot below.

You can read the details in the blog post here.


Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat and our Discord!

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Join over 38,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython – The easiest way to program microcontrollers – CircuitPython.org


New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — New Products 11/15/2024 Featuring Adafruit bq25185 USB / DC / Solar Charger with 3.3V Buck Board! (Video)

Python for Microcontrollers – Adafruit Daily — Python on Microcontrollers Newsletter: A New Arduino MicroPython Package Manager, How-Tos and Much More! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

EYE on NPI – Adafruit Daily — EYE on NPI Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

Adafruit IoT Monthly — The 2024 Recap Issue!

Maker Business – Adafruit Daily — Apple to build another chip at TSMC Arizona

Electronics – Adafruit Daily — SMT Tip – Stop moving around!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !


No Comments

No comments yet.

Sorry, the comment form is closed at this time.