This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C clock not working

Hello,


I've encountered some problems while trying to run some I2C code on my BeagleBone Black. As far as I know, during an I2C transfer both lines are held up due to the pull up resistors, and once the master generates an Start the SDA pin goes low and SCL line starts working with the configurated clock.

I've tried to accomplish the above on I2C0 and I2C2 with no success, nor the rest of the I2C transfer code works at all. The SDA is maintained high after an Start and no clock is generated either.

Here is my code for initialization:

/**
  * @brief  I2C initialization in interrupt mode.
  * @param  None.
  * @retval None.
  * @note	Source: http://processors.wiki.ti.com/index.php/StarterWare_HSI2C#Interrupt_Mode.
  */

void I2C_Init(void)
{
	// Configure I2C module. Same as I2C1 initialization but with I2C2 registers.
	I2C2ModuleClkConfig();
	// Pin mux for selected I2C instance.
	GpioPinMuxSetup(AUD_SCL_PIN, PAD_FS_RXE_PU_PUPDE(AUD_SCL_AF));
	GpioPinMuxSetup(AUD_SDA_PIN, PAD_FS_RXE_PU_PUPDE(AUD_SDA_AF));
	// Put I2C in reset state.
	I2CMasterDisable(AUD_I2C_INTERFACE);
	I2CSoftReset(AUD_I2C_INTERFACE);
	// Set clocks.
	I2CMasterInitExpClk(AUD_I2C_INTERFACE, 48000000, 12000000, 100000);
	// Disable auto Idle Functionality.
    I2CAutoIdleDisable(AUD_I2C_INTERFACE);
	// Set slave address for I2C.
	I2CMasterSlaveAddrSet(AUD_I2C_INTERFACE, TEMP_SLAVE_ADDRESS);
	// Bring I2C out of reset.
    I2CMasterEnable(AUD_I2C_INTERFACE);
    while(!I2CSystemStatusGet(AUD_I2C_INTERFACE));
}

Here is part of my code to read via polling:

/**
  * @brief  Reads a byte from the specified offset.
  * @param  Offset: Address whose data will be read.
  * @retval The value on the specified offset.
  * @note	Source: Audio Codec Datasheet I2C interface.
  */

int I2C_ReadSingleByte (int offset)
{
	unsigned int temp = 0;
	// Wait till bus is not busy.
	while (I2CMasterBusBusy(AUD_I2C_INTERFACE));
	// Clear interrupts.
	I2CMasterIntRawStatusClearEx(AUD_I2C_INTERFACE, I2C_INT_TRANSMIT_READY);
	I2CMasterIntRawStatusClearEx(AUD_I2C_INTERFACE, I2C_INT_ADRR_READY_ACESS);
	I2CMasterIntRawStatusClearEx(AUD_I2C_INTERFACE, I2C_INT_RECV_READY);
	I2CMasterIntRawStatusClearEx(AUD_I2C_INTERFACE, I2C_INT_GENERAL_CALL);
	I2CMasterIntRawStatusClearEx(AUD_I2C_INTERFACE, I2C_INT_NO_ACK);

	// Set I2C on master transmitter mode.
	I2CMasterControl(AUD_I2C_INTERFACE, I2C_CFG_MST_TX);
	// Wait till finish.
	while (!I2CMasterIntRawStatusEx(AUD_I2C_INTERFACE, I2C_INT_ADRR_READY_ACESS));
	I2CMasterIntRawStatusClearEx(AUD_I2C_INTERFACE, I2C_INT_ADRR_READY_ACESS);
	// Issue an start.
	I2CMasterStart(AUD_I2C_INTERFACE);
...

I guess I missed to configure something perhaps to enable something and my next step is checking the GEL file, but this is the same code as the Starterware examples so I don't know.

Any comments or help are appreciated.