Question
STM32 I2C problem
Posted on December 18, 2013 at 19:46
hello.
I want to communicate with sensör with I2C.First I must send the sensor register address to sensor.And then I receive the data from this sensor register.So first I configure I2C peripheral as master transmitter.Can I change the master transmitter to master receiver without generating stop condition ? I mean, I write this code : I2C_GenerateSTART(I2C1,ENABLE); I2C_GetFlagStatus(I2C1,I2C_FLAG_SB); while(I2C_GetFlagStatus(I2C1,I2C_FLAG_MSL)==RESET); I2C_Send7bitAddress(I2C1,MPU6050_Default_Address,I2C_Direction_Transmitter);while(I2C_GetFlagStatus(I2C1,I2C_FLAG_TRA)==RESET); while(I2C_GetFlagStatus(I2C1,I2C_FLAG_ADDR)==RESET); I2C_GetFlagStatus(I2C1,I2C_FLAG_ADDR); I2C_GetFlagStatus(I2C1,I2C_FLAG_MSL); // read sr2 . clear ADDR bit. I2C_SendData(I2C1,Gyrox_Data_MSB8_Register_Address); while(I2C_GetFlagStatus(I2C1,I2C_FLAG_TXE)==RESET);// Should I generate a STOP condition here ? or Can I resume like this ? :I2C_GenerateSTART(MPU6050_I2C, ENABLE);I2C_Send7bitAddress(MPU6050_I2C, slaveAddr, I2C_Direction_Receiver);...thanks for your help