Hello,
The SPTEF flag will be cleared and will then become set during the normal course of sending a byte. You need to test the flag, to make sure it is set, prior to sending each byte. More important is the clearing of the SPIF flag following the completion of each byte transfer. The following code would be typical for the transfer of a single byte in both directions.
byte SPI_trans( byte value)
{
while ((SPISR & 0x20) == 0); // Wait until SPTEF flag is set
SPIDR = value;
while ((SPISR & 0x80) == 0); // Wait until SPIF flag is set
return SPIDR; // Also clears flag
}
Regards,
Mac