SPI communication between Arduino Due(Master) and Arduino Uno(Slave) not working

Hello everyone,
Can you help me with my code. I have attached it below

I am using the Nick Gammon example code and have also included some print statements for debugging.
The output of both master and slave has been attached. It is printing garbage value.

Master code

#include <SPI.h>

void setup (void) {
   Serial.begin(115200); //set baud rate to 115200 
   digitalWrite(SS, HIGH); // disable Slave Select
   SPI.begin ();
   SPI.setClockDivider(SPI_CLOCK_DIV8);//divide the clock by 8

void loop (void) {
   char c;
   digitalWrite(SS, LOW); // enable Slave Select
   Serial.println(" SS is enabled now");
   // send test string
   for (const char * p = "Hello, world!\r" ; c = *p; p++) {
      SPI.transfer (c);
   Serial.println(" Data should have been sent");
   digitalWrite(SS, HIGH); // disable Slave Select

Slave Code

#include <SPI.h>
char buff [50];
volatile byte indx;
volatile boolean process;

void setup (void) {
   Serial.begin (115200);
   pinMode(MISO, OUTPUT); // have to send on master in so it set as output
   SPCR |= _BV(SPE); // turn on SPI in slave mode
   indx = 0; // buffer empty
   process = false;
   SPI.attachInterrupt(); // turn on interrupt
ISR (SPI_STC_vect) // SPI interrupt routine { 
  byte c = SPDR; // read byte from SPI Data Register
   if (indx < sizeof buff) {
      buff [indx++] = c; // save data in the next index in the array buff
      if (c == '\r') //check for the end of the word
      process = true;

void loop (void) {
  Serial.println("Slave start");
   if (process) {
      process = false; //reset the process
      Serial.println (buff); //print the array on serial monitor
      indx= 0; //reset button to zero

-Thanks in Advance for your help and time!


Some thoughts:

1/ Polarity and phase depend on what the Slave is expecting, and should be defined identically on both sides.



2/ Since a DUE is 3.3V compliant unlike a UNO, logic level shifters are compulsory between those boards (at least for MISO line)

3/ Did you connect MISO/MOSI from the correct SPI header from the DUE side ? (plus GNDs together ?)

4/ To troubleshoot this issue, a logic analyzer would be highly recommended

5/ Select the slowest possible SPI clock to begin your tests

6/ If nothing seems to work, try shiftin(), shiftout() arduino functions. They are super slow but might give you some hints to understand the issue for debugging.