Back to main page

STM32F10x Standard Peripherals Library: Peripheral’s examples

 

Copyright 2010 STMicroelectronics

 

The STM32F10x Standard Peripherals library provides a rich set of examples covering the main features of each peripheral. All the examples are independent from the software toolchain. These examples run on STMicroelectronics STM32100E-EVAL (High-density Value line), STM32100B-EVAL (Medium-density Value line), STM3210C-EVAL (Connectivity line), STM3210E-EVAL (High-density and XL-density) and STM3210B-EVAL (Medium-density) evaluation boards and can be easily tailored to any other supported device and development board. Only source files are provided for each example and user can tailor the provided project template to run the selected example with his preferred toolchain.

Contents

  1. STM32F10x  StdPeriph_Lib Examples
  2. What do I need to start successfully with Examples?
  3. How to proceed?

STM32F10x  StdPeriph_Lib Examples

Acronym:

  • All : STM32F10x Low-density, Low-density value line, Medium-density, Medium-density value line, High-density, High-density Value line, XL-density and Connectivity line devices.
  • Max frequency: 24MHz on value line devices and 72MHz on other devices.
  • EVAL board : STM32100E-EVAL, STM32100B-EVAL, STM3210B-EVAL, STM3210E-EVAL or STM3210C-EVAL boards.

The package contains the following examples:

IP/Module

Example

Microcontroller used resources




 

Name

Brief Description

Supported STM32 Devices




 ADC

3ADCs_DMA

This example describes how to use the 3 ADCs in independent conversions.
Two of them; ADC1 and ADC3 are transferring continuously converted data using DMA while ADC2 converted data are stored using End of conversion interrupt.

STM32F10x High-density and XL-density devices




ADC1_DMA

This example describes how to use the ADC1 and DMA to transfer continuously converted data from ADC1 to memory.

All




AnalogWatchdog

This example describes how to use the ADC analog watchdog to guard continuously an ADC channel.

All




ExtLinesTrigger

This example describes how to trigger ADC regular and injected groups channels conversion using two external line events. Discontinuous mode is enabled for regular group channel conversion and configured to convert one regular channel on each external trigger.

All




RegSimul_DualMode

This example describes how to use ADC1 and ADC2 in regular simultaneous dual mode. ADC1 is configured to convert channel14 and channel17 regular channels continuously. ADC2 is configured to convert channel11 and channel12 regular channels continuously. The connection between internal Vref and channel17 is enabled for ADC1.

All except Value line devices




TIMTrigger_AutoInjection

This example describes how to convert ADC regular group channels continuously using TIM1 external trigger and injected group channels using the auto-injected feature.

All




 BKP

Backup_Data

This example shows how to store user data in the Backup data registers.
As the Backup (BKP) domain still powered by VBAT when VDD is switched off, its contents are not lost if a battery is connected to VBAT pin.

All




Tamper

This example shows how to write/read data to/from Backup data registers and demonstrates the Tamper detection feature.




CEC

Network

This example shows how to configure the HDMI-CEC peripheral and how to create CEC network providing a high level communication between three different devices using CEC protocol messages.

Value Line devices




 CAN

LoopBack

This example provides a description of how to set a communication with the bxCAN in loopback mode.

All except Value Line devices




Networking

This example shows how to configure the CAN peripheral to send and receive CAN frames in normal mode. The sent frames are used to control Leds by pressing key push button.

All except Value Line devices




DualCAN

This example shows how to configure the CAN1 and CAN2 peripherals to send and receive CAN frames in normal mode. The sent frames are used to control Leds by pressing KEY or Tamper push buttons.

Connectivity line devices




 CortexM3

BitBand

This example shows how to use CortexM3 Bit-Band access to perform atomic read-modify-write and read operations on a variable in SRAM.

All




Mode_Privilege

This example shows how to modify CortexM3 Thread mode privilege access and stack. CortexM3 Thread mode is entered on Reset, and can be entered as a result of an exception return.




 CRC

Example

This example shows how to use CRC (cyclic redundancy check) calculation unit to get a CRC code of a given buffer of data word (32-bit), based on a fixed generator polynomial(0x4C11DB7).

