I2C module is excessively generated by CubeIDE
- March 14, 2020
- 1 reply
- 1137 views
Overview
While the I2C module is enabled by CubeIDE Device Configuration Tool,
- CubeIDE 1.3.0
- Nucleo H743ZI
- HAL FW 1.7.0
Reproduce the problem
Follow :
- Create a new Nucleo H743ZI project
- Generate the code from the Device Configuration Tool as default condition (All I2C are disabled)
- You can find Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_i2c.h while I2C is not chosen in the Device Configuration Tool.
This excessive I2C generation define a HAL_I2C_MODULE_ENABLED incorrectly, and it interferes the program which have IFDEF block with HAL_I2C_MODULE_ENABLED.
Demonstration of the problem
This problem can be demonstrated by the d009-nucleo-h743rb-i2c project inside attached d009.zip. This program doesn't have I2C as configured module. And this has following code in the main() function.
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_RESET);
#ifdef HAL_I2C_MODULE_ENABLED
// In this project, we don enable I2C by CubeIDE configuration.
// So, if the following code is executed, project is incorrectly configured.
HAL_GPIO_WritePin(LD3_GPIO_Port, LD3_Pin, GPIO_PIN_SET);
#endifThus, if LED is turned on, that is sign of the excessive I2C module. And you can see the LED is on if you run it on Nucleo.
Note that the d009-nucleo-g431rb-control has same logic as above, but LED is not turned on, if you run it on Nucleo G431RB. So there is no excessive I2C module issue for STM32G431
Others
I saw same problem for Nucleo L152 and Nucleo F091.
