Henrik and co,
Just to clarify, do I need a port with digital I/O capabilities to function for PBP's I2C communications or can I use a digital input only port? I'm using the PIC micro as the master only.
Thanks,
Troy
Henrik and co,
Just to clarify, do I need a port with digital I/O capabilities to function for PBP's I2C communications or can I use a digital input only port? I'm using the PIC micro as the master only.
Thanks,
Troy
Ok, I'm really confused regarding Pic Basic and i2c at the moment. I've experimented with a simple circuit with a PIC18f13k50 using the Pic's official i2c data and clock pins and the thing worked (eventually). I've kinda transferred that same Pic(micro) and code to an established circuit that only had 2 different pins/ports available ie. not the MSSP module's i2c data & clock pins. It doesn't work. Can I gather some clarification on what pins are available for i2c use in general?
Thanks,
Troy
Hi,
Like I said earlier, I've got no experience with I2C but as far as I understand both signal pins must be digital outputs. I think that it should work on pins with open drain output (ie, pins which can only switch to GND). Pins that are input only won't work as far as I understand.
So, any two pins which can function as digital outputs should work. Make sure any analog functions on these two pins are disabled. If you need help, tell us which chip it is and post the code.
/Henrik.
Henrik,
The only reference I can see to "open-drain" within my PIC18f14K50 datasheet is specifically in reference to the Data and Clock pins for the MSSP module *when set to* i2c mode. I guess I'll find out tonight when I whack the PIC back into the development board and try to run i2c through other (non MSSP module) ports/pins. Worst case scenario I can butcher the circuit board to accommodate the use of the correct i2c pins, but it would be nice to be able to avoid that.
Troy
Okay, I just found this on a Microchip forum (to quote):
"Any PIC I/O pin can be open drain.
Let's say you are using PORTD bit 2. COnfigure this bit as an input (initially). Set the output PORTD bit 2 = 0 (or port for a 16F). When you want the output to be active low then instead of writing to the lat or port register, you write the corresponding tris big. But toggling tris you are switching the pin to input (open drain) or output low."
So, it's basically suggesting that any port with I/O functionality can be "simulated" to be open-drain. I'm guessing this is what Pic Basic does ie. toggle the TRIS register to pull a port low?
Cheers,
Troy
Hi Troy,
Yes, any pin can "simulate" open drain but an open drain pin can not "simulate" a totem-pole / push-pull output. But, after some further reading on my behalf it seems like I2C is driven in open drain mode (hence the external pullup resistors) which means that pretty much ANY output pin on your PIC should work with the PBP I2C commands.
And, the data pin is obviously switched between input and output by the I2C commands depending on if data is being sent or received.
/Henrik.
Henrik,
Last night I experimented some more back on the development board with other pins to check this out. Turns out that all the pins for the "B" ports worked for either the clock or the data line for i2c communication. However, I also tried port C.3 on the development board as using this pin on the main board didn't work and sure enough it didn't work on the development board either. Dunno why not. It has digital I/O functionality like all the pins/ports I tested on the *B* port; the only difference that I can see between my B and C ports is that all the digital I/Os on B ports are listed as TTL whilst all the digital inputs on the C ports are listed as Schmitt Trigger.
Thanks,
Troy
Bookmarks