cancel
Showing results for 
Search instead for 
Did you mean: 

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

AKoval
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Foued_KH
ST Employee

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.

View solution in original post

5 REPLIES 5
Foued_KH
ST Employee

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
Associate II

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.

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.

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
ST Employee

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.