MEGA2560 servo/input-capture problem

Hi,
I'm working with a MEGA2560 board.
I have some code that controls a few servos using
servo.attach(5) & servo.attach(6).
I'm also using XIOL48 and XIOL49 with the pins configured for input-capture.

I can work with the servos successfully.
I can work with the input-capture successfully.
But when I put them together in the same sketch things don't work.
My hunch is that the servo control (5 & 6) is using the timers (4 & 5).
Is this true?
How can I look at the underlying code used by the servo library?
Thanks in advance,
Ed

How can I look at the underlying code used by the servo library?

/libraries/Servo/Servo.cpp and Servo.h

Thanks, I had just found that...
I see that the servo class uses timers 1,3,4 & 5 for MEGA2560!!!
Yuk!
I'm gonna start looking at how difficult it would be to free-up timers 4&5
for other things. So if anyone has any experience with this already, please
let me know...

I see that the servo class uses timers 1,3,4 & 5 for MEGA2560!!!

But not all at once, unless you have a lot of servos connected. There are specific timers for specific pins. Don't use the pins associated with timer N, for servo control, and timer N won't be used/will still be available.

Which pins go with which timer? I don't know.

Ok, it appears a timer is allocated for groups of 12 active servos, so the first 12 servos
would use one timer, second 12 would use a second timer etc...
The number of available servos depends on the board/cpu, but in the case of the MEGA2560
it looks like the first 12 servos use timer5, next 12 use timer1, then timer3, then timer4...

typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;

Since my configuration is 'hard' (custom board); I can't just change pins. I need to change the library.
Are there any gotchas (other than being non-standard) to be aware of in doing this kinda thing?

Thanks,
Ed

Since my configuration is 'hard' (custom board); I can't just change pins.

You didn't mock this up before hand?

I need to change the library.
Are there any gotchas (other than being non-standard) to be aware of in doing this kinda thing?

I don't see any major problems with changing which timer gets used for what set of pins, as long as you don't break something else. You'll need to test extensively, but, I think you know that.

You didn't mock this up before hand?

Nope, my fubar.

Anyway, this was an easy mod to make to servo.h. For anyone that may
be interested, here's the change in servo.h...
Original:

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define _useTimer5
#define _useTimer1
#define _useTimer3
#define _useTimer4
typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;

Modified (assumes you won't need more than 24 servos):

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#define _useTimer1
#define _useTimer3
typedef enum { _timer1, _timer3, _Nbr_16timers } timer16_Sequence_t ;

Check in my sketch:

...
#include <Servo.h>
...
#if defined(_useTimer5)
#error "This application uses timer5 for input-capture, modify servo.h"
#endif
#if defined(_useTimer4)
#error "This application uses timer4 for input-capture, modify servo.h"
#endif
...