Escolar Documentos
Profissional Documentos
Cultura Documentos
User manual
Getting started with STM32CubeF0 for STM32F0 series
Introduction
The STMCubeTM initiative was originated by STMicroelectronics to ease developers life by
reducing development efforts, time and cost. STM32Cube covers the STM32 portfolio.
STM32Cube Version 1.x includes:
The STM32CubeMX, a graphical software configuration tool that allows the generation
of C initialization code using graphical wizards.
This user manual describes how to get started with the STM32CubeF0 firmware package.
Section 1 describes the main features of STM32CubeF0 firmware which is part of the
STM32Cube initiative. Section 2 and Section 3 provide an overview of the STM32CubeF0
architecture and firmware package structure.
June 2014
DocID026464 Rev 1
1/21
www.st.com
Contents
UM1779
Contents
1
3.1
3.2
4.2
4.3
4.4
2/21
FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
DocID026464 Rev 1
UM1779
List of tables
List of tables
Table 1.
Table 2.
Table 3.
Table 4.
DocID026464 Rev 1
3/21
3
List of figures
UM1779
List of figures
Figure 1.
Figure 2.
Figure 3.
Figure 4.
4/21
DocID026464 Rev 1
UM1779
Full USB Device stack supporting many classes: Audio, HID, MSC, CDC and DFU.
(YDOXDWLRQERDUGV
'LVFRYHU\ERDUGV
6701XFOHR
ERDUGV
8WLOLWLHV
$SSOLFDWLRQOHYHOGHPRQVWUDWLRQV
7&3,3
86%
7RXFK
/LEUDU\
*UDSKLFV
)$7ILOH
V\VWHP
0LGGOHZDUHOHYHO
5726
&06,6
8WLOLWLHV
+DUGZDUH$EVWUDFWLRQ/D\HU+$/
%RDUG6XSSRUW3DFNDJH%63
+$/OHYHO
670)
670)
670)
670)
670)
670/
670/
+DUGZDUH
06Y9
DocID026464 Rev 1
5/21
20
UM1779
>
$SSOLFDWLRQV
>
/LEUDU\DQGSURWRFROEDVHGFRPSRQHQWV
IRUH[DPSOH)DW)6)UHH572686%'HYLFH
([DPSOHV
%63GULYHUV
>
+$/SHULSKHUDOGULYHUV
/RZOHYHO'ULYHU&RUHRSWLRQDO
,>
06Y9
6/21
DocID026464 Rev 1
UM1779
Level 0
This level is divided into three sub-layers:
Component: this is the driver relative to the external device on the board and not
related to the STM32. The component driver provides specific APIs to the BSP
driver external components and can be ported on any other board.
BSP driver: it permits to link the component driver to a specific board and
provides a set of user-friendly APIs. The APIs naming rule is
BSP_FUNCT_Action():
Example: BSP_LED_Init(), BSP_LED_On()
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.
Level 1
This level is divided into two sub-layers:
Middleware components
Set of Libraries covering USB Device library, STMTouch touch sensing library,
FreeRTOS and FatFS. Horizontal interactions between the components of this layer is
performed 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
DocID026464 Rev 1
7/21
20
UM1779
library system call interface. As 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 Library
Support of multi-packet transfer features that allows sending big amounts of data
without splitting them into maximum packet size transfers.
Use of configuration files to change the core and the library configuration without
changing the library code (Read Only).
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
Level 2
This level is composed of a single layer which consist in a global real-time graphical
demonstration based on the middleware service layer, the low level abstraction layer and
the basic peripheral usage applications for board based features.
8/21
DocID026464 Rev 1
UM1779
3.1
STM32F0 devices
STM32F030x6
STM32F030x8
STM32F030C8, STM32F030R8
STM32F031x6
STM32F051x8
STM32F071xB
STM32F042x6
STM32F072xB
STM32F038xx
STM32F048xx
STM32F058xx
STM32F078xx
STM32CubeF0 features a rich set of examples and applications at all levels making it easy
to understand and use any HAL driver and/or middleware components. These examples run
on the STMicroelectronics boards listed in Table 2.
DocID026464 Rev 1
9/21
20
UM1779
STM32072B-EVAL
STM32F072xB
STM32F072B-Discovery
STM32F072xB
STM32F0308-Discovery
STM32F030x8
NUCLEO-F072RB
STM32F072xB
NUCLEO-F030R8
STM32F030x8
As for all other STM32 Nucleo boards, the NUCLEO-F072RB and NUCLEO-F030R8
feature a reduced set of hardware components (one user key button and one user LED). To
enrich the middleware support offer for the STM32CubeF0 firmware package, an LCD
display Adafruit Arduino shield is used. This shield embeds a SD connector and a joystick
in addition to the LCD.
In the BSP component, the dedicated drivers for the Arduino shield are available. Their use
is illustrated through either the provided BSP example or in the demonstration firmware,
without forgetting the FatFS middleware application.
The STM32CubeF0 firmware can run on any compatible hardware. The user simply update
the BSP drivers to port the provided examples on his/her own board, if this later has the
same hardware features (LED, LCD display, buttons).
10/21
DocID026464 Rev 1
UM1779
3.2
%63GULYHUVIRUWKHVXSSRUWHGERDUGV
(YDOXDWLRQERDUG
'LVFRYHU\NLW
1XFOHRNLW
'ULYHUVRIH[WHUQDOFRPSRQHQWV
&RQWDLQV670)[[
&06,6ILOHVWKDWGHILQHWKH
SHULSKHUDOUHJLVWHU
GHFODUDWLRQVELWGHILQLWLRQV
DQGDGGUHVVPDSSLQJ
670)[[ +$/ GULYHUV IRU DOO
SHULSKHUDOV
7RXFK6HQVLQJOLEUDU\
86% 'HYLFH /LEUDU\ RIIHULQJ WKH
IROORZLQJ FODVVHV +,' 06& &'&
DQG')8
2SHQVRXUFHVPLGGOHZDUHVWDFNV
6HWRI([DPSOHV$SSOLFDWLRQVDQG
'HPRQVWUDWLRQVRUJDQL]HGE\
ERDUGDQGSURYLGHGZLWK
SUHFRQILJXUHGSURMHFWVXVHU
PRGLILDEOHILOHV
0LVFHOODQHRXVXWLOLWLHV
06Y9
1. The components files must not be modified by the user. Only the \Projects sources can be changed by the
user.
DocID026464 Rev 1
11/21
20
UM1779
For each board, a set of examples are provided with pre-configured projects for EWARM,
MDK-ARM and TrueSTUDIO toolchains.
Figure 4 shows the projects structure for the STM32072B-EVAL board.
Figure 4. STM32CubeF0 examples overview
12/21
DocID026464 Rev 1
UM1779
Examples in level 0 are called Examples. They use the HAL drivers without any
middleware component.
Examples in level 1 are called Applications.They provide typical use cases for each
middleware component and can call several HAL drivers.
The Template project available in the Template directory allows to quickly build any firmware
application on a given board.
All examples have the same structure:
\EWARM, \MDK-ARM and \TrueSTUDIO folders that contain the pre-configured project
for each toolchain
Examples
Applications
Demonstration
STM32072B_EVAL
40
16
N/A
STM32F072BDiscovery
43
STM32F0308Discovery
28
STM32F072RB-Nucleo
41
STM32F030R8-Nucleo
29
DocID026464 Rev 1
13/21
20
UM1779
4.1
2.
Browse to \Projects\STM32F072RB-Nucleo\Examples.
3.
4.
Open the project with your preferred toolchain. A quick overview on how to open, build
and run an example with the supported toolchains is given below.
5.
Rebuild all files and load your image into target memory.
6.
Run the example: each time you press the USER push button, the LED2 toggles (for
more details, refer to the example readme file).
To open, build and run an example with the supported toolchains, follow the steps below:
a.
14/21
EWARM
a)
b)
c)
d)
e)
MDK-ARM
a)
b)
c)
d)
e)
TrueSTUDO
a)
b)
c)
d)
e)
Rebuild all project files: select the project in the "Project explorer" window then
click Project->build project menu.
f)
DocID026464 Rev 1
UM1779
4.2
It contains the sources of HAL, CMSIS and BSP drivers which are the minimal
components required to develop a code on a given board.
It defines the STM32F0 device supported, thus allowing to configure the CMSIS
and HAL drivers accordingly.
Note:
When copying an existing project to another location, make sure to update the include
paths.
2.
3.
4.
b)
DocID026464 Rev 1
15/21
20
UM1779
clocked by the HSI (at this stage, the clock is not yet configured and thus the
system runs from the internal HSI at 8 MHz)
c)
5.
6.
7.
a)
b)
HAL_RCC_ClockConfig(): this API configures the system clock source, the Flash
memory latency and AHB and APB prescalers.
Peripheral initialization
a)
b)
Edit stm32xxx_it.c file to call the required interrupt handlers (peripheral and DMA),
if needed.
c)
Write process complete callback functions if you plan to use peripheral interrupt or
DMA.
d)
In your main.c file, initialize the peripheral handle structure then call the
HAL_PPP_Init() function to initialize your peripheral.
Caution:
16/21
In the default HAL implementation, SysTick timer is time base source. It is used to generate
interrupts at regular time intervals. If HAL_Delay() is called from peripheral ISR process,
make sure that the SysTick interrupt has higher priority (numerically lower) than the
peripheral interrupt. Otherwise, the caller ISR process is blocked. Functions affecting
timebase 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 please refer to HAL_TimeBase example.
DocID026464 Rev 1
UM1779
4.3
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 clocktree 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.
4.4
4.4.1
2.
Accept the license terms and follow the different installation steps.
3.
DocID026464 Rev 1
17/21
20
FAQ
UM1779
FAQ
5.1
5.2
5.3
5.4
5.5
18/21
DocID026464 Rev 1
UM1779
5.6
FAQ
5.7
5.8
DocID026464 Rev 1
19/21
20
Revision history
UM1779
Revision history
Table 4. Document revision history
20/21
Date
Revision
17-Jun-2014
Changes
Initial release.
DocID026464 Rev 1
UM1779
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (ST) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to STs terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN STS TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
ST PRODUCTS ARE NOT DESIGNED OR AUTHORIZED FOR USE IN: (A) SAFETY CRITICAL APPLICATIONS SUCH AS LIFE
SUPPORTING, ACTIVE IMPLANTED DEVICES OR SYSTEMS WITH PRODUCT FUNCTIONAL SAFETY REQUIREMENTS; (B)
AERONAUTIC APPLICATIONS; (C) AUTOMOTIVE APPLICATIONS OR ENVIRONMENTS, AND/OR (D) AEROSPACE APPLICATIONS
OR ENVIRONMENTS. WHERE ST PRODUCTS ARE NOT DESIGNED FOR SUCH USE, THE PURCHASER SHALL USE PRODUCTS AT
PURCHASERS SOLE RISK, EVEN IF ST HAS BEEN INFORMED IN WRITING OF SUCH USAGE, UNLESS A PRODUCT IS
EXPRESSLY DESIGNATED BY ST AS BEING INTENDED FOR AUTOMOTIVE, AUTOMOTIVE SAFETY OR MEDICAL INDUSTRY
DOMAINS ACCORDING TO ST PRODUCT DESIGN SPECIFICATIONS. PRODUCTS FORMALLY ESCC, QML OR JAN QUALIFIED ARE
DEEMED SUITABLE FOR USE IN AEROSPACE BY THE CORRESPONDING GOVERNMENTAL AGENCY.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.
DocID026464 Rev 1
21/21
21