SPI doesn't work

Here’s my code:

#include <SPI.h>


void setup() {
  SPI.begin;
}

void loop() {
  SPI.transfer(0b10101010);
}

Scoping pin 13 (SCK) or pin 11 (MOSI) gives a flat line at 0V. The blink example shows up on my scope so I know that there’s nothing wrong with the scope or the GPIO-pin. Perhaps the SPI interface on my atmega is broken? :\

It would be more useful if you actually called the begin() method.

I don't think that code will even compile - hint SPI.begin is a function.

Mark

holmes4:
I don’t think that code will even compile - hint SPI.begin is a function.

Mark

Yes, it is. And, it has an address. And, that address is a numeric value. The code posted is equivalent to:

#include <SPI.h>
void setup() {
  42;
}

void loop()
{
  SPI.transfer(0b10101010);
}

which is compilable, but useless.

42 - the answer to the question of Life, the Universe and Everything!

Mark

You also need to control the SS signal to select the SPI slave.

/facepalm I'm so sorry, that was a stupid mistake. Think that I messed around with this code for over an hour, pulling out a lot of hair in the process :P