Is there a way to avoid glitches caused by changing the output frequency with analogWriteFrequency()? It appears to force a reset of the counter when it is called, which causes a transition earlier than it should. In this example the same frequency value is written (when trace 2 goes high), so the square wave should be constant, but instead it has a truncated pulse on the PWM output.
Code:
void setup()
{
pinMode(10, OUTPUT);
pinMode(13, OUTPUT);
}
void loop()
{
analogWriteFrequency(10, 666);
analogWrite(10, 128);
digitalWrite(13, 1);
delay(90);
digitalWrite(13, 0);
delay(10);
}