0 ratings0% found this document useful (0 votes) 505 views6 pagesSTM32 HAL Library Tutorial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Corinna
Lem sT™Ma2
Bases
Setting Up STM
Teolchaln|
Getting Stared
vith STH22
sTw22 HAL
Library
(6PI0 Tuts}
15PI0 Output
Die Togale
Pn
PIO Input asd
Pi)
SSTM22 RCC Reset
led
STM22 delay. us
(wr Time)
STM22 daly. us
srwa2 || eseaz || arouino || pic || electronics
Ar ere ane
St Tat Tg rT
Lhe
Tela
STM32 HAL Library Tutorial
hea andy
¢.Predious Tutoria Tutorial 2 Next Tutorial >
STM32 HAL Library
s1¥32 Course Home Fage?72?
STMCube® Is STMicroolectionics’s original inive to ease and accelerate the
development cycle of embedded products. STM32Cube covers the STMS2 portico.
of microcontrollers.
It provides the developer wih all the lowslevel drivers, APIs, end enables hiner to
odicate most of the offert to develop the application layer and any required
rmidcloware.
STM32 HAL Library Drivers
‘The STM32CubeMX, a graphical sofware configuration tool that allows generating ©
Intiaizaton code using graphical wizards.
Search The
Website
Categories
catego
Selectcateoory
Subscribe To Our Newsletter
To Get All New Updates‘The STM32Cube Hardware Abstaction Layer (HAL), an STM32 abstraction layer
embedded software ensuring maximized porabilty across the STMS2 microcontroller.
The HAL is availabe forall the hardware perioheras.
The lovslayer APIs (LL) offering a fast ightweight expert orinted layer that is closer
to the hardvae than the HAL. The LLAPIs are avaliable only fr @ set of peripherals.
The HAL and LL are complementary and cover wide range of applications
requirements:
*+ The HAL offers highovel and festure-orierted APIs, wth ahigh-portabity level.
They hide the MCU and peripheral complexity to end-user.
+ The LL offers lowlevel APIs at registers level, with beter optimization but less
portabity. They cequie deep knowedge of the MCU and peripherals
specifications,
‘The source code of HAL and LL divers is developed in Stict ANSI-C whieh makes it
independent fom the development took. Its fly documented and is MISRA-C 2004
compliant
STM32 HAL Drivers Examples
HAL GPIO APIs
“secon coat lois Ae
rte)
2 Maer Banas
1 operation functions
“he acon coat ong AP
HAL Detaled Function Description
Inthe same menner, there sre lowlevel hardware drivers for simast all he hardware
Povipherals in the STM32 microcontolers. Including Timers, ADC, USART, 12C, USB,
DAC, Comparators, ae
Well configure these peripherals and generate the intiaizetion C-Code using the
CubeMX software tool, Here is a screenshot for what looks Ike inside the interface
‘whore we configure the tner module for example,
Hardware Timer Module Configuration Within CubeNxSUL FPA ei
eons
Using the STMS2 HAL device drivers can be advantageous in so many situations, and
help shorten the development ime. Especially for projects that fall n the category of
"proof of concept. | think no one wants to spend so much time buicing a complete
sofware stack fora specific target then it proves the msin idea needs more refinement
or the target tse does not perform well enough.
However, the moderately high-level APIs provided by the HAL may have extra more
feetures than what you may actualy need in some situations. So you end up using
more memory space and executing some tasks a Fle bit slower due to the overhead
ofthe functonsities embedded inthe ibrares,
You can use the LL chivers and optimize more at the register level in order to enhance
memory uization or the speed of execution, Howaver, the application atthe end would
notbe easiy portable across multiple targets.
Allin al, well be using the STM32 CubeMX toolto generate HAL + LL chivers C-Code
to iniaze cur hardware. Then well be developing the appfcation layer and some
rridaleware stuff onthe way.
Most, wel be focusing on the ECUAL layer bulding some ferware dkvers, and
tasting them in diferent applications. Those drivers must be easly ceconfigurable and
completely portable
To achieve reconfgurabity, well use something called “Linking Configuration’ that
you'l Team in the next tutorals, And in order to achieve the portabsty requirement; the
divers willbe totally based on the STM's HAL + LL crivors that have uniformed APIs
across all STMS2 microcontolers. n this way, you can use the code provided in the
practical LABs in this sees of tutorials and buld it to your specif target
rricracontrlle whataverits,# should work!ECUAL drivers wll be building ietude:[ Servo Motors - Keypad ~ LCD ~ HC-SRO4
Utrasonie = Joystick ~ and more... You can check thom out if youre curious or just
keop fllowing along with tese tutorials.
‘That's & for this short introduction to the STMS2 HAL Library and CubeMMX tool, In the
next tutorial, well get to know the hardivare GPIO ports and pins. How ®works and the
Internal éxcuity and funtionalties you can coafigue in various applications. Thereafter
\wellbe able to startthe first LAB in this series of tutorials andl “Bink an LEDY".
<¢.Preious Tutoria Tutorial 2 Next Tutorial D>
Shate This Page with Your Network!
Join Our +25,000 Newsletter Subscribers!
Stay Upsdated With All Nens Content Releases You Also Get Occasional FREE Coupon
Cotes For Courses & Other Stuf
bad Sys mace Trl, STME2 ARM,
© smazcore
Sting Sartecith STM? ARM Cortex CL
sttg2 G20 Tuna
Author
Pore LEST
eee eee
ene eet) ign, Ses
engineer in the Automative & e-Mobilly Industy. However,
ee ee
tems, Rob ee ete
eee a an a
eee en a ee ee
regard for what is possible, can and will change the wor | wil2 thoughts on “STM32 HAL Library
Tutorial”
Kenny Townsend
Fabrssy25, 2001691 9M
| am tying to design two seperate pid temperature contiolers for bya
machine One for the top heater and a seperate one for bottom heatecThen
‘embed both in software and us gui on computer using profilecan you point
ime tovwhere I might fred how to do thi?
Reply
Good explanations. Thanks 3 It 777
Reply
Leave a Comment
mail
> Notiy me of new posts by emailCategories
Categories
Select Catesory
ABOUT ii
See eee ee
een eeu
eee ro
bed eee
Ree ees
See ee
rear
ee
ete
dearcn Ine wepsite
Kesources
JPPORT
ee Se ee
eee eer ee are
ere ee Cec mee
oer) advertising programs designed
means for sites to ea 7
See eee
Ere
ee eat) ee a)
Pee