Mega 2560 Compatibility with 64 Button Shield from Spikenzielabs

My project uses the Spikenzielabs 64 button shield and a 16 channel PWM shield to control an array of LEDs. All development work was done on the Uno R3. However, due to the memory limitation on the Uno, I am trying to port the project to the Mega 2560.

The 64 button shield allows you to choose between serial and SPI for communications with Arduino. I am using SPI mode (note: not a true SPI) which communicates on digital pins 2, 3, and 4. This approach uses an interrupt handler in software to process button push and release events. Everything works perfectly on the Uno R3.

When I try to use the Mega 2560, it appears that the interrupts do not occur and therefore are not processed. I even removed all hardware except the Mega and 64 button shield and tried to run the SPI example that came with the 64 button shield. No luck here either.

Does anyone have a work around or is there a known incompatibility between these two boards?

It turns out that pins 3 and 4, which are used by the 64 button shield for DataIn and Clock, are interfering with some other interrupt mechanism on the Mega - possibly timers associated with PWM pins. Anyway, I changed these two pins to 22 and 24 on the Mega, and it works fine. Note that this implies that you cannot plug the 64 Button Shield directly into the Mega, but must wire it as follows using jumpers.

SPI64B Mega
Pin 2 Pin 2
Pin 3 Pin 22
Pin 4 Pin 24
5v 5v
Gnd Gnd

You also have to change the pin numbers in the example ISR code provided by Spikebzielabs to use 22 and 24 for DataIn and Clock. Note also that there is nothing magic about 22 & 24. I think you could use any of the digital pins from 22 to 53.