46. SPI Programming

Question.6

What number will be printed on Arduino2’s serial monitor? (after executing the following code)

Arduino1 (master) code:

#include <SPI.h>

void setup() {
  SPI.begin();
  delay(300);
}

void loop() {
 
    digitalWrite(SS, LOW);
    SPI.transfer(0xFFFF);
    digitalWrite(SS, HIGH);
    
  while (1);
}

Arduino2 (slave) code:

#include <SPI.h>

void setup() {
  Serial.begin(115200);

  pinMode(MISO, OUTPUT);
  SPCR |= _BV(SPE);
  pinMode(SS, INPUT_PULLUP);
  SPI.attachInterrupt();
}

void loop() {
}

ISR(SPI_STC_vect) {
  Serial.println(SPDR, HEX);
}

Select Answer