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.

TMS320F28377S: I2C busy bit always showing high

Part Number: TMS320F28377S

Hi ,

I would required I2C polling driver, i was developed following code,the busy bit of status register always set.

Please help me

void initI2C(void)
{
//
// Must put I2C into reset before configuring it
//
I2C_disableModule(I2CA_BASE);

//
// I2C configuration. Use a 400kHz I2CCLK with a 33% duty cycle.
//
I2C_initMaster(I2CA_BASE, DEVICE_SYSCLK_FREQ, 400000, I2C_DUTYCYCLE_33);
I2C_setBitCount(I2CA_BASE, I2C_BITCOUNT_8);
I2C_setSlaveAddress(I2CA_BASE, SLAVE_ADDRESS);
I2C_setEmulationMode(I2CA_BASE, I2C_EMULATION_FREE_RUN);

//
// Enable stop condition and register-access-ready interrupts
//
//I2C_enableInterrupt(I2CA_BASE, I2C_INT_STOP_CONDITION |
// I2C_INT_REG_ACCESS_RDY);

//
// FIFO configuration
//
// I2C_enableFIFO(I2CA_BASE);
// I2C_clearInterruptStatus(I2CA_BASE, I2C_INT_RXFF | I2C_INT_TXFF);

//
// Configuration complete. Enable the module.
//
I2C_enableModule(I2CA_BASE);
}

int VL6180x_WrByte(VL6180xDev_t dev, uint16_t index, uint8_t data)
{

//while( I2C_getStopConditionStatus(I2CA_BASE));
while(I2C_getStatus(I2CA_BASE)&I2C_STS_STOP_CONDITION);
//
// Setup slave address
//
I2C_setSlaveAddress(I2CA_BASE, SLAVE_ADDRESS);

//
// Check if bus busy
//
while(I2C_isBusBusy(I2CA_BASE));

//
// Setup number of bytes to send msgBuffer and address
//
I2C_setDataCount(I2CA_BASE, 3);


//
// Send start as master transmitter
//
I2C_setConfig(I2CA_BASE, I2C_MASTER_SEND_MODE);
I2C_sendStartCondition(I2CA_BASE);
while(!I2C_isBusBusy(I2CA_BASE));
//
// Setup data to send
//
I2C_putData(I2CA_BASE, (index>>8)&0x00FF);
while((I2C_getStatus(I2CA_BASE)&I2C_STS_TX_DATA_RDY));
I2C_putData(I2CA_BASE, index&0x00FF);
while((I2C_getStatus(I2CA_BASE)&I2C_STS_TX_DATA_RDY));
I2C_putData(I2CA_BASE, data&0x00FF);
while((I2C_getStatus(I2CA_BASE)&I2C_STS_TX_DATA_RDY));

I2C_sendStopCondition(I2CA_BASE);
while(!I2C_getStopConditionStatus(I2CA_BASE));
while(I2C_isBusBusy(I2CA_BASE));
//I2C_clearStatus(I2CA_BASE, (I2C_STS_NO_ACK|I2C_STS_REG_ACCESS_RDY));


return 0;
}