STM32F10x Standard Peripherals Library: Peripheral’s examples

 

Copyright 2011 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.

How to proceed?

  • Copy the files main.c, main.h (if exists), stm32f10x_it.c, system_stm32f10x.c, 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.

  • Open your preferred toolchain

  • If needed, add in the project list the additional files required to run the example (refer to your example readme file)

  • Rebuild all files and load your image into target memory

  • Run the example

STM32F10x  StdPeriph_Lib Examples

The package contains the following examples:

ADC - BKP - CAN - CEC - CortexM3 - CRC - DAC - DMA - EXTI - FLASH - FSMC - GPIO - I2C - I2S - IWDG - Lib_DEBUG - NVIC - PWR - RCC - RTC - SDIO - SPI - SysTick - TIM - USART - WWDG


IP/Module

Example

Name

Brief Description

 ADC

3 ADCs 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.

ADC1 DMA

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

ADC analog watchdog

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

ADC external lines trigger

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.

ADC regular simultaneous dual mode

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.

ADC TIM trigger and auto-injection

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

 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.

BKP Tamper

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

 CAN

LoopBack

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

Networking (Ex: Normal)

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.

Dual CAN

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.

CEC

CEC Data Exchange using Interrupt

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.

 CortexM3

Bit Banding

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

MPU

This example presents the MPU features on STM32F10x XL-density devices and it
can be easily ported to any other STM32 device supporting MPU.

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

CRC Calculation

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

 DAC

DAC dual mode sine wave

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

DAC one channel noise wave

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

DAC one channel DMA escalator

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

DAC two channels triangle wave

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

 DMA

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

FLASH to 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.

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.

I2C to RAM

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

SPI to RAM

This example provides a description of how to use four DMA channels to transfer
a data buffer from memory to SPI_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.

 EXTI

EXTI configuration

This example shows how to configure external interrupt lines.
In this example, 2 EXTI lines (EXTI0 and EXTI8 or EXTI9) are configured
to generate an interrupt on each rising or falling edge. In the interrupt routine
a led connected to a specific GPIO pin is toggled.

 FLASH

Program

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

XL-Density devices FLASH Dual Boot capability

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

Write Protection

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

 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.

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.

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.

One-NAND

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 library and an associate driver to perform read/write operations on the KFG1216U2A/B-DIB6 OneNAND memory.

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.

SRAM DataMemory

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

 GPIO

IO Toggle

GPIO ports are connected on APB2 bus, using BSRRH and BSRRL registers 2 cycles
are required to set a pin and another cycle to reset it. So GPIO pins can toggle
at AHB clock divided by 4.

JTAG Remap

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

I2C

I2C and M24CXX EEPROM communication

This example provides a basic example of how to use the I2C firmware 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}. I2C peripheral is configured in Master transmitter during write operation and in Master receiver during read operation from I2C EEPROM.

I2C and LM75 Temperature Sensor communication

This example provides a description of how to use the I2C to communicate with
an STLM75 (or a compatible device) I2C temperature sensor is mounted on the
evaluation board and used to get instantaneous external temperature
(-55°C to +125°C).

I2C and STMPE811 IO Expander communication

This firmware provides an example of configuring and using the IO Expander STMPE811 in order to control input Joystick IOs, output IOs and the Touch Screen feature.

 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.

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.

 IWDG

IWDG Reset

This example shows how to update at regular period the IWDG reload counter and
how to simulate a software fault generating an MCU IWDG reset on expiry of a
programmed time period.

 LIB_DEBUG

Run Time Checking

This example demonstrates how to declare dynamic peripherals pointers used for Debug mode.  To use Debug mode you have to add the stm32f10x_ip_dbg.c file to your application. This creates a pointer to the peripheral structure in SRAM. Debugging consequently becomes easier and all register settings can be obtained by dumping a peripheral variable.

 NVIC

DMA in WFI mode

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

IRQ Mask

This example demonstrates the use of the Nested Vectored Interrupt Controller (NVIC) IRQ Channels configuration and how to mask/activate different IRQs.

IRQ 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 enter the system to STANDBY mode and wake-up from this mode using: external RESET, RTC Alarm or WKUP pin.

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

Clock configuration

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

 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.

LSI_Calib

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

 SDIO

Micro SD Card

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.

 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.

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.

Full Duplex Software NSS

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.
SPIy and SPIz can be SPI1 and SPI2 or SPI3 and SPI2, depending on the STMicroelectronics EVAL board you are using.

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.
SPI_MASTER and SPI_SLAVE can be SPI1 and SPI2 or SPI3 and SPI2, depending on the
STMicroelectronics EVAL board you are using.

 SysTick

Time Base

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

 TIM

6 Steps

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.

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

Cascade Synchro

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

Complementary Signals

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.

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.

DMA Burst

 This example shows how to update the TIM1 channel1 period and the duty cycle
using the TIM1 DMA burst feature.

External Trigger Synchro

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

Input Capture

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

OC Active

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

OC Inactive

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

OC Toggle

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

One Pulse

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.

Parallel Synchro

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

PWM Input

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

PWM Output

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

TIM1 Synchro

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

TIM10 PWM Output

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

TIM15 Complementary Signals

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.

 TIM9 OC Toggle

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

Time Base

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 generate 4 different time bases.

  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.

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.

Half Duplex

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 Hardware Flow Control

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.

Multi Processor

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

 WWDG Reset

This example shows how to update at regular period the WWDG counter and how to simulate a software fault generating an MCU WWDG reset on expiry of a programmed time period.

Back to Top

 

 

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