The difference between STM32 HAL library and LL library

    The last time I developed a project, I used a small-capacity STM32 ARM CORTEX core single-chip microcomputer, and used STM32CUBEMX to automatically generate configuration code. When I was about to write a program, I found that the capacity was more than 6K. This capacity does not feel much when using a large-capacity FLASH single-chip microcomputer, but when using a small-capacity single-chip microcomputer, it is obviously not enough.

    I had no choice but to go back to using the original StdLib library. I didn't do that for the past two years, and it wasn't difficult. But when I looked back for the corresponding library, I found a tragedy, there is no standard library for this sequence.

    This is not difficult for our old driver! I will extract the necessary register statements from the HAL library, and remove the redundant effective checking and conflict handling.

    Open the "Drivers\STM32F0xx_HAL_Driver\Src" directory, and suddenly found that in addition to the commonly used files starting with "stm32f0xx_hal_", there are also files starting with "stm32f0xx_ll_", what the hell is this? ! And these two files are in one-to-one correspondence, each module, GPIO, RCC, CRC, DMA, ... , has a corresponding file. Open it and compare it with hal, and find that it is much simpler.

    All of a sudden I got my head around and realized that this is a stripped-down library. So I checked the information on the Internet and finally found it. This is the STM32Cube LL library. It looks relatively new and seems to be recently launched by ST.

LL1-COMP.png

    Looking at the table above, I also found that its optimization (memory and MIPS) is much better, but the product line coverage is not yet complete, but the series I need are there.

LL2 AVAIL.png

    So, decided to use it, and made a small comparison.

    I use a 16k microcontroller, turn on the UART, ADC, and GPIO functions during configuration, generate them with the HAL library and the LL library, and compile them with KEIL 5 for comparison.

    Here is the chip configuration:

LL3 CHIP.png

    The following is the compiled code comparison:

HAL library Program Size: Code=5376 RO-data=232 RW-data=8 ZI-data=1232  
LL库 Program Size: Code=1804 RO-data=232 RW-data=4 ZI-data=1028  

    Isn't it quite shocking, the compiled LL library is only 33% of the volume of the HAL library.

    It was perfect, so I did the rest of the programming using the LL library. The LL library is basically a register-based operation, and some modules need to be reconfigured by themselves. For example, Systick does not run after using STM32CUBEMX, you need to enable it and turn on IRQ.

     LL library selection, in STM32CUBEMX, click "Project" --> "Settings" in the menu, select "Advanced Settings" in the following interface, and then select the library used after each module.

LL4 MX.png


For more description of STM32 HAL library and LL library, see: http://www.st.com/content/ccc/resource/sales_and_marketing/presentation/product_presentation/37/55/ff/bc/a8/71/4f/c5 /stm32_embedded_software_offering.pdf/files/stm32_embedded_software_offering.pdf/jcr:content/translations/en.stm32_embedded_software_offering.pdf


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325296798&siteId=291194637