1.5.2 MSSP SPI Client Mode
When operating in SPI Client mode, if the incoming SCK clock signal arrives during any of the conditions below, the SSPBUF Transmit Shift Register (TSR) may become corrupted. The byte transmitted to the client cannot be ensured to be correct, and the state of the WCOL bit may or may not indicate a write collision.
These conditions include:
- A write to an SFR
- A write to RAM following an SFR read
- A write to RAM before an SFR read
Work around
Method 1 (Interrupt based using SS):
- Connect the SS line to both the SS input and either an INT or IOC input pin.
- Enable INT or IOC interrupts
(interrupt on falling edge if available, otherwise, check that
SS ==
0
when the interrupt occurs). - Load SSPBUF with the data to be transmitted.
- Continue program execution.
- When invoking the Interrupt
Service Routine (ISR), do either of the following:
- Add a delay that ensures the first SCK clock will be complete, or
- Poll SSPSTAT.BF
(while(BF ==
0
)) and wait for the transmission/reception to complete.
Method 2 (Bit polling based using
SS):
- Load SSPBUF with the data to be transmitted.
- Poll the
SS line and wait for the
SS to go active
(while(!PORTx.SS ==
0
)). - When
SS is active (SS ==
0
), do either of the following:- Add a delay that ensures the first SCK clock will be complete, or
- Poll SSPSTAT.BF
(while(BF ==
0
)) and wait for the transmission/reception to complete.
Once one of these two methods is complete, it is safe to return to program execution.
Method 3 (SS not available):
- Load SSPBUF with the data to be transmitted.
- Poll SSPSTAT.BF (while(BF ==
0
)) and wait for the transmission/reception to complete.
Affected Silicon Revisions
A3 | A4 | ||||||
X | X |