All




 DAC

DualModeDMA_SineWave

This example describes how to use DAC dual channel mode with DMA to generate sine waves on both DAC channels outputs.

STM32F10x High-density XL-density, Connectivity line, and Value line devices




OneChannel_NoiseWave

This example describes how to use one DAC channel to generate a signal with noise waves on DAC Channel1 output.




OneChannelDMA_Escalator

This example describes how to use one DAC channel mode with DMA to generate an escalator signal on DAC channel1 output.




TwoChannels_TriangleWave

This example describes how to use two DAC channels to generate two different signals with triangle waves on each DAC Channel output.




 DMA

ADC_TIM1

This example provides a description of how to use a DMA channel to transfer continuously a data from a peripheral (ADC1) to another peripheral (TIM1) supporting DMA transfer.

All




FLASH_RAM

This example provides a description of how to use a DMA channel to transfer a word data buffer from FLASH memory to embedded SRAM memory.

All




FSMC

This example provides a description of how to use two DMA channels to transfer a word data buffer from Flash memory to external SRAM memory and to recuperate the written data from external SRAM to be stored in internal SRAM.

STM32F10x High-density and XL-density devices




I2C_RAM

This example provides a description of how to use two DMA channels to transfer a data buffer from memory to I2C2 through I2C1.

All




SPI_RAM

This example provides a description of how to use four DMA channels to transfer a data buffer from memory to PI_SLAVE through SPI_MASTER and a second data buffer from memory to SPI_MASTER through SPI_SLAVE in full-duplex mode. SPI_MASTER and SPI_SLAVE can be SPI1 and SPI2 or SPI3 and SPI2, depending on the STMicroelectronics EVAL board you are using.

All




 EXTI

Example

This example shows how to configure an external interrupt line.
In this example, an EXTI line is configured to generate an interrupt on each falling edge. In the interrupt routine a led connected to a specific GPIO pin is toggled.

All




 FLASH

Program

This example provides a description of how to program the STM32F10x FLASH.

All




Dual_Boot

This example demonstrates the dual Flash boot capability of XL-Density devices; boot from Flash memory Bank1 or Bank2.

STM32F10x XL-density devices




Write_Protection

This example provides a description of how to enable and disable the write protection for the STM32F10x FLASH.

All




 FSMC

NAND

This example provides a basic example of how to use the FSMC firmware library and an associate driver to perform erase/read/write operations on the NAND512W3A2 memory mounted on STM3210E-EVAL board.

STM32F10x High-density and XL-density devices




NOR

This example provides a basic example of how to use the FSMC firmware library and an associate driver to perform erase/read/write operations on the M29W128FL, M29W128GL or S29GL128P NOR memories mounted on the STM3210E-EVAL board.

STM32F10x High-density , XL-density and High-density Value line devices



NOR_CodeExecute

This directory contains a set of sources files that describes how to build an application to be loaded into the NOR memory mounted on STM3210E-EVAL board then execute it from internal Flash.

STM32F10x High-density , XL-density and High-density Value line devices



OneNAND

This example shows how to configure the FSMC to drive the OneNAND memory mounted  on STM32100E-EVAL board.
In this example a basic example of how to use the FSMC firmware libraryand an associate driver to perform read/write operations on the KFG1216U2A OneNAND
memory.



STM32F10x 
High-density Value line devices



SRAM

This example provides a basic example of how to use the FSMC firmware library and an associate driver to perform read/write operations on the IS61WV51216BLL SRAM memory mounted on STM3210E-EVAL board.

STM32F10x High-density , XL-density and High-density Value line devices



SRAM_DataMemory

This example shows how to use the external SRAM mounted on STM3210E-EVAL board as program data memory and internal SRAM for Stack.

STM32F10x High-density , XL-density and High-density Value line devices



 GPIO

IOToggle

This example describes how to use GPIO BSRR (Port bit set/reset register) and BRR (Port bit reset register) for IO toggling.

All




JTAG_Remap

This example provides a short description of how to use the JTAG IOs as standard GPIOs and gives a configuration sequence.

All




 I2C

