My first post!
With my new 2560 I found it had many supported PWM timers.
I wanted to use these PWM timers to drive servos directly. This will give the project less interupt overhead than the Servo library.
So I followed the API model (and code) for analogWrite() and came up my own library. The library files and a simple test project are attached for others to enjoy.
The exposed Api is...
void pwmServoAttachPin(uint8_t pin, int pwmDutyCycle = pwmServoCenter);
void pwmServoDetachPin(uint8_t pin);
void pwmServoWrite(uint8_t pin, int pwmDutyCycle);
Note that I intentionally left out range checking for the pulses and left this to the application developer. I am using servos and motor controllers that support a wider range than normal and this would have got in the way.
Michael
p.s. I am long term hobby AVR programmer but have only owned my Arduino Mega 2560 for a few weeks.
PwmServo.h (1.17 KB)
PwmServo.cpp (8.29 KB)
keywords.txt (624 Bytes)
pwmServoTest.ino (1.07 KB)