thanks all for the responses, they are really helpful.
These clock sources are selected and routed to the various peripherals, such as the ADC, AC, DAC, TCC/TC timers, SERCOM modules, RTC, WTC, etc.. via generic its generic clock system.
The Arduino core code file "startup.c" already assigns the clock sources to certain generic clocks:
GCLK0 - DFLL48M (also acts as the main processor clock)
GCLK1 - XOSC32K if using external crystal, or OSC32K for crystalless operation
GCLK2 - OSCULP32K used by the Watchdog Timer Counter (WTC)
GCLK3 - OSC8M
However, neither the clock sources or the generic clocks are set to run on standby (RUNSTDBY) by default. To do this, it's necessary to set the RUNSTDBY bit for the clock source, possibly the generic clock and the peripheral itself.
Thanks for this, it is starting to make some sense.
Finally, if you intend to run a number of peripherals during sleep mode then it's necessary to keep the SAMD21's internal voltage regulator in normal mode. By default it will enter low power mode, but this means it won't be able to power all the peripherals. This is detailed here: https://forum.arduino.cc/index.php?topic=691880.0.
Maybe this is why it isn’t working, I will give that a go.
I don't know if you can actually save much power by configuring fewer clocks. The usual power-saving technique is to avoid routing clocks to the peripherals, rather than actually disabling the clocks.
You CAN look at that, you know. It even has unusually good comments!
ArduinoCore-samd/startup.c at master · arduino/ArduinoCore-samd · GitHub
Thanks for the pointer to the source code that controls the clocks, that is at least giving me a clue as to the default configuration.
I totally agree, the tool provided by Atmel is awful. the output is completely different from anything else I have seen, so other than using it as a nice visual tool to understand some of the language, it’s output is pointless.
At a minimum, you'll need an external 32K crystal to generate the 48MHz CPU clock, and the RTC. This means at least two clock generators, one for the main clock, and one for the RTC. Now if you need some of the other peripherals (USART/SPI/etc), you'll need another clock generator, so that makes it three.
You can't use the RTC clock generator since it has to be at 1 Hz (in Calendar mode at least)
This explains why when I first implemented the RTC and then added WDT, it just appeared to fail completely, although it did send data very infrequently!
Looks like I need to build my knowledge to understand the configuration of the chip and how best to do it. Datasheets are difficult documents to read, does anyone any easier way of getting to grips with it?
I had understood that I can turn off clocks etc to lower power consumption, one of the threads I read talked about swapping clocks for the RTC to the ultra lower power one, but maybe I have got all that wrong too.
All of this simply because I wanted to have Lora, RTC and WDT running at the same time and still keep power to the lowest possible.