I haven't got to the clock stretching yet. I'm still just working on reading the I2C bus. -- Sincerely, James Burkart *925.667.7175* On Sun, Oct 20, 2019 at 11:12 PM Joep Suijs wrote: > Hi James, > > I did check your code and didn't see where it actually checks for the clo= ck > to go high (that is, read input and check it, not fixed delay). Didn't > check all of your code though, so I might have missed it. > > Good luck. > Joep > > Op ma 21 okt. 2019 om 06:44 schreef James Burkart < > james@burkartstudios.com > >: > > > Thanks Joep, > > > > I appreciate the help. I do understand how I2C works, my questions are > > about my code. The port pins I am using for clock and data are operatin= g > as > > open drain, so I'm not driving anything high. > > > > -- > > Sincerely, > > > > James Burkart > > *925.667.7175* > > > > > > On Sun, Oct 20, 2019 at 4:11 AM Joep Suijs wrote: > > > > > Hi James, > > > > > > The slave hold the clock low to hold off the master when it needs tim= e. > > So > > > after the master 'releases' the clock to go high, it needs to wait > until > > > the clock line actually is high before it can proceed. This is also t= he > > > reason you shouldn't drive clock high, only low... > > > > > > Joep > > > > > > Op zo 20 okt. 2019 om 00:23 schreef James Burkart < > > > james@burkartstudios.com > > > >: > > > > > > > I am using pull up resistors on both SCL and SDA. Analog is disable= d > on > > > > RC7. The author of the original code mentions that he wrote the cod= e > to > > > be > > > > as universal as possible. I understand the reasoning, it's just > > > > implementing it that's giving me issue. So I re wrote the code and = am > > > using > > > > the open drain feature of my micro on SDA and SCL. But now I'm tryi= ng > > to > > > > successfully read from SDA. > > > > > > > > On Sat, Oct 19, 2019, 4:13 PM Mike wrote: > > > > > > > > > Do you have pull-up resistors on both SCL and SDA? Have you > > configured > > > > > the ANSELC register to disable analog input in RC7? > > > > > > > > > > Using the TRIS register to switch a pin between an input, or an > > output > > > > > with a logic 0 level set is a common way of simulating an > open-drain > > > > > output if this function is not support in hardware. The code you > used > > > > > was very likely written for an old 14 bit part (16C/16Fxx etc.) > which > > > > > don't have open-drain outputs. > > > > > > > > > > Regards > > > > > > > > > > Mike > > > > > > > > > > On 19/10/2019 22:49, James Burkart wrote: > > > > > > I wrote up a bit-bang I2C routine to communicate with a couple > > > devices, > > > > > an > > > > > > SSD1306 OLED and an MCP23018 port extender. I'm using a > > PIC18F27K40. > > > > > > > > > > > > I've got the sending data part just fine, but I can't figure ou= t > > the > > > > > > receiving part, including reading acknowledge bits. I, in large= , > > > copied > > > > > the > > > > > > code example from a blog post by Calvin Cherry ( > > > > > > > > > > > > > > > > > > > > > https://calcium3000.wordpress.com/2016/08/19/i2c-bit-banging-tutorial-par= t-i/ > > > > > > ). > > > > > > To be honest, the way he was switching SDA between an input and > > > output > > > > > was > > > > > > confusing to me and so I just enabled open drain on the port pi= ns > > in > > > > > > question. And that's why I can write to the I2C bus just fine, > but > > > > > reading > > > > > > from it I am stumbling. For my bit read function I change the > port > > > pin > > > > > used > > > > > > for SDA to an input and read its value through PORTCbits.RC7 bu= t > > it's > > > > > > always reading 0. > > > > > > > > > > > > I'd like to use the hardware I2C but I can't get the MCC code t= o > > > work, > > > > > > either the Foundation Services version, nor the other one that = is > > to > > > be > > > > > > obsoleted soon. > > > > > > -- > > > > > > Sincerely, > > > > > > > > > > > > James Burkart > > > > > > *925.667.7175* > > > > > > > > > > > > > > > > -- > > > > > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > > > > > View/change your membership options at > > > > > http://mailman.mit.edu/mailman/listinfo/piclist > > > > > > > > > -- > > > > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > > > > View/change your membership options at > > > > http://mailman.mit.edu/mailman/listinfo/piclist > > > > > > > -- > > > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > > > View/change your membership options at > > > http://mailman.mit.edu/mailman/listinfo/piclist > > > > > -- > > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > > View/change your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist > > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .