In a previous article for phase shift square waves, I wrote you had to reset a target channel wavegen port to avoid phase flips. FOC type instructions accomplished this.
But what if, we waited for the waveform to go LOW and then changed its OCR value? That should avoid the phase-flip problem and the need for FOC instructions. And it avoids Stopping and Restarting the Timer (very desirable).
Well, I have a project working using this technique. It did flip a phase now and then. But I trimmed up the Interrupt code and it seems OK now.
UPDATE: Its running as hoped up to 20 kHz. Higher frequencies allow less time for Interrupt code to execute properly. I'll be posting this project as soon as I can get it together.
Coming Soon -- another Example Project.
Lee
Created: Sep 2, 2022 Updated: Jan 11, 2024 |