From my tests right before the crash I found the following, that might be interesting:
With all the unmodified set-ups of your sketch, on this version of Arduino M0 & 1.7.8 IDE, yesterday evening I got 17.5 KHz.
When I started moving constants, nothing happened, save for Prescaler = 64, that brought me down to 1.25 KHz.
I use Picotech PC scope 2000 series, with Picoscope software which reads frequency, Duty Cycle, and many other parameters, so I am pretty sure of freq. readings, apart from seeing the waveform on the display.
Also I noticed that reading on pin 2 kept at 175.4 Khz, while the 17.5 Khz came on pin 4, thus these pins are used differently on the two IDES & Boards.
Same applies to the controls:
Timer TCC must be another one here.
The PER register command does not operate, so another must be used.
The only one that works here is PRESCALER, where DIV8 and DIV64 make the difference.
I am reading Section 6 of the SAMD21 to get a better ida of the works.
Today I have ordered an original Genuino Zero, coming from UK, then it will be possible to tabulate the differences between Boards, IDEs. etc. It will be an interesting exercise.
Unfortunately the "double click" reset trick does not work in my board, which stays recognized no longer by the USB.