• AVR Freaks

Hot!PIC32MZ and MCP4728 : I2C stuck!

Author
luca.leoncavallo@gaengineering.com
New Member
  • Total Posts : 30
  • Reward points : 0
  • Joined: 2015/02/12 03:52:15
  • Location: 0
  • Status: offline
2020/01/25 02:21:11 (permalink)
0

PIC32MZ and MCP4728 : I2C stuck!

Hi,
 
We are developing a system that controls device with 0-10VDC output. Then we use a custom PIC32MZ board with MCP4728. At startup always works good but after a while 0-10VDC stops changing.
Then I've changed the code to do some testing. Now every 500 msec I change the the DAC output to generate a square wave 0-10V.
After every FastWrite Command I read back the values from MCP4728 with a read command 25 msec after the write.
In minutes the test fail: the I2C Bus remains busy and the master then stops sending write/read commands.
 
In attach you can find some Scope screen of regular commands and stuck communications that happen always on the write cmd.
 
Any idea?
 
PS In debug if i Reset the PIC the I2C line still stays LOW then I suppose that the problem is on the MCP4728  side and not in PIC32MZ or in Harmony library. Correct?

Attached Image(s)

#1

4 Replies Related Threads

    maxruben
    Super Member
    • Total Posts : 3376
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: PIC32MZ and MCP4728 : I2C stuck! 2020/01/25 05:22:22 (permalink)
    0
    The I2C bus might become stuck if you get out of sync in the i2c communication between the master and slave (for example resetting the micro while the slave holds sda low). The only way to get ut of this state is to either power cycle the slave or to clock out enough clock cycles to make sure that the device releases the sda line before you can send a stop or start sequence again. Note that this has to be done by bit banging.
     
    You can check if the bus is in this locked state if the SDA line is low before you send out the start sequence. Your I2C routines should always perform this step and do the unlocking to be as robust as possible.
     
    See also this post.
     
    /Ruben
    #2
    Mysil
    Super Member
    • Total Posts : 3642
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: PIC32MZ and MCP4728 : I2C stuck! 2020/01/25 05:55:03 (permalink)
    0
    Hi,
    What exact PIC32MZ??????  device type is beeing used,
    and what  hardware silicon revision is the PIC32MZ device that is used for development and testing?
     
    The reason for this question, is that some revisions of PIC32MZ devices have hardware Errata
    that may cause I2C communication to get stuck.
     
    Hardware revision of the microcontroller is reported by MPLAB X  when communication is established,
    before programming or a debug session is started.
     
    Read the Errata document for the PIC device type beeing used,
    to see what applies to the hardware revision of the device in use.
     
        Mysil
    #3
    luca.leoncavallo@gaengineering.com
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2015/02/12 03:52:15
    • Location: 0
    • Status: offline
    Re: PIC32MZ and MCP4728 : I2C stuck! 2020/01/25 06:24:53 (permalink)
    0
    Hi Ruben,
    Thanks for support.
    I check the line status and in fact i stop sending I2C commands but i cannot understand the reason of the out of sync.
    Now I'm going to implement the bitbang clock as you suggest to verify if is possibile to come back to life the MCP4728
     
    See you soon
    #4
    luca.leoncavallo@gaengineering.com
    New Member
    • Total Posts : 30
    • Reward points : 0
    • Joined: 2015/02/12 03:52:15
    • Location: 0
    • Status: offline
    Re: PIC32MZ and MCP4728 : I2C stuck! 2020/01/25 06:27:54 (permalink)
    0
    Hi,
     
    The information returned by MPLABX are:
     
    Target device PIC32MZ2048EFH100 found.
    Device ID Revision = A1
    DEVSN0 = ec1a75f5
    DEVSN1 = cab55410
     
    I will check the errata....
    #5
    Jump to:
    © 2020 APG vNext Commercial Version 4.5