I have a Rapsberry Pi master sending SPI requests to an Uno Chinese clone slave : I send 16 characters to the Arduino, which answers 16 others characters. What I send is not important, it's the Arduino answer that matters.

When I set the speed on the Raspberry Pi at 1 Mbit/s with my C program, the received answer coming from the Arduino is mostly garbage (random characters), but this issue disappears with lower speeds.

So that leads me to this question : what is the maximum SPI speed for a slave Uno/clone, in order to have no errors ?

Edit : the Arduino code :

#include <SPI.h>

char receivingBuffer[5];
char sendingBuffer[5] = {'T', 'e', 's', 't', '!'};

volatile char bytes_received = 0;

void setup()

  SPCR |= bit(SPE);

  pinMode(MISO, OUTPUT);


  SPDR = sendingBuffer[bytes_received];



  if (++bytes_received == 5)

    bytes_received = 0;


  SPDR = sendingBuffer[bytes_received];


void loop()



Also, the C code on the RPi :

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wiringPiSPI.h>

#define SPI_CHANNEL 0
#define SPI_SPEED   1000000 // Hz.

int main(void)


   while (1)

      char buf[5] = {'T', 'e', 's', 't', '?'};

      printf("Sending   : %s\n", buf);

      wiringPiSPIDataRW(SPI_CHANNEL, buf, 5);

      printf("Receiving : %s\n\n", buf);



   return 1;

  • 1
    The theoretical maximum is 8Mbps, which is F_CPU/2. What matters though is that you react fast enough to the requests for each byte and fill the buffer fast enough. That's down to your program to determine.
    – Majenko
    Aug 2, 2017 at 9:48
  • Please show your code. What you are doing in order to answer is highly relevant. If you are sending at 1 Mbits/s then the slave doesn't have many clock cycles to formulate a response.
    – Nick Gammon
    Aug 2, 2017 at 10:37
  • I added the Arduino code. Aug 2, 2017 at 11:22
  • What happens if you set a transfer speed of >1Mbps and put a delay in between each byte (at the Pi side) - does it start working then?
    – Majenko
    Aug 2, 2017 at 11:29
  • With 1.5 or 2 Mbps, I receive the first character of the expected answer, and the other characters are the sent message's ones. Aug 2, 2017 at 11:32

1 Answer 1


The maximum speed for Arduino as a slave is F_CPU/4, so it's 4Mbps. When the Arduino is the master it can work at F_CPU/2, so it's 8Mbps

  • Thank you for your answer ! Do you have any source to confirm this ? Aug 2, 2017 at 11:33
  • 1
    You can find this in ATmega328 datasheet. The ATmega328 is the chip on Arduino Uno.
    – bouaaah
    Aug 3, 2017 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.