I'm trying to generate servo pulses using the TCD peripheral on the Attiny3217.
As far as I can tell, this should work.
The timer has two outputs (WOA and WOB) which can be independently set up with comparators to turn on the pulse, then it turns off again the next cycle.
This is "upside down" from what I want, so I just invert the bit on output - I can use the invert flag for this, but in this particular case, I'm using the CCL to duplicate those outputs, inverted, on different pins - this is mostly because these are more convenient pins for my application. (NB: In my project, I'm doing a lot of other things, generating other PWMs using TCA etc, which is all working well)
I've written a test program, here:
What this does is:
* Initialise the TCD to output the waveforms. (That works as expected)
* Set up CCL to invert those outputs and output on its own pins (that works as expected)
* Loop around, changing the pulse lengths
What I expect to happen is, approxiamtely every 10ms it should reset the TCD and generate a new pair of pulses (on different pins), with one of them changing length gradually between 1-2ms.
What actually happens, is it starts off ok, but then it doesn't change length smoothly, and the pulses don't happen very often - it seems semi-random, the pulses often only appear about once every 100ms, which is far less often than I'd expect.
If I change mainloop() into a NOP, then it generates static width pulses exactly as I'd expect (1ms and 2ms width , period about 12ms)
What I think's happening, is that I'm somehow not letting the TCD get started, and it's going wonky. I see the example on this forum, here: https://www.avrfreaks.net/forum/... which sends the command flag SYNCEOC in CTRLE with the comment "Sync the registers", I'm not sure whether that's a good idea.
Anyone have any ideas what's happening?