Announcement

Collapse
No announcement yet.

I2cwrite pic18f26k40

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • richard
    replied
    from the manual
    The I2C clock and data lines should be pulled up to Vcc with a 4.7K resistor per the

    following schematic as they are both run in a bidirectional open-collector manner.

    To make the I2C clock line bipolar instead of open-collector the following DEFINE

    may be added to the program:

    DEFINE I2C_SCLOUT 1
    The clock pin (in the master and slave device) must be bidirectional to detect the low conditions from the slave (DEFINE I2C_SCLOUT 1)

    bipolar is not equal to bidirectional, bipolar would drive the pins high making it difficult for the slave to hold the low level

    What kind of pic do you use?
    18f26k22, pic16f1619 they all work fine I doubt a bug , I don't have a k40 to test with
    maybe someone else can verify



    Leave a comment:


  • Viressrl
    replied
    the clock stretching is used when, for example, the slave has filled the buffer and needs some time to empty it. In this case the slave keeps the clock low, the master suspends the transmission
    The clock pin (in the master and slave device) must be bidirectional to detect the low conditions from the slave (DEFINE I2C_SCLOUT 1)

    In your picture I see that the start condition is correct
    What kind of pic do you use?
    Probably the bug is related to the 18F26K40 which has a different library

    Leave a comment:


  • richard
    replied
    DEFINE I2C_SCLOUT 1 makes the pic scl and sda pins bipolar instead of the usual open collector

    why do you think this is necessary ?
    especially why if clock stretching is to be employed ?

    to me the use of this define would make clock stretching difficult if not impossible

    I would like to know if it works or if there is a bug
    not that I can see
    top pic has
    DEFINE I2C_SCLOUT 1
    DEFINE I2C_HOLD 1

    the bottom neither


    Attached Files

    Leave a comment:


  • Viressrl
    replied
    Thankyou Richard,
    I2CWRITE SDA,SCL,indlcd,[comando,hello] is only an example
    The problem is if the command works or not and this is independent of the type of slave device
    BTW, in the specific case I'm talking to another pic not of my relevance, the customer asks me to manage the clock streching
    I would like to know if it works or if there is a bug

    Leave a comment:


  • richard
    replied
    DEFINE I2C_SCLOUT 1 makes the pic scl and sda pins bipolar instead of the usual open collector

    why do you think this is necessary ?
    especially why if clock stretching is to be employed ?

    perhaps if you supplied more info help would be more forthcoming


    I2CWRITE SDA,SCL,indlcd,[comando,hello] means very little

    device type ,datasheet link would help along with variable declarations


    Leave a comment:


  • Viressrl
    replied
    the fourth foto

    Leave a comment:


  • Viressrl
    replied
    To better explain the problem:
    The first two photos are SCL and SDA where there are no "DEFINE" instructions in the code
    DEFINE I2C_SCLOUT 1
    DEFINE I2C_HOLD 1
    it is possible to see the correct decoding and in the zoom the correct start condition

    The other two photos are the same signals inserting the "DEFINE" and it's possible to see the wrong start condition

    Leave a comment:


  • Viressrl
    started a topic I2cwrite pic18f26k40

    I2cwrite pic18f26k40

    I have a problem:

    in my code I have some
    I2CWRITE SDA,SCL,indlcd,[comando,hello]
    or similar
    Well it work and my scope decode and all is correct, I see the start condition, address ecc.
    Now my slave device must hold down the clock for clock stretching, OK I write
    DEFINE I2C_SCLOUT 1
    DEFINE I2C_HOLD 1
    and nothing work.
    In my scope I see that the start condition is wrong, the clock fall down before the data line
    Of course the slave device don't detect the start

    The bus have the 4,7K pullup resistor and
    SDA VAR PORTB.2
    SCL VAR PORTB.1

    Can help me?

    Thanks
    Marco
Working...
X