SPI direct port settings help.

I'm trying to figure out the direct port settings for the following:

pinMode(SCK, OUTPUT); pinMode(MOSI, OUTPUT); pinMode(SS, OUTPUT);

This is for the Arduino Mega 1280 -- I'd like to manipulate the port directly. The digital write I have setup and working but how do I set the SS as output directly for the Mega 1280?

You don't need pinMode for any but the SS Pin. SPI.begin(); // takes cares of SCK, MOSI, MISO pins you only need pinMode(SS, OUTPUT); and byte SS = 50-51-52-53; // whatever the pin is for a 1280 - should be the same as a Mega 2560?

What do you mean "manipulate the port directly"? Are you asking what is the port number for pin 53?

I should have been more clear. I wanted to know how to turn pins into input/outputs.

I figured it out – I was looking for the following:

DDRB &= ~(1<<PB2); //Configure PORTB Pin 2 as an input
DDRB |= (1<<PB2); //Configure PORTB Pin 2 an output

PORTB |= (1<<PB2); //Activate pull-ups in PORTB Pin 2

The sbi and cbi (set bit and clear bit macros) can be handy for this sort of coding:

  cbi (DDRB, PB2) ;    //Configure PORTB Pin 2 as an input
  sbi (DDRB, PB2) ;    //Configure PORTB Pin 2 an output
  sbi (PORTB, PB2) ;    //Activate pull-ups in PORTB Pin 2
byte SS = 50-51-52-53;

You can't assign a negative number to a byte.

Glad to see you were able to understand this in context PaulS: byte SS = 50-51-52-53;

@Mavromatis, Are you using SPI.transfer( ); for this application, or not? If you are, the SPI library takes care of setting the hardware for the SCK/MISO/MOSI pins, you do not need to declare them or set them as input/output. And if not, why are you not taking advantage of the up to 8 MHz transfer speed that SPI provides?