The bus busy flag (BBSY) clears to 0 when a stop condition is detected from an actual waveform. You cannot clear BBSY by writing 0 to it directly.
If issuing the stop condition (writing BBSY = 0 and SCP = 0) is not clearing the condition, this may be because this station or another station is fixing SCL or SDA to low level, and the stop condition is not being properly issued as an actual waveform.
If this station is the one that is fixing SCL/SDA to low level, you can use the following procedure to clear BBSY.
1) Write IICRST = 1 (release SCL/SDA output latch of this station).
2) Write IICRST = 0 (release internal reset).
3) Confirm that SCL/SDA = high (check port input of shared pin).
4) Enter master transmit mode (write MST = 1, TRS = 1)
5) Issue start condition (write BBSY = 1 and SCP = 0).
6) Confirm that start condition issued (confirm that SCLO = 0).
7) Issue stop condition (write BBSY = 0 and SCP = 0).
8) Confirm that stop condition issued (confirm that STOP = 1).
9) Clear the STOP flag (write STOP = 0).
|H8S/2556, 2552, 2506|