i have a problem understanding the transmitting function of SPI in atmega16 the function that i don't understand is
void SPI_SendByte (s8_t data){
SPDR = data;
/* check if operation of transmit or receive is running */
while (bit_is_clear(SPSR,SPIF));
}
i think it should replace the two lines like this one here
void SPI_SendByte (s8_t data){
/* check if operation of transmit or receive is running */
while (bit_is_clear(SPSR,SPIF));
SPDR = data;
}
aren't we suppose to check if busy first , then write the data ?? why we did otherwise , in other communication protocol like UART for example we first check for busy then we write to register , why it's not the same in SPI !!?