PIC32 I2C not operating as expected

I’m having a problem getting I2C running with a PIC32MX795F512L. It was not acknowledging the address byte being sent out, so I put a logic analyzer on SDA and SCL and got the trace shown below:


The two excursions on the SCL line are the only ones that occur. So I don’t understand why there are only two, instead of one per bit plus the start and stop conditions. This is obviously why I never see any acknowledgment.

Also, SCL is low all of the time before these sequence starts, and I expected it to be high and then go low with SDA high to indicate a start condition. I have checked that I have pullups on both SCL and SDA.

The code I am using is straight out of Microchip’s I2C example code. Here is the relevant part:
// Start the transfer to write data to the EEPROM
if( !StartTransfer(FALSE) )
{
while(1);
}

// Transmit all data
Index = 0;
while( Success && (Index < DataSz) )
{
    // Transmit a byte
    if (TransmitOneByte(i2cData[Index]))
    {
        // Advance to the next byte
        Index++;

        // Verify that the byte was acknowledged
        if(!I2CByteWasAcknowledged(EEPROM_I2C_BUS))
        {
            DBPRINTF("Error: Sent byte was not acknowledged\n");
            Success = FALSE;
        }
        else
        {
            Success = TRUE; 
        }
    }
    else
    {
        Success = FALSE;
    }
}

// End the transfer (hang here if an error occured)
StopTransfer();
if(!Success)
{
    while(1);
}

It gets to the I2CByteWasAcknowledged call and fails. Anyone have any pointers on getting I2C on a PIC32 to work with the Peripheral Library code?

Hi Yumi,
Unfortunately I have no idea on using the PIC microcontroller gear, perhaps @Graham might be the man.