The bus busy flag (BBSY) is cleared by detecting a stop condition from an actual waveform. Writing 0 to BBSY directly does not clear the flag.
In the case the flag is not cleared to 0 even when a stop condition is generated (writing BBSY = 0 and SCP = 0), it is assumed that the stop condition had not been generated as an actual waveform because SCL or SDA was fixed to low level by this station or another station.
If SCL or SDA is being fixed to low level by this station, release BBSY using the following procedure:
- IICRST = 1 (release the SCL/SDA output latch of this station)
- IICRST = 0 (release the internal reset)
- Confirm SCL/SDA = high level (check the port input of shared pins)
- Generate a start condition (write BBSY = 1 and SCP = 0)
- Confirm the start condition is generated (confirm SCLO = 0)
- Transmit dummy data.
- Generate a stop condition (write BBSY = 0 and SCP = 0)
- Confirm the stop condition is generated (confirm STOP = 1)
- Clear the STOP flag (write STOP = 0)