kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
I2C routines with timeout |
Posted: Tue Feb 17, 2009 5:14 pm |
|
|
Colleagues,
Currently the canned I2C routines that come with I2C compiler (i2c_read(), i2c_write()) don’t seem to have provisions for timeout. I think, this opens a door for the stuck bus problem. The slave can stretch the clock forever at that would hang the master. For example, the slave could be another PIC with a firmware bug.
I need to use slow bit-banged I2C. Is there a way to add timeout to canned I2C bit-banging routines? Are there I2C routines with timeout this forum? I realize that rolling my own routines is relatively straightforward, but I’d like not to reinvent the wheel if I can.
Cheers,
- Nick
P.S. If I had a hardware I2C, I would monitor SSPSTAT in the hardware interrupt and reset the I2C peripheral when necessary, which might unfreeze the main thread. _________________ Read the label, before opening a can of worms. |
|