PWM frequency library

Very nice library indeed!

Regarding the frequency sweep, hugoabreu mentioned... I'm actually doing that for a project, using the Arduino Pro Mini (sweeping from 1 Hz to 500 Hz, with a 1 Hz step size, transitioning steps every 1000 - 2000 msec). Simply set the frequency and duty cycle for each frequency step:

if (SetPinFrequencySafe(led, frequency)) 
{
       pwmWrite(led, brightness);
}

Only one problem... The frequency steps sometimes do not transition smoothly. Meaning, the output will glitch and stick in the high or low state, for up to a second, before stabilizing at the new frequency/duty cycle. In my use case, the duty cycle remains constant throughout the sweep.

Unfortunately, for me, this is not good. Sweeping with these glitches is causing problems with connected device(s). Has anyone else encountered this problem? Is there a fix for it? Any assistance is appreciated.