Fault Tolerant I2C Object?
eldonb46
Posts: 70
I have been working with the "jm_i2c" Object; to connect several devices to the Propeller. The Object appears not to observer the NAK status in any useful fault tolerant way.
For example, when a I2C peripherals miss-behaves (or is dead/missing) the object saturates the I2C bus with "wait(id)" output and never gives up. With my LCD Display on the same I2C bus, useful system diagnostic information that could have been displayed is lost, or stuck, in the blizzard.
Has anyone expanded the "jm_i2c" object to be more flexible and fault tolerant?
I have started some successful edits for my use, but because I am a little new to I2C, it would be better if there was a collaborative effort.
I currently have about six devices on a single I2C bus (and maybe more to come). With some I/O locking, I am very pleased how well they all work together, the Prop with multiple COG's manages them all at more than acceptable speeds. Yes, I know, I could have made it easier with additional I2C buses, but that is NOT my goal, I want to save as many I/O pin as possible.
Some of my Prop Projects can be seen at:
Note: I am new to the Propeller forum, is there a better place/method to "discuss" individual Exchange Objects?
BTW: Thanks "jm", I have learned a lot by reading your I2C Object, again, Thanks.
Regards,
Eldon - WA0UWH
For example, when a I2C peripherals miss-behaves (or is dead/missing) the object saturates the I2C bus with "wait(id)" output and never gives up. With my LCD Display on the same I2C bus, useful system diagnostic information that could have been displayed is lost, or stuck, in the blizzard.
Has anyone expanded the "jm_i2c" object to be more flexible and fault tolerant?
I have started some successful edits for my use, but because I am a little new to I2C, it would be better if there was a collaborative effort.
I currently have about six devices on a single I2C bus (and maybe more to come). With some I/O locking, I am very pleased how well they all work together, the Prop with multiple COG's manages them all at more than acceptable speeds. Yes, I know, I could have made it easier with additional I2C buses, but that is NOT my goal, I want to save as many I/O pin as possible.
Some of my Prop Projects can be seen at:
Note: I am new to the Propeller forum, is there a better place/method to "discuss" individual Exchange Objects?
BTW: Thanks "jm", I have learned a lot by reading your I2C Object, again, Thanks.
Regards,
Eldon - WA0UWH
Comments
Maybe add a timeout. Maybe the problem will clear itself. (The BASIC Stamp has a timeout on its i2c commands.) You might modify the code to include setting a status variable so that the program could deal with a particular locked up device by resetting it or something like that. The following modification returns the id of the offending i2c device as a negative number, to an abort handler at a higher level.
Note that the STOP method in jm_i2c also has provision for clock stretching, and that might also be a sticking point that could also be covered by a reasonable timeout, or comment it out if your system does not use clock stretching.