0% found this document useful (0 votes)
209 views31 pages

STM32Cube Firmware Examples

Uploaded by

cansu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
209 views31 pages

STM32Cube Firmware Examples

Uploaded by

cansu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

AN4724

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).

Figure 1. STM32CubeF1 firmware components

(YDOXDWLRQ 'LVFRYHU\ 6701XFOHR 'HGLFDWHG 8VHU


ERDUGV ERDUGV ERDUGV ERDUGV DSSOLFDWLRQ 8WLOLWLHV
$SSOLFDWLRQOHYHOGHPRQVWUDWLRQV

)$7ILOH &06,6
7&3,3 86% *UDSKLFV 5726
V\VWHP

0LGGOHZDUHOHYHO  8WLOLWLHV

%RDUG6XSSRUW3DFNDJH %63 /RZ/D\HU // +DUGZDUH$EVWUDFWLRQ/D\HU +$/

+$/DQG//$3,V

 7KHVHWRIPLGGOHZDUHFRPSRQHQWVGHSHQGVRQWKHSURGXFW6HULHV 069

April 2017 DocID028025 Rev 2 1/31


www.st.com 1
Contents AN4724

Contents

1 Reference documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 STM32CubeF1 examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

2/31 DocID028025 Rev 2


AN4724 Reference documents

1 Reference documents

The following user manuals are available on www.st.com/stm32cubefw:


• Latest release of STM32CubeF1 firmware package
• Getting started with the STM32CubeF1 firmware package for the STM32F1 series
(UM1847)
• STM32CubeF1 Nucleo demonstration firmware (UM1853)
• Description of STM32F1xx HAL and low-layer drivers (UM1850)
• STM32Cube USB Device library (UM1734)
• STM32Cube USB host library (UM1720)
• Developing applications on STM32Cube with FatFs (UM1721)
• Developing Applications on STM32Cube with RTOS (UM1722)
• Developing applications on STM32Cube with LwIP TCP/IP stack (UM1713)
• STM32Cube Ethernet IAP example (UM1709)

DocID028025 Rev 2 3/31


30
STM32CubeF1 examples AN4724

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.

4/31 DocID028025 Rev 2


AN4724 STM32CubeF1 examples

To run the example, proceed as follows:


1. Open the example using your preferred toolchain.
2. Rebuild all files and load the image into target memory.
3. Run the example by following the readme.txt instructions
Note: Refer to "Development toolchains and compilers" and "Supported devices and evaluation
boards" sections of the firmware package release notes to know more about the
software/hardware environment used for the firmware development and validation. The
correct operation of the provided examples is not guaranteed in other environments, for
example when using different compiler or board versions.
The examples can be tailored to run on any compatible hardware: simply update the BSP
drivers for your board, provided it has the same hardware functions (LED, LCD display,
pushbuttons, etc.). The BSP is based on a modular architecture that can be easily ported to
any hardware by implementing the low-level routines.
Table 1 contains the list of examples provided within STM32CubeF1 firmware package.

DocID028025 Rev 2 5/31


30
AN4724
Table 1. STM32CubeF1 firmware examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This projects provides a reference template based the LL


- Starter project X X X X
Templates_LL API that can be used to build any firmware application.

Total number of templates_ll: 4 1 1 1 1

This projects provides a reference template that can be


- Starter project X X X X
Templates used to build any firmware application.

Total number of templates: 4 1 1 1 1

This example provides a description of how to use the


- BSP - X - X
different BSP drivers.
This example provides a short description of how to use
ADC_Analog
the ADC peripheral to perform conversions with analog - - X -
Watchdog
watchdog and out-of-window interruptions enabled.
DocID028025 Rev 2

This example provides a short description of how to use


ADC_DualMode
two ADC peripherals to perform conversions in - - - X
Interleaved
interleaved dual-mode.
This example provides a short description of how to use
ADC the ADC peripheral to perform conversions using the two
ADC_Regular_injected_ ADC groups: regular group for ADC conversions on main
X - - X
groups stream and injected group for ADC conversions limited to
Examples
specific events (conversions injected within main
conversions stream).

This example provides a short description of how to use


ADC_Sequencer the ADC peripheral with sequencer, to convert several - X - -
channels.
This example shows how to configure the CAN peripheral

STM32CubeF1 examples
CAN CAN_Networking - X - -
to send and receive CAN frames in normal mode.

This example guides you through the different


configuration steps by means of the HAL API. The CRC
CRC CRC_Example (Cyclic Redundancy Check) calculation unit computes the X X X X
CRC code of a given buffer of 32-bit data words, using a
fixed generator polynomial (0x4C11DB7).
6/31
Table 1. STM32CubeF1 firmware examples (continued)
7/31

STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This example presents the MPU feature. The example


