Hello Lundin,
Your code appears to send two bytes in succession, but reads only a single return byte (after both have been sent or buffered). An overrun condition is possibly occurring, that may cause subsequent data to be missed. Both return bytes should be read, even if the data is to be discarded.
The safest approach is to send only a single byte at a time, and wait until SPRF flag becomes set before reading the data byte (also clears the flag), and then sending the next byte.
After you first enable the SPI module, it is necessary to read SPIS, before sending the first byte. But you appear to be already doing this by virtue of the while loop that tests the SPTEF flag.
Regards,
Mac