STM32F0xx Standard Peripherals Library: Peripheral’s examples

 

Copyright 2012 STMicroelectronics

 

The STM32F0xx 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 STM320518-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), stm32f0xx_it.c, system_stm32f0xx.c, stm32f0xx_it.h, stm32f0xx_conf.h and any other source files from the specified example to your toolchain folder under Project\STM32F0xx_StdPeriph_Templates. This project folder contains already all toolchain files needed for creating projects for STM32F0xx 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

STM32F0xx  StdPeriph_Lib Examples

The package contains the following examples:

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


IP

Module

Example

Name

Brief Description

ADC

ADC_DMA

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

ADC_LowPower

This example provides a short description of how to use the ADC peripheral with Auto-delayed conversion mode and Auto-poweroff modes.

ADC1_AnalogWatchdog

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

Basic_Example

This example describes how to use the ADC1 to convert continuously the Eval Board potentiometer. The converted voltage is displayed on the Eval Board LCD.

Battery_Charge_Monitoring

This example describes how to measure VBAT voltage using ADC1 regular channel 18, the measured value should correspond to VBAT/2.

    CEC

Data_Exchange

This example provides a basic communication between two  HDMI-CEC devices using interrupts.

Listen_Mode

This example provides a basic communication between two HDMI-CEC devices using interrupts and an spy CEC device which receives messages addressed to different destination.

Multi_Address

This example provides a basic communication between two HDMI-CEC devices using interrupts, which the follower one supports two addresses at the same time.

COMP

COMP_AnalogWatchdog

This example shows how to make an analog watchdog using the STM32F0xx 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).

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

PWMSignalControl

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

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_ADC

This example describes how to use the ADC1 and DAC to output on DAC_OUT1 sampled values of ADC1. The ADC1 is configured to convert continuously ADC1 channel11 (PC1). The End Of Conversion (EOC) interrupt is enabled and the conversion is triggered by software.

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

ADC_TIM3

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.

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.

RAM_DAC

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

Program

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

Write_Protection

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

GPIO

IOToggle

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 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 STM320518-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

DataExchangeDMA

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

DataExchangeInterrupt

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. 

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_WinwdowMode

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_WFI_Mode

This example shows how to enter the system to WFI mode and wake-up from this mode by the User key 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. The EXTI Line sources are PB8 and RTC Alarm.

PWR_CurrentConsumption

This example shows how to configure the STM32F0xx 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

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.

TimeStamp

This example provides a short description of how to use the RTC peripheral and the timeStamp Feature.

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 use the STM32F0xx new RTC's sub-seconds and Tamper feature (Filter, sampling) features. It simulates a precise chronometer with 2 record times possibilities stored in the Backup registers (2 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 example of how to use the SPI firmware library and an associate SPI SDcard driver to communicate with an SDcard available on The eval board.

DataExchangeDMA

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

DataExchangeInterrupt

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

SYSCFG

PVD

This example shows how to configure the programmable voltage detector.

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 48 MHz, 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 STM32F0xx TIM1 peripheral offers the possibility to program in advance the configuration for the next TIM1 outputs behaviour (step) and change the configurationof all the channels at the same time. This operation is possible when the COM (commutation) event is used.

7_PWMOutputs

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

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_Burst

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

Encoder_Mode

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

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.

OCToggle

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 received in Timer Input pin.

PWM_Input

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

Synchronization_Mode

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

TIM_ADC_Trigger

This example describes how to configure the TIM to trigger the ADC conversion.

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

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

Hyperterminal_Interrupt

This example provides a description of how to use the USART1 with    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.

DataExchangeDMA

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

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.






















Back to Top

 

 

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