Thanks to help from MartinL in (upload://znp3jHgReu79IVfTgBKx145uEsP.jpeg) this thread https://forum.arduino.cc/t/ideas-for-pwm-with-repeating-pattern/847923/2 , I've been able to generate PWM sine waveforms on two pins using two DMA channels and timer/counters TCC0 on one pin and TCC1 on the other.
Each channel reads the same sine lookup table. Since I want 1/2 cycle on each channel, the second half of the lookup table is all zeros, and I preset TCC1 to generate a 180 degree phase difference. The attached pic shows the result (sorry for the quality and jpg format; this scope is too old to have a USB port).
Now that the hard part is done, I'm looking for ideas to implement the last couple of issues. Specifically, I have two questions:
-
Is there a way to ensure that the two channels are exactly 180 degrees out of phase (ie, no overlap in their waveforms)?
-
What is the best way to stop and start both channels simultaneously -- I need to trigger the pair on and off via an external signal (a digital input on another GPIO pin)?
Thanks!