Skip to main content
YSim.1
Visitor II
August 10, 2021
Solved

STM32F405 HAL I2C Code Bug Report

Code is missing:

typedef struct

{

 __IO uint32_t CR1;    /*!< I2C Control register 1,   Address offset: 0x00 */

 __IO uint32_t CR2;    /*!< I2C Control register 2,   Address offset: 0x04 */

 __IO uint32_t OAR1;    /*!< I2C Own address register 1, Address offset: 0x08 */

 __IO uint32_t OAR2;    /*!< I2C Own address register 2, Address offset: 0x0C */

 __IO uint32_t DR;     /*!< I2C Data register,     Address offset: 0x10 */

 __IO uint32_t SR1;    /*!< I2C Status register 1,   Address offset: 0x14 */

 __IO uint32_t SR2;    /*!< I2C Status register 2,   Address offset: 0x18 */

 __IO uint32_t CCR;    /*!< I2C Clock control register, Address offset: 0x1C */

 __IO uint32_t TRISE;   /*!< I2C TRISE register,     Address offset: 0x20 */

 __IO uint32_t FLTR;    /*!< I2C FLTR register,     Address offset: 0x24 */ // Code is missing!

} I2C_TypeDef;

​

So, ​HAL_I2CEx_ConfigAnalogFilter() Function Occur Error:

 if (hi2c->State == HAL_I2C_STATE_READY)

 {

  hi2c->State = HAL_I2C_STATE_BUSY;

  /* Disable the selected I2C peripheral */

  __HAL_I2C_DISABLE(hi2c);

  /* Reset I2Cx ANOFF bit */

  hi2c->Instance->FLTR &= ~(I2C_FLTR_ANOFF); // error: No Member

  /* Disable the analog filter */

  hi2c->Instance->FLTR |= AnalogFilter; // error: No Member

  __HAL_I2C_ENABLE(hi2c);

  hi2c->State = HAL_I2C_STATE_READY;

  return HAL_OK;

 }

​

This topic has been closed for replies.
Amel NASRI
Amel NASRIBest answer
ST Technical Moderator
August 17, 2021

Hi @YSim.1​ ,

As mentioned in RM0090, the I2C_FLTR is available on STM32F42xxx and STM32F43xxx only.

So there is no analog filter for I2C of STM32F405. This is said, there is no need to use the function HAL_I2CEx_ConfigAnalogFilter().

Are you adding it by yourself on your code, or is it generated by some tool?

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.

1 reply

Amel NASRI
Amel NASRIBest answer
ST Technical Moderator
August 17, 2021

Hi @YSim.1​ ,

As mentioned in RM0090, the I2C_FLTR is available on STM32F42xxx and STM32F43xxx only.

So there is no analog filter for I2C of STM32F405. This is said, there is no need to use the function HAL_I2CEx_ConfigAnalogFilter().

Are you adding it by yourself on your code, or is it generated by some tool?

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.