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.

Waiting for clearing of busy bit in I2C module of CC2538

Other Parts Discussed in Thread: CC2538

Hi,

I am working to connect the CC2538 via I2C to HTU21D temperature and humidity sensor.

When I need to receive the measurement (i.e. receive a sequence of bytes) the datasheet says I should write to I2CM_CTRL register and then wait for the busy bit of I2CM_STAT to be cleared. Doing that didn't work for me, as the BUSY bit was always immediately cleared. Only a short while later the BUSY bit becomes busy and then I can wait for it to be cleared.

Is this behavior normal? According to the CC2538 datasheet at page 442, I should wait for the busy bit immediately after I write to I2CM_CTRL register.

I'd be happy to get an explanation for this behavior.

Here is the relevant piece of code with my workaround:

REG(I2CM_CTRL) = command;
status = REG(I2CM_STAT);
/*** Here is the work around - first wait for the busy bit to become set, in case it is not immediately set  ***/
if ( !(status & I2CM_STAT_BUSY) ) { do { status = REG(I2CM_STAT); } while ( !(status & I2CM_STAT_BUSY)); } /*** End of work around ***/
// Wait for busy bit to be cleared do { status = REG(I2CM_STAT); } while (status & I2CM_STAT_BUSY);