CubeMX generated code doesn't work when mixing use HAL and LL
My project running on STM32G071 uses LL drivers for ADC and USART. The configuration code is generated by STM32CubeMX. It works fine. However after adding I2C HAL module which connects to a sensor to the project, the I2C function HAL_I2C_IsDeviceReady() always returns HAL_ERROR.
To investigate it, I created a simple project. It only has I2C. If selecting HAL driver for RCC and GPIO in the CubeMX, the returns from HAL_I2C_IsDeviceReady() and HAL_I2C_Mem_Read() are correct.

but it selects LL drivers for RCC and GPIO, and I2C stays as HAL, the return from HAL_I2C_IsDeviceReady() is HAL_ERROR.

Any idea what is wrong? Is it possible to mix use HAL and LL like this?
Many thanks!


