PIC18F14K50 and i2cread/i2cwrite on PORT C


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PIC18F14K50 and i2cread/i2cwrite on PORT C

    Quote Originally Posted by RuudNL View Post
    TRISB=0 sets the outputs to a solid low level, but the I2C commands are still not working.
    Don't do that.
    I2C requires the pins to be in INPUT mode when not transfering data.
    The pins are never driven high, only low, which is why you need the pull-up resistors.

    Since it's a 14K50, you're probably running at 48Mhz.
    So you may want to add ...

    DEFINE I2C_SLOW 1

    Depending on if the device you're talking to is a 100Khz I2C part.
    If it's a 400Khz part, you won't need it.
    DT

  2. #2
    Join Date
    Feb 2012
    Posts
    57


    Did you find this post helpful? Yes | No

    Default Re: PIC18F14K50 and i2cread/i2cwrite on PORT C

    I know...
    The only reason I tried TRISB=0 is because I wanted to check if I could use the pins as a digital output.
    In the meantime I found the problem. In fact, it had nothing to do with the i2cread/i2cwrite commands.
    The crystal I used apparently had a low activity. Sometimes the oscillator was working, but most of the time it was not!
    I changed the crystal and now it works! (Maybe changing the values of the capacitors would have worked, but I did not try that.)

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