purpose is to configure a memory region as privileged
CORTEXM_MPU - X - -
read-only region and attempt to perform read and write
operations in different modes.

Cortex This example shows how to modify Thread mode


CORTEXM_Mode
privilege access and stack. Thread mode is entered on - X - -
Privilege
reset or when returning from an exception.

This example shows how to use the default SysTick


CORTEXM_SysTick - X - -
configuration with a 1 ms timebase to toggle LEDs.

This example provides a description of how to use the


DAC_Signals
DAC peripheral to generate several signals using the - - - X
Generation
Examples DAC DMA controller.

DAC_Simple This example provides a short description of how to use


DocID028025 Rev 2

- 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

This example describes how to configure the FSMC


FSMC_NAND - X - -
controller to access the NAND memory.
This example describes how to configure the FSMC
FSMC_NOR - X - -
controller to access the NOR memory.

This example describes how to build an application to be


FSMC_NOR_Code
FSMC loaded into the NOR memory mounted on board and then - X - -
Execute
execute it from internal Flash memory.

This example describes how to configure the FSMC


FSMC_SRAM - X - -
controller to access the SRAM.

FSMC_SRAM_Data This example describes how to configure the FSMC


- X - -
Memory controller to access the SRAM, including heap and stack.
Examples
This example shows how to configure external interrupt
GPIO_EXTI X - - -
DocID028025 Rev 2

lines.
GPIO
This example describes how to configure and use GPIOs
GPIO_IOToggle X X X X
through the HAL API.

This example describes how to customize the HAL


timebase using the RTC Alarm instead of the SysTick as
HAL_TimeBase_RTC_
main timebase source. The discovery board user button X X X X
ALARM
(connected to EXTI Line0) will be used to Suspend or
HAL Resume tick increment.
This example describes how to customize the HAL
HAL_TimeBase_TIM timebase using a general purpose timer instead of the X X X X
SysTick as main timebase source.

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

This example describes how to perform I2C data buffer


I2C_TwoBoards_
transmission/reception between two boards, using an - X X -
AdvComIT
interrupt.

I2C_TwoBoards_ This example describes how to perform I2C data buffer


- X X -
ComDMA transmission/reception between two boards, via DMA.

This example describes how to perform I2C data buffer


I2C_TwoBoards_
transmission/reception between two boards using an - X X -
ComIT
interrupt.
I2C This example describes how to perform I2C data buffer
I2C_TwoBoards_Com
transmission/reception between two boards in Polling - X X -
Polling
mode.
Examples This example describes how to perform I2C data buffer
I2C_TwoBoards_
sequential transmission/reception between two boards - X X -
DocID028025 Rev 2

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.

This example provides basic implementation of audio


I2S I2S_Audio - - - X
features.

This example describes how to reload the IWDG counter


and to simulate a software fault by generating an MCU
IWDG IWDG_Example - - - X
IWDG reset when a programmed time period has
elapsed.

AN4724
Table 1. STM32CubeF1 firmware examples (continued)

AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This example shows how to configure the programmable


PWR_PVD voltage detector using an external interrupt line. External - X - -
DC supply has to be used to power VDD.

This example shows how to enter Sleep mode and wake


PWR PWR_SLEEP X - - -
up from this mode by using an interrupt.

This example shows how to enters the system to Standby


PWR_STANDBY mode and wake up from this mode using external RESET - - X -
or WKUP pin.

This example describes how to use the RCC HAL API to


RCC RCC_ClockConfig configure the system clock (SYSCLK) and modify the X X X X
clock settings in Run mode.

This example guides you through the different


RTC_Alarm configuration steps by means of the RTC HAL API to - - X -
DocID028025 Rev 2

configure and generate an RTC alarm.

This example guides you through the different


Examples RTC_Calendar configuration steps by mean of HAL API to ensure - X - -
Calendar configuration using the RTC peripheral.

This example demonstrates and explains how to use the


RTC_LSI LSI clock source auto-calibration to get a precise RTC - - - X
RTC
clock.
This example shows how to enter Standby mode and
RTC_LowPower_
wake up from this mode using RTC Alarm Event X - - -
STANDBY
connected to EXTI_Line17.

This example guides you through the different


configuration steps by means of the RTC HAL API to
RTC_Tamper - X - -
write/read data to/from RTC Backup registers and

STM32CubeF1 examples
demonstrate the tamper detection feature.

This example describes a firmware Smartcard Interface


based on the USART peripheral. The main purpose of
SMARTCARD SMARTCARD_T0 this firmware example is to provide resources that - X - X
facilitate the development of an application using the
USART peripheral in Smartcard mode.
10/31
Table 1. STM32CubeF1 firmware examples (continued)
11/31

STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

SPI_FullDuplex_Com This example shows how to perform SPI data buffer


X - X -
DMA transmission/reception between two boards via DMA.

