Help with Digital Pot w/ Arduino Mega

Greetings!
I am new to programming the arduino (mega) board, and I have stumbled onto a problem.

I am trying to program a digital potentiometer (AD8400) with the arduino mega board. The problem is that I cannot get the right resistance value. I know that the potentiometer works with the normal arduino diecimilia board, however it does not work with the arduino mega. I am using the code on the arduino website called SPIDigitalPot with a few changes like MISO, MOSI, CLK, etc… for the arduino mega board.

#define DATAOUT 51
#define DATAIN 50
#define SPICLOCK 52
#define SLAVESELECT 53
#define ss 49

byte pot=0;
byte resistance=0;
int j = 0;

char spi_transfer(volatile char data)
{
SPDR = data;
while (!(SPSR & (1<<SPIF)))
{

};
return SPDR;
}

void setup()
{
Serial.begin(9600);
byte i;
byte clr;
pinMode(DATAOUT, OUTPUT);
pinMode(DATAIN, INPUT);
pinMode(SPICLOCK,OUTPUT);
pinMode(SLAVESELECT,OUTPUT);
pinMode(ss,OUTPUT);
digitalWrite(SLAVESELECT,HIGH); //disable device
digitalWrite(ss,HIGH);
// SPCR = 01010000
//interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
//sample on leading edge of clk,system clock/4 (fastest)
SPCR = (1<<SPE)|(1<<MSTR);
clr=SPSR;
clr=SPDR;
delay(10);

write_pot(0,255);
}

byte write_pot(int address, int value)
{
digitalWrite(ss,LOW);
//2 byte opcode
spi_transfer(address);
spi_transfer(value);
digitalWrite(ss,HIGH); //release chip, signal end transfer
}

void loop()
{
//write_pot(0,10);
}

Any help would be appreciated. :-?

BUMP I know that the spi_transfer is where the program stops working =/