Back to main page

STM32F30x/31x Standard Peripherals Library: Peripheral’s examples

 

Copyright 2014 STMicroelectronics

 

The STM32F30x/31x DSP and 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 STM32303C-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), stm32f30x_it.c, system_stm32f30x.c, stm32f30x_it.h, stm32f30x_conf.h and any other source files from the specified example to your toolchain folder under Projects\STM32F30x_StdPeriph_Templates. This project folder contains already all toolchain files needed for creating projects for STM32F30x 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.

STM32F30x  StdPeriph_Lib Examples

The package contains the following examples:

ADC - CAN  - COMP  - CRC - DAC - DMA - EXTI - FLASH - FMC  - GPIO - I2C - I2S - IWDG  - Lib_DEBUG - NVIC  - OPAMP -  PWR - RCC - RTC  SPI - SYSCFG - SysTick - TIM - USART - WWDG


IP

Module

Example

Name

Brief Description

ADC

ADC_BasicExample

This example describes how to use the ADC to convert continuously the voltage applied to a given analog input channel.

ADC_AnalogWatchdog

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

ADC_DifferentialMode

This example describes how to use the ADC1 to convert continuously voltage applied to a given analog input channel in differential mode.

ADC_DualMode

This example provides a short description of how to use the ADC peripheral to convert a regular channel in Dual interleaved mode using the DMA to read the converted Data from the common DR register.

    CAN

CAN_DualFIFO

This example shows how to configure the CAN peripheral to send and receive CAN frames in normal mode and using FIFO0 and FIFO1. The sent frames are used to control Leds by pressing key or SEL push buttons.

CAN_FIFOExtension

This example shows how to manage both CAN FIFO as a single FIFO composed by 6 mail boxes.

CAN_LoopBack

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

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

COMP

COMP_AnalogWatchdog

This example shows how to make an analog watchdog using the STM32F30x COMPs peripherals in window mode: If the input voltage is above the higher threshold, LD3 and LD1 are turned On. If the input voltage is under the lower threshold, LD2 and LD4 are turned On. If the input voltage is within the thresholds, the MCU remains in STOP mode and all leds are turned Off.

COMP_LDR

This example shows how to configure the comparator which can be used
in combination with DAC peripheral to mesure the light intensity (using the LDR sensor).

COMP_Hygrometer

This example shows how to make a hygrometer using the capacitive humidity sensor HS1101. The capacitance measurement is based on continuously charging/discharging the humidity sensor and measuring the time constant.

COMP_OutputBlanking

This example shows how to use the output blanking feature of COMP peripheral. The purpose of the output blanking feature in motor control is to prevent the current regulation to trip upon short current spikes at the beginning of the PWM period.

COMP_PulseWidthMeasurement

This example shows how to configure the COMP2 peripheral to measure pulse width. This method (measuring signal pulse using comparator is interesting when external signal doesn't respect the VIL and VIH levels).

COMP_PWMSignalControl

This example shows how to configure COMP1  peripheral to hold on safe state (low level) TIM2 channels as soon as COMP1 output is set at high level.

CRC

CRC_32BitsCRCMessage

This example aims to show how to use the CRC peripheral in order to compute 32-bit CRC checksum of a message.

CRC_8BitsCRCMessage

This example aims to show how to use the CRC peripheral in order to compute 8-bit CRC checksum of a message.

CRC_TwoBoards

This example aims to show how to verify CRC checksum during USART communication between two STM32F30x boards.

DAC

DAC_ADC

This example describes how to use the ADC1 and DAC to output on DAC_OUT1 sampled values of ADC1 channel5. 

DAC_SignalsGeneration

This example provides a short description of how to use the DAC peripheral to generate several signals using DMA controller. When the user presses the KEY push-button, DMA transfers the two selected waveforms to DAC.

DMA

DMA_ADCToTIM3Transfer

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

DMA_FLASHToRAMTransfer

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.

DMA_RAMToDACTransfer

This example provides a description of how to use a DMA channel to transfer data buffer from RAM memory to DAC.

EXTI

EXTI_Example

This example shows how to configure an external interrupt line. The EXTI line is configured to generate an interrupt on each falling edge. 

   FLASH

FLASH_Program

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

FLASH_WriteProtection

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

GPIO

GPIO_Toggle

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

I2C

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 M24M01 or M24LR64 EEPROM)

I2C_TSENSOR

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 STM32303C-EVAL board and used to get instantaneous external temperature (-55°C to +125°C).

I2C_TwoBoards

This example shows how to use the CPAL library to control I2C devices and communicate between two different boards.

