I don't have access to the documentation of your I2C library, but you may want to check how the implementation of I2C_Send7bitAddress() handles the slave address alignement.
The BME680 in I2C mode expects the Save Address to be left aligned, with the LSB as R/W bit:
Here is an example of chip ID read I2C transaction (note that in the Analyzer Settings, Address Display is set to "7-bit, address bits only"):
With your library, you may need to manually shift the slave address, e.g.:
I2C_Send7bitAddress(I2C1, (dev_addr << 1), I2C_Direction_Transmitter); // Send slave address for write
//[...]
I2C_Send7bitAddress(I2C1, (dev_addr << 1), I2C_Direction_Receiver); // Send slave address for read
Thanks guys, I already found where problem was. It is slave address as you wrote. Yesterday, after posting screenshot from LA, I tried to set gas_sensor.dev_id = 0xEC and I recieved ack from BME. And now I see your answers for the same thing. In my code I am using STM32F10x_StdPeriph_Lib_V3.5.0, and in library I2C_Send7bitAddress realized in such way:
/**
* @brief Transmits the address byte to select the slave device.
* @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
* @param Address: specifies the slave address which will be transmitted
* @param I2C_Direction: specifies whether the I2C device will be a
* Transmitter or a Receiver. This parameter can be one of the following values
* @arg I2C_Direction_Transmitter: Transmitter mode
* @arg I2C_Direction_Receiver: Receiver mode
* @retval None.
*/
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 |= OAR1_ADD0_Set; // Address |= 0x0001
}
else
{
/* Reset the address bit0 for write */
Address &= OAR1_ADD0_Reset; // Address &= 0xFFFE
}
/* Send the address */
I2Cx->DR = Address;
}
Now I am put in this function 0xEC address for writing to and 0xED for reading from BME.
Hello Guy's,
I am using STM32f103C8T6 module as a arduino framework but I am unble to complile the below mentioned BMSC library in Platform IO.