STM32Cube Firmware Examples
STM32Cube Firmware Examples
Application note
STM32Cube firmware examples for STM32F1 Series
Introduction
The STM32CubeF1 firmware package comes with a rich set of examples running on
STMicroelectronics boards. The examples are organized by board and provided with
preconfigured projects for the main supported toolchains (see Figure 1).
)$7ILOH &06,6
7&3,3 86% *UDSKLFV 5726
V\VWHP
0LGGOHZDUHOHYHO 8WLOLWLHV
+$/DQG//$3,V
7KHVHWRIPLGGOHZDUHFRPSRQHQWVGHSHQGVRQWKHSURGXFW6HULHV 069
Contents
1 Reference documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 STM32CubeF1 examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
1 Reference documents
2 STM32CubeF1 examples
The examples are classified depending on the STM32Cube level they apply to. They are
named as follows:
• Examples
The examples use only the HAL and BSP drivers (middleware not used). Their
objective is to demonstrate the product/peripherals features and usage. They are
organized per peripheral (one folder per peripheral, e.g. TIM). Their complexity level
ranges from the basic usage of a given peripheral (e.g. PWM generation using timer) to
the integration of several peripherals (e.g. how to use DAC for signal generation with
synchronization from TIM6 and DMA). The usage of the board resources is reduced to
the strict minimum.
• Examples_LL
These examples use only the LL drivers (HAL drivers and middleware components not
used). They offer an optimum implementation of typical use cases of the peripheral
features and configuration sequences. The examples are organized per peripheral
(one folder for each peripheral, e.g. TIM) and run exclusively on Nucleo board.
• Examples_MIX
These examples use only HAL, BSP and LL drivers (middleware components not
used). They aim at demonstrating how to use both HAL and LL APIs in the same
application to combine the advantages of both APIs:
– HAL offers high-level function-oriented APIs with high portability level by hiding
product/IPs complexity for end users.
– LL provides low-level APIs at register level with better optimization. The examples
are organized per peripheral (one folder for each peripheral, e.g. TIM) and run
exclusively on Nucleo board.
• Applications
The applications demonstrate the product performance and how to use the available
middleware stacks. They are organized either by middleware (a folder per middleware,
e.g. USB Host) or by product feature that require high-level firmware bricks (e.g.
Audio). The integration of applications that use several middleware stacks is also
supported.
• Demonstrations
The demonstrations aim at integrating and running the maximum number of
peripherals and middleware stacks to showcase the product features and performance.
• Template project
The template project is provided to allow quickly building a firmware application on a
given board.
The examples are located under STM32Cube_FW_F1_VX.Y.Z\Projects\. They all have the
same structure:
• \Inc folder containing all header files
• \Src folder containing the sources code
• \EWARM, \MDK-ARM, \SW4STM32 and \TrueSTUDIO folders containing the
preconfigured project for each toolchain.
• readme.txt file describing the example behavior and the environment required to run
the example.
STM32CubeF1 examples
CAN CAN_Networking - X - -
to send and receive CAN frames in normal mode.
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
- X - -
Conversion the DAC peripheral to perform a simple conversion.
This example provides a description of how to use a DMA
DMA DMA_FLASHToRAM channel to transfer a word data buffer from Flash memory - X - -
to embedded SRAM through the HAL API.
This example describes how to configure and use the
FLASH_Erase
FLASH HAL API to erase and program the internal Flash - - X -
Program
memory.
FLASH
This example describes how to configure and use the
FLASH_Write
FLASH HAL API to enable and disable the write - - X -
Protection
protection of the internal Flash memory.
AN4724
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
lines.
GPIO
This example describes how to configure and use GPIOs
GPIO_IOToggle X X X X
through the HAL API.
STM32CubeF1 examples
8/31
Table 1. STM32CubeF1 firmware examples (continued)
9/31
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
RestartAdvComIT
using an interrupt.
This example describes how to perform I2C data buffer
I2C_TwoBoards_
sequential transmission/reception between two boards - X X -
RestartComIT
using an interrupt.
AN4724
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
STM32CubeF1 examples
demonstrate the tamper detection feature.
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
AN4724
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
STM32CubeF1 examples
12/31
Table 1. STM32CubeF1 firmware examples (continued)
13/31
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
AN4724
initialization is done using LL unitary services functions for
optimization purpose (performance and size).
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
STM32CubeF1 examples
initialization is done using LL unitary services functions for
optimization purpose (performance and size).
14/31
Table 1. STM32CubeF1 firmware examples (continued)
15/31
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
AN4724
done using LL initialization function to demonstrate LL init
usage.
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
STM32CubeF1 examples
This example describes how to configure and use GPIOs
to toggle the user LEDs available on the board every 250
GPIO_InfiniteLed
ms. This example is based on the STM32F1xx LL API. - - X -
Toggling_Init
The peripheral initialization is done using LL initialization
function to demonstrate LL init usage.
16/31
Table 1. STM32CubeF1 firmware examples (continued)
17/31
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
AN4724
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
STM32CubeF1 examples
18/31
Table 1. STM32CubeF1 firmware examples (continued)
19/31
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
AN4724
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
Examples_
SPI SPI_OneBoard_Half to an SPI Slave device in Interrupt mode. The example is
LL - - X -
Duplex_IT based on the STM32F1xx SPI LL API.The peripheral
initialization is done using LL unitary services functions for
optimization purpose (performance and size).
STM32CubeF1 examples
size).
20/31
Table 1. STM32CubeF1 firmware examples (continued)
21/31
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
AN4724
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
STM32CubeF1 examples
22/31
Table 1. STM32CubeF1 firmware examples (continued)
23/31
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
AN4724
Communication_Tx_IT based on STM32F1xx USART LL API.The peripheral
initialization is done using LL unitary services functions for
optimization purpose (performance and size).
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
STM32CubeF1 examples
Revision ID and save them into a global information - - X -
Info
buffer.
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
DMA DMA_FLASHToRAM - - X -
embedded SRAM through the STM32F1xx DMA HAL and
LL API (LL API used for performance improvement).
AN4724
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
STM32CubeF1 examples
26/31
Table 1. STM32CubeF1 firmware examples (continued)
27/31
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
AN4724
Table 1. STM32CubeF1 firmware examples (continued)
AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
STM32CubeF1 examples
programming the embedded Flash memory through the
USB peripheral.
STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL
AN4724
Revision history AN4724
3 Revision history
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.
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.