cancel
Showing results for 
Search instead for 
Did you mean: 

i2c initialization issue in stm32f469i_Discovery

PKunK.1
Associate III

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..

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

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

View solution in original post

4 REPLIES 4
KnarfB
Principal III

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

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
Principal III

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

PKunK.1
Associate III

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 */

}