Beginner I2C Questions


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    172

    Default Re: Beginner I2C Questions

    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

  2. #2
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    172

    Default Re: Beginner I2C Questions

    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

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624

    Default Re: Beginner I2C Questions

    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.

  4. #4
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    172

    Default Re: Beginner I2C Questions

    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

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172

    Default Re: Beginner I2C Questions

    Is there any Analog feature enabled on port C?

    Robert

  6. #6
    Join Date
    Dec 2010
    Location
    Melbourne Australia
    Posts
    172

    Default Re: Beginner I2C Questions

    Demon,
    That PortC.3 does have an analog input option, but I'm pretty sure I initialised everything as digital.

    ANSEL = 0 'All ports digital
    ANSELH = 0 'All ports digital

    Of course, there's an awful lot of functionality on one of these micros so it's entirely possible I've overlooked something.

    Regards,

    Troy

Similar Threads

  1. Beginner help!
    By Recognize in forum General
    Replies: 14
    Last Post: - 26th April 2012, 15:55
  2. I2C howto questions
    By comwarrior in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 27th May 2010, 19:39
  3. i2c PBP questions
    By TimV in forum General
    Replies: 14
    Last Post: - 5th February 2007, 18:58
  4. Questions about i2C EEPROM
    By RunningMan in forum General
    Replies: 3
    Last Post: - 29th January 2007, 05:09
  5. Still new to PicBasic - i2c questions
    By cometboy in forum mel PIC BASIC
    Replies: 4
    Last Post: - 13th November 2006, 19:27

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts