Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

66%
+2 −0
Q&A What exactly is a HAL and how would I write my own?

So is a HAL really just a collection of functions that when called set/reset specific register bits for my specific microcontroller? The HAL created by ST for the STM32 is a relatively thin wr...

posted 28d ago by Nick Alexeev‭  ·  edited 28d ago by Nick Alexeev‭

Answer
#3: Post edited by user avatar Nick Alexeev‭ · 2026-08-20T15:23:26Z (28 days ago)
  • > So is a HAL really just a collection of functions that when called set/reset specific register bits for my specific microcontroller?
  • The HAL created by ST for the STM32 is a relatively thin wrapper around registers. Most functions access a register (or a few related registers) and perform some useful low-level operation for the caller.
  • The STM32 HAL library (plus the STM32cubeMX) is for the entire STM32 family, not just a specific microcontroller. If you need to move the calling code to a different STM32 microcontroller (say from an F4 to a G4), it should be able to call the HAL generated for that other microcontroller. (Generally. There may be exceptions, for example the ADC code for F0 isn't compatible with F4, G4, and most of the rest STM32.)
  • > If so, is it really necessary to call it a HAL?
  • If you want to access registers directly, you can do that without a HAL.
  • In my case STM32 HAL and CubeMX saved a lot of time, accounting for the time which I've spent learning the HAL.
  • *p.s.*
  • At some point you'll also come across the term Board Support Package (BSP).
  • > So is a HAL really just a collection of functions that when called set/reset specific register bits for my specific microcontroller?
  • The HAL created by ST for the STM32 is a relatively thin wrapper around registers. Most functions access a register (or a few related registers) and perform some useful low-level operation for the caller.
  • The STM32 HAL library (plus the STM32cubeMX) is for the entire STM32 family, not just a specific microcontroller. If you need to move the calling code to a different STM32 microcontroller (say from an F4 to a G4), your calling code should be able to call the HAL generated for that other microcontroller, generally. (There may be exceptions, for example the ADC code for F0 isn't compatible with F4, G4, and most of the rest STM32.)
  • > If so, is it really necessary to call it a HAL?
  • If you want to access registers directly, you can do that without a HAL.
  • In my case STM32 HAL and CubeMX saved a lot of time, accounting for the time which I've spent learning the HAL.
  • *p.s.*
  • At some point you'll also come across the term Board Support Package (BSP).
#2: Post edited by user avatar Nick Alexeev‭ · 2026-08-20T15:21:46Z (28 days ago)
  • > So is a HAL really just a collection of functions that when called set/reset specific register bits for my specific microcontroller?
  • The HAL created by ST for the STM32 is a relatively thin wrapper around registers. Most functions access a register (or a few related registers) and perform some useful low-level operation for the caller.
  • It's for the entire STM32 family, and not just you specific microcontroller. If you need to move the calling code to a different STM32 microcontroller (say from an F4 to a G4), it should be able to call the HAL generated for that other microcontroller. (Generally. There may be exceptions, for example the ADC code for F0 isn't compatible with F4, G4, and most of the rest STM32.)
  • > If so, is it really necessary to call it a HAL?
  • If you want to access registers directly, you can do that without a HAL.
  • In my case STM32 HAL and STM32cubeMX saved a lot of time, accounting for the time which I've spent learning the HAL.
  • *p.s.*
  • At some point you'll also come across the term Board Support Package (BSP).
  • > So is a HAL really just a collection of functions that when called set/reset specific register bits for my specific microcontroller?
  • The HAL created by ST for the STM32 is a relatively thin wrapper around registers. Most functions access a register (or a few related registers) and perform some useful low-level operation for the caller.
  • The STM32 HAL library (plus the STM32cubeMX) is for the entire STM32 family, not just a specific microcontroller. If you need to move the calling code to a different STM32 microcontroller (say from an F4 to a G4), it should be able to call the HAL generated for that other microcontroller. (Generally. There may be exceptions, for example the ADC code for F0 isn't compatible with F4, G4, and most of the rest STM32.)
  • > If so, is it really necessary to call it a HAL?
  • If you want to access registers directly, you can do that without a HAL.
  • In my case STM32 HAL and CubeMX saved a lot of time, accounting for the time which I've spent learning the HAL.
  • *p.s.*
  • At some point you'll also come across the term Board Support Package (BSP).
#1: Initial revision by user avatar Nick Alexeev‭ · 2026-08-20T15:12:39Z (28 days ago)
> So is a HAL really just a collection of functions that when called set/reset specific register bits for my specific microcontroller?

The HAL created by ST for the STM32 is a relatively thin wrapper around registers.  Most functions access a register (or a few related registers) and perform some useful low-level operation for the caller.  

It's for the entire STM32 family, and not just you specific microcontroller.  If you need to move the calling code to a different STM32 microcontroller (say from an F4 to a G4), it should be able to call the HAL generated for that other microcontroller.  (Generally.  There may be exceptions, for example the ADC code for F0 isn't compatible with F4, G4, and most of the rest STM32.)

> If so, is it really necessary to call it a HAL?

If you want to access registers directly, you can do that without a HAL.

In my case STM32 HAL and STM32cubeMX saved a lot of time, accounting for the time which I've spent learning the HAL.

*p.s.*  
At some point you'll also come across the term Board Support Package (BSP).