How can I generate a 20MHz clock wave (50% duty cycle) with PWM using Teensy 4.1. I don't understand at all the Pulse Width Modulation page.
Thank you.
Normally you can't get exactly 20 MHz because the timers run at 150 MHz and they can only create waveforms that are an integer division of 150 MHz. And to get exactly 50% duty cycle, that integer must be an even number, because you need the same number of clock cycles high and low. The closest you could get is 150 ÷ 8 = 18.75 MHz.
But if you're willing to stray from the well-worn "normally" path, there is a way to configure clock speed different than 150 MHz. It was discussed recently on this other thread: