cancel
Showing results for 
Search instead for 
Did you mean: 

I2C register read problem on STM32F2xx

ruben2
Associate
Posted on January 04, 2015 at 00:29

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.

http://community.broadcom.com/servlet/JiveServlet/showImage/2-11240-2833/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.

#i2c-stm32f2
1 REPLY 1
ruben2
Associate
Posted on January 04, 2015 at 04:03

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.