AnsweredAssumed Answered

Stm32 I2c transmit restart issue

Question asked by nalam.varun on Mar 18, 2015
Latest reply on Mar 21, 2015 by yvraut.gerard
Hi everyone,

I am working with a  sensor which communicates using i2c. I am very new to stm 32 and could only figure out the basics of the code.I have successfully obtained data from other sensors using i2c. This particular sensor has the following protocol to obtain data.
The S stands for start and the Sr for restart.
How do I generate the repeated start condition without stopping and also send ack and check for ack?

I have been using the HAL_I2C_Master_Transmit and HAL_I2C_Master_Receive functions.

My initialization is given below:
    GPIO_i2c.Mode = GPIO_MODE_AF_OD;
  GPIO_i2c.Pull = GPIO_PULLUP;
  GPIO_i2c.Pin |= GPIO_PIN_6|GPIO_PIN_7;
  //GPIO_Uart.Speed = GPIO_SPEED_LOW;
GPIO_i2c.Alternate = GPIO_AF4_I2C1;
    HAL_GPIO_Init(GPIOB, &GPIO_i2c);
    I2cHandle.Instance             = I2C1;
  I2cHandle.Init.AddressingMode  = I2C_ADDRESSINGMODE_7BIT;
  I2cHandle.Init.ClockSpeed      = 400000;
  I2cHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  I2cHandle.Init.DutyCycle       = I2C_DUTYCYCLE_2;
  I2cHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  I2cHandle.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLE;
  I2cHandle.Init.OwnAddress1     = 0x30F;

and the functions as I am using are given below

HAL_I2C_Master_Transmit(&I2cHandle, (uint16_t)0xB4, (uint8_t*)read1, 1, 10000);
    HAL_I2C_Master_Receive(&I2cHandle, (uint16_t)0xB5, (uint8_t *)Buffer1, 3, 10000);
    HAL_I2C_Master_Transmit(&I2cHandle, (uint16_t)0x00, (uint8_t*)read2, 3, 10000);
    HAL_I2C_Master_Receive(&I2cHandle, (uint16_t)0x01, (uint8_t *)Buffer2, 2, 10000);
where read1 has the address of the register and 0xB4 is address for read ,while 0xB5 is for write.