This example shows how to ensure SPI data buffer


SPI_FullDuplex_
transmission/reception between two boards by using an X - X -
SPI ComIT
interrupt.

This example shows how to ensure SPI data buffer


SPI_FullDuplex_Com
transmission/reception in Polling mode between two X - X -
Polling
boards.

This example shows how to configure the TIM1 peripheral


TIM_Complementary to generate three complementary TIM1 signals, insert a
- X - -
Signals defined dead time value, and use the break feature and
Examples lock the desired parameters.

This example provides a description of how to use DMA


DocID028025 Rev 2

TIM_DMA with TIM1 Update request to transfer data from memory - X X -


to TIM1 Capture Compare Register 3 (TIM1_CCR3).
TIM
This example shows how to use the TIM peripheral to
TIM_InputCapture - X - -
measure the frequency of an external signal.
This example shows how to configure the TIM peripheral
TIM_PWMOutput - X - -
in PWM (Pulse Width Modulation) mode.

This example shows how to configure the TIM peripheral


TIM_TimeBase to generate a 1 second timebase with the corresponding X X X X
Interrupt request.

AN4724
Table 1. STM32CubeF1 firmware examples (continued)

AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This example shows how to perform UART data buffer


UART_HyperTerminal_ transmission and reception with DMA. The
X - X X
DMA communication is done with the HyperTerminal PC
application.

This example shows how to reroute the C library printf


UART_Printf function to the UART. It outputs a message sent by the X X X X
UART to the HyperTerminal.
UART
UART_TwoBoards_ This example describes an UART transmission
X - X X
ComDMA (transmit/receive) in DMA mode between two boards.

Examples UART_TwoBoards_ This example describes an UART transmission


X - X X
ComIT (transmit/receive) in Interrupt mode between two boards.

UART_TwoBoards_ This example describes an UART transmission


X - X X
ComPolling (transmit/receive) in Polling mode between two boards.
DocID028025 Rev 2

This example guides you through the different


configuration steps by means of the HAL API to perform
WWDG WWDG_Example periodic WWDG counter update and simulate a software - - X -
fault that generates an MCU WWDG reset when a
predefined time period has elapsed.

Total number of examples: 98 18 34 27 19

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

This example describes how to use a ADC peripheral with


ADC analog watchdog to monitor a channel and detect
when the corresponding conversion data is out of window
ADC_Analog
thresholds; This example is based on the STM32F1xx - - X -
Watchdog
ADC LL API. The peripheral initialization is done using LL
unitary services functions for optimization purpose
(performance and size).

This example describes how to use a ADC peripheral to


perform continuous ADC conversions of a channel, from
ADC_Continuous
a software start. This example is based on the
Conversion_Trigger - - X -
STM32F1xx ADC LL API. The peripheral initialization is
SW
done using LL unitary services functions for optimization
purpose (performance and size).

This example describes how to use a ADC peripheral to


DocID028025 Rev 2

perform continuous ADC conversions of a channel, from


ADC_Continuous
a software start. This example is based on the
Conversion_Trigger - - X -
STM32F1xx ADC LL API. The peripheral initialization is
SW_Init
done using LL unitary services functions for optimization
Examples_ purpose (performance and size).
ADC
LL
This example describes how to use a ADC peripheral with
both ADC groups (ADC group regular and ADC group
ADC_GroupsRegular injected) in their intended use case. This example is
- - X -
Injected based on the STM32F1xx ADC LL API. The peripheral
initialization is done using LL unitary services functions for
optimization purpose (performance and size).

This example describes how to use a ADC peripheral to


convert several channels. ADC conversions are
performed successively in a scan sequence. This
ADC_MultiChannel
example is based on the STM32F1xx ADC LL API. The - - X -
SingleConversion
peripheral initialization is done using LL unitary services
functions for optimization purpose (performance and
size).

This example describes how to use several ADC


peripherals in multimode mode interleaved. This example
ADC_MultimodeDual
is based on the STM32F1xx ADC LL API. The peripheral - - X -
Interleaved

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

This example describes how to use a ADC peripheral to


perform a single ADC channel conversion at each
software start. It uses the polling programming model (for
ADC_Single
details on interrupt or DMA transfer programming models,
Conversion_Trigger - - X -
refer to other examples). This example is based on the
SW
STM32F1xx ADC LL API. The peripheral initialization is
done using LL unitary services functions for optimization
purpose (performance and size).
This example describes how to use an ADC peripheral to
perform a single ADC channel conversion at each
software start. It uses the DMA transfer programming
ADC_Single
model (for details on polling or interrupt programming
Conversion_Trigger - - X -
models, refer to other examples); This example is based
SW_DMA
on the STM32F1xx ADC LL API. The peripheral
DocID028025 Rev 2

initialization is done using LL unitary services functions for


