Pic16F628 + portexpander I2C

Status
Not open for further replies.
Jason
Your are not following the I2C standard. There is no advantage in that.
 

It would be a REALLY bad idea to try and do it that way - and what would be the point?, it gives no advantage whatsoever, and probably isn't workable - part of I2C requires the bus to be released.

You simply set the SDA/SCL pins permanent LOW, and alter TRIS to switch the I/O pin HIGH or LOW as required - it's simple, meets every requirement, and simulates an open-collector pin perfectly.
 
I have one thing to say and it's it for me If the line is pulled high .
And you send data out you clock out seven bits and the one bit that tells if it is read or write for 8 bits in all.
1. Line pulled high it's in read mode
2. Line pulled low it's in write mode
3. receive data your pic is set to input
4. send data your pic is set to output
You want the SDA pulled high with a resistor so it can be read or wrote to.
If you want to send data you send out a (0) to tell it that your writing data in thats the first bit then you send three bits for Address then four bits to tell what your writing to if it was eepron memory chip i would send out.
id address R/Wbit
1010 XXX 0 for writing
1010 XXX 1 for reading
Is that not how it works?
You simply set the SDA/SCL pins permanent LOW, and alter TRIS to switch the I/O pin HIGH or LOW as required - it's simple, meets every requirement, and simulates an open-collector pin perfectly.
That's what I'm taking about lol
 
Last edited:
ok ok guys] this isnt a argue post lol and we arent in **** chat forum ok lol all i know is i never did it your way and got mines working perfectly. Since it was 1 device. If i have 2+ devices then i would use the tris ok.
 
Last edited:
Thanks to all of you for considering my problem. I will however switch to a pic with build in hardware. Somehow, I am not quite sure that the choice of the resistor is so trivial as it appears to be. Mr. Goodwin's code is, of course, above any suspision. And so is my hardware: the same slaves perform in an AVR/ATmega environment in a most flawless manner. I should mention that several I2Cdevices coexist in my construction, even the ordinary 16X2 LCD (thanks to the portexpander).
Mr. Goodwin, may I give a suggestion for an expansionboard for your excellent winpicprog-tutorials? Connecting the 16f628 to a RC-servo. Nice for robotics!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…