STM32CubeL0 Getting Started Manual Datasheet by STMicroelectronics

View All Related Products | Download PDF Datasheet
Introduction
STM32Cube™ is an STMicroelectronics original initiative to make developers’ life easier by reducing development effort, time
and cost. STM32Cube™ covers the whole STM32 portfolio.
STM32Cube™ includes:
STM32CubeMX, a graphical software configuration tool that allows the generation of the C initialization code using
graphical wizards
A comprehensive embedded software platform, delivered per series (such as STM32CubeL0 for STM32L0 Series):
The STM32Cube™ HAL, STM32 abstraction layer embedded software ensuring maximized portability across the
STM32 portfolio.
Low-layer APIs (LL) offering a fast light-weight expert-oriented layer which is closer to the hardware than the HAL. LL
APIs are available only for a set of peripherals
A consistent set of middleware components such as RTOS, USB, STMTouch and FatFS
All embedded software utilities, delivered with a full set of examples.
This user manual describes how to get started with the STM32CubeL0 MCU Package.
Section 1 describes the main features of STM32CubeL0 MCU Package.
Section 2 and Section 3 provide an overview of the STM32CubeL0 architecture and MCU Package structure.
Getting started with STM32CubeL0 for STM32L0 Series
UM1754
User manual
UM1754 - Rev 6 - October 2018
For further information contact your local STMicroelectronics sales office.
www.st.com
arm AL and LL APls
1STM32CubeL0 main features
The STM32CubeL0 MCU Package runs on STM32 32-bit microcontrollers based on the Arm® Cortex® -M
processor.
STM32CubeL0 gathers together, in a single package, all the generic embedded software components required to
develop an application on STM32L0 Series microcontrollers. In line with the STM32Cube™ initiative, this set of
components is highly portable, not only within the STM32L0 Series but also to other STM32 series.
STM32CubeL0 is fully compatible with STM32CubeMX code generator that allows the user to generate
initialization code. The package includes the low-layer (LL) and the hardware abstraction layer (HAL) APIs that
cover the microcontroller hardware, together with an extensive set of examples running on STMicroelectronics
boards. The HAL and LL APIs are available in an open-source BSD license for user convenience.
The STM32CubeL0 MCU Package also contains a set of middleware components with the corresponding
examples. They come with very permissive license terms:
Full USB device stack supporting many classes
Device classes: HID, MSC, CDC, DFU
CMSIS-RTOS implementation with FreeRTOS™ open source solution
FAT file system based on open source FatFS solution
STMTouch touch sensing solutions
A demonstration implementing all these middleware components is also provided in the STM32CubeL0 MCU
Package.
Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
Figure 1. STM32CubeL0 firmware components
Application level demonstrations
Utilities
Middleware level(1)
HAL and LL APIs
(1) The set of middleware components depends on the product Series.
User
application
Evaluation
boards
Discovery
boards
STM32 Nucleo
boards
Dedicated
boards
FatFS RTOS
USB
Hardware abstraction layer APIs
(HAL)
Board Support Package (BSP) Low-lAyer APIs (LL)
Utilities
CMSIS
Touch library
UM1754
STM32CubeL0 main features
UM1754 - Rev 6 page 2/22
2STM32CubeL0 architecture overview
The STM32CubeL0 firmware solution is built around three independent levels that can easily interact with each
other as described in the following figure.
Figure 2. STM32CubeL0 firmware architecture
Evaluation board and Discovery Kit demonstration
Applications
Library and protocol based components
(for example FatFS, FreeRTOS, USB Device)
Examples
BSP drivers
Core drivers (optional)
Hardware abstraction layer (HAL)
HAL
Level 0
Level 1
Level 2
Low Layer (LL)
2.1 Level 0
This level is divided into three sub-layers:
Board support package (BSP)
Hardware abstraction layer (HAL)
HAL peripheral drivers
Low-layer drivers
Basic peripheral usage examples
2.1.1 Board support package (BSP)
This layer offers a set of APIs related to the hardware components on the hardware boards (such as LCD drivers,
microSD™) and composed of two parts:
• Component
This is the driver relative to the external device on the board and not to the STM32. The component driver
provides specific APIs to the BSP driver external components and can be ported to any other board.
BSP driver
UM1754
STM32CubeL0 architecture overview
UM1754 - Rev 6 page 3/22
it allows linking the component driver to a specific board and provides a set of user-friendly APIs. The API naming
rule is BSP_FUNCT_Action().
Examples: BSP_LED_Init(), BSP_LED_On()
The BSP is based on a modular architecture allowing an easy porting on any hardware by just implementing the
low level routines.
2.1.2 Hardware abstraction layer (HAL) and low layer (LL)
The STM32CubeL0 HAL and LL are complementary and cover a wide range of applications requirements:
The HAL drivers offer high-level function-oriented highly-portable APIs. They hide the MCU and peripheral
complexity to end user.
The HAL drivers provide generic multi-instance feature-oriented APIs which simplify user application
implementation by providing ready to use process. As example, for the communication peripherals (I2S,
UART…), it provides APIs allowing initializing and configuring the peripheral, managing data transfer based
on polling, interrupt or DMA process, and handling communication errors that may raise during
communication.
The HAL driver APIs are split in two categories:
Generic APIs which provides common and generic functions to all the STM32 series
Extension APIs which provides specific and customized functions for a specific family or a specific part
number.
The low-layer APIs provide low-level APIs at register level, with better optimization but less portability. They
require a deep knowledge of MCU and peripheral specifications. The LL drivers are designed to offer a fast
light-weight expert-oriented layer which is closer to the hardware than the HAL. Contrary to the HAL, LL
APIs are not provided for peripherals where optimized access is not a key feature, or for those requiring
heavy software configuration and/or complex upper-level stack (such as USB).
The LL drivers feature:
A set of functions to initialize peripheral main features according to the parameters specified in data
structures
A set of functions used to fill initialization data structures with the reset values corresponding to each
field
A function for peripheral de-initialization (peripheral registers restored to their default values)
A set of inline functions for direct and atomic register access
A full independence from HAL and capability to be used in standalone mode (without HAL drivers)
A full coverage of the supported peripheral features.
2.1.3 Basic peripheral usage examples
This layer includes the examples build over the STM32 peripheral and using either the HAL or/and the low-layer
drivers APIs as well as the BSP resources.
2.2 Level 1
This level is divided into two sub-layers:
Middleware components
Examples based on the middleware components.
2.2.1 Middleware components
The middleware components are a set of libraries covering USB and Device Libraries, STMTouch touch sensing,
FreeRTOS™ and FatFS. Horizontal interactions between the components of this layer is done directly by calling
the feature APIs while the vertical interaction with the low-level drivers is done through specific callbacks and
static macros implemented in the library system call interface. For example, the FatFS implements the disk I/O
driver to access microSD™ drive or the USB Mass Storage Class.
The main features of each middleware component are as follows:
USB device libraries
Several USB classes supported (Mass-Storage, HID, CDC, DFU, MSC).
Support of multi-packet transfer features that allows sending big amounts of data without splitting them
into maximum packet size transfers.
UM1754
Level 1
UM1754 - Rev 6 page 4/22
Use of configuration files to change the core and the library configuration without changing the library
code (Read Only).
RTOS and Standalone operation.
Link with low-level driver through an abstraction layer using the configuration file to avoid any
dependency between the Library and the low-level drivers.
FreeRTOS™
Open source standard.
CMSIS compatibility layer.
Tickless operation during low-power mode.
Integration with all STM32Cube middleware modules.
FAT file system
FatFS FAT open source library.
Long file name support.
Dynamic multi-drive support.
RTOS and standalone operation.
Examples with microSD™.
STM32 touch sensing library
Robust STMTouch capacitive touch sensing solution supporting proximity, touchkey, linear and rotary touch
sensors. It is based a proven surface charge transfer acquisition principle.
2.2.2 Examples based on the middleware components
Each middleware component comes with one or more examples (called also applications) showing how to use it.
Integration examples that use several middleware components are provided as well.
2.3 Level 2
This level is composed of a single layer which consist in a global real-time and graphical demonstration based on
the middleware service layer, the low-level abstraction layer and the basic peripheral usage applications for board
based features.
UM1754
Level 2
UM1754 - Rev 6 page 5/22
3STM32CubeL0 MCU Package overview
3.1 Supported STM32L0 Series devices and hardware
STM32Cube offers a highly portable hardware abstraction layer (HAL) built around a generic and modular
architecture. It allows the upper layers, such as the middleware and application layers, to implement their
functions without knowing, in-depth, the MCU used. This improves the library code re-usability and guarantees an
easy portability on other devices.
The STM32CubeL0 offers full support for all STM32L0 Series devices. The user has only to define the right macro
in stm32l0xx.h.
The following table gives the macro to define depending on the STM32L0 Series device used. This macro must
also be defined in the compiler preprocessor.
Table 1. Macros for STM32L0 Series
Macro defined in stm32l0xx.h STM32L0 Series devices
STM32L010x4 STM32L010K4, STM32L010F4
STM32L010x6 STM32L010C6
STM32L010x8 STM32L010K8, STM32L010R8
STM32L010xB STM32L010RB
STM32L011xx STM32L011K4, STM32L011G4, STM32011F4, STM32L011E4, STM32L011D4
STM32L021xx STM32L021D4, STM32L021F4, STM32L021G4, STM32L021K4
STM32L031xx STM32L031C6, STM32L031E6, STM32L031F6, STM32L031G6, STM32L031K6
STM32L041xx STM32L041C6, STM32L041K6, STM32L041G6, STM32L041F6, STM32L041E6
STM32L051xx STM32L051K8, STM32L051C6, STM32L051C8, STM32L051R6, STM32L051R8,
STM32L051K6, STM32L051T6, STM32L051T8
STM32L052xx STM32L052K6, STM32L052K8, STM32L052C6, STM32L052C8, STM32L052R6,
STM32L052R8, STM32L052T6, STM32L052T8
STM32L053xx STM32L053C6, STM32L053C8, STM32L053R6, STM32L053R8
STM32L062xx STM32L062K8
STM32L063xx STM32L063C8, STM32L063R8
STM32L071xx
STM32L071V8, STM32L071K8, STM32L071VB, STM32L071RB, STM32L071CB,
STM32L071KB, STM32L071VZ, STM32L071RZ, STM32L071CZ, STM32L071KZ,
STM32L071C8
STM32L072xx STM32L072V8, STM32L072VB, STM32L072RB, STM32L072CB, STM32L072VZ,
STM32L072RZ, STM32L072CZ, STM32L072KB, STM32L072KZ
STM32L073xx STM32L073V8, STM32L073VB, STM32L073RB, STM32L073VZ, STM32L073RZ,
STM32L073CB, STM32L073CZ
STM32L081xx STM32L081CB, STM32L081CZ, STM32L081KZ
STM32L082xx STM32L082KB, STM32L082KZ, STM32L082CZ
STM32L083xx STM32L083V8, STM32L083VB, STM32L083RB, STM32L083VZ, STM32L083RZ,
STM32L083CB, STM32L083CZ
The STM32CubeL0 features a rich set of examples and applications making it easy to understand and use any
HAL driver and/or Middleware components. These examples are running on STMicroelectronics boards as listed
in the following table:
UM1754
STM32CubeL0 MCU Package overview
UM1754 - Rev 6 page 6/22
Table 2. STM32 boards for STM32L0 Series
Board STM32L0 Series devices supported
NUCLEO-L053R8 STM32L053x8
32L0538DISCOVERY STM32L053C8
NUCLEO-L073RZ STM32L073RZ
STM32L073Z_EVAL STM32L073VZ
NUCLEO-L031K6 STM32L031K6
NUCLEO-L011K4 STM32L011K4
NUCLEO-L010RB STM32L010RB
As for all other STM32 Nucleo boards, the NUCLEO-L053R8 and NUCLEO-L073RZ feature a reduced set of
hardware components (one user Key button and one user LED). To enrich the middleware support offer for
STM32CubeL0 firmware package, an LCD display Adafruit Arduino™ shield was chosen, which embeds in
addition to the LCD a µSD connector and a Joystick. The NUCLEO-L031K6 and NUCLEO-L011K4 boards are
Nucleo-32 boards, a new format for 32 pins component.
The STM32CubeL0 family supports now both Nucleo-32 and Nucleo-64 boards.
Nucleo-64 boards support Adafruit LCD display Arduino™ UNO shields which embedded microSD™
connector and a joystick in addition to the LCD
Nucleo-32 boards support Gravitech 7-segment display Arduino™ NANO shield which allows displaying up
to four-digit numbers and characters
The Arduino™ shield drivers are provided within the BSP component. Their usage is illustrated by a
demonstration firmware.
In the BSP component the dedicated drivers, for that Arduino™ shield are available and their use is illustrated
through either the provided BSP example or in the Demonstration firmware, without forgetting the FatFS
middleware application.
The STM32CubeL0 MCU Package is able to run on any compatible hardware. The users can simply update the
BSP drivers to port the provided examples to their own board, providing it has the same hardware functions (for
example LED, pushbuttons).
UM1754
Supported STM32L0 Series devices and hardware
UM1754 - Rev 6 page 7/22
a smaumjm a STM32_USB_Demee_Lmy MLKILEO-LOIORE MLKlEO-Lm “(A UH Nucuzounms magnum mummy: H\D_§avdawe_LPM . MnnJ‘hnm mum- Emu- Tumm- 1mg ‘ O my”: Mucusmomz swazmrmavu km,- mum. am 1% 1mm; Mae mm m :93 EUUUAU 0 [9:93 a“ m i g? E. sigm O fink-lqux-nrll swam: Pmmmm |:|
3.2 MCU Package overview
The STM32CubeL0 firmware solution is provided in one single zip package having the structure shown in the
following figure.
Figure 3. STM32CubeL0 MCU Package structure
BSP drivers for the supported
boards:
- Evaluation board
- Discovery kit
STM32 HAL and LL drivers
Touch Sensing Library
Open source Middleware
stacks
Miscellaneous utilities
USB Device Library offering
the following classes: HID,
MSC, CDC and DFU
Contains STM32L0xx CMSIS files
that define peripheral’s registers
declarations, bits definition and the
address mapping
Set of examples, applications and
demonstrations organized by board
and provided with preconfigured
projects
Library files, to not be modified by user
User modifiable files
For each board, a set of examples are provided with pre-configured projects for EWARM, MDK-ARM and
SW4STM32 toolchains.
the following figure shows the project structure for the NUCLEO-L053R8 board. The structure is identical for any
other additional supported board.
UM1754
MCU Package overview
UM1754 - Rev 6 page 8/22
El I Med: BZLDSJSDISUJVERY NLquLmoaa NUCLm-Lfll 1 K4 NLKILED-LDS‘KB ‘UART
Figure 4. STM32CubeL0 example overview
The examples are classified depending on the STM32Cube level they apply to, and are named as follows:
Examples in level 0 are called Examples, Examples_LL and Examples_MIX. They use respectively HAL
drivers, LL drivers and a mix of HAL and LL drivers without any middleware component
Examples in level 1 are called Applications, that provide typical use cases of each Middleware component
Examples in level 2 are called Demonstration, that implement all the HAL, BSP and Middleware components
The template project available in the "Templates" and "Templates_LL" directories allows to quickly build any
firmware application on a given board.
All examples have the same structure,
\Inc folder that contains all header files
\Src folder for the sources code
\EWARM, \MDK-ARM and \SW4STM32 folders containing the pre-configured project for each toolchain
readme.txt describing the example behavior and the required environment to make it work
The list of examples provided in the STM32CubeL0 package is available in the STM32Cube_FW_L0_VX.Y.Z/
Projects/STM32CubeProjectsList.html file.
The following table gives the number of projects available for each board.
UM1754
MCU Package overview
UM1754 - Rev 6 page 9/22
Table 3. Number of examples for each board
Level NUCLEO-
L031K6
NUCLEO-
L010RB
STM32L073Z
_EVAL
NUCLEO-
L011K4
32L0538
DISCOVERY
NUCLEO-
L053R8
NUCLEO-
L073RZ Total
Templates_LL 1 1 1 1 1 1 1 7
Templates 1 1 1 1 1 1 1 7
Examples_MIX 0 0 0 0 0 0 11 11
Examples_LL 0 0 0 0 0 0 82 82
Examples 56 11 75 50 57 72 64 385
Demonstrations 1 0 1 1 1 1 1 6
Applications 10 0 21 0 15 17 10 73
Total 69 13 99 53 75 92 170 571
UM1754
MCU Package overview
UM1754 - Rev 6 page 10/22
4Getting started with STM32CubeL0
4.1 Running your first example
This section explains how to run a first example with STM32CubeL0, using as illustration the generation of a
simple LED toggle running on the NUCLEO-L053R8 board:
1. Download the STM32CubeL0 MCU Package. Unzip the package into a directory. Make sure not to modify
the package structure shown in Figure 3. STM32CubeL0 MCU Package structure
2. Browse to \Projects\STM32L053R8-Nucleo\Examples
3. Open the \GPIO folder, then open the \GPIO_EXTI folder
4. Open the project by selecting preferred toolchain
5. Rebuild all files and load the generated image into the target memory
6. Run the example: each time the Key push button is pressed, the LED2 toggles (for more details, refer to the
example readme file).
Below is a quick overview on how to open, build and run an example with the supported toolchains.
• EWARM
1. Under the example folder, open the \EWARM sub folder
2. Open the Project.eww workspace (1)
3. Rebuild all files: Project->Rebuild all
4. Load the project image: Project->Debug
5. Run the program: Debug->Go (F5)
• MDK-ARM
1. Under the example folder, open the \MDK-ARM sub folder
2. Open the Project.uvproj workspace(1)
3. Rebuild all files: Project->Rebuild all target files
4. Load the project image: Debug->Start/Stop Debug Session
5. Run the program: Debug->Run (F5)
• SW4STM32
1. Open the \SW4STM32 toolchain
2. Click on File->Switch Workspace->Other and browse to the SW4STM32 workspace directory
3. Click on File->Import, select General->Existing Projects into Workspace and then click Next
4. Browse to the SW4STM32 workspace directory and select the project
5. Rebuild all project files: select the project in the “Project explorer” window then click on Project-
>build project menu
6. Run program: Run->Debug (F11)
1. The workspace name may change from one example to another
UM1754
Getting started with STM32CubeL0
UM1754 - Rev 6 page 11/22
4.2 Developing your own application
4.2.1 HAL application
This section describes the steps required to create your own HAL application using STM32CubeL0:
1. Create your project: to create a new project, it is possible to start from the Template project provided for
each board under \Projects\<STM32xx_xxx>\Templates or from any available project under
\Projects\<STM32xx_xxx>\Examples or \Projects\STM32xx_xxx\Applications
(<STM32xx_xxx> refers to the board name, for example STM32L053R8).
The Template project provides an empty main loop function. It is a good starting point to get familiar with the
project settings forSTM32CubeL0. The template has the following characteristics:
a. It contains source code of the HAL, CMSIS and BSP drivers, that are the minimum components
required to develop a code on a given board.
b. It contains the include paths for all the firmware components.
c. It defines the STM32L0 Series device supported and allows configuring the CMSIS and HAL drivers
accordingly.
d. It provides ready-to-use user files, that are pre-configured as follows:
HAL is initialized
SysTick ISR implemented for HAL_Delay() purpose
System clock is configured with the minimum frequency of the device (MSI) and though for an
optimum power consumption.
Note: When copying an existing project to another location, make sure to update the include paths
2. Add the necessary middleware to the project (optional): the available Middleware stacks are: USB
Device Libraries, STMTouch touch library, FreeRTOS™ and FatFS. To find out which source files are
needed to add to the project files list, refer to the documentation provided for each Middleware. It is possible
also to look at the applications available under \Projects\STM32xx_xxx\Applications\<MW_Stack>
(<MW_Stack> refers to the Middleware stack, for example USB_Device) to get a better idea of the source
files to be added and the include paths.
3. Configure the firmware components: the HAL and Middleware components offer a set of build time
configuration options using macros declared with “#define” in a header file. A template configuration file is
provided within each component, which has to be copied into to the project folder (usually the configuration
file is named xxx_conf_template.h. Make sure to remove the word “_template” when copying the file to the
project folder). The configuration file provides enough information to know the effect of each configuration
option. More detailed information is available in the documentation provided for each component.
4. Start the HAL Library: after jumping to the main program, the application code needs to call HAL_Init() API
to initialize the HAL Library and do the following:
a. Configure the Flash prefetch, instruction and data caches (user-configurable by macros defined in
stm32l0xx_hal_conf.h)
b. Configure the Systick to generate an interrupt every 1 msec, which is clocked by the MSI, this the
default configuration after reset (at this stage, the clock is not yet configured and thus the system is
running from the internal 4 MHz MSI).
c. Call the HAL_MspInit() callback function defined in the user file stm32l0xx_hal_msp.c to do the global
low-level hardware initialization
5. Configure the system clock: the system clock configuration is set by calling the two following APIs
a. HAL_RCC_OscConfig(): configures the internal and/or external oscillators, PLL source and factors.
The user can choose to configure one oscillator or all oscillators. The user can also skip the PLL
configuration if there is no need to run the system at high frequency
b. HAL_RCC_ClockConfig(): configures the system clock source, Flash latency and AHB and APB
prescalers.
Note: Prior to configuring the system clock, it is recommended to enable the power controller clock, and to configure
the appropriate voltage scaling, and therefore to optimize the power consumption when the system is clocked
below the maximum allowed frequency.
6. Initialize the peripheral
a. Start by writing the peripheral HAL_PPP_MspInit function. For this function, proceed as follows:
UM1754
Developing your own application
UM1754 - Rev 6 page 12/22
Enable the peripheral clock
Configure the peripheral GPIOs
Configure DMA channel and enable DMA interrupt (if needed).
Enable peripheral interrupt (if needed)
b. Edit the stm32xxx_it.c to call required interrupt handlers (peripheral and DMA), if needed
c. Write process complete callback functions if peripheral interrupt or DMA has to be used
d. In the main.c file, initialize the peripheral handle structure then call the function HAL_PPP_Init() to
initialize the peripheral
7. Develop custom application:At this stage, the system is ready and development of an application code
can started.
a. The HAL provides intuitive and ready-to-use APIs to configure the peripheral, and supports polling,
interrupt and DMA programming models, to accommodate any application requirements. For more
details on how to use each peripheral, refer to the extensive set of examples provided.
b. If the application has some real-time constraints, a large set of examples are available showing how to
use FreeRTOS™ and how integrate it with all Middleware stacks provided in STM32CubeL0. This can
be a good starting point for development.
Caution: In the default HAL implementation, Systick timer is the source of time base. It is used to generate interrupts at
regular time intervals. Take care if HAL_Delay() is called from peripheral ISR process. The SysTick interrupt
must have higher priority (numerically lower) than the peripheral interrupt. Otherwise, the caller ISR process is
blocked. Functions affecting time base configurations are declared as __Weak to make override possible in case
of other implementations in user file (using a general purpose timer for example or other time source), for more
details refer to HAL_TimeBase example.
4.2.2 LL application
This section describes the steps needed to create your own LL application using STM32CubeL0.
1. Create your project
To create a new project, it is possible to start either from the Templates_LL project provided for each board
under \Projects\<STM32xxx_yyy>\Templates_LL or from any available project under \Projects
\<STM32xxy_yyy>\Examples_LL (<STM32xxx_yyy> refers to the board name, such as
STM32L073Z_EVAL).
The template project provides an empty main loop function, however it is a good starting point to get familiar
with project settings for STM32CubeL0.
The template main characteristics are listed below:
a. It contains the source code of LL and CMSIS drivers, that are the minimal components to develop a
code on a given board.
b. It contains the include paths for all the required firmware components.
c. It selects the supported STM32L0 Series device and allows configuring the CMSIS and LL drivers
accordingly.
d. It provides ready-to-use user files, that are pre-configured as follows:
main.h: LED & USER_BUTTON definition abstraction layer
main.c: System clock configured with the minimum frequency of the device (HSI) for an optimum
power consumption.
2. Port an existing project to another board
To port an existing project to another target board, start from the Templates_LL project provided for each
board and available under \Projects\<STM32xxx_yyy>\Templates_LL:
a. Select an LL example
To find the board on which LL examples are deployed, refer to the list of LL examples in
STM32CubeProjectsList.html, to Table 3. Number of examples for each board, or to the application
note “STM32Cube firmware examples for STM32L0 Series” (AN4725).
b. Port the LL example
Copy/paste the Templates_LL folder to keep the initial source or directly update the existing
Templates_LL project.
Then LL example porting consists mainly in replacing the Templates_LL files by the Examples_LL
targeted.
UM1754
Developing your own application
UM1754 - Rev 6 page 13/22
Keep all board specific parts. For reasons of clarity, the board specific parts have been flagged
with specific tags:
/* ====== BOARD SPECIFIC CONFIGURATION CODE BEGIN =========== */
/* ======BOARD SPECIFIC CONFIGURATION CODE END ============= */
Thus the main porting steps are the following:
Replace stm32l0xx_it.h file
Replace stm32l0xx_it.c file
Replace main.h file and update it: keep the LED and user button definition of the LL template
under "BOARD SPECIFIC CONFIGURATION" tags.
Replace main.c file, and update it:
- Keep the clock configuration of the SystemClock_Config() LL template: function under
"BOARD SPECIFIC CONFIGURATION" tags.
- Depending on LED definition, replace all LEDx_PIN by another LEDx (number) available in
main.h file.
Thanks to these adaptations, the example should be functional on the targeted board.
4.3 Using STM32CubeMX to generate the initialization C code
An alternative to steps 1 to 6 described in Section 4.2 Developing your own application consists in using the
STM32CubeMX tool to generate code for the initialization of the system, the peripherals and middleware (Steps 1
to 5 above) through a step-by-step process:
1. Select the STMicroelectronics STM32 microcontroller that matches the required set of peripherals.
2. Configure each required embedded software thanks to a pinout-conflict solver, a clock-tree setting helper, a
power consumption calculator, and the utility performing MCU peripheral configuration (for example GPIO,
USART) and middleware stacks (for example USB).
3. Generate the initialization C code based on the configuration selected. This code is ready to use within
several development environments. The user code is kept at the next code generation.
For more information, refer to STM32CubeMX user manual (UM1718).
4.4 Getting STM32CubeL0 release updates
The STM32CubeL0 MCU Package comes with an updater utility: STM32CubeUpdater, also available as a menu
within STM32CubeMX code generation tool.
The updater solution detects new firmware releases and patches available from www.st.com and proposes to
download them to the user’s computer.
4.4.1 Installing and running the STM32CubeUpdater program
Double-click on the SetupSTM32CubeUpdater.exe file to launch the installation.
Accept the license terms and follow the different installation steps.
Upon successful installation, STM32CubeUpdater becomes available as an STMicroelectronics program under
program files and is automatically launched.
The STM32CubeUpdater icon appears in the system tray:
Right-click the updater icon and select Updater settings to configure the Updater connection and whether
to perform manual or automatic checks. For more details on Updated configuration, refer to section 3 of
STM32CubeMX User manual (UM1718).
UM1754
Using STM32CubeMX to generate the initialization C code
UM1754 - Rev 6 page 14/22
5FAQs
5.1 What is the license scheme for the STM32CubeL0 MCU Package?
The HAL is distributed under a non-restrictive BSD (Berkeley software distribution) license.
The middleware stacks made by ST (USB device libraries, STMTouch touch library) come with a licensing model
allowing easy reuse, provided it runs on an ST device.
The middleware based on well-known open-source solutions (FreeRTOS™ and FatFS) have user-friendly license
terms. For more details, refer to the license agreement of each Middleware.
5.2 What boards are supported by the STM32CubeL0 MCU Package?
The STM32CubeL0 MCU Package provides BSP drivers and ready-to-use examples for the NUCLEO-L053R8,
NUCLEO-L073RZ, NUCLEO-L011K4, NUCLEO-L031K6, STM32L073Z_EVAL and 32L0538DISCOVERY boards.
For the up-to-date list of supported boards, refer to the firmware package release notes.
5.3 Are any examples provided with the ready-to-use toolset projects?
Yes. STM32CubeL0 provides a rich set of examples and applications. They come with the pre-configured projects
of several toolsets: IAR™, Keil® and GCC.
5.4 Is there any link with standard peripheral libraries?
The STM32Cube HAL and LL drivers are the replacement of the standard peripheral library:
The HAL drivers offer a higher abstraction level compared to the standard peripheral APIs. They focus on
peripheral common features rather than hardware. Their higher abstraction level allows defining a set of
user-friendly APIs that can be easily ported from one product to another.
The LL drivers offer low-level APIs at registers level. They are organized in a simpler and clearer way than
direct register accesses. LL drivers also include peripheral initialization APIs, which are more optimized
compared to what is offered by the SPL, while being functionally similar. Compared to HAL drivers, these LL
initialization APIs allows an easier migration from the SPL to the STM32Cube LL drivers, since each SPL
API has its equivalent LL API(s).
5.5 Does the HAL take benefit from interrupts or DMA? How can this be
controlled?
Yes. The HAL supports three API programming models: polling, interrupt and DMA (with or without interrupt
generation).
5.6 How are the product/peripheral specific features managed?
The HAL offers extended APIs, i.e. specific functions as add-ons to the common API to support features available
on some products/lines only.
5.7 How can STM32CubeMX generate code based on embedded software?
STM32CubeMX has a built-in knowledge of STM32 microcontrollers, including their peripherals and software.
This enables the tool to provide a graphical representation to the user and generate *.h/*.c files based on user
configuration.
5.8 How to get regular updates on the latest STM32CubeL0 firmware releases?
The STM32CubeL0 MCU Package comes with an updater utility, STM32CubeUpdater, that can be configured for
automatic or on-demand checks for new MCU Package updates (new releases or/and patches).
STM32CubeUpdater is integrated as well within the STM32CubeMX tool. When using this tool for STM32L0
configuration and initialization C code generation, the user can benefit from STM32CubeMX self-updates as well
as STM32CubeL0 MCU Package updates.
For more details, refer to Section 4.4 Getting STM32CubeL0 release updates.
UM1754
FAQs
UM1754 - Rev 6 page 15/22
5.9 When should I use HAL versus LL drivers?
HAL drivers offer high-level and function-oriented APIs, with a high level of portability. Product/IPs complexity is
hidden for end users.
LL drivers offer low-level APIs at registers level, with a better optimization but less portability. They require a deep
knowledge of product/IPs specifications.
5.10 How can I include LL drivers in my environment? Is there any LL configuration
file as for HAL?
There is no configuration file. Source code shall directly include the necessary stm32l0xx_ll_ppp.h file(s).
5.11 Can I use HAL and LL drivers together? If yes, what are the constraints?
It is possible to use both HAL and LL drivers. One can handle the IP initialization phase with HAL and then
manage the I/O operations with LL drivers.
The major difference between HAL and LL is that HAL drivers require to create and use handles for operation
management while LL drivers operates directly on peripheral registers. Mixing HAL and LL is illustrated in
Examples_MIX example.
5.12 Is there any LL APIs which are not available with HAL?
Yes, there are.
A few Cortex® APIs have been added in stm32l0xx_ll_cortex.h e.g. for accessing SCB or SysTick registers.
5.13 Why are SysTick interrupts not enabled on LL drivers?
When using LL drivers in standalone mode, SysTick interrupts has not to be enabled because they are not used
in LL APIs, while HAL functions requires SysTick interrupts to manage timeouts.
5.14 How are LL initialization APIs enabled?
The definition of LL initialization APIs and associated resources (structure, literals and prototypes) is conditioned
by the USE_FULL_LL_DRIVER compilation switch.
UM1754
When should I use HAL versus LL drivers?
UM1754 - Rev 6 page 16/22
Revision history
Table 4. Document revision history
Date Revision Changes
24-Apr-2014 1 Initial release.
27-Feb-2015 2
Extended the applicability to STM32L073Z-EVAL and NUCLEO-L073RZ boards for STM32L073xx
and STM32L083xx device families, respectively.
Updated:
Table 1. Macros for STM32L0 Series,
Table 2. STM32 boards for STM32L0 Series
the list of available STM32 Nucleo boards in Section 3.1 Supported STM32L0 Series devices
and hardware,
Figure 3. STM32CubeL0 MCU Package structure,
the sentence introducing Figure 4. STM32CubeL0 example overview,
Figure 4. STM32CubeL0 example overview,
the sentence introducing Table 3.
13-Nov-2015 3
Introduction of the STM32L031xx and STM32L011xx devices. Addition of new boards: NUCLEO-
L031K6, NUCLEO-L011K4.
Updated:
Table 1. Macros for STM32L0 Series
Table 2. STM32 boards for STM32L0 Series
Figure 3. STM32CubeL0 MCU Package structure
24-May-2016 4
Added Low Layer (LL) drivers
Figure 1. STM32CubeL0 firmware components
Figure 2. STM32CubeL0 firmware architecture
Figure 3. STM32CubeL0 MCU Package structure
Figure 4. STM32CubeL0 example overview
Removed table of available examples, applications and demonstrations
FAQ updated
21-Nov-2016 5
Updated Section 3.2 MCU Package overview:
Updated Figure 4. STM32CubeL0 example overview.
Added Table 3. Number of examples for each board.
Added Section 4.2.2 LL application.
29-Oct-2018 6
Updated :
Table 1. Macros for STM32L0 Series.
Figure 1. STM32CubeL0 firmware components.
Table 2. STM32 boards for STM32L0 Series.
Table 3. Number of examples for each board.
Figure 3. STM32CubeL0 MCU Package structure
Figure 4. STM32CubeL0 example overview.
Modified LL APIs preferred spelling to low-layer APIs.
Removed reference to TrueSTUDIO in the whole document.
UM1754
UM1754 - Rev 6 page 17/22
Contents
1STM32CubeL0 main features.......................................................2
2STM32CubeL0 architecture overview...............................................3
2.1 Level 0 .......................................................................3
2.1.1 Board Support Package (BSP) ..............................................3
2.1.2 Hardware abstraction layer (HAL) and low layer (LL) .............................4
2.1.3 Basic peripheral usage examples ............................................4
2.2 Level 1 .......................................................................4
2.2.1 Middleware components ...................................................4
2.2.2 Examples based on the middleware components ................................5
2.3 Level 2 .......................................................................5
3STM32CubeL0 MCU Package overview.............................................6
3.1 Supported STM32L0 Series devices and hardware ..................................6
3.2 MCU Package overview .........................................................8
4Getting started with STM32CubeL0 ...............................................11
4.1 Running your first example .....................................................11
4.2 Developing your own application.................................................12
4.2.1 HAL application.........................................................12
4.2.2 LL application ..........................................................13
4.3 Using STM32CubeMX to generate the initialization C code ..........................14
4.4 Getting STM32CubeL0 release updates ..........................................14
4.4.1 Installing and running the STM32CubeUpdater program..........................14
5FAQs .............................................................................15
5.1 What is the license scheme for the STM32CubeL0 MCU Package? ...................15
5.2 What boards are supported by the STM32CubeL0 MCU Package? ...................15
5.3 Are any examples provided with the ready-to-use toolset projects?....................15
5.4 Is there any link with standard peripheral libraries? .................................15
5.5 Does the HAL take benefit from interrupts or DMA? How can this be controlled? ........15
5.6 How are the product/peripheral specific features managed?..........................15
5.7 How can STM32CubeMX generate code based on embedded software? ..............15
UM1754
Contents
UM1754 - Rev 6 page 18/22
5.8 How to get regular updates on the latest STM32CubeL0 firmware releases?............15
5.9 When should I use HAL versus LL drivers?........................................15
5.10 How can I include LL drivers in my environment? Is there any LL configuration file as for
HAL?........................................................................16
5.11 Can I use HAL and LL drivers together? If yes, what are the constraints? ..............16
5.12 Is there any LL APIs which are not available with HAL? .............................16
5.13 Why are SysTick interrupts not enabled on LL drivers? ..............................16
5.14 How are LL initialization APIs enabled? ...........................................16
Revision history .......................................................................17
Contents ..............................................................................18
List of tables ..........................................................................20
List of figures..........................................................................21
UM1754
Contents
UM1754 - Rev 6 page 19/22
List of tables
Table 1. Macros for STM32L0 Series ............................................................6
Table 2. STM32 boards for STM32L0 Series .......................................................7
Table 3. Number of examples for each board...................................................... 10
Table 4. Document revision history ............................................................. 17
UM1754
List of tables
UM1754 - Rev 6 page 20/22
List of figures
Figure 1. STM32CubeL0 firmware components ....................................................2
Figure 2. STM32CubeL0 firmware architecture.....................................................3
Figure 3. STM32CubeL0 MCU Package structure...................................................8
Figure 4. STM32CubeL0 example overview .......................................................9
UM1754
List of figures
UM1754 - Rev 6 page 21/22
IMPORTANT NOTICE – PLEASE READ CAREFULLY
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST
products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST
products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of
Purchasers’ products.
No license, express or implied, to any intellectual property right is granted by ST herein.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.
© 2018 STMicroelectronics – All rights reserved
UM1754
UM1754 - Rev 6 page 22/22

Products related to this Datasheet

NUCLEO-32 STM32L031K6 EVAL BRD
NUCLEO-32 STM32L011K4 EVAL BRD