Can you change the PWM frequency on Arduino 101?

I am working on a motor control project, and would like to change the PWM frequency - is that possible on Arduino 101? Looking at the current PWM output, it appears that it is set to ~500Hz (2mS).

I have used the timer one support to change it for one pin, but I have more than one motor to control, so I am wondering if there is anyway to change the PWM frequency for the 4 pins with native PWM support (pins 3, 5, 6 and 9)?

Yes, it is possible to generate four PWM signals using Timer1 and the attached sketch shows one way of doing this. In this example the four signals have different duty cycles, but operate at the same 500 Hz frequency and are synchronous. You can modify the code to generate different frequencies. The example isn't optimized and doesn't account for time spent in the ISR. There may even be corner cases. But, this example does work and verified with an oscilloscope for correct frequency and duty cycle.

MultiChPWM.ino (2.51 KB)

Thanks for the pointer! I was able to get a prototype working with custom PWM freq on multiple pins, but beware of asking for a delay of less then ~200us from timer1, at min or max PWM values, as unexpected things happen. This also includes the spacing of falling edge PWM pulses between different pins.

Hello
I would like to generate 4MHz 50% duty cycle PWM, can you please help me with it.

Many Thanks,

Hi, thank you for the MultiChPWM.ino source.
I'm newbie and I have a question.
Following your sketch to pilot 4 ESC to 500hz: How can I execute the analog write operation?
In loop code I think that i cannot use the command (I try it and it failed):
analogWrite(5, 138);
...
What I do to execute a command like this?