2025-08-04 5:56 AM
Hi, my name is Zaeem Ahmed.
I'm currently digging into the STM32F1 HAL and trying to understand it at a deeper level. I'm intentionally not using STM32CubeMX — not because I have anything against it (it’s a great tool) — but because I want to read the HAL documentation and implement configurations manually to better understand what’s really happening under the hood.
I would really appreciate any good resources, expert tips, or learning strategies that help connect:
HAL APIs ↔ Hardware-level understanding from the reference manual
Often, when reading HAL documentation, I encounter vague or overly simplified explanations. For example:
HAL_TIM_Base_Init vs. HAL_TIM_Base_MspInit — the documentation just says one initializes the timer and the other the MSP, which is obvious from the names but not why they're separated or how they work together under the hood.
Another example:
When initializing timers, there are different functions for different modes (e.g., HAL_TIM_OnePulse_Init, HAL_TIM_PWM_Init, etc.).
But modes like PWM, Input Capture, Output Compare seem to be channel-specific, not timer-wide.
So why is the timer itself initialized in a specific mode?
This leads to questions like:
What happens if I initialize a timer in one mode (say PWM), and configure its channel for another (like Input Capture)?
How is HAL actually helping if I have to dig into its source every time to validate my approach?
I understand how the timer works at the register level from the reference manual, but when I move to HAL, it feels like a black box. I'd really like to bridge that gap.
How can one truly learn HAL (not just use it as a wrapper)?
Are there any guides/resources that map HAL APIs to actual peripheral behavior?
What’s the best way to approach HAL if you want full control and hardware understanding, but still benefit from its abstraction?
I’d really appreciate any learning resources, explanations, or just your own journey if you’ve been through this.
Thanks in advance!
— Zaeem Ahmed
2025-08-04 6:01 AM
Timers are one of the things that HAL doesn't do that well, purely due to the sheer number of configurations possible. Consider using register-only code instead if it's something that can't be selected in CubeMX.
Best way to learn is to look at the code and see what it's doing, IMO.
2025-08-04 6:41 AM
Hello @Zaeem-Ahmed
To learn what the HAL function do exactly you should follow these steps
2025-08-04 6:51 AM
@Zaeem-Ahmed wrote:I want to read the HAL documentation
That would be a good starting point - have you done that?
eg, for F1, it's UM1850 Description of STM32F1 HAL and low-layer drivers.
See also the 'Documentation' tab on the Cube-F1 package Product Page:
https://www.st.com/en/embedded-software/stm32cubef1.html#documentation
You could also look at the code that CubeMX generates - it's all just HAL calls...