2015-07-09 09:33 PM
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: 0xC0I 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? #stm32l051x-i2c2015-07-13 02:06 AM
Hi shah.kaival,
In the code you shared, I don't see the call for processing functions (HAL_I2C_Master_Transmit & HAL_I2C_Master_Receive). The slave address besides to the data are transferred on the bus based on these functions.You can take the examples available in the STM32CubeL0 package as reference.Have a look to the ones under STM32Cube_FW_L0\Projects\STM32L053C8-Discovery\Examples\I2C. If the processing functions are already called on your code, try to check the acceptable address for TLC59116, is it really 0xC0?-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.