I just power read the 30 or so pages associated with the clock system and now have an inkling of what’s going on
I read the pages normally 30 times, and I would say another 30 times is required for me.
Just playing around, I can get my code to toggle using a template to get N cycles (duplicated str instructions inline)-
//pinN, N cycles (=N*2 toggles)
Toggle< 25,8 >(); //30 tc1 counts (includes tc1 return from start and get count) = 8Mhz/30*8 = 2.133333Mhz
Toggle< 25,512 >(); //1070 tc1 counts = 8Mhz/1070*512 = 3.828037Mhz
(I'm not sure if these numbers square away correctly, but seem reasonable)
with templates, you can get up to 900 recursions (in gcc anyway), so 900 cycles is the limit with one 'call'
Maybe it would make sense to tell everyone what is the purpose of the bit-banging, maybe there is an easy alternative waiting for you if the purpose was known. Maybe not, but who knows.
I wish the PTC peripheral was not hidden. I know there is a dragon inside, but I would like to see the dragon.