EEPROM

This example provides a basic example of how to use the I2C software library and an associate I2C EEPROM driver to communicate with an I2C EEPROM device (here the example is interfacing with M24CXX EEPROMs where XX={01, 02, 04, 08, 16, 32, 64}.

All




I2C_TSENSOR

Thisexample provides a description of how to use the I2C to communicatewith an STLM75 (or a compatible device) I2C temperature sensor ismounted on the  evaluation board and used to get instantaneous external temperature
(-55ÝC to +125ÝC).

All




I2C_IOExpander

Thisfirmware provides an example of configuring and using the IO ExpanderSTMPE811 in order to control input Joystick IOs, output IOs and the Touch Screen feature.

All




 I2S

Interrupt

This example provides a description of how to set a communication between two SPIs in I2S mode using interrupts and performing a transfer from Master to Slave.

ALL




SPI_I2S_Switch

This example provides a description of how to set a communication between two SPIs in I2S mode, and how to switch between SPI and I2S modes, performing a transfer from Master to Slave in I2S modes then a transfer from master to slave in SPI mode and finally a transfer from Slave to Master in I2S mode.

STM32F10x High-density, XL-density and Connectivity line devices




 IWDG

Example

This example shows how to reload at regulate period the IWDG counter using the SysTick interrupt. The IWDG timeout is set to 280 ms (the timeout may vary due to LSI frequency dispersion).

All




 LIB_DEBUG

Example

This example demonstrates how to declare dynamic peripherals pointers used for Debug mode. 

All




 NVIC

DMA_WFIMode

This example shows how to enters the system to WFI mode with DMA transfer enabled and wake-up from this mode by the DMA End of Transfer interrupt.

All




IRQ_Channels

This example demonstrates the use of the Nested Vectored Interrupt Controller (NVIC) IRQ Channels configuration.




Priority

This example demonstrates the use of the Nested Vectored Interrupt Controller (NVIC).




VectorTable_Relocation

This example describes how to set the CortexM3 vector table in a specific address other than default using the NVIC_SetVectorTable function from the misc.h/.c driver.




 PWR

STANDBY

This example shows how to enters the system to STANDBY mode and wake-up from this mode using: external RESET, RTC Alarm or WKUP pin.

All




STOP

This example shows how to enter the system to STOP mode and wake-up using EXTI Line interrupts. The EXTI Line sources are PB.09/PG.08 and RTC Alarm.




PVD

This example shows how to configure the programmable voltage detector using
an external interrupt line. In this example, EXTI line 16 is configured to generate an interrupt on each rising or falling edge of the PVD output signal (which  indicates that the Vdd voltage is below the PVD threshold).




 RCC

Example

This example shows how to configure the System clock (SYSCLK) to have different frequencies: 24MHz, 36MHz, 48MHz, 56MHz and 72MHz (common frequencies that covers the major of the applications). 

All




 RTC

Calendar

This example demonstrates and explains how to use the RTC peripheral. As an application example, it demonstrates how to setup the RTC peripheral, in terms of prescaler and interrupts, to be used to keep time and to generate Second interrupt.

All




LSI_Calib

This example demonstrates and explains how to use the LSI clock source auto calibration to get a precise RTC clock. 

STM32F10x High-density, XL-density and Connectivity line devices




 SDIO

Example

This example provides a basic example of how to use the SDIO firmware library and an associate driver to perform read/write operations on the SD Card memory (SD Card V1.0, V1.1, V2.0 and SDHC (High Capacity) protocol) that could be mounted on the STM3210E-EVAL board.

STM32F10x High-density and XL-density devices




 SPI

CRC

This example provides a description of how to set a communication between two SPIs in full-duplex mode and performs a transfer from Master to Slave and Slave to Master followed by CRC transmission.

All




DMA

This example provides a description of how to set a communication between the two SPIs in simplex mode and performs a transfer from SPI_MASTER in polling mode to the SPI_SLAVE in DMA receive mode. 




FullDuplex_SoftNSS

This example provides a description of how to set a communication between SPIy and SPIz in full-duplex mode and performs a transfer from Master to Slave and then Slave to Master in the same application with software NSS management.




SPI_FLASH

This example provides a basic example of how to use the SPI firmware library
and an associate SPI FLASH driver to communicate with an M25P64 or M25P128 FLASH.




Simplex_Interrupt

This example provides a description of how to set a communication between two SPIs in simplex mode and performs a data buffer transfer from SPI_MASTER to SPI_SLAVE using TxE interrupt for master and RxNE interrupt for slave.




 SysTick

Example

This example shows how to configure the SysTick to generate a time base equal to 1 ms. The system clock is set to 24 MHz on Value line devices and to 72 MHz on  other devices, the SysTick is clocked by the AHB clock (HCLK).

All




 TIM

6Steps

This example shows how to configure the TIM1 peripheral to generate 6 Steps.
The STM32F10x TIM1 peripheral offers the possibility to program in advance the configuration for the next TIM1 outputs behavior (step) and change the configuration of all the channels at the same time. This operation is possible when the COM (commutation) event is used.

All (TIM1)




7PWM_Output

This example shows how to configure the TIM1 peripheral to generate 7 PWM signals with 4 different duty cycles (50%, 37.5%, 25% and 12.5%).

All (TIM1)




Cascade_Synchro

This example shows how to synchronize TIM peripherals in cascade mode.

All (TIM2,3,4)




ComplementarySignals

This example shows how to configure the TIM1 peripheral to generate three complementary TIM1 signals, to insert a defined dead time value, to use the break feature and to lock the desired parameters.

All (TIM1)




DMA

This example provides a description of how to use DMA with TIM1 Update request to transfer Data from memory to TIM1 Capture Compare Register3.

All (TIM1)




ExtTrigger_Synchro

This example shows how to synchronize TIM peripherals in cascade mode with an external trigger.

All (TIM2,3,4)




InputCapture

This example shows how to use the TIM peripheral to measure the frequency of an external signal.

All (TIM2)




OCActive

This example shows how to configure the TIM peripheral to generate four different signals with four different delays.

All (TIM2)




OCInactive

This example shows how to configure the TIM peripheral in Output Compare Inactive mode with the corresponding Interrupt requests for each channel.

All (TIM2)




OCToggle

This example shows how to configure the TIM3 peripheral to generate four different signals with four different frequencies.

All (TIM2)




OnePulse

This example shows how to use the TIM peripheral to generate a One pulse Mode after a Rising edge of an external signal is received in Timer Input pin.

All (TIM2)




Parallel_Synchro

This example shows how to synchronize TIM peripherals in parallel mode.

All (TIM2,3,4)




PWM_Input

This example shows how to use the TIM peripheral to measure the frequency and duty cycle of an external signal.

All (TIM2)




PWM_Output

This example shows how to configure the TIM peripheral in PWM (Pulse Width Modulation) mode.

All (TIM3)




TIM1_Synchro

This example shows how to synchronize TIM1 and Timers (TIM3 and TIM4) in parallel mode.

All (TIM1,3,4)




TIM15_ComplementarySignals

This example shows how to configure the TIM15 peripheral to generate one complementary TIM15 signal, to insert a defined dead time value, to use the break feature and to lock the desired parameters.

STM32F10x Value Line   devices




TIM9_OCToggle

This example shows how to configure the TIM9 peripheral to generate two different signals with two different frequencies.

STM32F10x XL-density devices




TIM10_PWMOutput

This example shows how to configure the TIM10 peripheral in PWM (Pulse Width Modulation) mode.

STM32F10x XL-density devices




TimeBase

This example shows how to configure the TIM peripheral in Output Compare Timing  mode with the corresponding Interrupt requests for each channel in order to generate4 different time bases.

All (TIM2)




  USART

DMA_Interrupt

This example provides a basic communication between USARTy and USARTz using DMA capability, flags and interrupts. USARTy and USARTz can be USART1 and USART2 or USART2 and USART3, depending on the STMicroelectronics EVAL board you are using.

All




DMA_Polling

This example provides a basic communication between USARTy and USARTz using DMA capability. USARTy and USARTz can be USART1 and USART2 or USART2 and USART3, depending on the STMicroelectronics EVAL board you are using.




HalfDuplex

This example provides a basic communication between USARTy and USARTz in Half-Duplex mode using flags. USARTy and USARTz can be USART1 and USART2 or USART2 and USART3, depending on the STMicroelectronics EVAL board you are using.




HyperTerminal_HwFlowControl

This example provides a description of how to use the USART with hardware flow control and communicate with the HyperTerminal.




HyperTerminal_Interrupt

This example provides a description of how to use the EVAL_COM1 Transmit and Receive interrupts to communicate with the HyperTerminal.




Interrupt

This example provides a basic communication between USARTy and USARTz using interrupts. USARTy and USARTz can be USART1 and USART2 or USART2 and USART3, depending on the STMicroelectronics EVAL board you are using.




IrDA Receive

This example provides a basic communication USARTy IrDA receive mode. Four leds are used to show which byte is received. USARTy can be USART3 or USART2 depending on the STMicroelectronics EVAL board you are using.




IrDA Transmit

This example provides a basic communication USARTy IrDA transmit mode. Five pins, configured in input floating mode, are used to select the byte to be send at each pin state change. USARTy can be USART3 or USART2 depending on the STMicroelectronics EVAL board you are using.




MultiProcessor

This example provides a description of how to use the USART in multi-processor mode. USARTy and USARTz can be USART1 and USART2 or USART2 and USART3 respectively, depending on the STMicroelectronics EVAL board you are using.




Polling

This example provides a basic communication between USARTy and USARTz using flags. USARTy and USARTz can be USART1 and USART2 or USART2 and USART3, depending on the STMicroelectronics EVAL board you are using.




Printf

This example shows how to retarget the C library printf function to the USART.
This implementation output the printf message on the HyperTerminal using USARTx. USARTx can be USART1 or USART2 depending on the EVAL board you are using.




Smartcard

This example provides a description of how  to use the USART in Smartcard mode. The example gives only the possibility to read the ATR and decode it into predefined buffer.




Synchronous

This example provides a basic communication between USARTy (Synchronous mode) and SPIy using flags. USARTy and SPIy can be USART1 and SPI1 or USART2 and SPI3, depending on the STMicroelectronics EVAL board you are using.




 WWDG

Example

This example shows how to update at regulate period the WWDG counter using the Early Wakeup interrupt (EWI).

All




Back to Top

What do I need to start successfully with Examples?

Evaluation Board:   STMicroelectronics STM32100E-EVAL (High-density Value line), STM32100B-EVAL (Medium-density Value line), STM3210C-EVAL (Connectivity line), STM3210E-EVAL (High-density and XL-density) and STM3210B-EVAL (Medium-density) evaluation boards or any other compatible hardware. To use your own specific hardware, you need simply to adapt the examples hardware configuration to your platform.

Tool chain:

Use your preferred toolchain. MDK-ARM (Keil), EWARM (IAR) , RIDE (Raisonance), HiTOP (Hitex) or TrueSTUDIO (Atollic)

 

Back to Top

How to proceed?

Copy the files main.c , main.h (if exists),  stm32f10x_it.c, platform_config.h (if exists), stm32f10x_it.h, stm32f10x_conf.h and any other source files from the specified example to your toolchain folder under Project\STM32F10x_StdPeriph_Template. This project folder contains already all toolchain files needed for creating projects for STM32F10x microcontrollers.

Set active the project related to the used STM32F10x device and hardware platform:

                      STM32100E-EVAL: to configure the project for STM32F10x High-density Value line devices
                      STM32100B-EVAL: to configure the project for STM32F10x Medium-density Value line devices

STM3210C-EVAL: to configure the project for STM32F10x Connectivity line devices

STM3210B-EVAL: to configure the project for STM32F10x Medium-density devices

STM3210E-EVAL: to configure the project for STM32F10x High-density devices  

STM32F10X_XL: to configure the project for STM32F10x XL-density devices  

Add the needed Library sources files (peripheral’s drivers) according to the “ How to use it ” section of the readme file

Finally compile, load and run the example

 

 

Back to Top

 

 

For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32