Examples_ optimization purpose (performance and size).
ADC
LL
This example describes how to use an ADC peripheral to
perform a single ADC channel conversion at each
software start. It uses the interrupt programming model
ADC_Single
(for details on polling or DMA transfer programming
Conversion_Trigger - - X -
models, refer to other examples).This example is based
SW_IT
on the STM32F1xx ADC LL API. The peripheral
initialization is done using LL unitary services functions for
optimization purpose (performance and size).

This example describes how to use an ADC peripheral to


perform a single ADC channel conversion at each timer
ADC_Single trigger event. Converted data are indefinitely transferred
Conversion_Trigger by DMA into a table (circular mode); This example is - - X -
Timer_DMA based on the STM32F1xx ADC LL API. The peripheral

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

This example describes how to use an ADC peripheral to


perform a single ADC conversion of the internal
temperature sensor and to calculate the temperature in
Celsius degrees. This example using the polling
ADC_Temperature programming model (for details on interrupt or DMA
ADC - - X -
Sensor transfer programming models, refer to other examples).
This example is based on the STM32F1xx ADC LL API.
The peripheral initialization is done using LL unitary
services functions for optimization purpose (performance
and size).

This example presents the MPU feature. Its purpose is to


configure a memory area as privileged read-only area
CORTEX CORTEX_MPU - X - -
and attempt to perform read and write operations in
different modes.
DocID028025 Rev 2

This example shows how to configure the CRC


calculation unit to get the CRC code of a given data
CRC_CalculateAnd buffer, based on a fixed generator polynomial (default
CRC - - X -
Check value 0x4C11DB7). The peripheral initialization is done
Examples_
using LL unitary services functions for optimization
LL purpose (performance and size).

This example describes how to use the DAC peripheral to


DAC_Generate generate a constant voltage signal.This example is based
ConstantSignal_ on the STM32F1xx DAC LL API. The peripheral - X - -
TriggerSW initialization is done using LL unitary services functions for
optimization purpose (performance and size).

This example describes how to use the DAC peripheral to


generate a waveform voltage from a digital data stream
DAC_Generate transferred by DMA. This example is based on the
- X - -
DAC Waveform_TriggerHW STM32F1xx DAC LL API. The peripheral initialization is
done using LL unitary services functions for optimization
purpose (performance and size).

This example describes how to use the DAC peripheral to


generate a waveform voltage from a digital data stream
DAC_Generate
transfered by DMA. This example is based on the
Waveform_TriggerHW_ - X - -
STM32F1xx DAC LL API. The peripheral initialization is
Init

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

This example describes how to use a DMA channel to


transfer a word data buffer from Flash memory to
DMA_CopyFromFlashTo
embedded SRAM. The peripheral initialization is done - - X -
Memory
using LL unitary services functions for optimization
purpose (performance and size).
DMA
This example describes how to use a DMA channel to
transfer a word data buffer from Flash memory to
DMA_CopyFromFlashTo
embedded SRAM. The peripheral initialization is done - - X -
Memory_Init
using LL initialization function to demonstrate LL init
usage.

This example describes how to configure the EXTI and


use GPIOs to toggle the user LEDs available on the
board when a user button is pressed. It is based on the
EXTI_ToggleLedOnIT - - X -
STM32F1xx LL API. The peripheral initialization is done
DocID028025 Rev 2

using LL unitary services functions for optimization


purpose (performance and size).
Examples_ EXTI
LL This example describes how to configure the EXTI and
use GPIOs to toggle the user LEDs available on the
EXTI_ToggleLedOnIT_ board when a user button is pressed. This example is
- - X -
Init based on the STM32F1xx LL API. The peripheral
initialization is done using LL initialization function to
demonstrate LL init usage.

This example describes how to configure and use GPIOs


to toggle the user LEDs available on the board every
GPIO_InfiniteLed 250 ms. This example is based on the STM32F1xx LL
- - X -
Toggling API. The peripheral initialization is done using LL unitary
services functions for optimization purpose (performance
GPIO and size).

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

This example describes how to exchange data between


I2C_OneBoard_Adv an I2C Master device in DMA mode and an I2C Slave
Communication_DMA device in Interrupt mode.The peripheral initialization is - - X -
AndIT done using LL unitary services functions for optimization
purpose (performance and size).
This example describes how to transmit data bytes from
I2C_OneBoard_ an I2C Master device using DMA mode to an I2C Slave
Communication_DMA device using Interrupt mode.The peripheral initialization is - - X -
AndIT done using LL unitary services functions for optimization
purpose (performance and size).

This example describes how to receive one data byte


from an I2C Slave device to an I2C Master device. Both
I2C_OneBoard_
devices operate in Interrupt mode.The peripheral - - X -
Communication_IT
initialization is done using LL unitary services functions for
DocID028025 Rev 2

