cancel
Showing results for 
Search instead for 
Did you mean: 

How to have both HAL and LL driver files for the same component?

ANauz.1
Senior II

Hello,

I'm following this tutorial to "play" with ADC.

https://www.youtube.com/watch?v=pLsAhJ8umJk&list=PLnMKNibPkDnFCosVVv98U5dCulE6T3Iy8&index=10

At the end (27:30), it is using a LL function for the ADC driver, while during all the video it is using the HAL driver.

There is no problem because both stm32g0xx_hal_adc.h/c and stm32g0xx_ll_adc.h/c files are included in the projet.

In my project (i'm using L073RZ mcu) I have to select HAL or LL for the ADC driver in the ProjectManager->Advanced Settings of STM32CubeMX. So I cannot select both, and only HAL or LL files are included in STM32CubeIDE project.

As a consequence I cannot use the __LL_ADC_CALC_TEMPERATURE macro.

So how to add both HAL and LL files in the project?

I'm working with STMCubeIDE 1.4.0.

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions

Hello ANauz.1,

Unfortunately  "Delete previously generated files when not re-generated" option doesn't work properly, it is a known issue and it has been already reported to CubeMX development team to be fixed. The fix will be available in a future release. Thanks for your patience.

Otherwise manual modifications will be saved even after code regeneration.

Regards,

Khouloud.

View solution in original post

7 REPLIES 7
ANauz.1
Senior II

Ok, so...

For test, I just generate a new project for the G071RB, for the ADC, both HAL and LL files are present. For the L073RZ, only HAL files are present.

The difference is that:

stm32g0xx_hal_adc.h include stm32g0xx_ll_adc.h (without condition)

While

stm32l0xx_hal_adc.h does not include stm32l0xx_ll_adc.h

Any idea why the G0 can use both HAL and LL while the L0 can not?

Thx

ANauz.1
Senior II

Hello,

In the documentation of HAL/LL, there are informations about mixed use of Low Layer APIs and HAL drivers. You have to be carrefull but it is possible.

But in MX, you have to choose between HAL or LL. Is there a way to automatically include HAL and LL files in the project, or do I have to do it manually?

ANauz.1
Senior II

So nobody? Any ST support? How to mix HAL and LL for the same device in a project?

Artur IWANICKI
ST Employee

Hello,

In general LowLayer libraries are always tuned to particular family, thus the code migration is not that straightforward.

STM32G0 is a new family member, where a new HAL+LL libraries coexistence mechanism has been used. As HAL libraries within STM32G0 are using LowLayer drivers, both files are visible during code generation.

It is not the case when you are using STM32L0 libraries.

In this case you should include stm32l0xx_tt_adc.h file manually.

Some examples which demonstrates HAL+LL mix within one project can be found within STM32L0 Cube library i.e within folder:

.\STM32Cube_FW_L0_V1.11.2\Projects\NUCLEO-L073RZ\Examples_MIX\

I hope it helps you.

Hello ANauz.1,

Sorry for the delay.

The Low Layer is designed to be used in standalone mode or combined with the HAL, it cannot be automatically used with the HAL for the same peripheral instance.

STM32CubeMX offers you the possibility to select just one driver for each IP to work with (whether HAL or LL) and you can do the change needed for your project manually.

Please refer to the "Description of STM32L0 HAL and Low Layer drivers ": https://www.st.com/resource/en/user_manual/dm00113898-description-of-stm32l0-hal-and-low-layer-drivers-stmicroelectronics.pdf , for further information.

Regards,

Khouloud.

ANauz.1
Senior II

Hello, thank you for your answer.

So, in documentation UM1749, part 4: Cohabiting of HAL and LL, there is no way to do it automaticcaly?

In STM32CubeMX, I untick "Dekete previously generated files when not re-generated", all the ll files I add in the project where deleted when regenarating with MX. Is there a way to avoid this? Or I have to create a new "drivers" directory with the ll files in it?

Regards

Hello ANauz.1,

Unfortunately  "Delete previously generated files when not re-generated" option doesn't work properly, it is a known issue and it has been already reported to CubeMX development team to be fixed. The fix will be available in a future release. Thanks for your patience.

Otherwise manual modifications will be saved even after code regeneration.

Regards,

Khouloud.