Skip to main content
AKoval
Associate
November 28, 2022
Solved

Why I2C4 related functions are defined in HAL for MCU that did not have it?

  • November 28, 2022
  • 3 replies
  • 1835 views

Hi! I am working with STM32F722VET which has 3 i2cs in total. But in the HAL file \STM32F7xx_DFP\2.15.1\CMSIS\Driver\I2C_STM32F7xx.c there are function calls related to I2C4.

For example, on line 1153: else /*(i2c->reg == I2C4)*/{ __HAL_RCC_I2C4_CLK_ENABLE(); }

The __HAL_RCC_I2C4_CLK_ENABLE() macro is not defined in stm32f7xx_hal_rcc_ex.h so the project cannot be compiled.

I'm using Keil with its device package manager and classic configuration (no cubeMX). Maybe I should include something to solve this problem?

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

Hello @AKoval​,

The content of the CMSIS folder available under the root of the STM32F7xx_DFP package is owned by KEIL and not supporting all the STM32F7 MCU devices. In this case, the I2C_STM32F7xx.c file is specific to the STM32F746G-Discovery board based on STM32F746NG MCU.

The I2C4 instance is available on STM32F746NG but not on STM32F722VET device. This explains your issue.

For reference drivers supporting all STM32F7 MCU devices, we recommend the STM32CubeF7 package available for download from st.com, GitHub, or via STM32CubeMx.

Foued

3 replies

Foued_KH
ST Employee
November 28, 2022

Hello @AKoval​,

The I2C drivers are related to all F7xx devices but you can find in Repository\STM32Cube_FW_F7\Drivers\CMSIS\Device\ST\STM32F7xx\Include that the STM32F722 supports only 3 instances.

Foued

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.
AKoval
AKovalAuthor
Associate
November 28, 2022

I know it only supports 3 instances. The problem is that the driver doesn't know about it and tries to access undefined functions related to i2c4. I fixed this by adding dummy definitions of the missing functions to my _hal_conf.h file. But I think the driver should correctly recognize the number of i2c devices by itself.

Foued_KH
ST Employee
November 30, 2022

Hello @AKoval​,

Thanks for clarification, I see the issue now. We are deeply reviewing the problem you highlighted and will come back to you with corrective actions.

Foued

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.
AKoval
AKovalAuthor
Associate
November 30, 2022

Hello!

Here is an example project https://github.com/koval-alexander/i2c_tst

It uses the CMSIS I2C driver, maybe that's the issue.

Foued_KH
Foued_KHBest answer
ST Employee
December 5, 2022

Hello @AKoval​,

The content of the CMSIS folder available under the root of the STM32F7xx_DFP package is owned by KEIL and not supporting all the STM32F7 MCU devices. In this case, the I2C_STM32F7xx.c file is specific to the STM32F746G-Discovery board based on STM32F746NG MCU.

The I2C4 instance is available on STM32F746NG but not on STM32F722VET device. This explains your issue.

For reference drivers supporting all STM32F7 MCU devices, we recommend the STM32CubeF7 package available for download from st.com, GitHub, or via STM32CubeMx.

Foued

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.