[Runtimemicro] has the answer, at least if you are writing PWM code for the Arduino. Their free application lets you set a few parameters, visually see the results, and then generates code for you.
Results that may be inaccessible to you are currently showing.