The 5th and 6th bits of the control register, the ‘Overrun’ and the ‘SPI_Complete’ bits are cleared when the ‘SPIM_bReadStatus’ function is called. As an example, consider the following code snippet.
SPIM_Start (SPIM_SPIM_MODE_0 | SPIM_SPIM_MSB_FIRST);
The initial value of the SPIM_CR register would be 0x11 (Tx Buffer Empty, SPIM running)
After the two transmissions, the value of SPIM_CR would be 0x79 (Rx Buffer overrun, SPI complete, Tx buffer empty, Rx register full, SPI running)
Now, a call to ‘SPIM_bReadStatus( )’ function will clear Bit5 and Bit6 and the value of the SPIM_CR register will be 0x19. So, always check for the Overrun error whenever the SPIM_bReadStatus( ) function is called. If not checked, an error status may be missed.
The ‘Rx Buffer Full’ bit is not cleared by this call. This bit will be cleared when the ‘SPIM_bReadRxData()’ function is called.