optimization purpose (performance and size).

This example describes how to receive one data byte


I2C_OneBoard_ from an I2C Slave device to an I2C Master device. Both
Examples_
I2C Communication_IT_ devices operate in Interrupt mode.The peripheral - - X -
LL
Init initialization is done using LL initialization function to
demonstrate LL init usage.
This example describes how to transmit data bytes from
I2C_OneBoard_ an I2C Master device using Polling mode to an I2C Slave
Communication_ device using Interrupt mode.The peripheral initialization is - - X -
PollingAndIT done using LL unitary services functions for optimization
purpose (performance and size).

This example describes how to receive one data byte


from an I2C Slave device to an I2C Master device. Both
I2C_TwoBoards_
devices operate in Interrupt mode.The peripheral - - X -
MasterRx_SlaveTx_IT
initialization is done using LL unitary services functions for
optimization purpose (performance and size).

This example describes how to transmit data bytes from


an I2C Master device using Polling mode to an I2C Slave
I2C_TwoBoards_
device using Interrupt mode.The peripheral initialization is - - X -
MasterTx_SlaveRx
done using LL unitary services functions for optimization
purpose (performance and size).

AN4724
Table 1. STM32CubeF1 firmware examples (continued)

AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This example describes how to transmit data bytes from


I2C_TwoBoards_ an I2C Master device using DMA mode to an I2C Slave
I2C MasterTx_SlaveRx_ device using DMA mode.The peripheral initialization is - - X -
DMA done using LL unitary services functions for optimization
purpose (performance and size).
This example describes how to configure the IWDG to
ensure period counter update and generate an MCU
IWDG_RefreshUntil
IWDG IWDG reset when a user button is pressed.The peripheral - - X -
UserEvent
initialization is done using LL unitary services functions for
optimization purpose (performance and size).

Examples_ This example shows how to enter Standby mode and


PWR_EnterStandby
LL wake up from this mode using external RESET or wakeup - - X -
Mode
PWR interrupt.
DocID028025 Rev 2

This example shows how to enter STOP_MAINREGU


PWR_EnterStopMode - - X -
mode.

RCC_OutputSystem This example describes how to configure MCO pin (PA8)


- - X -
ClockOnMCO to output the system clock.

RCC_UseHSEas This example describes how to use the RCC LL API to


RCC - - X -
SystemClock start the HSE and use it as system clock.

RCC_UseHSI_PLLasSys This example shows how to modify the PLL parameters in


- - X -
temClock run time.

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

This example guides you through the different


configuration steps by mean of LL API to ensure Alarm
configuration and generation using the RTC peripheral.
RTC_Alarm - - X -
The peripheral initialization is done using LL unitary
services functions for optimization purpose (performance
and size).

This example guides you through the different


configuration steps by mean of LL API to ensure Alarm
RTC_Alarm_Init configuration and generation using the RTC peripheral. - - X -
The peripheral initialization is done using LL initialization
Examples_ function to demonstrate LL init usage.
RTC
LL
This example guides you through the different
configuration steps by mean of HAL API to configure the
RTC_Calendar RTC calendar. The peripheral initialization is done using - - X -
DocID028025 Rev 2

LL unitary services functions for optimization purpose


(performance and size).

This example guides you through the different


configuration steps by mean of LL API to ensure Tamper
RTC_Tamper configuration using the RTC peripheral. The peripheral - - X -
initialization is done using LL unitary services functions for
optimization purpose (performance and size).

AN4724
Table 1. STM32CubeF1 firmware examples (continued)

AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This example shows how to configure GPIO and SPI


peripherals to transmit bytes from an SPI Master device
SPI_OneBoard_Half to an SPI Slave device in DMA mode. The example is
- - X -
Duplex_DMA based on the STM32F1xx SPI LL API.The peripheral
initialization is done using LL unitary services functions for
optimization purpose (performance and size).

This example shows how to configure GPIO and SPI


peripherals to transmit bytes from an SPI Master device
SPI_OneBoard_Half to an SPI Slave device in DMA mode. The example is
- - X -
Duplex_DMA_Init based on the STM32F1xx SPI LL API.The peripheral
initialization is done using LL initialization function to
demonstrate LL init usage.

This example shows how to configure GPIO and SPI


peripherals to transmit bytes from an SPI Master device
DocID028025 Rev 2

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).

This example shows how to ensure SPI data buffer


transmission and reception in DMA mode. The example is
SPI_TwoBoards_Full
based on the STM32F1xx SPI LL API.The peripheral - - X -
Duplex_DMA
initialization is done using LL unitary services functions for
optimization purpose (performance and size).

This example shows how to ensure SPI Data buffer


