Hot!Code getting stuck in PIC32 i2c legacy function IdleI2C1

Author
sanket.meher111
Starting Member
  • Total Posts : 37
  • Reward points : 0
  • Status: offline
2018/01/13 06:55:12 (permalink)
0

Code getting stuck in PIC32 i2c legacy function IdleI2C1

hello,
 
Code getting stuck in PIC32 i2c legacy function IdleI2C1.
I2C speed is 400kbps
peripheral clock is 10Mhz
What is the issue?
Please help
#1

7 Replies Related Threads

    RISC
    Super Member
    • Total Posts : 4741
    • Reward points : 0
    • Status: offline
    Re: Code getting stuck in PIC32 i2c legacy function IdleI2C1 2018/01/13 07:28:09 (permalink)
    0
    Hi,
    Give more details....otherwise nobody cna help.
    Which PIC32 ?
    Which compiler ? which version ?
    Are you using the peripheral libraries of XC32 ?
    Regards
     
    #2
    DavidBLit
    Super Member
    • Total Posts : 1480
    • Reward points : 0
    • Joined: 2012/02/18 13:08:48
    • Location: The Land of Confusion
    • Status: offline
    Re: Code getting stuck in PIC32 i2c legacy function IdleI2C1 2018/01/13 07:29:28 (permalink)
    0
    First guess: lack of pull-ups on the clock and data signals.

    Yeah, "//Code and stuff".
    #3
    aschen0866
    Super Member
    • Total Posts : 4215
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: Code getting stuck in PIC32 i2c legacy function IdleI2C1 2018/01/13 13:36:29 (permalink)
    0
    Here is the source code:

    /************************************************************************
    * Function Name: IdleI2C1
    * Description: This routine generates wait condition intil I2C
    * bus is Idle.
    * Parameters: void
    * Return Value: void
    *************************************************************************/

    void IdleI2C1(void)
    {
    /* Wait until I2C Bus is Inactive */
    while(I2C1CONbits.SEN || I2C1CONbits.PEN || I2C1CONbits.RSEN || I2C1CONbits.RCEN || I2C1CONbits.ACKEN || I2C1STATbits.TRSTAT);
    }

    Put I2C1CON in the Watch window and you'll know which bit is set.
    #4
    sanket.meher111
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Status: offline
    Re: Code getting stuck in PIC32 i2c legacy function IdleI2C1 2018/01/13 22:25:08 (permalink)
    0
    Pullups are given with 4.7k resistors
    #5
    sanket.meher111
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Status: offline
    Re: Code getting stuck in PIC32 i2c legacy function IdleI2C1 2018/01/13 22:30:12 (permalink)
    0
    Pullups are given with 4.7k resistors
    #6
    sanket.meher111
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Status: offline
    Re: Code getting stuck in PIC32 i2c legacy function IdleI2C1 2018/01/13 22:33:01 (permalink)
    0
    PIC32MX230F064D
    Compiler XC32 version v1.22
    I am using i2c peripheral library peripheral/i2c.h
     
    #7
    maxruben
    Super Member
    • Total Posts : 3140
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: Code getting stuck in PIC32 i2c legacy function IdleI2C1 2018/01/14 05:00:19 (permalink)
    0
    Always or just sometimes?
     
    It can happen that the I2C slave gets out of sync with the master and then holds the data line low so a new START sequence can not be executed. Especially when debugging and single stepping. Could this be it?
     
    /Ruben
    #8
    Jump to:
    © 2018 APG vNext Commercial Version 4.5