• AVR Freaks

Hot!Problem with I2C

Author
dobrosoft
Starting Member
  • Total Posts : 84
  • Reward points : 0
  • Joined: 2019/05/20 04:44:55
  • Location: 0
  • Status: offline
2020/03/26 08:27:24 (permalink)
0

Problem with I2C

Hello, I have strange problem with I2C. Master is PIC32MZ2048efh100 , Harmony 2.06. It works well, but I need to do communication errorless - between i2c slave and i2c master is cable - about 30cm. There is not problem with communication. But I test next situation:
 
When system is communicating, I2C data wire I connect hard to ground for some seconds and then disconnect from ground. From this point i2c is not communicating. All while loops in I2C are protected with timer for situation when slave not answer and not communicating. I got status, that communication with I2C is lost, when data wire grounded to zero. But after disconnect from zero, It look like communication continues. Above situation does not do problem with main application loop, only i2c will not communicate correctly. 
 
In debugging I found that when I will not send stop bit in i2c communication, this will fix the problem. But It's not correct solution. What can cause this problem with I2C ?
#1

8 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 18779
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Problem with I2C 2020/03/26 09:13:13 (permalink)
    4 (2)
    What is the Slave? is it a Hardware device? Is you are messing with the Bus you will need to clear the non responding slave.  This is usually done by sending 9 clocks then a stop bit.
    #2
    Paul PortSol
    Super Member
    • Total Posts : 619
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: Problem with I2C 2020/03/27 05:28:00 (permalink)
    5 (1)
    Bugs in PIC32MZ I2C hardware.
    See the PIC32MZ errata (on website with datasheet).
    Safer to use I2C BitBang option in MHC (or you have to check PIC's silicon version and workarounds).
     
    **Best check Errata for all PIC features you use to avoid surprises.
     
    Paul
    #3
    NKurzman
    A Guy on the Net
    • Total Posts : 18779
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Problem with I2C 2020/03/27 06:11:33 (permalink)
    0
    I am using HW for the PIC32MZ it works fine within the limits of the Errata. But bit bang the clearing locked i2c slaves.
    #4
    dobrosoft
    Starting Member
    • Total Posts : 84
    • Reward points : 0
    • Joined: 2019/05/20 04:44:55
    • Location: 0
    • Status: offline
    Re: Problem with I2C 2020/03/30 00:58:14 (permalink)
    0
    My version of chip has not problem in I2C. 
     
    When I wire I2C data to ground, and unwire from ground, I2C not works, signal randomly skip between 0 and 1.
    After that when I wire I2C clock to ground, for about 1second, and disconnect, I2C work back without problem.
     
    I can detect problem in bus with I2C1STATbits.IWCOL . But when ground wired problem will finished, IWCOL bit is set. Set this bit manually has no effect. 
     
    post edited by dobrosoft - 2020/03/30 01:37:32
    #5
    ric
    Super Member
    • Total Posts : 27627
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Problem with I2C 2020/03/30 02:16:51 (permalink)
    0
    Did you try the recovery process suggested by NKurzman in post #2?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    dobrosoft
    Starting Member
    • Total Posts : 84
    • Reward points : 0
    • Joined: 2019/05/20 04:44:55
    • Location: 0
    • Status: offline
    Re: Problem with I2C 2020/03/30 02:38:39 (permalink)
    0
    Yes, I try it. But there is not problem with slave. There is forced problem in bus. I2C will not work after problem in bus wiring is solved.
    #7
    ric
    Super Member
    • Total Posts : 27627
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Problem with I2C 2020/03/30 02:44:13 (permalink)
    0
    dobrosoft
    Yes, I try it.

    and we are to accept that you did it right?
     

    But there is not problem with slave.

    How do you know?
     

    There is forced problem in bus. I2C will not work after problem in bus wiring is solved.

    What does this mean?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    dobrosoft
    Starting Member
    • Total Posts : 84
    • Reward points : 0
    • Joined: 2019/05/20 04:44:55
    • Location: 0
    • Status: offline
    Re: Problem with I2C 2020/03/30 05:03:40 (permalink)
    0
    I found problem. SEN must be set back to 0, when loop timer expires (slave not responds, wire problem ....).
    My function which send start bit is next:
     
    void i2c_master_start(void){

    I2C1CONbits.SEN = 1;
    uint32_t tick = _CP0_GET_COUNT();
      while(I2C1CONbits.SEN){
        if((_CP0_GET_COUNT()-tick)>MAX_TIME){
           I2C1CONbits.SEN = 0; //this must be set back to zero, otherwise bus not works after data or clk hard grounded to zero and back and loop timer expires
           break;
        }
      } 
    }
    #9
    Jump to:
    © 2020 APG vNext Commercial Version 4.5