2023-10-04 07:20 AM
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!
Solved! Go to Solution.
2023-10-06 03:00 AM
Hello @why_q ,
Yes you can mix HAL and LL :
I couldn't reproduce your issue!
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.
2023-10-06 03:00 AM
Hello @why_q ,
Yes you can mix HAL and LL :
I couldn't reproduce your issue!
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.
2023-11-06 07:32 AM
Hi Foued,
Thank you for your reply and sorry to hear that you couldn't repeat the issue.
My project was created by Keil uVision, ran CubeMX from there. The below is the code. If selecting LL for RCC and GPIO, the return from HAL_I2C_IsDeviceReady() is HAL_ERROR
2023-11-06 07:41 AM
Could you take an oscilloscope and check the SDA & SCL behavior.
If you have NACK, you should set the correct address.
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.
2023-11-06 09:37 AM
I don't have an oscilloscope. Just wondering why it works correctly if choosing HAL for RCC and GPIO.
2023-11-07 08:49 AM
Hi Foued,
Just let you know I tried to create a project using CubeIDE. The issue didn't happen. It worked on HAL and LL. Don't understand why using Keil has this problem.