AnsweredAssumed Answered

I2C register read problem on STM32F2xx

Question asked by lysens.ruben on Jan 4, 2015
Latest reply on Jan 4, 2015 by lysens.ruben

Hi guys,

I'm trying to bring up I2C on the STM32F2xx MCU.  I've got an audio codec hooked up as i2c slave.

I'm running into an issue with I2C register reads. The first i2c transaction where the register read address is posted goes through OK. The slave acks, so at least basic connectivity seems to be OK.

The 2nd transaction however, where the device address lsb is set to 1 to indicate read, goes wrong. SDA stays low and SCL just stops right when the read bit should be issued. See logic analyzer screenshot.

wiced_i2c_reg_read_capture.jpg

i.e. the problem appears to occur right before the i2c master should enter receive mode.

I confirmed using a debugger that SW does set the device address lsb when writing to the I2C DR register:

void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, uint8_t Address, uint8_t I2C_Direction) {
  if (I2C_Direction != I2C_Direction_Transmitter) {
    /* Set the address bit0 for read */
    Address |= I2C_OAR1_ADD0;
  }
  else {
    /* Reset the address bit0 for write */
    Address &= (uint8_t)~((uint8_t)I2C_OAR1_ADD0);
  }

  /* Send the address */
  I2Cx->DR = Address; <---- Address = 0x35

}

Any idea what's going wrong here?

Thanks for the help,

Ruben.

Outcomes