STM32F2xx Standard Peripherals Library: Peripheral’s examples

 

Copyright 2011 STMicroelectronics

 

The STM32F2xx 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 STM322xG-EVAL evaluation board 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), stm32f2xx_it.c, system_stm32f2xx.c, stm32f2xx_it.h, stm32f2xx_conf.h and any other source files from the specified example to your toolchain folder under Project\STM32F2xx_StdPeriph_Template. This project folder contains already all toolchain files needed for creating projects for STM32F2xx 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

STM32F2xx  StdPeriph_Lib Examples

The package contains the following examples:

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

 

IP/Module

Example

Name

 Brief description

 ADC

ADC3_DMA

This example describes how to use the ADC3 and DMA to transfer continuously converted data from ADC3 to memory. The ADC3 is configured to convert continuously channel7.

DualADC_Interleaved_DMAmode3

This example provides a short description of how to use the ADC peripheral to convert a regular channel in Dual interleaved mode using DMA in mode 3 with 5Msps.

DualADC_RegulSimu_DMAmode1

This example provides a short description of how to use the ADC peripheral to convert regular channels simultaneously in dual mode using DMA in mode 1.

TripleADC_Interleaved_DMAmode2

This example provides a short description of how to use the ADC peripheral to convert a regular channel in Triple interleaved mode using DMA in mode 2 with 6Msps.

VBAT_Measurement

This example describes how to measure VBAT voltage using ADC1 regular channel 18. In fact, the measured value correspond to VBAT/2; as the VBAT voltage could be higher than VDDA, to ensure the correct operation of the ADC, the VBAT pin is internally connected to a bridge divider by 2.

CAN

LoopBack

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

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.

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.

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.

MPU

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

CRC

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

CRYP

AES_ECBmode_DMA

This example provides a short description of how to use the CRYPTO peripheral to encrypt and decrypt data using AES-128 Algorithm.

AES_modes

This example provides a short description of how to use the CRYPTO peripheral to encrypt and decrypt data using AES in all modes (ECB, CBC, CTR) and all key sizes (128, 192, 256) Algorithm.

DES_TDES_modes

This example provides a short description of how to use the CRYPTO peripheral to encrypt and decrypt data using DES and TDES in all modes (ECB, CBC) Algorithm.

TDES_ECBmode_DMA

This example provides a short description of how to use the CRYPTO peripheral to encrypt and decrypt data using TDES Algorithm.

 DAC

DAC_SignalsGeneration

This example provides a short description of how to use the DAC peripheral to generate several signals using DMA controller.

DCMI

OV9655_Camera

This example shows how to use the DCMI to control the OV9655 Camera module mounted on STM322xG-EVAL board RevA.

DMA

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.

EXTI

EXTI_Example

This example shows how to configure external interrupt lines. In this example, 2 EXTI lines (EXTI Line0 and Line15) are configured to generate an interrupt on each rising and falling edge, respectively.  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 STM32F2xx FLASH.

Write_Protection

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

FSMC

OneNAND

This example shows how to configure the FSMC to drive the KFG1216U2A/B-DIB6 OneNAND memory mounted on STM322xG-EVAL evaluation board (MB786) RevA.

SRAM

This example shows how to configure the FSMC to drive the CY7C1071DV33-12BAXI SRAM memory mounted on STM322xG-EVAL evaluation board (MB786) RevB.

SRAM_DataMemory

This example shows how to use the external SRAM mounted on STM322xG-EVAL RevB as program data memory (including heap and stack).

GPIO

IOToggle

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

JTAG_Remap

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

HASH

Context_Swap

This example provides a short description of how to use the HASH peripheral to save and restore hash context to serve a high priority hash operation.

HASH_SHA1_MD5

This example provides a short description of how to use the HASH peripheral to hash data using SHA-1 and MD5 Algorithms.

HMAC_SHA1_MD5

This example provides a short description of how to use the HASH peripheral to hash data using HMAC SHA-1 and HMAC MD5 Algorithms.

SHA1_MD5_DMA

This example provides a short description of how to use the HASH peripheral to hash data using SHA-1 and MD5 Algorithms.

 I2C

