Is there a way to set the PWM frequency on Pins 5 and 6 to a value anywhere in the range of 10kHz to 50kHz for an Arduino Uno
Thanks
Is there a way to set the PWM frequency on Pins 5 and 6 to a value anywhere in the range of 10kHz to 50kHz for an Arduino Uno
Thanks
Unfortunately pins 5 and 6 are 62500 hz. The largest divisor is 1024. That gives 61
That library only changes the prescaler.
To get the full flexibility from the timers, I would consult the datasheet and configure the timer based on that. You'd be setting the CS bits as they do in that example to set the prescaler, but then you can also put timer 1 into a WGM where it counts to the value in ICR1 - and with ICR1 and the prescaler, you can generate a huge range of frequencies. Once you start doing this, of course, analogWrite() won't do what you expect - you'll have to handle setting the duty cycle manually.
sorry for the math error. Can't divide 62,500 hz or 62.5 khz by 1, 8, 64, etc to get in the needed range