I2C register read problem on STM32F2xx

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi guys,

I'm trying to bring up I2C on the STM32F2xx MCU on my WICED evaluation board. I've got an i2c slave hooked up via the Expansion Header.

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 electricial 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 the 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)

{

  /* Check the parameters */

  assert_param(IS_I2C_ALL_PERIPH(I2Cx));

  assert_param(IS_I2C_DIRECTION(I2C_Direction));

  /* Test on the direction to set/reset the read/write bit */

  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.

0 Likes
1 Reply
Anonymous
Not applicable

OK, before I waste anybody's time, let me answer my own dumb question. After pouring over the slave's data sheet some more I found that it's a write-only device. It does not respond to read requests. Duh. Stupid. Case closed. Nothing to see here. Move along.

/Ruben.

0 Likes