Hi, On the Teensy 3.2, I have been use the following "trick" to synchronize to a square wave that I generate with the PWM. It seems to not work on the Teensy 4.0
First to setup the square wave
Code:
analogWriteResolution(4);
analogWriteFrequency(fMPin, 1000000);
analogWrite(fMPin,8);
Then, at some later point in the code I do this to synchronize to the clock
Code:
while (!digitalReadFast(fMPin)){}
Now the mystery. When I do this on the Teensy 4.0, it hangs at the loop. I checked with the oscilloscope, it generates a beautiful 1MHz square wave.
What is wrong? And what is the right way to do it?
Thank you