There is a lot of pins linked to a Timer.
The analogWrite well use the timer if available on the requested pins.
One other solution is to use directly the HardwareTimer api:
https://github.com/stm32duino/wiki/wiki ... er-library
This is what is called by the analogWrite when Timer is available.
To simulate a pwm on a pin without timer, this is the same, use the HardwareTimer librarly. This is done for the servo.
For analogWrite it is also possible to change frequency and resolution:
Code: Select all
/*
* \brief Set the resolution of analogWrite parameters. Default is 8 bits (range from 0 to 255).
*
* \param res
*/
extern void analogWriteResolution(int res);
/*
* \brief Set the frequency of analogWrite. Default is PWM_FREQUENCY (1000) in Hertz.
*
* \param freq
*/
extern void analogWriteFrequency(uint32_t freq);