Since this topic comes up a lot on this forum, I've added an example project which provides a simple-ish C API for configuring clocks on SAM D5x/E5x.
Use at your own risk/no warranty/no guarantee/yada yada.
Maverick Embedded Technologies Ltd. Home of wAVR and Maven.
wAVR: WiFi AVR ISP/PDI/uPDI Programmer.
Maven: WiFi ARM Cortex-M Debugger/Programmer
© 2020 Microchip Technology Inc.