when I send some data in SPI master mode (ATmega168) I noticed strange behavior. Every time data block is sent, second byte is lost (not transmitted).
The operation is as follows.:
1. Load byte #1 to SPDR
2. wait for buffer empty (SPIF bit)
3. send byte #2
4. wait for buffer empty (SPIF bit)
5. send byte #3
6. wait for buffer empty (SPIF bit)
and so on.
I suspect it's connected with the way SPI module buffers data, but I'd rather expect that 1st byte is lost.
Temporary solution is just to send twice byte #2.
I played with timing an other things but without satisfying results.
Anybody know clean solution of this problem?