Electronic – CMSIS vs HAL vs Standard Peripherals Library


So I'm switching from PICs to ARM and I bought an STM32F4 discovery board.
So far I understand that to program it you can either access all registers directly in memory (obvious way) and also there are 3 main libraries you can use to make your life easier.
Now my question is, which one of those 3 (CMSIS, HAL, Std Peripherals Lib) is the most LOW level one? ie. the one with the less overhead. My goal is to learn the controller's inner workings and not make my life easier (only a little), so I would like to know which of these is closer to the core without resorting to use assembly.

Best Answer

Definitely the CMSIS. It is not exactly a library, it mostly contains definitions for the various registers.

It is exactly what one needs to access the microcontroller's registers easy, so as to implement his/her own HAL. It has no overhead, since you just access the registers.

Keep in mind that CMSIS, unlike the other two, is defined by ARM and not ST. This means that the various CMSIS libraries out there for the various microcontrollers are quite similar, which greatly aids in portability.

Furthermore, CMSIS is the simpler one so it is (IMO) the most versatile, and most reliable, with possibly fewer (or no) bugs. Some hal libraries for the various mcu's that I've used are quite infamous for their bugs.

On the other hand, CMSIS needs quite more work from you. It is however my personal choice, since I prefer to invest my time creating quality libraries, that suit my needs, and understanding how the chip works, than just spending time to learn another, new library.

Related Topic