Arduino Mega Compatibility Issues

So I've spent the past few months working on an 8x8x8 led cube, and I've been able to successfully complete it using a regular Arduino Uno. The source code I used was from the same person who created the DIY guide I used to make the cube, and he designed his source code around the Arduino Uno. When I try to upload my code to an Arduino Mega 2560 though, my cube does not work. I do not receive any error messages when I upload my code, the code purely does not work (the cube does nothing). So, what could be causing the code to not upload properly? My suspicion is that there is a command in the setup loop that is compatible with an Atmega 328 micro controller but is incompatible with the Atmega 256[tt][/tt]0. Note: when I test out my code with the Arduino Mega, I hook up all my connectors to the exact same ports that I hook it up to with my Arduino Uno.

The DIY page:

The source code directly from the DIY page:
http://www.instructables.com/files/orig/FNH/V3UU/GICYB47D/FNHV3UUGICYB47D.tmp

The void setup loop, where I suspect the issue lies:

#include <avr/interrupt.h>
#include <string.h>
#define AXIS_X 1
#define AXIS_Y 2
#define AXIS_Z 3

volatile unsigned char cube[8][8];
volatile int current_layer = 0;

void setup()
{
  int i;
  
  for(i=0; i<14; i++)
    pinMode(i, OUTPUT);
  
  // pinMode(A0, OUTPUT) as specified in the arduino reference didn't work. So I accessed the registers directly.
  DDRC = 0xff;
  PORTC = 0x00;
  
  // Reset any PWM configuration that the arduino may have set up automagically!
  TCCR2A = 0x00;
  TCCR2B = 0x00;

  TCCR2A |= (0x01 << WGM21); // CTC mode. clear counter on TCNT2 == OCR2A
  OCR2A = 10; // Interrupt every 25600th cpu cycle (256*100)
  TCNT2 = 0x00; // start counting at 0
  TCCR2B |= (0x01 << CS22) | (0x01 << CS21); // Start the clock with a 256 prescaler
  
  TIMSK2 |= (0x01 << OCIE2A);
}

ISR (TIMER2_COMPA_vect)
{
  int i;
  
  // all layer selects off
  PORTC = 0x00;
  PORTB &= 0x0f;
  
  PORTB |= 0x08; // output enable off.
  
  for (i=0; i<8; i++)
  {
    PORTD = cube[current_layer][i];
    PORTB = (PORTB & 0xF8) | (0x07 & (i+1));
  }
  
  PORTB &= 0b00110111; // Output enable on.
  
  if (current_layer < 6)
  {
    PORTC = (0x01 << current_layer);
  } else if (current_layer == 6)
  {
    digitalWrite(12, HIGH);
  } else
  {
    digitalWrite(13, HIGH);
  }
  
  current_layer++;
  
  if (current_layer == 8)
    current_layer = 0;
}

The sketch is using direct port manipulation (those statements using PORTB, PORTC, PORTD) to set the output pins, and as such is not portable across a 328 chip and a 2560 chip. You will have to modify those statements to reflect the port/pins you are going to use on the mega board. This document should help you figure out the the differences in port/pin for the different chip types:

https://spreadsheets.google.com/pub?key=rtHw_R6eVL140KS9_G8GPkA&gid=0

Lefty

mmans1626:
So I've spent the past few months working on an 8x8x8 led cube, and I've been able to successfully complete it using a regular Arduino Uno. The source code I used was from the same person who created the DIY guide I used to make the cube, and he designed his source code around the Arduino Uno. When I try to upload my code to an Arduino Mega 2560 though, my cube does not work. I do not receive any error messages when I upload my code, the code purely does not work (the cube does nothing). So, what could be causing the code to not upload properly?

The analog ports are PORTC on an UNO and PORTF on a MEGA2560.

Did anyone get the 8x8x8 led cube to work with the Mega? Mine works fine with the Uno but does not work with the Mega.