cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 I2C TXIS flag not set.

Yuti Amonkar
Associate II

Hi

I am using B-L072Z-LRWAN1 board and connected ToF sensor to I2C1 (PB8 and PB9).I am using the following I2C configuration:

                __HAL_RCC_I2C1_FORCE_RESET();
		__HAL_RCC_I2C1_RELEASE_RESET();
		I2cHandle1.Instance             = ( I2C_TypeDef * )I2C1_BASE;
		I2cHandle1.Init.Timing          = I2C_TIMING;
		I2cHandle1.Init.OwnAddress1     = 0x52;
		I2cHandle1.Init.AddressingMode  = I2C_ADDRESSINGMODE_7BIT;
		I2cHandle1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
		I2cHandle1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
		I2cHandle1.Init.OwnAddress2     = 0xFF;
		I2cHandle1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
		I2cHandle1.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLE; 
		if(HAL_I2C_Init(&I2cHandle1) != HAL_OK)
		{
				/* Initialization Error */
				return;
		}
		/* Enable the Analog I2C Filter */
		if(HAL_I2CEx_ConfigAnalogFilter(&I2cHandle1,I2C_ANALOGFILTER_ENABLE) != 
                 HAL_OK) {
				return;
		}
 
		return;

I am using the following configuration for GPIO:

	RCC_PeriphCLKInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2C1;
		RCC_PeriphCLKInitStruct.I2c1ClockSelection = RCC_I2C1CLKSOURCE_SYSCLK;
		HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphCLKInitStruct);
 
		/*##-2- Enable peripherals and GPIO Clock #################################*/
		/* Enable GPIO TX/RX clock */
		 __HAL_RCC_GPIOB_CLK_ENABLE();
		__HAL_RCC_GPIOB_CLK_ENABLE();
		/* Enable I2Cx clock */
		__HAL_RCC_I2C1_CLK_ENABLE();
 
		/*##-3- Configure peripheral GPIO ##########################################*/  
		/* I2C TX GPIO pin configuration  */
		GPIO_InitStruct.Pin       = PB_8;
		GPIO_InitStruct.Mode      = GPIO_MODE_AF_OD;
		GPIO_InitStruct.Pull      = GPIO_PULLUP;
		GPIO_InitStruct.Speed     = GPIO_SPEED_FREQ_HIGH;
		GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
		HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
		/* I2C RX GPIO pin configuration  */
		GPIO_InitStruct.Pin       = PB_9;
		GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
		HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

When I use HAL_I2C_Master_Transmit, timeout occurs after wait for TXIS function.I checked in debug, TXIS is not set and NACK is also not set.

Is there any thing that needs to be added in the configuration?

1 REPLY 1
Kishan Joshi
Associate III

did you get any resolution ?