I2C_WakeUpFromStop

This example shows how to use the WakeUp from STOP feature of I2C device using the CPAL library. This example requires two boards, one configured in master mode and another one configured in slave mode.

I2S

I2S_FullDuplexDataExchangeDMA

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

I2S_FullDuplexDataExchangeIT

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

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.

IWDG_WindowMode

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  using window mode  feature.

LIB_DEBUG

Lib_DEBUG_Example

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

NVIC

NVIC_IRQMask

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

NVIC_IRQPriority

This example shows how to configure interrupt priorities.

NVIC_WFIMode

This example shows how to enter the system to WFI mode and wake-up from this mode using external interrupt.

PWR

PWR_Standby

This example shows how to enter the system to STANDBY mode and wake-up from this mode using RTC Alarm.

PWR_Stop

This example shows how to enter the system to STOP mode and wake-up using EXTI Line interrupts. 

PWR_PVD

This example shows how to configure the programmable voltage detector using an external interrupt line.

PWR_CurrentConsumption

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

RCC

RCC_Example

This example shows how to:
  - Configure the PLL (clocked by HSE) as System clock source
  - Use the Clock Security System (CSS) feature to detect HSE failure
  - Output the System clock on MCO pin

RTC

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

RTC_Tamper

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

RTC_LSI

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

RTC_StopWatch

  This example illustrates how to simulate a precise chronometer
  with 5 record times possibilities stored in the Backup registers (5 registers for time (second, minutes and hours) and 5 registers for subsecond).

RTC_Timer

This example provides a short description of how to use the RTC peripheral’s with Alarm sub seconds feature to simulate a timer with refresh time equal to 250 ms  (1 second/ 8) * 2).

SPI

SPI_MSD

This example provides a basic application of how to use the SPI firmware library and an associate SPI SDcard driver to communicate with an SDcard available on The eval board.

SPI_EEPROM

This example provides a basic application  of how to use the SPI firmware library and an associate SPI EEPROM driver to communicate with an SPI EEPROM device (here the example is interfacing with M95M01 EEPROM)

SPI_DataExchangeDMA

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

SPI_DataExchangeInterrupt

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

SYSCFG

SYSCFG_PVDLock

This example shows how to configure the SYSCFG to enable and lock the PVD connection to TIM1 Break input.

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

TIM

TIM_DMABurst

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

TIM_EncoderMode

This example shows how to configure the TIM peripheral to interface with a encoder sensor.
The TIM3 is configured in encoder mode1: Counter counts up/down on TI2 rising edge depending on TI1 level

TIM_InputCapture

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

TIM_OCActive

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

TIM_OCToggle

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

TIM_OnePulse

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

TIM_PWMInput

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

TIM_Synchronization

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

TIM_6Steps

This example shows how to configure the TIM1 peripheral to generate 6 Steps.

TIM_7PWMOutputs

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

TIM_Asymetric

This example shows how to configure the TIM peripheral to generate an Asymetric signal.

TIM_Combined

This example shows how to configure the TIM1 peripheral to generate 3 PWM combined signals with TIM1 Channel5.

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

TIM_RetriggerableOPM

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

TIM_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

USART_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  USART2 (EVAL_COM1).

USART_HyperTerminalInterrupt

This example provides a description of how to use the EVAL_COM1 when using the STM32303C-EVAL Transmit and Receive interrupts to communicate with the hyperterminal.

USART_AutoBaudRate

This example provides a description of how to use the Auto BaudRate capability of the USART via the HyperTerminal.

USART_WakeUpFromStop

This example provides a description of how to use the WakeUp from STOP mode capability of the USART via the hyperterminal.

USART_DataExchangeDMA

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

USART_DataExchangeInterrupt

This example provides a small application in which joystick buttons are used to trigger UART communication and though using UART 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.

OPAMP

OPAMP_InternalFollower

This example provides a short description of how to configure the OPAMP1 in internal follower and how to use OPAMP1 output as ADC input.

OPAMP_PGA

This example shows how to configure OPAMP1 peripheral to amplify applied signal on OPAMP1 non inverting input using the built-in PGA.

OPAMP_TimerControlledMux

This example shows how to configure OPAMP1 peripheral in timer-controlled multiplexer. In this mode, the selection of OPAMP inverting and non inverting inputs can be done automatically. This automatic switch is triggered by the TIM1 OC6 output.

FMC

FMC_SRAM

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























 

 

Back to Top

 

 

For complete documentation on STM32 Microcontrollers visit www.st.com/STM32