transmission and reception in Interrupt mode. The
SPI_TwoBoards_Full example is based on the STM32F1xx SPI LL API.The
- - X -
Duplex_IT peripheral initialization is done using LL unitary services
functions for optimization purpose (performance and

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

This example shows how to configure the timer to perform


the following operations:
– generate three center-aligned PWM and
complementary PWM signals
– insert a defined dead time value
TIM_BreakAndDeadtime – use the break feature - - X -
– lock the desired parameters
This example is based on the STM32F1xx TIM LL API.
The peripheral initialization is done using LL unitary
services functions for optimization purpose (performance
and size).

This example provides a description of how to use DMA


with timer update request to transfer data from memory to
TIMER Capture Compare Register 3 (TIMx_CCR3). This
DocID028025 Rev 2

TIM_DMA example uses the STM32F1xx TIM LL API. The - - X -


Examples_
TIM peripheral initialization is done using LL unitary services
LL functions for optimization purpose (performance and
size).

This example shows how to use the timer peripheral to


measure the frequency of a periodic signal provided
either by an external signal generator or by another timer
TIM_InputCapture instance. This example uses the STM32F1xx TIM LL API. - - X -
The peripheral initialization is done using LL unitary
services functions for optimization purpose (performance
and size).

This example shows how to configure a timer to generate


a positive pulse in Output Compare mode with a length of
tPULSE and after a delay of tDELAY. This example is based
TIM_OnePulse - - X -
on the STM32F1xx TIM LL API. The peripheral
initialization is done using LL unitary services functions for
optimization purpose (performance and size).

AN4724
Table 1. STM32CubeF1 firmware examples (continued)

AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This example shows how to configure the timer peripheral


to generate an output waveform in different output
compare modes. This example uses the STM32F1xx TIM
TIM_OutputCompare - - X -
LL API. The peripheral initialization is done using LL
unitary services functions for optimization purpose
(performance and size).

This example describes how to use a timer peripheral to


generate a PWM output signal and update PWM duty
cycle. This example uses the STM32F1xx TIM LL API.
TIM_PWMOutput - - X -
The peripheral initialization is done using LL unitary
Examples_ services functions for optimization purpose (performance
TIM and size).
LL
This example describes how to use a timer peripheral to
generate a PWM output signal and update PWM duty
DocID028025 Rev 2

TIM_PWMOutput_Init cycle. This example using the STM32F1xx TIM LL API. - - X -


The peripheral initialization is done using LL initialization
function to demonstrate LL init usage.
This example shows how to configure the timer peripheral
to generate a time base. This example uses the
TIM_TimeBase STM32F1xx TIM LL API. The peripheral initialization is - - X -
done using LL unitary services functions for optimization
purpose (performance and size).

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

This example shows how to configure GPIO and USART


peripheral to receive characters from an HyperTerminal
USART_ (PC) in Asynchronous mode using Interrupt mode.The
- - X -
Communication_Rx_IT peripheral initialization is done using LL unitary services
functions for optimization purpose (performance and
size).

This example shows how to configure GPIO and USART


peripheral to continuously receive characters from an
USART_
HyperTerminal (PC) in Asynchronous mode using
Communication_Rx_IT_ - - X -
Interrupt mode.The peripheral initialization is done using
Continuous
LL unitary services functions for optimization purpose
(performance and size).

This example shows how to configure GPIO and USART


USART_ peripheral to receive characters from an HyperTerminal
DocID028025 Rev 2

Communication_Rx_IT_ (PC) in Asynchronous mode using Interrupt mode.The - - X -


Init peripheral initialization is done using LL initialization
function to demonstrate LL init usage.

This example shows how to configure GPIO and USART


Examples_ peripherals to send characters asynchronously to an
USART
LL HyperTerminal (PC) in Polling mode. If the transfer could
not be completed within the allocated time, a timeout
USART_
allows to exit from the sequence with a Timeout error - - X -
Communication_Tx
code. This example is based on STM32F1xx USART LL
API.The peripheral initialization is done using LL unitary
services functions for optimization purpose (performance
and size).
This example shows how to configure GPIO and USART
peripheral to send characters asynchronously to/from an
USART_
HyperTerminal (PC) in DMA mode. This example is based
Communication_TxRx_ - - X -
on STM32F1xx USART LL API.The peripheral
DMA
initialization is done using LL unitary services functions for
optimization purpose (performance and size).
This example shows how to configure GPIO and USART
peripheral to send characters asynchronously to an
USART_ HyperTerminal (PC) in Interrupt mode. This example is
- - X -

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

This example shows how to configure GPIO and USART


peripheral to receive characters asynchronously from an
HyperTerminal (PC) in Interrupt mode with Hardware
USART_Hardware
Flow Control feature enabled. This example is based on - - X -
FlowControl
STM32F1xx USART LL API.The peripheral initialization is
done using LL unitary services functions for optimization
purpose (performance and size).

This example shows how to configure GPIO, USART,


DMA and SPI peripherals for transmitting bytes from/to an
USART_Sync USART peripheral to/from an SPI peripheral (in slave
Communication_Full mode) by using DMA mode through the STM32F1xx - - X -
USART
Duplex_DMA USART LL API.The peripheral initialization is done using
LL unitary services functions for optimization purpose
(performance and size).
DocID028025 Rev 2

This example shows how to configure GPIO, USART,


DMA and SPI peripherals to transmit bytes from/to an
USART peripheral to/from an SPI peripheral (in slave
USART_Sync
mode) by using Interrupt mode through the STM32F1xx
Communication_Full - - X -
Examples_ USART LL API (the SPI uses DMA to receive/transmit the
Duplex_IT
LL characters sent from/received by USART).The peripheral
initialization is done using LL unitary services functions for
optimization purpose (performance and size).

This example describes how to use UTILS LL API to


configure the system clock using PLL with HSI as source
UTILS_Configure
clock. The user application just needs to calculate PLL - - X -
SystemClock
parameters using STM32CubeMX and call the UTILS LL
UTILS API.

This example describes how to read UID, Device ID and


UTILS_ReadDevice

STM32CubeF1 examples
Revision ID and save them into a global information - - X -
Info
buffer.

This example describes how to configure the WWDG,


periodically update the counter, and generate an MCU
WWDG_RefreshUntil WWDG reset when a user button is pressed.The
WWDG - - X -
UserEvent peripheral initialization is done using LL unitary services
functions for optimization purpose (performance and
size).
24/31

Total number of examples_ll: 65 0 4 61 0


Table 1. STM32CubeF1 firmware examples (continued)
25/31

STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This example describes how to use the ADC to perform a


single ADC channel conversion at each software start.
ADC_Single This example uses the interrupt programming model (for
ADC Conversion_Trigger programming models in Polling or DMA mode, refer to - X - -
SW_IT other examples). This example is based on the
STM32F1xx ADC HAL and LL API (LL API usage for
performance improvement).

This example provides a description of how to use CRC


peripheral through the STM32F1xx CRC HAL & LL API
CRC_CalculateAnd
CRC (LL API used for performance improvement); Fixed - - X -
Check
generator polynomial used in CRC IP is CRC-32
(Ethernet) polynomial: 0x4C11DB7.

This example provides a description of how to use a DMA


to transfer a word data buffer from Flash memory to
DocID028025 Rev 2

DMA DMA_FLASHToRAM - - X -
embedded SRAM through the STM32F1xx DMA HAL and
LL API (LL API used for performance improvement).

Examples_ This example describes how to perform I2C data buffer


MIX transmission/reception between one master and two
slaves with different address sizes (7-bit or 10-bit) and at
I2C_OneBoard_Com
I2C different maximum speeds (400 KHz or 100 KHz). This - - X -
Slave7_10bits_IT
example uses the STM32F1xx I2C HAL and LL API (LL
API usage for performance improvement) and an
interrupt.
This example shows how to enter Stop with Low power
regulator mode and wake up from this mode using
PWR PWR_STOP external RESET or wakeup interrupt (all the RCC - - X -
functions calls use RCC LL API for footprint and
performance improvements).

This example shows how to ensure SPI data buffer


SPI_FullDuplex_Com
transmission/reception in Polling mode between two - - X -
Polling
boards.
SPI
This example shows how to ensure SPI data buffer
SPI_HalfDuplex_Com
transmission/reception between two boards by using - - X -
PollingIT
Polling (LL Driver) an interrupt mode (HAL Driver).

AN4724
Table 1. STM32CubeF1 firmware examples (continued)

AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This example shows how to configure the TIM1 peripheral


to generate 6-steps PWM signal. The STM32F1xx TIM1
peripheral allows programming in advance the
configuration for the next TIM1 output behavior (or step)
TIM_6Steps and changing the configuration of all the channels - - X -
simultaneously. This operation is possible when the COM
TIM (commutation) event is used. This example is based on
the STM32F1xx TIM HAL and LL API (LL API usage for
performance improvement).

This example shows how to use the TIM peripheral to


TIM_PWMInput measure the frequency and duty cycle of an external - - X -
signal.

Examples_ This example describes how to use an UART to transmit


MIX data (transmit/receive) between a board and an
DocID028025 Rev 2

HyperTerminal PC application in Interrupt mode. This


UART_HyperTerminal_IT - - X -
example provides a description of how to use USART
peripheral through the STM32F1xx UART HAL and LL
API (LL API usage for performance improvement).
UART This example describes how to use an UART to transmit
data (transmit/receive) between a board and an
HyperTerminal PC application both in Polling and
UART_HyperTerminal_
Interrupt modes. This example provides a description of - - X -
TxPolling_RxIT
how to use USART peripheral through the STM32F1xx
UART HAL and LL API (LL API usage for performance
improvement).

Total number of examples_mix: 11 0 1 10 0

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

Please refer to AN2594 for further details regarding this


EEPROM EEPROM_Emulation - - X -
application.
This example provides a description on how to use
STM32Cube firmware with FatFs middleware component
FatFs FatFs_uSD as a generic FAT file system module. The objective is to - X - X
develop an application using most of the features offered
by FatFs to configure a microSD drive.

This application shows how to use mail queues with


FreeRTOS_Mail - X - -
CMSIS RTOS API.

This application shows how to use thread signaling using


FreeRTOS_Signal - X - -
CMSIS RTOS API.
Applications FreeRTOS FreeRTOS_SignalFrom This application shows how to use thread signaling from
- X - -
ISR an interrupt using CMSIS RTOS API.
DocID028025 Rev 2

This example creates two threads with the same priority,


FreeRTOS_Thread
which execute in a periodic cycle of 5 seconds for Thread - X X X
Creation
1 and 10 seconds for Thread 2.

This directory contains a set of sources files that build the


IAP_Binary_Template application to be loaded into Flash memory using In- - X - X
Application Programming (IAP) through the USART.
IAP This directory contains a set of sources files and pre-
configured projects that describes how to build an
IAP_Main - X - X
application to be loaded into Flash memory using In-
Application Programming (IAP) through USART).

