SPI not working, ATmega328 only sending 1 byte
It looks like you have the parantheses in the wrong spot while waiting for the SPI transaction to complete. Because the ! operator has a higher precedence than &amp; it will be trying to do a bitwise not of the SPSR register first. Instead you want something like this:

while (!(SPSR &amp; (1&lt;&lt;SPIF)))
    ;


At the moment presumably that wait is returning immediately so the SPDR register is getting set three times in rapid succession without enough time for the data to be transferred.