The following minor change to i2c.Initialize appears to solve this.
Code: Select all
****************************************************************************
* Name : Initialize *
* Purpose : Initialize SSP module for I2C bus *
****************************************************************************
}
Public Sub Initialize(pBaudrate As Byte = I2C_100_KHZ, pSlew As Byte = I2C_SLEW_OFF)
SSPAddress = pBaudrate // set baudrate
SSPStatus = pSlew // POR state, optional slew
SSPControl2 = $00 // POR state
Input(SCL) // set SCL (clock pin) to input
Input(SDA) // set SDA (data pin) to input
// clear locked up peripheral
If SDA<>1 Then //there must be an i2c device holding SDA low
Output(SCL)
While SDA<>1 //clock in bits from the stuck peripheral until SDA is high
Low(SCL)
DelayUS(100)
High(SCL)
DelayUS(100)
Wend
Input(SCL) // set SDA (data pin) to input
EndIf
//
SSPControl1 = $28 // master mode, enable synchronous serial port
End Sub