AN4724
Table 1. STM32CubeF1 firmware examples (continued)

AN4724
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This application shows how to run TCP Echo Client


application based on Raw API of LwIP TCP/IP stack. To
LwIP_TCP_Echo_Client - - - X
run this application, open a command prompt window on
the remote PC.

This application shows how to run TCP Echo Server


application based on Raw API of LwIP TCP/IP stack. To
LwIP_TCP_Echo_Server - - - X
run this application, open a command prompt window on
the remote PC.
LwIP
This application shows how to run a UDP Echo Client
application based on Raw API of LwIP TCP/IP stack. To
LwIP_UDP_Echo_Client - - - X
run this application, open a command prompt window on
the remote PC.

This application shows how to run UDP Echo Server


DocID028025 Rev 2

application based on Raw API of LwIP TCP/IP stack. To


LwIP_UDP_Echo_Server - - - X
run this application, open a command prompt window on
the remote PC.
Applications This application shows how to implement a simple "Hello
STemWin STemWin_HelloWorld - X - X
World" example based on STemWin.

This application shows how to use the USB device


application based on the Device Communication Class
CDC_Standalone - X - X
(CDC) following the PSTN subprotocol using the USB
Device and UART peripherals.

This application shows how to use the USB device


CustomHID_Standalone - X - X
application based on the Custom HID Class.