EEPROM

This firmware 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 M24C64 EEPROM)

IOE

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.

DataExchangeDMA

This is a typical example of how to use the I2C firmware library to ensure the steps of an I2C communication between slave Receiver/Transmitter and master Transmitter/Receiver using DMA.

DataExchangeInterrupt

This is a typical example of how to use the I2C firmware library to ensure the steps of an I2C communication between slave Receiver/Transmitter and master Transmitter/Receiver using interrupts.

MasterReceiverInterrupt

This is a typical example of how to use the I2C firmware library to ensure the steps of an I2C communication between slave transmitter and master receiver using interrupt.

MasterTransmitterInterrupt

This example provides a small application in which joystick buttons are used to trigger I2C communication using interrupt and though using I2C firmware library.

 I2S

I2S_Audio

This example provides basic implementation of audio features. It allows playing an audio file through the I2S peripheral and using the external codec implemented on the STM322xG-EVAL board.

 IWDG

IWDG_Example

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

Lib_DEBUG_Example

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

NVIC

DMA_WFIMode

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) and how to configure their priorities.

VectorTable_Relocation

This example describes how to relocate the CortexM3 vector table in a specific address other than the default Flash memory base address.

 PWR

BOR

This example shows how to configure the programmable BOR thresholds using the FLASH option bytes.

CurrentConsumption

This example shows how to configure the STM32F2xx system to measure different Low Power modes current consumption.

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

STANDBY

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

STOP

This example shows how to enter the system to STOP mode and wake-up from this mode using RTC Wakeup Timer Event connected to EXTI Line 22.

RCC

RCC_Example

This example shows how to use, for debug purpose, the RCC_GetClocksFreq function to retrieve the current status and frequencies of different on chip clocks. You can see the RCC_ClockFreq structure content, which hold the frequencies of different on chip clocks, using your toolchain debugger.

RNG

RNG_MultiRNG

This example provides a short description of how to use the RNG peripheral to generate Random 32bit numbers.

RTC

BKP_Domain

This example demonstrates and explains how to use the peripherals available on Backup Domain. These peripherals are: the RCC BDCR register containing the LSE Osc configuration and the RTC Clock enable/disable bits. It embeds also the RTC peripheral with its associated Backup Data registers. And finally the Backup SRAM (4KB) with its low power regulator allowing preserving its contents when the product is powered by VBAT pin.

HW_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 alarm interrupt.

RTC_LSI

This example demonstrates and explains how to use the LSI clock source auto calibration to get a precise RTC clock.  As an application example, it demonstrates how to configure the TIM5 timer internally connected to LSI clock output, in order to adjust the RTC prescaler.

Tamper

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

TimeStamp

This example provides a short description of how to use the RTC peripheral and the Time Stamp feature.

SDIO

uSDCard

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 STM322xG_EVAL board.

SPI

SPI_FLASH

This example provides a basic example of how to use the SPI firmware library and an associated driver "spi_flash.c" to communicate with an M25P64 SPI FLASH.

SPI_DataExchangeInterrupt

This example provides a small application in which joystick buttons are used to trigger SPI communication using interrupts and though using SPI firmware library.

SysTick

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 120 MHz, the SysTick is clocked by the AHB clock (HCLK).

TIM

6Steps

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

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

Cascade_Synchro

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

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.

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.

DMABurst

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

ExtTrigger_Synchro

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

InputCapture

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

OCActive

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

OCInactive

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

OCToggle

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

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.

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.

TIM10_PWMOutput

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.

TIM9_OCToggle

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

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

USART

HyperTerminal_Interrupt

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

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

Smartcard

This example describes a firmware Smartcard Interface based on the STM32F2xx USART peripheral. The main purpose of this firmware example is to provide resources facilitating the development of an application using the USART peripheral in smartcard mode.

DataExchangeDMA

This example provides a small application in which joystick buttons are used to trigger USART communications using DMA and though using USART firmware library.

DataExchangeInterrupt

This example provides a small application in which joystick buttons are used to trigger USART communication using interrupts and though using USART firmware library.

 WWDG

WWDG_Example

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