Skip to main content
PKunK.1
Associate III
February 22, 2021
Solved

i2c initialization issue in stm32f469i_Discovery

  • February 22, 2021
  • 4 replies
  • 2006 views

It is developing products using stm32f469i_Discovery.

The stm32f469i_Discovery board is intended to be used with DS3231.

It was connected to I2C1 for I2C communication.

I2C1 initialization runs on MX_I2C1_Init();

In this function,

It is developing products using stm32f469i_Discovery.

The stm32f469i_Discovery board is intended to be used with DS3231.

It was connected to I2C1 for I2C communication.

I2C1 initialization runs on MX_I2C1_Init();

hi2c->State = HAL_I2C_STATE_RESET;

I2C communication is not possible because it is in a state.

Thus, after MX_I2C1_Init();, hi2c->State = HAL_I2C_STATE_READY; was added for use.

What I want to know is why the status of HAL_I2C_STATE_RESET continues when I2C is initialized.

For your information, I am working on it using TouchFGX.

 Init Code is Add..

This topic has been closed for replies.
Best answer by KnarfB

You can step through the source code and find it out.

4 replies

KnarfB
KnarfBBest answer
Super User
February 23, 2021

You can step through the source code and find it out.

PKunK.1
PKunK.1Author
Associate III
March 3, 2021

The part HAL_I2C_DeInit(&hi2c1) was deleted from static void MX_I2C1_Init(void).

Like the stm32f429i_Discovery i2c setting.

if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)

{

Error_Handler();

}

/** Configure Digital filter

*/

if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)

{

Error_Handler();

}

I added

Am I mistaken?

KnarfB
Super User
March 3, 2021

The code you are showing is part of MX_I2C1_Init and should be present.

PKunK.1
PKunK.1Author
Associate III
March 4, 2021

It is My Code.

static void MX_I2C1_Init(void)

 /* USER CODE BEGIN I2C1_Init 0 */

 /* USER CODE END I2C1_Init 0 */

 /* USER CODE BEGIN I2C1_Init 1 */

 /* USER CODE END I2C1_Init 1 */

 hi2c1.Instance = I2C1;

 hi2c1.Init.ClockSpeed = 400000;

 hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;

 hi2c1.Init.OwnAddress1 = 0;

 hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;

 hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;

 hi2c1.Init.OwnAddress2 = 0;

 hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;

 hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;

 if (HAL_I2C_Init(&hi2c1) != HAL_OK)

 {

   Error_Handler();

 }

 /* USER CODE BEGIN I2C1_Init 2 */

#if 1

 /** Configure Analogue filter

  */

  if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)

  {

    Error_Handler();

  }

  /** Configure Digital filter

  */

  if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)

  {

    Error_Handler();

  }

#else

 HAL_I2C_DeInit(&hi2c1);

#endif

 /* USER CODE END I2C1_Init 2 */

}