• AVR Freaks

Hot!Cannot set i2c scl clock frequency

Author
azaman
Starting Member
  • Total Posts : 43
  • Reward points : 0
  • Joined: 2018/06/14 05:08:52
  • Location: 0
  • Status: offline
2019/07/31 06:10:40 (permalink)
0

Cannot set i2c scl clock frequency

I am using pic32mx470F512H as I2C master and have 3 slave devices connected (ADAU1451 DSP and  2x MA12070P amp). The max allowed frequency for both devices is 400KHz as per datasheet. If I set the clock at 70KHz it works fine and all data writes are good. But if I increase the clock more than 70KHz e.g 100KHz  I cannot get any output.
 
I have 2.2K pull up on the MCU SCL/ SDA. My PLL is set to 40MHz.I am using baudrate to change the clock frequency and can see on the scope that it does change the scl freq to whatever I change it to.
Can someone suggest what the problem could be? 
post edited by azaman - 2019/07/31 06:24:50
#1

4 Replies Related Threads

    Paul PortSol
    Super Member
    • Total Posts : 493
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: Cannot set i2c scl clock frequency 2019/07/31 06:26:37 (permalink)
    0
    Check the errata for the PIC's datasheet, some have I2C issues, for some of my PIC boards I have to enable the "bitbang" option in MHC. 
    #2
    azaman
    Starting Member
    • Total Posts : 43
    • Reward points : 0
    • Joined: 2018/06/14 05:08:52
    • Location: 0
    • Status: offline
    Re: Cannot set i2c scl clock frequency 2019/07/31 08:24:00 (permalink)
    0
    I went through the errata but could not find any problems regarding to this issue. 
    #3
    Paul PortSol
    Super Member
    • Total Posts : 493
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: Cannot set i2c scl clock frequency 2019/07/31 08:55:42 (permalink)
    0
    a) What Versions: Harmony, MHC, XC32, etc. (Always post this as affects answers)
    b) Did you configure I2C with MHC, or your own code?
    c) Did you base your code on any examples? which?
    d) If using HarmonyV2.0X then see [MHC_CreatingProjectWithoutBSP_v00PR.txt], the last section about generating example code in MHC and comparing/extracting required bits is important. Possibly you are missing a bit of code so something isn't being consistently initialized (Default may work at 70KHz but not at higher).
    e) Do a compare between project at 70KHz and one at higher rate, and ensure that only the expected items are being changed in generated code. (a) copy project to a separate backup folder (b) change datarate & generate (c) compare copied and changed projects, possibly using beyond compare. MHC has on occasion generated false code due to bug.
    f) Create project fresh. MHC doesn't always change things properly. In past I had issues with MHC left over code when changed MHC settings.
     
    *If you find an MHC bug submit a ticket.
     
    #4
    azaman
    Starting Member
    • Total Posts : 43
    • Reward points : 0
    • Joined: 2018/06/14 05:08:52
    • Location: 0
    • Status: offline
    Re: Cannot set i2c scl clock frequency 2019/08/01 07:26:07 (permalink)
    4.5 (2)
    The problem was not giving enough time to DSP to settle after PLL lock.
    The uC needs to wait a little longer for the DSPs PLL to lock before starting I2C comm. Adding additional delay after PLL lock fixed the problem and now I can do the writes at max of 400KHz.
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5