AnsweredAssumed Answered

STM32L05x not getting ACK from I2C slave.

Question asked by shah.kaival on Jul 10, 2015
Latest reply on Jul 13, 2015 by Amel N
Hi

I am using STM32L05x for my project. I interfaced TLC59116 with MCU on I2C. Issue is, I can send address on but is slave is not acknowledge to the address.

Slave Address: 0xC0

I am sharing my I2C related code for reference.

static void I2c_Driver_Init(void)
{
  /*##-1- Configure the I2C peripheral #######################################*/
  I2CxHandle.Instance              = I2C1;
  I2CxHandle.Init.AddressingMode   = I2C_ADDRESSINGMODE_7BIT;
  I2CxHandle.Init.Timing           = 0x10A13E56;
  I2CxHandle.Init.DualAddressMode  = I2C_DUALADDRESS_DISABLED;
  I2CxHandle.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
  I2CxHandle.Init.GeneralCallMode  = I2C_GENERALCALL_DISABLED;
  I2CxHandle.Init.NoStretchMode    = I2C_NOSTRETCH_DISABLED;
  I2CxHandle.Init.OwnAddress1      = I2C_ADDRESS;
  I2CxHandle.Init.OwnAddress2      = 0;
  if(HAL_I2C_Init(&I2CxHandle) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();    
  } 
}



void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
{


  GPIO_InitTypeDef GPIO_InitStruct;
  if(hi2c->Instance==I2C1)
  {
  /* USER CODE BEGIN I2C1_MspInit 0 */


  /* USER CODE END I2C1_MspInit 0 */
  
    /**I2C1 GPIO Configuration    
    PB6     ------> I2C1_SCL
    PB7     ------> I2C1_SDA 
    */
    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF1_I2C1;
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);


    /* Peripheral clock enable */
    __I2C1_CLK_ENABLE();
  /* Peripheral interrupt init*/
    HAL_NVIC_SetPriority(I2C1_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(I2C1_IRQn);
  /* USER CODE BEGIN I2C1_MspInit 1 */


  /* USER CODE END I2C1_MspInit 1 */
  }
}

Please let me know I am missing something?




Outcomes