This application presents a compliant implementation of


USB_Device
the Device Firmware Upgrade (DFU) capability for
DFU_Standalone - X - X

STM32CubeF1 examples
programming the embedded Flash memory through the
USB peripheral.

This application shows how to use the USB device


HID_Standalone - X X X
application based on the Human Interface (HID).

This application shows how to use the USB device


MSC_Standalone - X - X
application based on the Mass Storage Class (MSC).
28/31
Table 1. STM32CubeF1 firmware examples (continued)
29/31

STM32CubeF1 examples
STM32VL STM3210E- NUCLEO- STM3210C-
Level Module Name Project Name Description
DISCOVERY EVAL F103RB EVAL

This application shows how to use the USB host


CDC_Standalone - - - X
application based on the CDC class.
This application shows how to use the USB host
HID_RTOS - - - X
application based on the HID class.

This application shows how to use the USB host


USB_Host HID_Standalone - - - X
Applications application based on the HID class.

This application shows how to use the USB host


MSC_RTOS - - - X
application based on the Mass Storage Class (MSC).

This application shows how to use the USB host


MSC_Standalone - - - X
application based on the Mass Storage Class (MSC).

Total number of applications: 35 0 13 3 19


DocID028025 Rev 2

The provided demonstration firmware based on


Adafruit_LCD_1_8_SD_
Demonstra- - STM32Cube helps you to discover STM32 Cortex-M - - X -
Joystick
tions devices that can be plugged on a STM32 Nucleo board.

Total number of demonstrations: 1 0 0 1 0

Total number of projects: 218 20 54 104 40

AN4724
Revision history AN4724

3 Revision history

Table 2. Document revision history


Date Revision Changes

06-Jul-2015 1 Initial release.


Updated Figure 1: STM32CubeF1 firmware components
20-Apr-2017 2 and Section 2: STM32CubeF1 examples to add Low
Layer (LL).

30/31 DocID028025 Rev 2


AN4724

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.

© 2017 STMicroelectronics – All rights reserved

DocID028025 Rev 2 31/31


31

You might also like